-
Notifications
You must be signed in to change notification settings - Fork 23
/
eslint.config.js
124 lines (122 loc) · 3.19 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// @ts-check
import eslint from '@eslint/js'
import configPrettier from 'eslint-config-prettier'
import pluginReact from 'eslint-plugin-react'
import pluginReactHooks from 'eslint-plugin-react-hooks'
import pluginSimpleImportSort from 'eslint-plugin-simple-import-sort'
import globals from 'globals'
import tseslint from 'typescript-eslint'
export default tseslint.config(
{
name: 'exuanbo/languages-node',
files: ['**/*.?(c|m)js', '*.?(c|m)ts'],
languageOptions: {
// https://vitejs.dev/blog/announcing-vite5.html#node-js-support
// https://node.green/#ES2022
ecmaVersion: 2022,
globals: {
...globals.es2022,
...globals.node,
},
},
},
{
name: 'exuanbo/languages-browser',
files: ['src/**/*.?(c|m){j,t}s?(x)'],
languageOptions: {
// https://vitejs.dev/guide/build.html#browser-compatibility
ecmaVersion: 2021,
globals: {
...globals.browser,
...globals.es2021,
},
},
},
{
name: 'exuanbo/ignores',
ignores: ['.yarn', 'coverage', 'dist'],
},
{
name: 'exuanbo/files',
files: ['**/*.?(c|m){j,t}s?(x)'],
},
{
name: 'eslint/recommended',
...eslint.configs.recommended,
},
{
name: 'exuanbo/typescript',
files: ['**/*.?(c|m)ts?(x)'],
extends: tseslint.configs.recommendedTypeChecked,
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
'@typescript-eslint/consistent-type-exports': 'error',
'@typescript-eslint/consistent-type-imports': ['error', { fixStyle: 'inline-type-imports' }],
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-import-type-side-effects': 'error',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unused-expressions': ['error', { allowShortCircuit: true }],
},
},
{
name: 'exuanbo/react',
files: ['**/*.{j,t}sx'],
extends: [
{
name: 'react/recommended',
...pluginReact.configs.flat.recommended,
},
{
name: 'react/jsx-runtime',
...pluginReact.configs.flat['jsx-runtime'],
},
{
name: 'react-hooks',
...pluginReactHooks.configs.recommended,
plugins: {
'react-hooks': pluginReactHooks,
},
},
],
rules: {
'react/prop-types': 'off',
'react/jsx-sort-props': [
'error',
{
callbacksLast: true,
shorthandFirst: true,
reservedFirst: true,
},
],
},
settings: {
react: {
version: 'detect',
},
},
},
{
name: 'simple-import-sort',
plugins: {
'simple-import-sort': pluginSimpleImportSort,
},
rules: {
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
},
},
{
name: 'config-prettier',
...configPrettier,
},
)