Skip to content

Commit 4396ef7

Browse files
author
Josh Goldberg
authored
Added converter for underscore-consistent-invocation (#1071)
* Added converter for underscore-consistent-invocation * Switched to 0 for always, only
1 parent 50842ed commit 4396ef7

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

src/converters/lintConfigs/rules/ruleConverters.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ import { convertTripleEquals } from "./ruleConverters/triple-equals";
140140
import { convertTypedefWhitespace } from "./ruleConverters/typedef-whitespace";
141141
import { convertTypeLiteralDelimiter } from "./ruleConverters/type-literal-delimiter";
142142
import { convertTypeofCompare } from "./ruleConverters/typeof-compare";
143+
import { convertUnderscoreConsistentInvocation } from "./ruleConverters/underscore-consistent-invocation";
143144
import { convertUnifiedSignatures } from "./ruleConverters/unified-signatures";
144145
import { convertUnnecessaryBind } from "./ruleConverters/unnecessary-bind";
145146
import { convertUnnecessaryConstructor } from "./ruleConverters/unnecessary-constructor";
@@ -431,6 +432,7 @@ export const ruleConverters = new Map([
431432
["type-literal-delimiter", convertTypeLiteralDelimiter],
432433
["typedef-whitespace", convertTypedefWhitespace],
433434
["typeof-compare", convertTypeofCompare],
435+
["underscore-consistent-invocation", convertUnderscoreConsistentInvocation],
434436
["unified-signatures", convertUnifiedSignatures],
435437
["unnecessary-bind", convertUnnecessaryBind],
436438
["unnecessary-constructor", convertUnnecessaryConstructor],
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { convertUnderscoreConsistentInvocation } from "../underscore-consistent-invocation";
2+
3+
describe(convertUnderscoreConsistentInvocation, () => {
4+
test("conversion without arguments", () => {
5+
const result = convertUnderscoreConsistentInvocation({
6+
ruleArguments: [],
7+
});
8+
9+
expect(result).toEqual({
10+
plugins: ["eslint-plugin-lodash"],
11+
rules: [
12+
{
13+
ruleArguments: ['never'],
14+
ruleName: "lodash/chaining",
15+
},
16+
],
17+
});
18+
});
19+
20+
test("conversion with an instance argument", () => {
21+
const result = convertUnderscoreConsistentInvocation({
22+
ruleArguments: ['instance'],
23+
});
24+
25+
expect(result).toEqual({
26+
plugins: ["eslint-plugin-lodash"],
27+
rules: [
28+
{
29+
ruleArguments: ['never'],
30+
ruleName: "lodash/chaining",
31+
},
32+
],
33+
});
34+
});
35+
36+
test("conversion with a static argument", () => {
37+
const result = convertUnderscoreConsistentInvocation({
38+
ruleArguments: ['static'],
39+
});
40+
41+
expect(result).toEqual({
42+
plugins: ["eslint-plugin-lodash"],
43+
rules: [
44+
{
45+
ruleArguments: ['always', 0],
46+
ruleName: "lodash/chaining",
47+
},
48+
],
49+
});
50+
});
51+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { RuleConverter } from "../ruleConverter";
2+
3+
export const convertUnderscoreConsistentInvocation: RuleConverter = (tslintRule) => {
4+
return {
5+
plugins: ["eslint-plugin-lodash"],
6+
rules: [
7+
{
8+
ruleArguments: tslintRule.ruleArguments.length === 0 || tslintRule.ruleArguments[0] === 'instance'
9+
? ['never']
10+
: ['always', 0],
11+
ruleName: "lodash/chaining",
12+
},
13+
],
14+
};
15+
};

0 commit comments

Comments
 (0)