another step
This commit is contained in:
@@ -9,6 +9,31 @@
|
||||
import next from 'eslint-config-next';
|
||||
import prettier from 'eslint-config-prettier/flat';
|
||||
|
||||
// Unused variables/imports are dead code. eslint-config-next already enables
|
||||
// `@typescript-eslint/no-unused-vars` at 'warn'; we raise it to 'error' so
|
||||
// `npm run check` fails on dead code instead of merely warning. We patch the
|
||||
// severity *in place* on next's own config objects rather than adding a separate
|
||||
// override object, because in flat config a rule can only be referenced from a
|
||||
// config object that registers its plugin — and the `@typescript-eslint` plugin
|
||||
// is registered inside next's objects, not ours. Prefix a name with `_` to opt
|
||||
// out (intentionally-unused args, catch bindings, rest-spread siblings).
|
||||
const NO_UNUSED_VARS = [
|
||||
'error',
|
||||
{
|
||||
args: 'after-used',
|
||||
argsIgnorePattern: '^_',
|
||||
varsIgnorePattern: '^_',
|
||||
caughtErrorsIgnorePattern: '^_',
|
||||
ignoreRestSiblings: true,
|
||||
},
|
||||
];
|
||||
|
||||
const nextWithStrictUnusedVars = [...next].map((entry) =>
|
||||
entry?.rules?.['@typescript-eslint/no-unused-vars']
|
||||
? { ...entry, rules: { ...entry.rules, '@typescript-eslint/no-unused-vars': NO_UNUSED_VARS } }
|
||||
: entry
|
||||
);
|
||||
|
||||
/** @type {import('eslint').Linter.Config[]} */
|
||||
const config = [
|
||||
// Things ESLint should never look at.
|
||||
@@ -16,17 +41,15 @@ const config = [
|
||||
ignores: ['.next/**', 'out/**', 'coverage/**', 'node_modules/**', 'next-env.d.ts'],
|
||||
},
|
||||
|
||||
// Next.js + TypeScript + React + import/a11y rule sets.
|
||||
...next,
|
||||
// Next.js + TypeScript + React + import/a11y rule sets, with no-unused-vars
|
||||
// raised to error (see NO_UNUSED_VARS above).
|
||||
...nextWithStrictUnusedVars,
|
||||
|
||||
// Turn off every stylistic rule that would fight Prettier. Keep this last
|
||||
// among the rule-providing entries so it wins. Formatting is owned by
|
||||
// Prettier (`npm run format`), never by ESLint.
|
||||
prettier,
|
||||
|
||||
// Project-specific rule overrides go here, e.g.:
|
||||
// { rules: { 'react/jsx-key': 'error' } }
|
||||
//
|
||||
// NOTE: `import/no-cycle` is intentionally NOT enabled. On this toolchain the
|
||||
// eslint-plugin-import TypeScript resolver bundled by eslint-config-next 16
|
||||
// throws "invalid interface loaded as resolver" for that rule, and it cannot
|
||||
|
||||
Reference in New Issue
Block a user