Skip to content

Commit 3d3d7f8

Browse files
author
Josh Goldberg
authored
Added converter for no-suspicious-comment (#1069)
* Added converter for no-suspicious-comment * match, not ignore
1 parent fcfabad commit 3d3d7f8

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

src/converters/lintConfigs/rules/ruleConverters.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ import { convertNoSparseArrays } from "./ruleConverters/no-sparse-arrays";
9393
import { convertNoStringLiteral } from "./ruleConverters/no-string-literal";
9494
import { convertNoStringThrow } from "./ruleConverters/no-string-throw";
9595
import { convertNoSubmoduleImports } from "./ruleConverters/no-submodule-imports";
96+
import { convertNoSuspiciousComment } from "./ruleConverters/no-suspicious-comment";
9697
import { convertNoSwitchCaseFallThrough } from "./ruleConverters/no-switch-case-fall-through";
9798
import { convertNoThisAssignment } from "./ruleConverters/no-this-assignment";
9899
import { convertNoTrailingWhitespace } from "./ruleConverters/no-trailing-whitespace";
@@ -361,6 +362,7 @@ export const ruleConverters = new Map([
361362
["no-string-literal", convertNoStringLiteral],
362363
["no-string-throw", convertNoStringThrow],
363364
["no-submodule-imports", convertNoSubmoduleImports],
365+
["no-suspicious-comment", convertNoSuspiciousComment],
364366
["no-switch-case-fall-through", convertNoSwitchCaseFallThrough],
365367
["no-this-assignment", convertNoThisAssignment],
366368
["no-trailing-whitespace", convertNoTrailingWhitespace],
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { RuleConverter } from "../ruleConverter";
2+
3+
export const convertNoSuspiciousComment: RuleConverter = (tslintRule) => {
4+
return {
5+
rules: [
6+
{
7+
...(tslintRule.ruleArguments.length !== 0
8+
? { notices: ["ESLint's no-warning-comments does not allow an array of terms to match."] }
9+
: {}),
10+
ruleArguments: [
11+
{
12+
location: "anywhere",
13+
terms: ['BUG', 'HACK', 'FIXME', 'LATER', 'LATER2', 'TODO']
14+
}
15+
],
16+
ruleName: "no-warning-comments",
17+
},
18+
],
19+
};
20+
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { convertNoSuspiciousComment } from "../no-suspicious-comment";
2+
3+
describe(convertNoSuspiciousComment, () => {
4+
test("conversion without arguments", () => {
5+
const result = convertNoSuspiciousComment({
6+
ruleArguments: [],
7+
});
8+
9+
expect(result).toEqual({
10+
rules: [
11+
{
12+
ruleArguments: [
13+
{
14+
location: "anywhere",
15+
terms: ['BUG', 'HACK', 'FIXME', 'LATER', 'LATER2', 'TODO']
16+
}
17+
],
18+
ruleName: "no-warning-comments",
19+
},
20+
],
21+
});
22+
});
23+
24+
test("conversion with terms argument", () => {
25+
const result = convertNoSuspiciousComment({
26+
ruleArguments: ["https://github.com/my-org/my-project/(.*)"],
27+
});
28+
29+
expect(result).toEqual({
30+
rules: [
31+
{
32+
notices: ["ESLint's no-warning-comments does not allow an array of terms to match."],
33+
ruleArguments: [
34+
{
35+
location: "anywhere",
36+
terms: ['BUG', 'HACK', 'FIXME', 'LATER', 'LATER2', 'TODO']
37+
}
38+
],
39+
ruleName: "no-warning-comments",
40+
},
41+
],
42+
});
43+
});
44+
});

0 commit comments

Comments
 (0)