-
Notifications
You must be signed in to change notification settings - Fork 609
/
eslint.config.js
110 lines (106 loc) · 3 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
106
107
108
109
110
// @ts-check
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import eslintConfigPrettier from 'eslint-config-prettier'
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
import react from 'eslint-plugin-react'
import pluginReactCompiler from 'eslint-plugin-react-compiler'
import pluginReactHooks from 'eslint-plugin-react-hooks'
import globals from 'globals'
import neostandard from 'neostandard'
import tseslint from 'typescript-eslint'
import { includeIgnoreFile } from '@eslint/compat'
import { FlatCompat } from '@eslint/eslintrc'
// import ImportX from "eslint-plugin-import-x";
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const compat = new FlatCompat({
// import.meta.dirname is available after Node.js v20.11.0
baseDirectory: __dirname,
})
const gitignorePath = path.resolve(__dirname, '.gitignore')
const ignores = [
path.resolve(__dirname, 'index.html'),
'**/node_modules/',
'node_modules/',
'**/dist/',
'dist/',
'backend/',
'backend/**/target',
]
export default tseslint.config(
includeIgnoreFile(gitignorePath),
{
ignores,
},
{
files: ['**/*.{jsx,mjsx,tsx,mtsx}'],
extends: [
// @ts-expect-error fucking plugin why export flat config with nullable types?
react.configs.flat.recommended,
],
plugins: {
// @ts-expect-error react hooks not compatible with eslint types
'react-hooks': pluginReactHooks,
'react-compiler': pluginReactCompiler,
},
settings: {
react: {
version: 'detect',
},
},
rules: {
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'react-compiler/react-compiler': 'warn',
},
},
{
files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
extends: [
...neostandard({ ts: true, semi: true, noStyle: true }),
eslintConfigPrettier,
eslintPluginPrettierRecommended,
],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'warn',
'react/react-in-jsx-scope': 'off',
'prettier/prettier': [
'error',
{
singleQuote: true,
},
],
},
},
{
files: ['**/*.{ts,tsx,mtsx}'],
extends: [...tseslint.configs.recommended],
ignores,
rules: {
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
},
languageOptions: {
parserOptions: {
project: true,
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
{
files: ['**/*.{jsx,mjsx,tsx,mtsx}'],
languageOptions: {
...react.configs.flat?.recommended.languageOptions,
globals: {
...globals.serviceworker,
...globals.browser,
},
},
},
)