-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy patheslint.config.mjs
108 lines (102 loc) · 2.69 KB
/
eslint.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import * as fs from "fs"
// https://github.com/francoismassart/eslint-plugin-tailwindcss/pull/381
// 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"],
// https://github.com/francoismassart/eslint-plugin-tailwindcss/pull/381
// ...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