From 6ff31d94bf296eed60a1a8559ab390bf67c08cf7 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Tue, 18 May 2021 23:08:18 -0400 Subject: [PATCH 1/2] Added converter for no-suspicious-comment --- .../lintConfigs/rules/ruleConverters.ts | 2 + .../ruleConverters/no-suspicious-comment.ts | 20 +++++++++ .../tests/no-suspicious-comment.test.ts | 44 +++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 src/converters/lintConfigs/rules/ruleConverters/no-suspicious-comment.ts create mode 100644 src/converters/lintConfigs/rules/ruleConverters/tests/no-suspicious-comment.test.ts 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..a49e0b35b --- /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 ignore."] } + : {}), + 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..7b87da47c --- /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 ignore."], + ruleArguments: [ + { + location: "anywhere", + terms: ['BUG', 'HACK', 'FIXME', 'LATER', 'LATER2', 'TODO'] + } + ], + ruleName: "no-warning-comments", + }, + ], + }); + }); +}); From 89b2353331220465fb9126083596c8f701651e25 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Fri, 21 May 2021 00:00:30 -0400 Subject: [PATCH 2/2] match, not ignore --- .../lintConfigs/rules/ruleConverters/no-suspicious-comment.ts | 2 +- .../rules/ruleConverters/tests/no-suspicious-comment.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/converters/lintConfigs/rules/ruleConverters/no-suspicious-comment.ts b/src/converters/lintConfigs/rules/ruleConverters/no-suspicious-comment.ts index a49e0b35b..13b3407b7 100644 --- a/src/converters/lintConfigs/rules/ruleConverters/no-suspicious-comment.ts +++ b/src/converters/lintConfigs/rules/ruleConverters/no-suspicious-comment.ts @@ -5,7 +5,7 @@ export const convertNoSuspiciousComment: RuleConverter = (tslintRule) => { rules: [ { ...(tslintRule.ruleArguments.length !== 0 - ? { notices: ["ESLint's no-warning-comments does not allow an array of terms to ignore."] } + ? { notices: ["ESLint's no-warning-comments does not allow an array of terms to match."] } : {}), ruleArguments: [ { 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 index 7b87da47c..df72076e5 100644 --- a/src/converters/lintConfigs/rules/ruleConverters/tests/no-suspicious-comment.test.ts +++ b/src/converters/lintConfigs/rules/ruleConverters/tests/no-suspicious-comment.test.ts @@ -29,7 +29,7 @@ describe(convertNoSuspiciousComment, () => { expect(result).toEqual({ rules: [ { - notices: ["ESLint's no-warning-comments does not allow an array of terms to ignore."], + notices: ["ESLint's no-warning-comments does not allow an array of terms to match."], ruleArguments: [ { location: "anywhere",