Skip to content

Commit 2f92ded

Browse files
deerawanJosh Goldberg
authored and
Josh Goldberg
committed
add no-duplicate-variable converter and unit test (#214)
* add no-duplicate-variable converter and unit test * add dash in check parameters Co-Authored-By: Josh Goldberg <joshuakgoldberg@outlook.com> * Update no-duplicate-variable.test.ts
1 parent d8d34d8 commit 2f92ded

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

src/rules/converters.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import { convertNoDefaultExport } from "./converters/no-default-export";
4545
import { convertNoDuplicateImports } from "./converters/no-duplicate-imports";
4646
import { convertNoDuplicateSuper } from "./converters/no-duplicate-super";
4747
import { convertNoDuplicateSwitchCase } from "./converters/no-duplicate-switch-case";
48+
import { convertNoDuplicateVariable } from "./converters/no-duplicate-variable";
4849
import { convertNoEmpty } from "./converters/no-empty";
4950
import { convertNoEmptyInterface } from "./converters/no-empty-interface";
5051
import { convertNoEval } from "./converters/no-eval";
@@ -172,6 +173,7 @@ export const converters = new Map([
172173
["no-duplicate-imports", convertNoDuplicateImports],
173174
["no-duplicate-super", convertNoDuplicateSuper],
174175
["no-duplicate-switch-case", convertNoDuplicateSwitchCase],
176+
["no-duplicate-variable", convertNoDuplicateVariable],
175177
["no-empty-interface", convertNoEmptyInterface],
176178
["no-empty", convertNoEmpty],
177179
["no-eval", convertNoEval],
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { RuleConverter } from "../converter";
2+
3+
export const convertNoDuplicateVariable: RuleConverter = tslintRule => {
4+
return {
5+
rules: [
6+
{
7+
...(tslintRule.ruleArguments.includes("check-parameters") && {
8+
notices: ["ESLint does not support check-parameters."],
9+
}),
10+
ruleName: "no-redeclare",
11+
},
12+
],
13+
};
14+
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { convertNoDuplicateVariable } from "../no-duplicate-variable";
2+
3+
describe(convertNoDuplicateVariable, () => {
4+
test("conversion without arguments", () => {
5+
const result = convertNoDuplicateVariable({
6+
ruleArguments: [],
7+
});
8+
9+
expect(result).toEqual({
10+
rules: [
11+
{
12+
ruleName: "no-redeclare",
13+
},
14+
],
15+
});
16+
});
17+
18+
test("conversion with check parameters argument", () => {
19+
const result = convertNoDuplicateVariable({
20+
ruleArguments: ["check-parameters"],
21+
});
22+
23+
expect(result).toEqual({
24+
rules: [
25+
{
26+
ruleName: "no-redeclare",
27+
notices: ["ESLint does not support check-parameters."],
28+
},
29+
],
30+
});
31+
});
32+
});

0 commit comments

Comments
 (0)