-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.js
105 lines (99 loc) · 2.47 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
104
105
import eslint from "@eslint/js";
import tseslint from "@typescript-eslint/eslint-plugin";
import tseslintParser from "@typescript-eslint/parser";
import importPlugin from "eslint-plugin-import";
import jsxA11yPlugin from "eslint-plugin-jsx-a11y";
import reactPlugin from "eslint-plugin-react";
import reactHooksPlugin from "eslint-plugin-react-hooks";
import simpleImportSortPlugin from "eslint-plugin-simple-import-sort";
import globals from "globals";
/** @type {import('eslint').Linter.FlatConfig[]} */
export default [
// Ignore build directory
{
ignores: ["build/**"],
},
// Base config
// The one coming after would override the one before it
eslint.configs.recommended,
// Browser environment
{
languageOptions: {
globals: {
...globals.browser,
},
},
},
{
files: ["**/*.{js,jsx,ts,tsx}"],
plugins: {
"simple-import-sort": simpleImportSortPlugin,
},
rules: {
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
},
},
// React
{
files: ["**/*.{js,jsx,ts,tsx}"],
plugins: {
"react": reactPlugin,
"react-hooks": reactHooksPlugin,
"jsx-a11y": jsxA11yPlugin,
},
rules: {
...reactPlugin.configs.recommended.rules,
...reactPlugin.configs["jsx-runtime"].rules,
...reactHooksPlugin.configs.recommended.rules,
...jsxA11yPlugin.configs.recommended.rules,
},
settings: {
"react": {
version: "detect",
},
"formComponents": ["Form"],
"linkComponents": [
{ name: "Link", linkAttribute: "to" },
{ name: "NavLink", linkAttribute: "to" },
],
"import/resolver": {
typescript: {},
},
},
},
// Typescript
{
files: ["**/*.{ts,tsx}"],
plugins: {
"@typescript-eslint": tseslint,
"import": importPlugin,
},
rules: {
...tseslint.configs.recommended.rules,
...importPlugin.configs.recommended.rules,
...importPlugin.configs.typescript.rules,
},
languageOptions: {
parser: tseslintParser,
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
},
settings: {
"import/internal-regex": "^~/",
"import/parsers": {
espree: [".js", ".cjs", ".mjs", ".jsx"],
},
"import/resolver": {
node: {
extensions: [".ts", ".tsx"],
},
typescript: {
alwaysTryTypes: true,
},
},
},
},
];