Skip to content

Commit 7978dc4

Browse files
authored
use all casing values on rule options (#1526)
1 parent bc192ca commit 7978dc4

File tree

2 files changed

+67
-3
lines changed

2 files changed

+67
-3
lines changed

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

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,38 @@ describe("convertVariableName", () => {
104104
});
105105
});
106106

107+
test("conversion with allow-pascal-case argument with check-format", () => {
108+
const result = convertVariableName({
109+
ruleArguments: ["allow-pascal-case", "check-format"],
110+
});
111+
112+
expect(result).toEqual({
113+
rules: [
114+
{
115+
ruleName: "@typescript-eslint/naming-convention",
116+
rules: [
117+
{
118+
selector: "variable",
119+
format: ["camelCase", "UPPER_CASE", "PascalCase"],
120+
leadingUnderscore: "forbid",
121+
trailingUnderscore: "forbid",
122+
},
123+
],
124+
},
125+
{
126+
notices: [ForbiddenLeadingTrailingIdentifierMsg],
127+
ruleName: "no-underscore-dangle",
128+
},
129+
{
130+
ruleName: "id-denylist",
131+
},
132+
{
133+
ruleName: "id-match",
134+
},
135+
],
136+
});
137+
});
138+
107139
test("conversion with allow-snake-case argument without check-format argument", () => {
108140
const result = convertVariableName({
109141
ruleArguments: ["allow-snake-case"],
@@ -136,6 +168,38 @@ describe("convertVariableName", () => {
136168
});
137169
});
138170

171+
test("conversion with allow-snake-case argument with check-format", () => {
172+
const result = convertVariableName({
173+
ruleArguments: ["allow-snake-case", "check-format"],
174+
});
175+
176+
expect(result).toEqual({
177+
rules: [
178+
{
179+
ruleName: "@typescript-eslint/naming-convention",
180+
rules: [
181+
{
182+
selector: "variable",
183+
format: ["camelCase", "UPPER_CASE", "snake_case"],
184+
leadingUnderscore: "forbid",
185+
trailingUnderscore: "forbid",
186+
},
187+
],
188+
},
189+
{
190+
notices: [ForbiddenLeadingTrailingIdentifierMsg],
191+
ruleName: "no-underscore-dangle",
192+
},
193+
{
194+
ruleName: "id-denylist",
195+
},
196+
{
197+
ruleName: "id-match",
198+
},
199+
],
200+
});
201+
});
202+
139203
test("conversion with allow-leading-underscore without check-format argument", () => {
140204
const result = convertVariableName({
141205
ruleArguments: ["allow-leading-underscore"],
@@ -388,7 +452,7 @@ describe("convertVariableName", () => {
388452
rules: [
389453
{
390454
selector: "variable",
391-
format: ["camelCase", "UPPER_CASE"],
455+
format: ["camelCase", "UPPER_CASE", "PascalCase", "snake_case"],
392456
leadingUnderscore: "allow",
393457
trailingUnderscore: "allow",
394458
},

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ export const convertVariableName: RuleConverter = (tslintRule) => {
4949
if (!hasCheckFormat) {
5050
camelCaseRules.push({
5151
selector: "variable",
52-
format: ["camelCase", "UPPER_CASE"],
52+
format: formats,
5353
leadingUnderscore: "forbid",
5454
trailingUnderscore: "forbid",
5555
});
5656
} else {
5757
camelCaseRules.push({
5858
selector: "variable",
59-
format: ["camelCase", "UPPER_CASE"],
59+
format: formats,
6060
leadingUnderscore: allowedLeadingUnderscore ? "allow" : "forbid",
6161
trailingUnderscore: allowedTrailingUnderscore ? "allow" : "forbid",
6262
});

0 commit comments

Comments
 (0)