chore: upgrade eslint to v9 and flat config
This commit is contained in:
parent
00f9a89ffb
commit
e96bb9a6d7
9 changed files with 1781 additions and 1757 deletions
106
eslint.config.mjs
Normal file
106
eslint.config.mjs
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
import * as fs from "fs"
|
||||
|
||||
import eslintPluginTailwindcss from "eslint-plugin-tailwindcss"
|
||||
import eslintPluginImport from "eslint-plugin-import"
|
||||
import eslintPluginNext from "@next/eslint-plugin-next"
|
||||
import eslintPluginStorybook from "eslint-plugin-storybook"
|
||||
import typescriptEslint from "typescript-eslint"
|
||||
|
||||
const eslintIgnore = [
|
||||
".git/",
|
||||
".next/",
|
||||
"node_modules/",
|
||||
"dist/",
|
||||
"build/",
|
||||
"coverage/",
|
||||
"*.min.js",
|
||||
"*.config.js",
|
||||
"*.d.ts",
|
||||
]
|
||||
|
||||
const config = typescriptEslint.config(
|
||||
{
|
||||
ignores: eslintIgnore,
|
||||
},
|
||||
...eslintPluginStorybook.configs["flat/recommended"],
|
||||
...eslintPluginTailwindcss.configs["flat/recommended"],
|
||||
typescriptEslint.configs.recommended,
|
||||
eslintPluginImport.flatConfigs.recommended,
|
||||
{
|
||||
plugins: {
|
||||
"@next/next": eslintPluginNext,
|
||||
},
|
||||
rules: {
|
||||
...eslintPluginNext.configs.recommended.rules,
|
||||
...eslintPluginNext.configs["core-web-vitals"].rules,
|
||||
},
|
||||
},
|
||||
{
|
||||
settings: {
|
||||
tailwindcss: {
|
||||
callees: ["classnames", "clsx", "ctl", "cn", "cva"],
|
||||
},
|
||||
|
||||
"import/resolver": {
|
||||
typescript: true,
|
||||
node: true,
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"warn",
|
||||
{
|
||||
argsIgnorePattern: "^_",
|
||||
varsIgnorePattern: "^_",
|
||||
},
|
||||
],
|
||||
"sort-imports": [
|
||||
"error",
|
||||
{
|
||||
ignoreCase: true,
|
||||
ignoreDeclarationSort: true,
|
||||
},
|
||||
],
|
||||
"import/order": [
|
||||
"warn",
|
||||
{
|
||||
groups: ["external", "builtin", "internal", "sibling", "parent", "index"],
|
||||
pathGroups: [
|
||||
...getDirectoriesToSort().map((singleDir) => ({
|
||||
pattern: `${singleDir}/**`,
|
||||
group: "internal",
|
||||
})),
|
||||
{
|
||||
pattern: "env",
|
||||
group: "internal",
|
||||
},
|
||||
{
|
||||
pattern: "theme",
|
||||
group: "internal",
|
||||
},
|
||||
{
|
||||
pattern: "public/**",
|
||||
group: "internal",
|
||||
position: "after",
|
||||
},
|
||||
],
|
||||
pathGroupsExcludedImportTypes: ["internal"],
|
||||
alphabetize: {
|
||||
order: "asc",
|
||||
caseInsensitive: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
function getDirectoriesToSort() {
|
||||
const ignoredSortingDirectories = [".git", ".next", ".vscode", "node_modules"]
|
||||
return fs
|
||||
.readdirSync(process.cwd())
|
||||
.filter((file) => fs.statSync(process.cwd() + "/" + file).isDirectory())
|
||||
.filter((f) => !ignoredSortingDirectories.includes(f))
|
||||
}
|
||||
|
||||
export default config
|
||||
Loading…
Add table
Add a link
Reference in a new issue