Upgrade to ESLint 9
This commit is contained in:
@ -2,35 +2,42 @@ import type { ReactRulesObject } from '@aet/eslint-define-config/src/rules/react
|
||||
import type { ReactRefreshRulesObject } from '@aet/eslint-define-config/src/rules/react-refresh';
|
||||
|
||||
import { error, off, warn } from '../constants';
|
||||
import { defineMiddleware } from '../middleware';
|
||||
import { def } from '../middleware';
|
||||
import { defineConfig } from '../types';
|
||||
|
||||
const reactRules: Partial<ReactRulesObject> = {
|
||||
'@eslint-react/no-missing-component-display-name': off,
|
||||
'@eslint-react/no-children-prop': error,
|
||||
'@eslint-react/no-leaked-conditional-rendering': error,
|
||||
};
|
||||
|
||||
export const react = defineMiddleware((config, { addRules }) => {
|
||||
config.plugins.push('@eslint-react/eslint-plugin', 'react-hooks');
|
||||
config.extends.push(
|
||||
'plugin:@eslint-react/recommended-legacy',
|
||||
'plugin:@eslint-react/dom-legacy',
|
||||
'plugin:react-hooks/recommended',
|
||||
'plugin:jsx-a11y/recommended',
|
||||
);
|
||||
config.overrides.push({
|
||||
files: ['*.tsx'],
|
||||
rules: {
|
||||
'@eslint-react/no-leaked-conditional-rendering': error,
|
||||
export async function react() {
|
||||
const reactPlugin = def(await import('@eslint-react/eslint-plugin'));
|
||||
const a11y = def(await import('../../packages/eslint-plugin-jsx-a11y/src/index'));
|
||||
const hooks = await import('../../packages/eslint-plugin-react-hooks');
|
||||
|
||||
return defineConfig([
|
||||
reactPlugin.configs['recommended-type-checked'] as any,
|
||||
hooks.flatConfigs.recommended,
|
||||
a11y.flatConfigs.recommended,
|
||||
{
|
||||
files: ['*.tsx'],
|
||||
rules: reactRules,
|
||||
},
|
||||
});
|
||||
addRules(reactRules);
|
||||
});
|
||||
]);
|
||||
}
|
||||
|
||||
const refreshRules: Partial<ReactRefreshRulesObject> = {
|
||||
'react-refresh/only-export-components': [warn, { allowConstantExport: true }],
|
||||
};
|
||||
|
||||
export const reactRefresh = defineMiddleware((config, { addRules }) => {
|
||||
config.plugins.push('react-refresh');
|
||||
addRules(refreshRules);
|
||||
});
|
||||
export async function reactRefresh() {
|
||||
const refreshPlugin = def(await import('eslint-plugin-react-refresh'));
|
||||
return defineConfig({
|
||||
plugins: {
|
||||
// @ts-expect-error no types
|
||||
'react-refresh': refreshPlugin,
|
||||
},
|
||||
rules: refreshRules,
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user