Skip to content

Commit

Permalink
Merge branch 'main' into disable-checkinfinity
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Apr 9, 2024
2 parents 0eeec4e + 29025d9 commit 611870c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 36 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Expand Up @@ -51,10 +51,11 @@ jobs:
env:
AVA_FORCE_CI: not-ci
- run: git diff --exit-code
- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
files: coverage/lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
run-rules-on-codebase:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion package.json
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
18 changes: 2 additions & 16 deletions rules/no-useless-switch-case.js
Expand Up @@ -16,31 +16,17 @@ 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 = [];

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
2 changes: 1 addition & 1 deletion rules/prevent-abbreviations.js
Expand Up @@ -116,7 +116,7 @@ const getNameReplacements = (name, options, limit = 3) => {
}

// Split words
const words = name.split(/(?=[^a-z])|(?<=[^A-Za-z])/).filter(Boolean);
const words = name.split(/(?=\P{Lowercase_Letter})|(?<=\P{Letter})/u).filter(Boolean);

let hasReplacements = false;
const combinations = words.map(word => {
Expand Down
17 changes: 0 additions & 17 deletions test/no-useless-switch-case.mjs
Expand Up @@ -160,20 +160,3 @@ test.snapshot({
`,
],
});

test.typescript({
valid: [
outdent`
switch (1) {
default:
handleDefaultCase1();
break;
case 1:
default:
handleDefaultCase2();
break;
}
`,
],
invalid: [],
});
4 changes: 4 additions & 0 deletions test/prevent-abbreviations.mjs
Expand Up @@ -1931,6 +1931,10 @@ test({
code: 'foo();',
filename: 'err/http-error.js',
},
{
code: 'foo();',
filename: 'Мiръ.html',
},
// `ignore` option
{
code: outdent`
Expand Down

0 comments on commit 611870c

Please sign in to comment.