Skip to content

Commit 8993188

Browse files
KingDarBojaJosh Goldberg
and
Josh Goldberg
authored
Add codelyzer component-max-inline-declarations converter (#451)
Co-authored-by: Josh Goldberg <joshuakgoldberg@outlook.com>
1 parent dc4ed26 commit 8993188

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { RuleConverter } from "../../converter";
2+
3+
export const convertComponentMaxInlineDeclarations: RuleConverter = (tslintRule) => {
4+
return {
5+
rules: [
6+
{
7+
...(tslintRule.ruleArguments.length !== 0 && {
8+
ruleArguments: [...tslintRule.ruleArguments],
9+
}),
10+
ruleName: "@angular-eslint/component-max-inline-declarations",
11+
},
12+
],
13+
plugins: ["@angular-eslint/eslint-plugin"],
14+
};
15+
};
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { convertComponentMaxInlineDeclarations } from "../component-max-inline-declarations";
2+
3+
describe(convertComponentMaxInlineDeclarations, () => {
4+
test("conversion without arguments", () => {
5+
const result = convertComponentMaxInlineDeclarations({
6+
ruleArguments: [],
7+
});
8+
9+
expect(result).toEqual({
10+
rules: [
11+
{
12+
ruleName: "@angular-eslint/component-max-inline-declarations",
13+
},
14+
],
15+
plugins: ["@angular-eslint/eslint-plugin"],
16+
});
17+
});
18+
19+
test("conversion with arguments", () => {
20+
const result = convertComponentMaxInlineDeclarations({
21+
ruleArguments: [
22+
{
23+
template: 7,
24+
styles: 2,
25+
animations: 10,
26+
},
27+
],
28+
});
29+
30+
expect(result).toEqual({
31+
rules: [
32+
{
33+
ruleArguments: [
34+
{
35+
template: 7,
36+
styles: 2,
37+
animations: 10,
38+
},
39+
],
40+
ruleName: "@angular-eslint/component-max-inline-declarations",
41+
},
42+
],
43+
plugins: ["@angular-eslint/eslint-plugin"],
44+
});
45+
});
46+
});

src/rules/rulesConverters.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ import { convertVariableName } from "./converters/variable-name";
139139

140140
// Codelyzer converters
141141
import { convertComponentClassSuffix } from "./converters/codelyzer/component-class-suffix";
142+
import { convertComponentMaxInlineDeclarations } from "./converters/codelyzer/component-max-inline-declarations";
142143
import { convertComponentSelector } from "./converters/codelyzer/component-selector";
143144

144145
/**
@@ -159,6 +160,7 @@ export const rulesConverters = new Map([
159160
["class-name", convertClassName],
160161
["comment-format", convertCommentFormat],
161162
["component-class-suffix", convertComponentClassSuffix],
163+
["component-max-inline-declarations", convertComponentMaxInlineDeclarations],
162164
["component-selector", convertComponentSelector],
163165
["curly", convertCurly],
164166
["cyclomatic-complexity", convertCyclomaticComplexity],

0 commit comments

Comments
 (0)