-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
48 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ import eslintConfigPrettier from 'eslint-config-prettier' | |
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended' | ||
import type { EslintConfigOptions } from './types' | ||
|
||
import antfu, { perfectionist } from '@antfu/eslint-config' | ||
import antfu from '@antfu/eslint-config' | ||
import { FlatCompat } from '@eslint/eslintrc' | ||
// @ts-expect-error no types | ||
import nextPlugin from '@next/eslint-plugin-next' | ||
|
@@ -14,26 +14,49 @@ import tailwindPlugin from 'eslint-plugin-tailwindcss' | |
|
||
const compat = new FlatCompat() | ||
|
||
export const factory = ({ prettier, tailwind, next, reactQuery }: EslintConfigOptions = {}) => { | ||
export const factory = ({ next, prettier, reactQuery, tailwind }: EslintConfigOptions = {}) => { | ||
const base = antfu({ | ||
stylistic: false, | ||
react: true, | ||
plugins: { | ||
perfectionist, | ||
}, | ||
}).overrideRules({ 'import/order': 'off', 'ts/no-unused-expressions': 'off' }) | ||
stylistic: false, | ||
}).overrideRules({ | ||
'@next/next/no-img-element': 'off', | ||
'import/order': 'off', | ||
'no-irregular-whitespace': 'off', | ||
'node/prefer-global/process': 'warn', | ||
'react/prefer-destructuring-assignment': 'off', | ||
'sort-imports': 'off', | ||
'ts/no-unused-expressions': 'off', | ||
'ts/no-use-before-define': 'off', | ||
'unused-imports/no-unused-vars': 'warn', | ||
}) | ||
|
||
base.append([ | ||
...compat.config({ | ||
plugins: ['svg-jsx'], | ||
rules: { | ||
'svg-jsx/camel-case-dash': 'error', | ||
'svg-jsx/camel-case-colon': 'error', | ||
'svg-jsx/camel-case-dash': 'error', | ||
'svg-jsx/no-style-string': 'error', | ||
}, | ||
}), | ||
]) | ||
|
||
// perfectionist | ||
base.append({ | ||
rules: { | ||
'perfectionist/sort-array-includes': 'error', | ||
'perfectionist/sort-enums': 'error', | ||
'perfectionist/sort-exports': 'error', | ||
'perfectionist/sort-interfaces': 'error', | ||
'perfectionist/sort-intersection-types': 'error', | ||
'perfectionist/sort-jsx-props': 'error', | ||
'perfectionist/sort-named-exports': 'error', | ||
'perfectionist/sort-object-types': 'error', | ||
'perfectionist/sort-objects': 'error', | ||
'perfectionist/sort-union-types': 'error', | ||
}, | ||
}) | ||
|
||
!!prettier && base.append([eslintPluginPrettierRecommended, eslintConfigPrettier]) | ||
|
||
!!tailwind && | ||
|
@@ -53,8 +76,8 @@ export const factory = ({ prettier, tailwind, next, reactQuery }: EslintConfigOp | |
rules: { | ||
...nextPlugin.configs.recommended.rules, | ||
...nextPlugin.configs['core-web-vitals'].rules, | ||
'@next/next/no-img-element': 'error', | ||
'@next/next/no-duplicate-head': 'off', | ||
'@next/next/no-img-element': 'error', | ||
'@next/next/no-page-custom-font': 'off', | ||
}, | ||
}, | ||
|
@@ -65,7 +88,7 @@ export const factory = ({ prettier, tailwind, next, reactQuery }: EslintConfigOp | |
return base | ||
} | ||
|
||
const defaultConfig = factory({ prettier: true, tailwind: true, next: true, reactQuery: true }) | ||
const defaultConfig = factory({ next: true, prettier: true, reactQuery: true, tailwind: true }) | ||
export default defaultConfig | ||
|
||
// Fix `error TS2742: The inferred type of 'factory' cannot be named without a reference to '.pnpm/[email protected]/node_modules/eslint-flat-config-utils'. This is likely not portable. A type annotation is necessary.` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export interface EslintConfigOptions { | ||
prettier?: boolean | ||
tailwind?: boolean | ||
next?: boolean | ||
prettier?: boolean | ||
reactQuery?: boolean | ||
tailwind?: boolean | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters