Skip to content

Commit 840a264

Browse files
authored
test: More test cases for no-case-declarations (#17315)
* feat: Added more no-case-declarations tests * Fix: Removed parserOptions
1 parent e6e74f9 commit 840a264

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

tests/lib/rules/no-case-declarations.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,42 @@ ruleTester.run("no-case-declarations", rule, {
3535
{
3636
code: "switch (a) { case 1: { class C {} break; } default: { class C {} break; } }",
3737
parserOptions: { ecmaVersion: 6 }
38-
}
38+
},
39+
`
40+
switch (a) {
41+
case 1:
42+
case 2: {}
43+
}
44+
`,
45+
`
46+
switch (a) {
47+
case 1: var x;
48+
}
49+
`
3950
],
4051
invalid: [
52+
{
53+
code: `
54+
switch (a) {
55+
case 1:
56+
{}
57+
function f() {}
58+
break;
59+
}
60+
`,
61+
errors: [{ messageId: "unexpected", type: "FunctionDeclaration" }]
62+
},
63+
{
64+
code: `
65+
switch (a) {
66+
case 1:
67+
case 2:
68+
let x;
69+
}
70+
`,
71+
parserOptions: { ecmaVersion: 6 },
72+
errors: [{ messageId: "unexpected", type: "VariableDeclaration" }]
73+
},
4174
{
4275
code: "switch (a) { case 1: let x = 1; break; }",
4376
parserOptions: { ecmaVersion: 6 },

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy