Skip to content

Commit

Permalink
test: More test cases for no-case-declarations (#17315)
Browse files Browse the repository at this point in the history
* feat: Added more no-case-declarations tests

* Fix: Removed parserOptions
  • Loading branch information
ElianCordoba committed Jun 30, 2023
1 parent e6e74f9 commit 840a264
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion tests/lib/rules/no-case-declarations.js
Expand Up @@ -35,9 +35,42 @@ ruleTester.run("no-case-declarations", rule, {
{
code: "switch (a) { case 1: { class C {} break; } default: { class C {} break; } }",
parserOptions: { ecmaVersion: 6 }
}
},
`
switch (a) {
case 1:
case 2: {}
}
`,
`
switch (a) {
case 1: var x;
}
`
],
invalid: [
{
code: `
switch (a) {
case 1:
{}
function f() {}
break;
}
`,
errors: [{ messageId: "unexpected", type: "FunctionDeclaration" }]
},
{
code: `
switch (a) {
case 1:
case 2:
let x;
}
`,
parserOptions: { ecmaVersion: 6 },
errors: [{ messageId: "unexpected", type: "VariableDeclaration" }]
},
{
code: "switch (a) { case 1: let x = 1; break; }",
parserOptions: { ecmaVersion: 6 },
Expand Down

0 comments on commit 840a264

Please sign in to comment.