-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.eslintrc.js
50 lines (50 loc) · 1.55 KB
/
.eslintrc.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
module.exports = {
root: true,
env: {
// 支持浏览器环境
browser: true,
// 识别 CommonJS
node: true,
// 识别 ES 的代码,使用 ECMAScript 2021 自动设置 ecmaVersion parser 为 12,
es2021: true,
},
extends: [
"eslint:recommended", // eslint 自己的推荐规则,最佳实践最小集
"plugin:prettier/recommended", // 禁用 eslint 关于代码的风格的规则,使用 prettier 的风格
],
overrides: [
// 处理 JS 文件
{
files: ["**/*.{js,jsx}"], // 只处理 js 和 jsx 文件
extends: ["plugin:react/recommended"],
parserOptions: {
sourceType: "module", // 支持 import/export
allowImportExportEverywhere: false,
ecmaFeatures: {
globalReturn: false,
},
},
},
// 处理 TS 文件
{
files: ["**/*.{ts,tsx}"], // 只处理 ts 和 js 文件
parser: "@typescript-eslint/parser", // 能看懂 TypeScript
parserOptions: {
project: ["./tsconfig.json"], // 告诉 eslint:tsconfig 在哪
},
extends: [
// typescript-eslint 的推荐规则,只是这些最佳规则都是针对 TS 的
"plugin:@typescript-eslint/recommended",
// tsconfig.json 里 Type Checking 的推荐规则
"plugin:@typescript-eslint/recommended-requiring-type-checking",
],
plugins: [
// 使用 typescript x eslint 的插件
"@typescript-eslint",
],
rules: {
"@typescript-eslint/explicit-module-boundary-types": "off",
},
},
],
};