-
Notifications
You must be signed in to change notification settings - Fork 636
/
eslint.config.js
158 lines (143 loc) · 3.83 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
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
// @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,
},
},
// 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 },
},
},
);