Skip to content

Commit

Permalink
Update @typescript-eslint/parser to v7
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Apr 6, 2024
1 parent 41ac422 commit cdb36fd
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 33 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"@babel/core": "^7.23.6",
"@babel/eslint-parser": "^7.23.3",
"@lubien/fixture-beta-package": "^1.0.0-beta.1",
"@typescript-eslint/parser": "^6.15.0",
"@typescript-eslint/parser": "^7.5.0",
"ava": "^6.0.1",
"c8": "^8.0.1",
"chalk": "^5.3.0",
Expand Down
17 changes: 2 additions & 15 deletions rules/no-useless-switch-case.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,18 @@ const create = context => ({
* SwitchStatement(switchStatement) {
const {cases} = switchStatement;

// TypeScript allows multiple `default` cases
const defaultCases = cases.filter(switchCase => switchCase.test === null);
if (defaultCases.length !== 1) {
return;
}

const [defaultCase] = defaultCases;

// We only check cases where the last case is the `default` case
if (defaultCase !== cases.at(-1)) {
if (cases.length < 2 || cases.at(-1).test !== null) {
return;
}

const uselessCases = [];

Check failure on line 24 in rules/no-useless-switch-case.js

View workflow job for this annotation

GitHub Actions / lint-test (ubuntu-latest)

More than 1 blank line not allowed.
for (let index = cases.length - 2; index >= 0; index--) {
const node = cases[index];
if (isEmptySwitchCase(node)) {
uselessCases.unshift(node);
} else {
if (!isEmptySwitchCase(node)) {
break;
}
}

for (const node of uselessCases) {
yield {
node,
loc: getSwitchCaseHeadLocation(node, context.sourceCode),
Expand Down
17 changes: 0 additions & 17 deletions test/no-useless-switch-case.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,3 @@ test.snapshot({
`,
],
});

test.typescript({
valid: [
outdent`
switch (1) {
default:
handleDefaultCase1();
break;
case 1:
default:
handleDefaultCase2();
break;
}
`,
],
invalid: [],
});

0 comments on commit cdb36fd

Please sign in to comment.