Skip to content

Commit edba604

Browse files
authored
fix(rule/variable-name): Use ruleArguments property (#1565)
1 parent 7f0f593 commit edba604

File tree

2 files changed

+58
-16
lines changed

2 files changed

+58
-16
lines changed

src/converters/lintConfigs/rules/ruleConverters/tests/variable-name.test.ts

Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe("convertVariableName", () => {
1717
rules: [
1818
{
1919
ruleName: "@typescript-eslint/naming-convention",
20-
rules: [
20+
ruleArguments: [
2121
{
2222
selector: "variable",
2323
format: ["camelCase", "UPPER_CASE"],
@@ -49,7 +49,7 @@ describe("convertVariableName", () => {
4949
rules: [
5050
{
5151
ruleName: "@typescript-eslint/naming-convention",
52-
rules: [
52+
ruleArguments: [
5353
{
5454
selector: "variable",
5555
format: ["camelCase", "UPPER_CASE"],
@@ -81,7 +81,7 @@ describe("convertVariableName", () => {
8181
rules: [
8282
{
8383
ruleName: "@typescript-eslint/naming-convention",
84-
rules: [
84+
ruleArguments: [
8585
{
8686
selector: "variable",
8787
format: ["camelCase", "UPPER_CASE"],
@@ -113,7 +113,7 @@ describe("convertVariableName", () => {
113113
rules: [
114114
{
115115
ruleName: "@typescript-eslint/naming-convention",
116-
rules: [
116+
ruleArguments: [
117117
{
118118
selector: "variable",
119119
format: ["camelCase", "UPPER_CASE", "PascalCase"],
@@ -145,7 +145,7 @@ describe("convertVariableName", () => {
145145
rules: [
146146
{
147147
ruleName: "@typescript-eslint/naming-convention",
148-
rules: [
148+
ruleArguments: [
149149
{
150150
selector: "variable",
151151
format: ["camelCase", "UPPER_CASE"],
@@ -177,7 +177,7 @@ describe("convertVariableName", () => {
177177
rules: [
178178
{
179179
ruleName: "@typescript-eslint/naming-convention",
180-
rules: [
180+
ruleArguments: [
181181
{
182182
selector: "variable",
183183
format: ["camelCase", "UPPER_CASE", "snake_case"],
@@ -209,7 +209,7 @@ describe("convertVariableName", () => {
209209
rules: [
210210
{
211211
ruleName: "@typescript-eslint/naming-convention",
212-
rules: [
212+
ruleArguments: [
213213
{
214214
selector: "variable",
215215
format: ["camelCase", "UPPER_CASE"],
@@ -241,7 +241,7 @@ describe("convertVariableName", () => {
241241
rules: [
242242
{
243243
ruleName: "@typescript-eslint/naming-convention",
244-
rules: [
244+
ruleArguments: [
245245
{
246246
selector: "variable",
247247
format: ["camelCase", "UPPER_CASE"],
@@ -273,7 +273,7 @@ describe("convertVariableName", () => {
273273
rules: [
274274
{
275275
ruleName: "@typescript-eslint/naming-convention",
276-
rules: [
276+
ruleArguments: [
277277
{
278278
selector: "variable",
279279
format: ["camelCase", "UPPER_CASE"],
@@ -296,6 +296,49 @@ describe("convertVariableName", () => {
296296
});
297297
});
298298

299+
test("conversion with ban-keywords argument without check-format argument", () => {
300+
const result = convertVariableName({
301+
ruleArguments: ["ban-keywords"],
302+
});
303+
304+
expect(result).toEqual({
305+
rules: [
306+
{
307+
ruleName: "@typescript-eslint/naming-convention",
308+
ruleArguments: [
309+
{
310+
selector: "variable",
311+
format: ["camelCase", "UPPER_CASE"],
312+
leadingUnderscore: "forbid",
313+
trailingUnderscore: "forbid",
314+
},
315+
],
316+
},
317+
{
318+
ruleName: "no-underscore-dangle",
319+
notices: [ForbiddenLeadingTrailingIdentifierMsg],
320+
},
321+
{
322+
ruleName: "id-denylist",
323+
ruleArguments: [
324+
"any",
325+
"Number",
326+
"number",
327+
"String",
328+
"string",
329+
"Boolean",
330+
"boolean",
331+
"Undefined",
332+
"undefined",
333+
],
334+
},
335+
{
336+
ruleName: "id-match",
337+
},
338+
],
339+
});
340+
});
341+
299342
test("conversion with require-const-for-all-caps argument and check-format argument", () => {
300343
const result = convertVariableName({
301344
ruleArguments: ["check-format", "require-const-for-all-caps"],
@@ -306,7 +349,7 @@ describe("convertVariableName", () => {
306349
{
307350
notices: [ConstRequiredForAllCapsMsg],
308351
ruleName: "@typescript-eslint/naming-convention",
309-
rules: [
352+
ruleArguments: [
310353
{
311354
selector: "variable",
312355
format: ["camelCase", "UPPER_CASE"],
@@ -338,7 +381,7 @@ describe("convertVariableName", () => {
338381
rules: [
339382
{
340383
ruleName: "@typescript-eslint/naming-convention",
341-
rules: [
384+
ruleArguments: [
342385
{
343386
selector: "variable",
344387
format: ["camelCase", "UPPER_CASE"],
@@ -371,7 +414,7 @@ describe("convertVariableName", () => {
371414
rules: [
372415
{
373416
ruleName: "@typescript-eslint/naming-convention",
374-
rules: [
417+
ruleArguments: [
375418
{
376419
selector: "variable",
377420
format: ["camelCase", "UPPER_CASE"],
@@ -408,7 +451,7 @@ describe("convertVariableName", () => {
408451
rules: [
409452
{
410453
ruleName: "@typescript-eslint/naming-convention",
411-
rules: [
454+
ruleArguments: [
412455
{
413456
selector: "variable",
414457
format: ["camelCase", "UPPER_CASE"],
@@ -449,7 +492,7 @@ describe("convertVariableName", () => {
449492
rules: [
450493
{
451494
ruleName: "@typescript-eslint/naming-convention",
452-
rules: [
495+
ruleArguments: [
453496
{
454497
selector: "variable",
455498
format: ["camelCase", "UPPER_CASE", "PascalCase", "snake_case"],

src/converters/lintConfigs/rules/ruleConverters/variable-name.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export const convertVariableName: RuleConverter = (tslintRule) => {
3838
const camelCaseRules: Record<string, unknown>[] = [];
3939
const camelCaseOptionNotices: string[] = [];
4040
const formats = ["camelCase", "UPPER_CASE"];
41-
4241
if (hasCheckFormat && allowPascalCase) {
4342
formats.push("PascalCase");
4443
}
@@ -68,7 +67,7 @@ export const convertVariableName: RuleConverter = (tslintRule) => {
6867

6968
return {
7069
...(camelCaseOptionNotices.length !== 0 && { notices: camelCaseOptionNotices }),
71-
...(camelCaseRules.length !== 0 && { rules: camelCaseRules }),
70+
...(camelCaseRules.length !== 0 && { ruleArguments: camelCaseRules }),
7271
ruleName: "@typescript-eslint/naming-convention",
7372
};
7473
};

0 commit comments

Comments
 (0)