-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy patheslint.config.mjs
More file actions
127 lines (120 loc) · 3.61 KB
/
eslint.config.mjs
File metadata and controls
127 lines (120 loc) · 3.61 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import { FlatCompat } from "@eslint/eslintrc";
import eslint from "@eslint/js";
import * as importPlugin from "eslint-plugin-import";
import jsxA11yPlugin from "eslint-plugin-jsx-a11y";
import eslintConfigPrettier from "eslint-plugin-prettier/recommended";
import reactPlugin from "eslint-plugin-react";
import reactHooksPlugin from "eslint-plugin-react-hooks";
import simpleImportSortPlugin from "eslint-plugin-simple-import-sort";
import unicornPlugin from "eslint-plugin-unicorn";
import vitestPlugin from "eslint-plugin-vitest";
import globals from "globals";
import tseslint from "typescript-eslint";
import { fileURLToPath } from "url";
const rootDir = fileURLToPath(new URL(".", import.meta.url));
const compat = new FlatCompat({ baseDirectory: rootDir });
export default tseslint.config(
{
files: ["**/*.{ts,tsx,cts,mts,js,jsx,mjs}"],
plugins: {
"@typescript-eslint": tseslint.plugin,
import: importPlugin,
"jsx-a11y": jsxA11yPlugin,
"react-hooks": reactHooksPlugin,
react: reactPlugin,
"simple-import-sort": simpleImportSortPlugin,
unicorn: unicornPlugin,
vitest: vitestPlugin,
},
},
{
ignores: ["**/node_modules/**/*", "**/dist/**/*", "**/*.d.ts"],
},
{
files: ["**/*.{ts,tsx,cts,mts,js,jsx,mjs}"],
languageOptions: {
parserOptions: {
allowAutomaticSingleRunInference: true,
project: "./tsconfig.json",
tsconfigRootDir: rootDir,
ecmaFeatures: {
jsx: true,
},
},
globals: {
...globals.es2021,
...globals.node,
...vitestPlugin.environments.env.globals,
},
},
extends: [
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
...compat.config(jsxA11yPlugin.configs.recommended),
...compat.config(reactHooksPlugin.configs.recommended),
...compat.config(reactPlugin.configs.recommended),
...compat.config(reactPlugin.configs["jsx-runtime"]),
],
settings: {
"import/internal-regex": "^~/",
"import/resolver": {
typescript: {
project: ["./tsconfig.json"],
},
},
react: {
version: "detect",
},
formComponents: ["Form"],
linkComponents: [
{ name: "Link", linkAttribute: "to" },
{ name: "NavLink", linkAttribute: "to" },
],
},
rules: {
"@typescript-eslint/no-base-to-string": "warn",
"@typescript-eslint/no-redundant-type-constituents": "off",
"@typescript-eslint/no-misused-promises": "warn",
"simple-import-sort/imports": "error",
"react/prop-types": "off",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unused-vars": [
"error",
{
args: "all",
argsIgnorePattern: "^_",
caughtErrors: "all",
caughtErrorsIgnorePattern: "^_",
destructuredArrayIgnorePattern: "^_",
varsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
"no-return-await": "off",
"@typescript-eslint/return-await": ["error", "always"],
"no-restricted-imports": [
"error",
{
name: "nuqs",
message: "Please use exported functions from '/ui/hooks/nuqs.ts'",
},
],
},
},
{
files: ["**/*.{js,jsx,mjs}"],
extends: [tseslint.configs.disableTypeChecked],
},
{
files: ["**/*.{spec,test}.{ts,tsx,cts,mts,js,jsx,mjs}"],
rules: {
...vitestPlugin.configs.recommended.rules,
},
languageOptions: {
globals: {
...vitestPlugin.environments.env.globals,
},
},
},
eslintConfigPrettier,
);