From 34987cc55414f46125608dd413785783b9f86e7e Mon Sep 17 00:00:00 2001 From: Budi Irawan Date: Sun, 6 Oct 2019 21:50:09 +1100 Subject: [PATCH 1/3] add no-duplicate-variable converter and unit test --- src/rules/converters.ts | 2 ++ src/rules/converters/no-duplicate-variable.ts | 14 ++++++++ .../tests/no-duplicate-variable.test.ts | 32 +++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 src/rules/converters/no-duplicate-variable.ts create mode 100644 src/rules/converters/tests/no-duplicate-variable.test.ts diff --git a/src/rules/converters.ts b/src/rules/converters.ts index 78b2b9e94..5bb763a2b 100644 --- a/src/rules/converters.ts +++ b/src/rules/converters.ts @@ -43,6 +43,7 @@ import { convertNoDebugger } from "./converters/no-debugger"; import { convertNoDuplicateImports } from "./converters/no-duplicate-imports"; import { convertNoDuplicateSuper } from "./converters/no-duplicate-super"; import { convertNoDuplicateSwitchCase } from "./converters/no-duplicate-switch-case"; +import { convertNoDuplicateVariable } from "./converters/no-duplicate-variable"; import { convertNoEmpty } from "./converters/no-empty"; import { convertNoEmptyInterface } from "./converters/no-empty-interface"; import { convertNoEval } from "./converters/no-eval"; @@ -161,6 +162,7 @@ export const converters = new Map([ ["no-duplicate-imports", convertNoDuplicateImports], ["no-duplicate-super", convertNoDuplicateSuper], ["no-duplicate-switch-case", convertNoDuplicateSwitchCase], + ["no-duplicate-variable", convertNoDuplicateVariable], ["no-empty-interface", convertNoEmptyInterface], ["no-empty", convertNoEmpty], ["no-eval", convertNoEval], diff --git a/src/rules/converters/no-duplicate-variable.ts b/src/rules/converters/no-duplicate-variable.ts new file mode 100644 index 000000000..ab3d984af --- /dev/null +++ b/src/rules/converters/no-duplicate-variable.ts @@ -0,0 +1,14 @@ +import { RuleConverter } from "../converter"; + +export const convertNoDuplicateVariable: RuleConverter = tslintRule => { + return { + rules: [ + { + ...(tslintRule.ruleArguments.includes("check-parameters") && { + notices: ["ESLint does not support check parameters."], + }), + ruleName: "no-redeclare", + }, + ], + }; +}; diff --git a/src/rules/converters/tests/no-duplicate-variable.test.ts b/src/rules/converters/tests/no-duplicate-variable.test.ts new file mode 100644 index 000000000..ef0fdfbd3 --- /dev/null +++ b/src/rules/converters/tests/no-duplicate-variable.test.ts @@ -0,0 +1,32 @@ +import { convertNoDuplicateVariable } from "../no-duplicate-variable"; + +describe(convertNoDuplicateVariable, () => { + test("conversion without arguments", () => { + const result = convertNoDuplicateVariable({ + ruleArguments: [], + }); + + expect(result).toEqual({ + rules: [ + { + ruleName: "no-redeclare", + }, + ], + }); + }); + + test("conversion with check parameters argument", () => { + const result = convertNoDuplicateVariable({ + ruleArguments: ["check-parameters"], + }); + + expect(result).toEqual({ + rules: [ + { + ruleName: "no-redeclare", + notices: ["ESLint does not support check parameters."], + }, + ], + }); + }); +}); From d7484829c6f5b6d7c4c78dd2dd774253a28c213a Mon Sep 17 00:00:00 2001 From: Budi Irawan Date: Mon, 7 Oct 2019 07:12:50 +1100 Subject: [PATCH 2/3] add dash in check parameters Co-Authored-By: Josh Goldberg --- src/rules/converters/no-duplicate-variable.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rules/converters/no-duplicate-variable.ts b/src/rules/converters/no-duplicate-variable.ts index ab3d984af..8d0a64c73 100644 --- a/src/rules/converters/no-duplicate-variable.ts +++ b/src/rules/converters/no-duplicate-variable.ts @@ -5,7 +5,7 @@ export const convertNoDuplicateVariable: RuleConverter = tslintRule => { rules: [ { ...(tslintRule.ruleArguments.includes("check-parameters") && { - notices: ["ESLint does not support check parameters."], + notices: ["ESLint does not support check-parameters."], }), ruleName: "no-redeclare", }, From 1c05e3af1f60496ba04fe5d4edac7211f243fd64 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Mon, 7 Oct 2019 05:40:48 -0400 Subject: [PATCH 3/3] Update no-duplicate-variable.test.ts --- src/rules/converters/tests/no-duplicate-variable.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rules/converters/tests/no-duplicate-variable.test.ts b/src/rules/converters/tests/no-duplicate-variable.test.ts index ef0fdfbd3..329e225b4 100644 --- a/src/rules/converters/tests/no-duplicate-variable.test.ts +++ b/src/rules/converters/tests/no-duplicate-variable.test.ts @@ -24,7 +24,7 @@ describe(convertNoDuplicateVariable, () => { rules: [ { ruleName: "no-redeclare", - notices: ["ESLint does not support check parameters."], + notices: ["ESLint does not support check-parameters."], }, ], });