This commit is contained in:
Alex
2024-08-03 23:20:11 -04:00
parent 92e6e5081b
commit f3fbf99c0c
22 changed files with 704 additions and 232 deletions

View File

@ -1,14 +1,14 @@
import type { Middleware } from '../index';
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 { ReactRulesObject } from '@aet/eslint-define-config/src/rules/react';
import { ReactRefreshRulesObject } from '@aet/eslint-define-config/src/rules/react-refresh';
import { defineMiddleware } from '../middleware';
const reactRules: Partial<ReactRulesObject> = {
'@eslint-react/no-missing-component-display-name': off,
'@eslint-react/no-children-prop': error,
};
export const react: Middleware = (config, { addRules }) => {
export const react = defineMiddleware((config, { addRules }) => {
config.plugins.push('@eslint-react/eslint-plugin', 'react-hooks');
config.extends.push(
'plugin:@eslint-react/recommended-legacy',
@ -23,13 +23,13 @@ export const react: Middleware = (config, { addRules }) => {
},
});
addRules(reactRules);
};
});
const refreshRules: Partial<ReactRefreshRulesObject> = {
'react-refresh/only-export-components': [warn, { allowConstantExport: true }],
};
export const reactRefresh: Middleware = (config, { addRules }) => {
export const reactRefresh = defineMiddleware((config, { addRules }) => {
config.plugins.push('react-refresh');
addRules(refreshRules);
};
});