-
-
Notifications
You must be signed in to change notification settings - Fork 129
/
Copy patheslint.config.js
103 lines (100 loc) · 2.71 KB
/
eslint.config.js
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
import { fixupPluginRules } from "@eslint/compat";
import { FlatCompat } from "@eslint/eslintrc";
import js from "@eslint/js";
import prettier from "eslint-plugin-prettier/recommended";
import reactPlugin from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import globals from "globals";
import tseslint from "typescript-eslint";
const project = "./tsconfig.app.json";
// eslint flat structure backwards compatibility
const compat = new FlatCompat({
recommendedConfig: js.configs.recommended,
});
function legacyPlugin(name, alias = name) {
const plugin = compat.plugins(name)[0]?.plugins?.[alias];
if (!plugin) {
throw new Error(`Unable to resolve plugin ${name} and/or alias ${alias}`);
}
return fixupPluginRules(plugin);
}
export default tseslint.config(
{ ignores: ["node_modules", "dist", "coverage"] },
{
extends: [
js.configs.recommended,
...tseslint.configs.recommended,
prettier,
...compat.extends("plugin:import/typescript"),
reactPlugin.configs.flat.recommended,
],
files: ["**/*.{js,ts,tsx}"],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
"react-hooks": reactHooks,
"react-refresh": reactRefresh,
import: legacyPlugin("eslint-plugin-import", "import"),
},
settings: {
"import/resolver": {
typescript: {
project,
alwaysTryTypes: true,
},
},
react: {
version: "detect",
},
},
rules: {
...reactHooks.configs.recommended.rules,
"@typescript-eslint/no-empty-object-type": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
"import/order": [
"error",
{
groups: [
"builtin",
"external",
"internal",
["parent", "sibling"],
"index",
"object",
"type",
"unknown",
],
pathGroups: [
{
pattern: "@*",
group: "internal",
position: "after",
},
],
pathGroupsExcludedImportTypes: ["builtin", "internal"],
"newlines-between": "always",
alphabetize: {
order: "asc",
caseInsensitive: true,
},
},
],
"react/react-in-jsx-scope": "off",
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
semi: ["error", "always"],
},
}
);