diff --git a/src/converters/lintConfigs/rules/ruleConverters.ts b/src/converters/lintConfigs/rules/ruleConverters.ts index 093edb285..153b4bf97 100644 --- a/src/converters/lintConfigs/rules/ruleConverters.ts +++ b/src/converters/lintConfigs/rules/ruleConverters.ts @@ -90,6 +90,7 @@ import { convertNoSparseArrays } from "./ruleConverters/no-sparse-arrays"; import { convertNoStringLiteral } from "./ruleConverters/no-string-literal"; import { convertNoStringThrow } from "./ruleConverters/no-string-throw"; import { convertNoSubmoduleImports } from "./ruleConverters/no-submodule-imports"; +import { convertNoSuspiciousComment } from "./ruleConverters/no-suspicious-comment"; import { convertNoSwitchCaseFallThrough } from "./ruleConverters/no-switch-case-fall-through"; import { convertNoThisAssignment } from "./ruleConverters/no-this-assignment"; import { convertNoTrailingWhitespace } from "./ruleConverters/no-trailing-whitespace"; @@ -354,6 +355,7 @@ export const ruleConverters = new Map([ ["no-string-literal", convertNoStringLiteral], ["no-string-throw", convertNoStringThrow], ["no-submodule-imports", convertNoSubmoduleImports], + ["no-suspicious-comment", convertNoSuspiciousComment], ["no-switch-case-fall-through", convertNoSwitchCaseFallThrough], ["no-this-assignment", convertNoThisAssignment], ["no-trailing-whitespace", convertNoTrailingWhitespace], diff --git a/src/converters/lintConfigs/rules/ruleConverters/no-suspicious-comment.ts b/src/converters/lintConfigs/rules/ruleConverters/no-suspicious-comment.ts new file mode 100644 index 000000000..13b3407b7 --- /dev/null +++ b/src/converters/lintConfigs/rules/ruleConverters/no-suspicious-comment.ts @@ -0,0 +1,20 @@ +import { RuleConverter } from "../ruleConverter"; + +export const convertNoSuspiciousComment: RuleConverter = (tslintRule) => { + return { + rules: [ + { + ...(tslintRule.ruleArguments.length !== 0 + ? { notices: ["ESLint's no-warning-comments does not allow an array of terms to match."] } + : {}), + ruleArguments: [ + { + location: "anywhere", + terms: ['BUG', 'HACK', 'FIXME', 'LATER', 'LATER2', 'TODO'] + } + ], + ruleName: "no-warning-comments", + }, + ], + }; +}; diff --git a/src/converters/lintConfigs/rules/ruleConverters/tests/no-suspicious-comment.test.ts b/src/converters/lintConfigs/rules/ruleConverters/tests/no-suspicious-comment.test.ts new file mode 100644 index 000000000..df72076e5 --- /dev/null +++ b/src/converters/lintConfigs/rules/ruleConverters/tests/no-suspicious-comment.test.ts @@ -0,0 +1,44 @@ +import { convertNoSuspiciousComment } from "../no-suspicious-comment"; + +describe(convertNoSuspiciousComment, () => { + test("conversion without arguments", () => { + const result = convertNoSuspiciousComment({ + ruleArguments: [], + }); + + expect(result).toEqual({ + rules: [ + { + ruleArguments: [ + { + location: "anywhere", + terms: ['BUG', 'HACK', 'FIXME', 'LATER', 'LATER2', 'TODO'] + } + ], + ruleName: "no-warning-comments", + }, + ], + }); + }); + + test("conversion with terms argument", () => { + const result = convertNoSuspiciousComment({ + ruleArguments: ["https://github.com/my-org/my-project/(.*)"], + }); + + expect(result).toEqual({ + rules: [ + { + notices: ["ESLint's no-warning-comments does not allow an array of terms to match."], + ruleArguments: [ + { + location: "anywhere", + terms: ['BUG', 'HACK', 'FIXME', 'LATER', 'LATER2', 'TODO'] + } + ], + ruleName: "no-warning-comments", + }, + ], + }); + }); +});