From b8c653f8076f2a31dbd9e3fc8bfbafb26741b6b5 Mon Sep 17 00:00:00 2001 From: KingDarBoja Date: Mon, 4 May 2020 22:15:31 -0500 Subject: [PATCH] Add codelyzer component-max-inline-declarations converter --- .../component-max-inline-declarations.ts | 15 ++++++ .../component-max-inline-declarations.test.ts | 46 +++++++++++++++++++ src/rules/rulesConverters.ts | 2 + 3 files changed, 63 insertions(+) create mode 100644 src/rules/converters/codelyzer/component-max-inline-declarations.ts create mode 100644 src/rules/converters/codelyzer/tests/component-max-inline-declarations.test.ts 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 206f02b00..559d7ba42 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"; /** * Keys TSLint rule names to their ESLint rule converters. @@ -158,6 +159,7 @@ export const rulesConverters = new Map([ ["class-name", convertClassName], ["comment-format", convertCommentFormat], ["component-class-suffix", convertComponentClassSuffix], + ["component-max-inline-declarations", convertComponentMaxInlineDeclarations], ["curly", convertCurly], ["cyclomatic-complexity", convertCyclomaticComplexity], ["deprecation", convertDeprecation],