diff --git a/src/converters/lintConfigs/rules/ruleConverters.ts b/src/converters/lintConfigs/rules/ruleConverters.ts index 093edb285..3305de3c9 100644 --- a/src/converters/lintConfigs/rules/ruleConverters.ts +++ b/src/converters/lintConfigs/rules/ruleConverters.ts @@ -135,6 +135,7 @@ import { convertTripleEquals } from "./ruleConverters/triple-equals"; import { convertTypedefWhitespace } from "./ruleConverters/typedef-whitespace"; import { convertTypeLiteralDelimiter } from "./ruleConverters/type-literal-delimiter"; import { convertTypeofCompare } from "./ruleConverters/typeof-compare"; +import { convertUnderscoreConsistentInvocation } from "./ruleConverters/underscore-consistent-invocation"; import { convertUnifiedSignatures } from "./ruleConverters/unified-signatures"; import { convertUnnecessaryBind } from "./ruleConverters/unnecessary-bind"; import { convertUnnecessaryConstructor } from "./ruleConverters/unnecessary-constructor"; @@ -421,6 +422,7 @@ export const ruleConverters = new Map([ ["type-literal-delimiter", convertTypeLiteralDelimiter], ["typedef-whitespace", convertTypedefWhitespace], ["typeof-compare", convertTypeofCompare], + ["underscore-consistent-invocation", convertUnderscoreConsistentInvocation], ["unified-signatures", convertUnifiedSignatures], ["unnecessary-bind", convertUnnecessaryBind], ["unnecessary-constructor", convertUnnecessaryConstructor], diff --git a/src/converters/lintConfigs/rules/ruleConverters/tests/underscore-consistent-invocation.test.ts b/src/converters/lintConfigs/rules/ruleConverters/tests/underscore-consistent-invocation.test.ts new file mode 100644 index 000000000..8e76a5e0a --- /dev/null +++ b/src/converters/lintConfigs/rules/ruleConverters/tests/underscore-consistent-invocation.test.ts @@ -0,0 +1,51 @@ +import { convertUnderscoreConsistentInvocation } from "../underscore-consistent-invocation"; + +describe(convertUnderscoreConsistentInvocation, () => { + test("conversion without arguments", () => { + const result = convertUnderscoreConsistentInvocation({ + ruleArguments: [], + }); + + expect(result).toEqual({ + plugins: ["eslint-plugin-lodash"], + rules: [ + { + ruleArguments: ['never'], + ruleName: "lodash/chaining", + }, + ], + }); + }); + + test("conversion with an instance argument", () => { + const result = convertUnderscoreConsistentInvocation({ + ruleArguments: ['instance'], + }); + + expect(result).toEqual({ + plugins: ["eslint-plugin-lodash"], + rules: [ + { + ruleArguments: ['never'], + ruleName: "lodash/chaining", + }, + ], + }); + }); + + test("conversion with a static argument", () => { + const result = convertUnderscoreConsistentInvocation({ + ruleArguments: ['static'], + }); + + expect(result).toEqual({ + plugins: ["eslint-plugin-lodash"], + rules: [ + { + ruleArguments: ['always', 0], + ruleName: "lodash/chaining", + }, + ], + }); + }); +}); diff --git a/src/converters/lintConfigs/rules/ruleConverters/underscore-consistent-invocation.ts b/src/converters/lintConfigs/rules/ruleConverters/underscore-consistent-invocation.ts new file mode 100644 index 000000000..9819f6f16 --- /dev/null +++ b/src/converters/lintConfigs/rules/ruleConverters/underscore-consistent-invocation.ts @@ -0,0 +1,15 @@ +import { RuleConverter } from "../ruleConverter"; + +export const convertUnderscoreConsistentInvocation: RuleConverter = (tslintRule) => { + return { + plugins: ["eslint-plugin-lodash"], + rules: [ + { + ruleArguments: tslintRule.ruleArguments.length === 0 || tslintRule.ruleArguments[0] === 'instance' + ? ['never'] + : ['always', 0], + ruleName: "lodash/chaining", + }, + ], + }; +};