diff --git a/src/rules/converters/codelyzer/no-input-prefix.ts b/src/rules/converters/codelyzer/no-input-prefix.ts new file mode 100644 index 00000000..f5c3b886 --- /dev/null +++ b/src/rules/converters/codelyzer/no-input-prefix.ts @@ -0,0 +1,19 @@ +import { RuleConverter } from "../../converter"; + +export const convertNoInputPrefix: RuleConverter = (tslintRule) => { + return { + rules: [ + { + ...(tslintRule.ruleArguments.length !== 0 && { + ruleArguments: [ + { + prefixes: tslintRule.ruleArguments, + }, + ], + }), + ruleName: "@angular-eslint/no-input-prefix", + }, + ], + plugins: ["@angular-eslint/eslint-plugin"], + }; +}; diff --git a/src/rules/converters/codelyzer/tests/no-input-prefix.test.ts b/src/rules/converters/codelyzer/tests/no-input-prefix.test.ts new file mode 100644 index 00000000..0f09fea1 --- /dev/null +++ b/src/rules/converters/codelyzer/tests/no-input-prefix.test.ts @@ -0,0 +1,38 @@ +import { convertNoInputPrefix } from "../no-input-prefix"; + +describe(convertNoInputPrefix, () => { + test("conversion without arguments", () => { + const result = convertNoInputPrefix({ + ruleArguments: [], + }); + + expect(result).toEqual({ + rules: [ + { + ruleName: "@angular-eslint/no-input-prefix", + }, + ], + plugins: ["@angular-eslint/eslint-plugin"], + }); + }); + + test("conversion with arguments", () => { + const result = convertNoInputPrefix({ + ruleArguments: ["can", "is", "should"], + }); + + expect(result).toEqual({ + rules: [ + { + ruleArguments: [ + { + prefixes: ["can", "is", "should"], + }, + ], + ruleName: "@angular-eslint/no-input-prefix", + }, + ], + plugins: ["@angular-eslint/eslint-plugin"], + }); + }); +}); diff --git a/src/rules/rulesConverters.ts b/src/rules/rulesConverters.ts index 8cf684e8..d1346ba3 100644 --- a/src/rules/rulesConverters.ts +++ b/src/rules/rulesConverters.ts @@ -148,6 +148,7 @@ import { convertNoAttributeDecorator } from "./converters/codelyzer/no-attribute import { convertUsePipeDecorator } from "./converters/codelyzer/use-pipe-decorator"; import { convertNoForwardRef } from "./converters/codelyzer/no-forward-ref"; import { convertNoHostMetadataProperty } from "./converters/codelyzer/no-host-metadata-property"; +import { convertNoInputPrefix } from "./converters/codelyzer/no-input-prefix"; /** * Keys TSLint rule names to their ESLint rule converters. @@ -226,6 +227,7 @@ export const rulesConverters = new Map([ ["no-implicit-dependencies", convertNoImplicitDependencies], ["no-import-side-effect", convertNoImportSideEffect], ["no-inferrable-types", convertNoInferrableTypes], + ["no-input-prefix", convertNoInputPrefix], ["no-internal-module", convertNoInternalModule], ["no-invalid-regexp", convertNoInvalidRegexp], ["no-invalid-template-strings", convertNoInvalidTemplateStrings],