Skip to content

Commit f96e66f

Browse files
add test to eslint config creator
1 parent 1fbf40a commit f96e66f

File tree

1 file changed

+69
-1
lines changed

1 file changed

+69
-1
lines changed

tools/eslintConfigCreator_test.go

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func TestCreateEslintConfigConfig1(t *testing.T) {
3535
`export default [
3636
{
3737
rules: {
38-
"semi": "error",
38+
"semi": ["error"],
3939
}
4040
}
4141
];`)
@@ -133,3 +133,71 @@ func TestCreateEslintConfigDoNotSupportPlugins(t *testing.T) {
133133
}
134134
];`)
135135
}
136+
137+
func TestCreateEslintConfigWithDefaultValues(t *testing.T) {
138+
testConfig(t,
139+
[]domain.PatternConfiguration{
140+
{
141+
PatternDefinition: domain.PatternDefinition{
142+
Id: "ESLint8_no-fallthrough",
143+
Parameters: []domain.ParameterConfiguration{
144+
{
145+
Name: "commentPattern",
146+
Default: "",
147+
},
148+
{
149+
Name: "allowEmptyCase",
150+
Default: "false",
151+
},
152+
},
153+
},
154+
Parameters: []domain.ParameterConfiguration{
155+
{
156+
Name: "commentPattern",
157+
Value: "", // Empty value with empty default - should be skipped
158+
},
159+
{
160+
Name: "allowEmptyCase",
161+
Value: "", // Empty value with default "false" - should use default
162+
},
163+
},
164+
},
165+
},
166+
`export default [
167+
{
168+
rules: {
169+
"no-fallthrough": ["error", {"allowEmptyCase": false}],
170+
}
171+
}
172+
];`)
173+
}
174+
175+
func TestCreateEslintConfigWithUnnamedDefaultValues(t *testing.T) {
176+
testConfig(t,
177+
[]domain.PatternConfiguration{
178+
{
179+
PatternDefinition: domain.PatternDefinition{
180+
Id: "ESLint8_no-inner-declarations",
181+
Parameters: []domain.ParameterConfiguration{
182+
{
183+
Name: "unnamedParam",
184+
Default: "functions",
185+
},
186+
},
187+
},
188+
Parameters: []domain.ParameterConfiguration{
189+
{
190+
Name: "unnamedParam",
191+
Value: "", // Empty value with default "functions" - should use default
192+
},
193+
},
194+
},
195+
},
196+
`export default [
197+
{
198+
rules: {
199+
"no-inner-declarations": ["error", "functions"],
200+
}
201+
}
202+
];`)
203+
}

0 commit comments

Comments
 (0)