69 lines
2.3 KiB
JavaScript
69 lines
2.3 KiB
JavaScript
import js from '@eslint/js';
|
|
import tseslint from 'typescript-eslint';
|
|
import { fixupPluginRules } from '@eslint/compat';
|
|
import reactPlugin from 'eslint-plugin-react';
|
|
import reactHooksPlugin from 'eslint-plugin-react-hooks';
|
|
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
|
|
|
|
/** Base ESLint config for all TS packages (no React). */
|
|
export const base = tseslint.config(
|
|
js.configs.recommended,
|
|
...tseslint.configs.recommended,
|
|
{
|
|
rules: {
|
|
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
|
'@typescript-eslint/no-explicit-any': 'error',
|
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
'@typescript-eslint/consistent-type-imports': [
|
|
'error',
|
|
{ prefer: 'type-imports', fixStyle: 'inline-type-imports' },
|
|
],
|
|
'no-console': 'warn',
|
|
'no-restricted-imports': [
|
|
'error',
|
|
{
|
|
patterns: [
|
|
{
|
|
regex: '^(\\.+/[^\'"]*)\\.(js|jsx|ts|tsx)$',
|
|
message:
|
|
'Use extensionless imports. Import from "./module" instead of "./module.js".',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
},
|
|
{
|
|
ignores: ['**/dist/**', '**/generated/**', '**/.next/**', '**/node_modules/**'],
|
|
},
|
|
);
|
|
|
|
/**
|
|
* ESLint config for React/Next.js packages.
|
|
*
|
|
* `fixupPluginRules` wraps ESLint 9-era plugins for ESLint 10 compatibility.
|
|
*/
|
|
export const react = tseslint.config(...base, {
|
|
plugins: {
|
|
react: fixupPluginRules(reactPlugin),
|
|
'react-hooks': fixupPluginRules(reactHooksPlugin),
|
|
'jsx-a11y': fixupPluginRules(jsxA11yPlugin),
|
|
},
|
|
settings: {
|
|
react: { version: 'detect' },
|
|
},
|
|
rules: {
|
|
'react/react-in-jsx-scope': 'off',
|
|
'react/prop-types': 'off',
|
|
'react-hooks/rules-of-hooks': 'error',
|
|
'react-hooks/exhaustive-deps': 'warn',
|
|
'jsx-a11y/alt-text': 'error',
|
|
'jsx-a11y/aria-props': 'error',
|
|
'jsx-a11y/aria-role': 'error',
|
|
'jsx-a11y/interactive-supports-focus': 'warn',
|
|
'jsx-a11y/label-has-associated-control': 'error',
|
|
},
|
|
});
|
|
|
|
export default base;
|