-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.eslintrc.js
98 lines (97 loc) · 2.35 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
const OFF = 0;
const WARN = 1;
const ERROR = 2;
module.exports = {
root: true,
extends: 'airbnb-base',
parser: 'babel-eslint',
plugins: ['import', 'html'],
parserOptions: {
sourceType: 'module',
},
env: {
browser: true,
es6: true,
},
settings: {
'import/resolver': {
webpack: {
config: 'build/webpack.base.conf.js',
},
},
},
globals: {
wx: true,
},
rules: {
// 没有找到模块
'import/extensions': [
'off',
'always',
{
js: 'never',
vue: 'never',
},
],
'object-curly-newline': OFF, // 一行超长了, 才换行
'import/no-unresolved': [OFF, { commonjs: true, amd: true }],
// 允许 console warn, error
'no-console': [
'error',
{
allow: ['warn', 'error', 'info'],
},
],
'arrow-parens': OFF,
'linebreak-style': OFF, // 回车风格不报错
// indent: [
// 'error',
// 2, // 缩进2个空格
// {
// SwitchCase: 1,
// FunctionDeclaration: { body: 1, parameters: 4 },
// flatTernaryExpressions: false,
// ignoredNodes: ['ConditionalExpression'],
// ObjectExpression: 1,
// },
// ],
indent: WARN,
'no-unused-expressions': [
'error',
{
allowTernary: true,
allowShortCircuit: true,
},
],
'global-require': OFF, // 可以使用 require(); 用于 require(图片)
'no-debugger': process.env.NODE_ENV === 'production' ? ERROR : OFF,
'import/no-extraneous-dependencies': [
'error',
{
optionalDependencies: ['test/unit/index.js'],
},
],
'func-names': ['error', 'never'],
// 允许改对象类型的参数, 比如 vuex 里的 state
'no-param-reassign': ['error', { props: false }],
// 允许重复命名相同名字的变量, 比如 vuex 里的 state
'no-shadow': ['error', { allow: ['state'] }],
// 箭头函数
'arrow-parens': ['error', 'as-needed'],
// 逗号
'comma-dangle': [
'error',
{
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'ignore',
},
],
'function-paren-newline': WARN,
'import/prefer-default-export': WARN,
camelcase: WARN,
'max-len': ['error', { code: 120 }],
},
};