-
Notifications
You must be signed in to change notification settings - Fork 277
/
.eslintrc.js
116 lines (113 loc) · 2.66 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
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
const compileTimeConfiguration = require('./script/config.js');
// 配置小程序内全局函数,避免报错
const globals = {
require: true,
Page: true,
wx: true,
App: true,
getApp: true,
getCurrentPages: true,
Component: true,
getRegExp: true,
Behavior: true,
};
// 配置编译时配置,避免报错
Object.keys(compileTimeConfiguration).forEach((key) => {
globals[key] = true;
});
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
impliedStrict: true,
},
},
env: {
browser: true,
node: true,
es6: true,
jest: true,
},
// 启用默认核心规则
extends: ['eslint-config-airbnb-base', 'eslint-config-prettier'],
plugins: ['@typescript-eslint', 'prettier', 'import'],
// add your custom rules here
rules: {
'import/order': [
'error',
{
groups: [
'builtin', // Built-in types are first
'external', // Then the index file
'internal',
],
},
],
// 非开发模式禁用debugger
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'warn',
// 允许调用首字母大写的函数时没有 new 操作符
'new-cap': 'off',
// 在工具库中允许变量以下划线开头
'no-underscore-dangle': 'off',
// 在工具库中允许参数重新赋值
'no-param-reassign': 'off',
'number-leading-zero': 'off',
// 在类属性和方法上关闭需要显式的可访问性修饰符
'@typescript-eslint/explicit-member-accessibility': 'off',
eqeqeq: [
'error',
'always',
{
null: 'ignore',
},
],
'import/no-unresolved': 0,
'import/no-named-as-default': 0,
'import/extensions': 0,
'import/export': 0,
'import/no-cycle': 0,
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: true,
},
],
'import/no-dynamic-require': 0,
'object-shorthand': 0,
'no-shadow': 0,
'no-unused-expressions': 0,
'no-unused-vars': 0,
'@typescript-eslint/no-unused-vars': 2,
'consistent-return': 0,
'no-return-assign': 0,
'func-names': 0,
'class-methods-use-this': 0,
'no-console': [
2,
{
allow: ['warn', 'error'],
},
],
'no-undef': 0,
'no-proto': 0,
},
globals,
overrides: [
{
files: ['script/**'],
rules: {
// node 环境下支持 require
'@typescript-eslint/no-require-imports': 'off',
'no-console': 0,
},
},
{
files: ['example/**', '**/_example/**'],
rules: {
'no-console': 0,
},
},
],
};