This commit is contained in:
Alex
2023-08-21 15:45:59 -04:00
parent 198c731cbb
commit fda7f22872
5 changed files with 214 additions and 153 deletions

View File

@ -4,6 +4,8 @@ import type { ESLintConfig } from 'eslint-define-config';
const { name } = (0, require)('./package.json');
const unique = <T>(arr: T[]): T[] => [...new Set(arr)];
const ensureArray = <T>(value?: T | T[]): T[] =>
value == null ? [] : Array.isArray(value) ? value : [value];
const error = 'error';
const warn = 'warn';
@ -25,6 +27,7 @@ export function extendConfig({
const hasReact = plugins?.includes('react');
const hasUnicorn = plugins?.includes('unicorn');
const hasReactRefresh = plugins?.includes('react-refresh');
const hasNext = ensureArray(_extends).some(name => name.includes(':@next/next'));
const result: ESLintConfig = {
root: true,
@ -151,7 +154,10 @@ export function extendConfig({
'react/no-children-prop': error,
'react/prop-types': off,
'react/react-in-jsx-scope': off,
'react/no-unknown-property': [error, { extends: ['emotion'] }],
'react/no-unknown-property': [
error,
{ extends: hasNext ? ['emotion', 'next'] : ['emotion'] },
],
}
: {}),
...(hasUnicorn