-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.mjs
113 lines (106 loc) · 3.13 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
109
110
111
112
113
import { FlatCompat } from "@eslint/eslintrc";
import eslint from "@eslint/js";
import prettierRecommended from "eslint-plugin-prettier/recommended";
import reactPlugin from "eslint-plugin-react";
import hooksPlugin from "eslint-plugin-react-hooks";
import simpleImportSort from "eslint-plugin-simple-import-sort";
import unusedImports from "eslint-plugin-unused-imports";
import { dirname } from "path";
import tseslint from "typescript-eslint";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
});
const eslintConfig = [
{
files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"],
settings: {
react: {
version: "detect",
},
},
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
},
...compat.extends("next/core-web-vitals", "next/typescript"),
reactPlugin.configs.flat.recommended,
eslint.configs.recommended,
...tseslint.configs.recommended,
prettierRecommended,
{
rules: {
"prettier/prettier": ["warn"],
"@typescript-eslint/no-unused-expressions": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-ts-comment": "off",
"react/react-in-jsx-scope": "off",
"no-prototype-builtins": "off",
"no-useless-catch": "off",
"react/prop-types": "off",
"react/no-children-prop": "off",
"react/display-name": "off",
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "off",
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"warn",
{
caughtErrors: "all",
caughtErrorsIgnorePattern: "^_",
vars: "all",
varsIgnorePattern: "^_",
args: "after-used",
argsIgnorePattern: "^_",
},
],
},
},
{
plugins: {
"unused-imports": unusedImports,
"react-hooks": hooksPlugin,
"simple-import-sort": simpleImportSort,
},
rules: {
"react/react-in-jsx-scope": "off",
"simple-import-sort/exports": "error",
"unused-imports/no-unused-imports": "error",
"simple-import-sort/imports": [
"error",
{
groups: [
// Packages, react related packages come first.
["^react", "^@?\\w"],
// @/*, then @/features
["^@(?!/features)(/.*|$)", "^@/features(/.*|$)"],
// Side effect imports.
["^\\u0000"],
// Parent imports. Put .. last.
// Other relative imports. Put same-folder imports and . last.
[
"^\\.\\.(?!/?$)",
"^\\.\\./?$",
"^\\./(?=.*/)(?!/?$)",
"^\\.(?!/?$)",
"^\\./?$",
],
// Style imports.
["^.+\\.?(css)$"],
],
},
],
...hooksPlugin.configs.recommended.rules,
},
ignores: ["*.test.tsx"],
},
];
export default eslintConfig;