From 311570b30178e5c86a0d342461ddb65e824d21b9 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Mon, 29 Mar 2021 02:45:19 -0400 Subject: [PATCH 1/3] Added prefer-array-literal constructor No rule options. Nice and easy. --- .../lintConfigs/rules/ruleConverters.ts | 2 ++ .../ruleConverters/prefer-array-literal.ts | 11 +++++++++++ .../tests/prefer-array-literal.test.ts | 17 +++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 src/converters/lintConfigs/rules/ruleConverters/prefer-array-literal.ts create mode 100644 src/converters/lintConfigs/rules/ruleConverters/tests/prefer-array-literal.test.ts diff --git a/src/converters/lintConfigs/rules/ruleConverters.ts b/src/converters/lintConfigs/rules/ruleConverters.ts index 82f53ff2d..f97b98949 100644 --- a/src/converters/lintConfigs/rules/ruleConverters.ts +++ b/src/converters/lintConfigs/rules/ruleConverters.ts @@ -110,6 +110,7 @@ import { convertOneLine } from "./ruleConverters/one-line"; import { convertOneVariablePerDeclaration } from "./ruleConverters/one-variable-per-declaration"; import { convertOnlyArrowFunctions } from "./ruleConverters/only-arrow-functions"; import { convertOrderedImports } from "./ruleConverters/ordered-imports"; +import { convertPreferArrayLiteral } from "./ruleConverters/prefer-array-literal"; import { convertPreferConst } from "./ruleConverters/prefer-const"; import { convertPreferForOf } from "./ruleConverters/prefer-for-of"; import { convertPreferFunctionOverMethod } from "./ruleConverters/prefer-function-over-method"; @@ -367,6 +368,7 @@ export const ruleConverters = new Map([ ["only-arrow-functions", convertOnlyArrowFunctions], ["ordered-imports", convertOrderedImports], ["pipe-prefix", convertPipePrefix], + ["prefer-array-literal", convertPreferArrayLiteral], ["prefer-const", convertPreferConst], ["prefer-for-of", convertPreferForOf], ["prefer-function-over-method", convertPreferFunctionOverMethod], diff --git a/src/converters/lintConfigs/rules/ruleConverters/prefer-array-literal.ts b/src/converters/lintConfigs/rules/ruleConverters/prefer-array-literal.ts new file mode 100644 index 000000000..5cfe04729 --- /dev/null +++ b/src/converters/lintConfigs/rules/ruleConverters/prefer-array-literal.ts @@ -0,0 +1,11 @@ +import { RuleConverter } from "../ruleConverter"; + +export const convertPreferArrayLiteral: RuleConverter = () => { + return { + rules: [ + { + ruleName: "@typescript-eslint/no-array-constructor", + }, + ], + }; +}; diff --git a/src/converters/lintConfigs/rules/ruleConverters/tests/prefer-array-literal.test.ts b/src/converters/lintConfigs/rules/ruleConverters/tests/prefer-array-literal.test.ts new file mode 100644 index 000000000..90d358c04 --- /dev/null +++ b/src/converters/lintConfigs/rules/ruleConverters/tests/prefer-array-literal.test.ts @@ -0,0 +1,17 @@ +import { convertPreferArrayLiteral } from "../prefer-array-literal"; + +describe(convertPreferArrayLiteral, () => { + test("conversion without arguments", () => { + const result = convertPreferArrayLiteral({ + ruleArguments: [], + }); + + expect(result).toEqual({ + rules: [ + { + ruleName: "@typescript-eslint/no-array-constructor", + }, + ], + }); + }); +}); From 1d85c73f45fd4a9810081f86145ed21e4af05b41 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sun, 16 May 2021 19:55:10 -0400 Subject: [PATCH 2/3] Post merge touchups --- src/api/convertFileCommentsStandalone.ts | 4 ++-- src/converters/lintConfigs/rules/ruleConverters.ts | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/api/convertFileCommentsStandalone.ts b/src/api/convertFileCommentsStandalone.ts index 4307a4f2b..af1095123 100644 --- a/src/api/convertFileCommentsStandalone.ts +++ b/src/api/convertFileCommentsStandalone.ts @@ -33,8 +33,8 @@ export type ConvertFileCommentsStandaloneDependencies = { export const convertFileCommentsStandalone = ({ fileContent, filePath, - ruleCommentsCache = new Map(), - ruleEquivalents = new Map(), + ruleCommentsCache = new Map(), + ruleEquivalents = new Map(), }: ConvertFileCommentsStandaloneDependencies) => { const comments = parseFileComments(filePath, fileContent); diff --git a/src/converters/lintConfigs/rules/ruleConverters.ts b/src/converters/lintConfigs/rules/ruleConverters.ts index df723aea4..093edb285 100644 --- a/src/converters/lintConfigs/rules/ruleConverters.ts +++ b/src/converters/lintConfigs/rules/ruleConverters.ts @@ -112,8 +112,11 @@ import { convertOneLine } from "./ruleConverters/one-line"; import { convertOneVariablePerDeclaration } from "./ruleConverters/one-variable-per-declaration"; import { convertOnlyArrowFunctions } from "./ruleConverters/only-arrow-functions"; import { convertOrderedImports } from "./ruleConverters/ordered-imports"; +import { convertPreferArrayLiteral } from "./ruleConverters/prefer-array-literal"; import { convertPreferConditionalExpression } from "./ruleConverters/prefer-conditional-expression"; +import { convertPreferConst } from "./ruleConverters/prefer-const"; import { convertPreferForOf } from "./ruleConverters/prefer-for-of"; +import { convertPreferFunctionOverMethod } from "./ruleConverters/prefer-function-over-method"; import { convertPreferObjectSpread } from "./ruleConverters/prefer-object-spread"; import { convertPreferReadonly } from "./ruleConverters/prefer-readonly"; import { convertPreferSwitch } from "./ruleConverters/prefer-switch"; From 12359bd35eded53029836faa90800dded359623f Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sun, 16 May 2021 20:17:01 -0400 Subject: [PATCH 3/3] Added no-array-constructor off --- .../lintConfigs/rules/ruleConverters/prefer-array-literal.ts | 4 ++++ .../rules/ruleConverters/tests/prefer-array-literal.test.ts | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/converters/lintConfigs/rules/ruleConverters/prefer-array-literal.ts b/src/converters/lintConfigs/rules/ruleConverters/prefer-array-literal.ts index 5cfe04729..00c47ed9f 100644 --- a/src/converters/lintConfigs/rules/ruleConverters/prefer-array-literal.ts +++ b/src/converters/lintConfigs/rules/ruleConverters/prefer-array-literal.ts @@ -3,6 +3,10 @@ import { RuleConverter } from "../ruleConverter"; export const convertPreferArrayLiteral: RuleConverter = () => { return { rules: [ + { + ruleName: "no-array-constructor", + ruleSeverity: "off" + }, { ruleName: "@typescript-eslint/no-array-constructor", }, diff --git a/src/converters/lintConfigs/rules/ruleConverters/tests/prefer-array-literal.test.ts b/src/converters/lintConfigs/rules/ruleConverters/tests/prefer-array-literal.test.ts index 90d358c04..0e48424bf 100644 --- a/src/converters/lintConfigs/rules/ruleConverters/tests/prefer-array-literal.test.ts +++ b/src/converters/lintConfigs/rules/ruleConverters/tests/prefer-array-literal.test.ts @@ -8,6 +8,10 @@ describe(convertPreferArrayLiteral, () => { expect(result).toEqual({ rules: [ + { + ruleName: "no-array-constructor", + ruleSeverity: "off" + }, { ruleName: "@typescript-eslint/no-array-constructor", },