diff --git a/src/rules/converters/codelyzer/component-max-inline-declarations.ts b/src/rules/converters/codelyzer/component-max-inline-declarations.ts new file mode 100644 index 000000000..33bb8008d --- /dev/null +++ b/src/rules/converters/codelyzer/component-max-inline-declarations.ts @@ -0,0 +1,15 @@ +import { RuleConverter } from "../../converter"; + +export const convertComponentMaxInlineDeclarations: RuleConverter = (tslintRule) => { + return { + rules: [ + { + ...(tslintRule.ruleArguments.length !== 0 && { + ruleArguments: [...tslintRule.ruleArguments], + }), + ruleName: "@angular-eslint/component-max-inline-declarations", + }, + ], + plugins: ["@angular-eslint/eslint-plugin"], + }; +}; diff --git a/src/rules/converters/codelyzer/tests/component-max-inline-declarations.test.ts b/src/rules/converters/codelyzer/tests/component-max-inline-declarations.test.ts new file mode 100644 index 000000000..b03785b9e --- /dev/null +++ b/src/rules/converters/codelyzer/tests/component-max-inline-declarations.test.ts @@ -0,0 +1,46 @@ +import { convertComponentMaxInlineDeclarations } from "../component-max-inline-declarations"; + +describe(convertComponentMaxInlineDeclarations, () => { + test("conversion without arguments", () => { + const result = convertComponentMaxInlineDeclarations({ + ruleArguments: [], + }); + + expect(result).toEqual({ + rules: [ + { + ruleName: "@angular-eslint/component-max-inline-declarations", + }, + ], + plugins: ["@angular-eslint/eslint-plugin"], + }); + }); + + test("conversion with arguments", () => { + const result = convertComponentMaxInlineDeclarations({ + ruleArguments: [ + { + template: 7, + styles: 2, + animations: 10, + }, + ], + }); + + expect(result).toEqual({ + rules: [ + { + ruleArguments: [ + { + template: 7, + styles: 2, + animations: 10, + }, + ], + ruleName: "@angular-eslint/component-max-inline-declarations", + }, + ], + plugins: ["@angular-eslint/eslint-plugin"], + }); + }); +}); diff --git a/src/rules/rulesConverters.ts b/src/rules/rulesConverters.ts index 14034375c..383b0891e 100644 --- a/src/rules/rulesConverters.ts +++ b/src/rules/rulesConverters.ts @@ -139,6 +139,7 @@ import { convertVariableName } from "./converters/variable-name"; // Codelyzer converters import { convertComponentClassSuffix } from "./converters/codelyzer/component-class-suffix"; +import { convertComponentMaxInlineDeclarations } from "./converters/codelyzer/component-max-inline-declarations"; import { convertComponentSelector } from "./converters/codelyzer/component-selector"; /** @@ -159,6 +160,7 @@ export const rulesConverters = new Map([ ["class-name", convertClassName], ["comment-format", convertCommentFormat], ["component-class-suffix", convertComponentClassSuffix], + ["component-max-inline-declarations", convertComponentMaxInlineDeclarations], ["component-selector", convertComponentSelector], ["curly", convertCurly], ["cyclomatic-complexity", convertCyclomaticComplexity],