-
Notifications
You must be signed in to change notification settings - Fork 660
Expand file tree
/
Copy patheslint.config.js
More file actions
191 lines (176 loc) · 5.29 KB
/
eslint.config.js
File metadata and controls
191 lines (176 loc) · 5.29 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
// @ts-check
import eslint from '@eslint/js';
import prettierConfig from 'eslint-config-prettier';
import jestPlugin from 'eslint-plugin-jest';
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = dirname(fileURLToPath(import.meta.url));
export default tseslint.config(
// config ignores files, equal `.eslintignore`
{
ignores: [
'**/node_modules/**',
'**/dist/**',
'**/fixtures/**',
'**/coverage/**',
'**/__snapshots__/**',
'**/coverage/**',
'**/temp/**',
'**/.cache/**',
'**/.history/**',
'**/.idea/**',
// Files pakasges of the build
'packages/*/es/*',
'packages/*/lib/*',
'packages/*/dist/*',
// Website static files
'site/public/*',
'site/public_site/*',
],
},
// extends configs
eslint.configs.recommended,
// basic config
{
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: {
...globals.es2021,
...globals.browser,
...globals.node,
},
},
rules: {
'no-unused-vars': 'warn',
'no-unsafe-optional-chaining': 'warn',
'no-constant-condition': 'off',
'no-prototype-builtins': 'off',
'no-case-declarations': 'off',
'no-useless-catch': 'off',
'prefer-rest-params': 'off',
},
},
// ts files linting
{
files: ['**/*.{ts,tsx}'],
extends: [...tseslint.configs.recommended],
languageOptions: {
parserOptions: {
// OOM when many project configs passed to the parser with multi-package monorepos, see https://github.com/typescript-eslint/typescript-eslint/issues/1192
// project: [
// './tsconfig.eslint.json',
// './packages/*/tsconfig.json',
// './site/tsconfig.json',
// ],
project: './tsconfig.eslint.json',
tsconfigRootDir: __dirname,
},
},
rules: {
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
'@typescript-eslint/no-loss-of-precision': 0,
'@typescript-eslint/no-inferrable-types': 0,
'@typescript-eslint/ban-types': 0,
'@typescript-eslint/ban-ts-comment': 0,
'@typescript-eslint/no-empty-function': 0,
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-duplicate-enum-values': 0,
'@typescript-eslint/no-empty-object-type': 0,
'@typescript-eslint/no-unsafe-function-type': 0,
'@typescript-eslint/no-unused-expressions': 0,
'@typescript-eslint/no-unused-vars': 0,
'@typescript-eslint/no-non-null-assertion': 0,
'@typescript-eslint/prefer-ts-expect-error': 0,
'@typescript-eslint/no-unnecessary-type-assertion': 0,
'eslint-comments/require-description': 0,
'eslint-comments/no-use': 0,
'eslint-comments/no-unused-disable': 0,
'eslint-comments/no-unused-enable': 0,
'eslint-comments/no-duplicate-disable': 0,
'eslint-comments/no-aggregating-enable': 0,
'eslint-comments/no-unlimited-disable': 0,
'eslint-comments/no-restricted-disable': 0,
'eslint-comments/disable-enable-pair': 0,
'eslint-comments/check-disable': 0,
'eslint-comments/no-unused-disable-directives': 0,
'eslint-comments/no-unused-disable-directives-comment': 0,
'eslint-comments/no-unused-disable-directives-next-line': 0,
'eslint-comments/no-unused-disable-directives-line': 0,
'no-new': 0,
'default-param-last': 0,
'no-unused-vars': 0,
'no-unused-expressions': 0,
'no-constant-condition': 0,
'no-prototype-builtins': 0,
'no-case-declarations': 0,
'no-useless-catch': 0,
'prefer-rest-params': 0,
'no-unsafe-optional-chaining': 0,
'unused-imports/no-unused-vars': 0,
'unused-imports/no-unused-imports': 0,
},
},
// react tsx files linting
{
files: ['**/*.{tsx}'],
...reactPlugin.configs.recommended,
plugins: {
'react-hooks': reactHooksPlugin,
'jsx-a11y': jsxA11yPlugin,
},
rules: {},
},
//
// test jest file linting
//
{
files: ['test/**/*.spec.ts', 'packages/*/__tests__/**/*.spec.ts'],
...jestPlugin.configs['flat/recommended'],
rules: {},
},
// after all eslint plugins configs to override, see https://github.com/prettier/eslint-config-prettier
// @ts-ignore
prettierConfig,
//
// test workspace linting
//
{
files: ['test/**/*.{ts}', 'packages/*/__tests__/**/*.ts'],
rules: {
'@typescript-eslint/no-unused-vars': 'warn',
},
},
//
// examples workspace linting
//
{
files: ['examples/**/*.{ts,tsx}'],
rules: {
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/consistent-type-imports': 'warn',
'prefer-const': 'warn',
},
},
//
// website workspace linting
//
{
files: ['site/**/*.{ts,tsx}'],
rules: {
'@typescript-eslint/no-unused-vars': 'warn',
},
},
{
files: ['site/**/*.js'],
languageOptions: {
globals: { AMap: true },
},
},
);