-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.mjs
97 lines (91 loc) · 2.42 KB
/
eslint.config.mjs
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
import globals from 'globals'
import eslint_js from '@eslint/js'
import reactPlugin from 'eslint-plugin-react'
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
import tsEslintPlugin from '@typescript-eslint/eslint-plugin'
import tsEslintParser from '@typescript-eslint/parser'
import reactHooksPlugin from 'eslint-plugin-react-hooks'
import eslintConfigPrettier from 'eslint-config-prettier'
const customTsFlatConfig = [
{
name: 'typescript-eslint/base',
languageOptions: {
parser: tsEslintParser,
sourceType: 'module',
},
files: ['**/*.{js,jsx,mjs,cjs,ts,tsx}'],
rules: {
...tsEslintPlugin.configs.recommended.rules,
},
plugins: {
// ts 语法特有的规则,例如泛型
'@typescript-eslint': tsEslintPlugin,
},
},
]
export default [
// es lint默认规则
eslint_js.configs.recommended,
// prettier 默认推荐规则
eslintPluginPrettierRecommended,
//ts默认规则
...customTsFlatConfig,
{
name: 'global config',
languageOptions: {
globals: {
...globals.es2022,
...globals.browser,
...globals.node,
},
parserOptions: {
warnOnUnsupportedTypeScriptVersion: false,
},
},
rules: {
'no-unused-vars': 'off',
'no-undef': 'off',
'@typescript-eslint/no-explicit-any': 'off',
//关闭不能再promise中使用ansyc
'no-async-promise-executor': 'off',
//关闭不能再常量中使用??
'no-constant-binary-expression': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/no-unused-vars': 'off',
//禁止失去精度的字面数字
'@typescript-eslint/no-loss-of-precision': 'off',
},
},
{
ignores: ['**/node_modules', '**/dist', '**/output'],
},
{
name: 'react-eslint',
files: ['src/*.{js,jsx,mjs,cjs,ts,tsx}'],
plugins: {
react: reactPlugin,
'react-hooks': reactHooksPlugin,
},
languageOptions: {
...reactPlugin.configs.recommended.languageOptions,
// parserOptions: {
// ecmaFeatures: {
// jsx: true,
// },
// },
},
rules: {
...reactPlugin.configs.recommended.rules,
},
settings: {
react: {
// 需要显示安装 react
version: 'detect',
},
},
},
{
languageOptions: { globals: { ...globals.browser, ...globals.node } },
},
eslintConfigPrettier,
]