Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion eslint.cli.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export default defineConfig([
// This override adds type-checked rules.
// Linting with type-checked rules is very slow and needs a lot of memory,
// so we exclude non-essential files.
// NOTE: eslint.config.mjs has a config block that mirrors these
// `files`/`ignores` to override non-type-checked rules for the same set of
// files. Keep both in sync if you change the globs.
ignores: [
'bench/**/*',
'examples/**/*',
Expand All @@ -27,7 +30,10 @@ export default defineConfig([
rules: {
// TODO: enable in follow-up PR
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/switch-exhaustiveness-check': 'error',
'@typescript-eslint/switch-exhaustiveness-check': [
'error',
{ requireDefaultForNonUnion: true },
],
},
},
])
24 changes: 24 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,30 @@ export default defineConfig([
'@typescript-eslint/prefer-literal-enum-member': 'error',
},
},
{
// This block mirrors the `files`/`ignores` of the type-checked config in
// eslint.cli.config.mjs, so it targets exactly the files for which those
// type-aware rules run. Use it to override non-type-checked rules whose
// behavior overlaps with a type-checked rule. Keep the globs below in sync
// with eslint.cli.config.mjs.
files: ['**/*.ts', '**/*.tsx'],
ignores: [
'bench/**/*',
'examples/**/*',
'test/**/*',
'**/*.d.ts',
'turbopack/**/*',
],
rules: {
// `@typescript-eslint/switch-exhaustiveness-check` already enforces
// complete switch coverage on these files: every member of a union or
// enum must be handled, and with `requireDefaultForNonUnion` a default
// is required for switches on plain types (string, number, …). Leaving
// `default-case` on would additionally force a redundant default on
// exhaustive union/enum switches.
'default-case': 'off',
},
},
{
files: ['packages/**/*.ts', 'packages/**/*.tsx'],
plugins: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export default async function loader(
}

for (const message of result.messages) {
// eslint-disable-next-line default-case
switch (message.type) {
case 'dependency':
this.addDependency(message.file)
Expand All @@ -109,6 +108,9 @@ export default async function loader(
message.info
)
}
break
default:
break
}
}

Expand Down
3 changes: 2 additions & 1 deletion packages/next/src/shared/lib/head.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ function unique() {
}
}

// eslint-disable-next-line default-case
switch (h.type) {
case 'title':
case 'base':
Expand Down Expand Up @@ -106,6 +105,8 @@ function unique() {
}
}
break
default:
break
}

return isUnique
Expand Down
Loading