-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path.eslintrc.js
executable file
·80 lines (79 loc) · 2.44 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
/*
* 本规范由 'JavaScript Standard Style' 规范 —— 添加自定义内容 组成的加强版
* Standard规则 中文文档 : https://github.com/feross/standard/blob/master/docs/RULES-zhcn.md
* ESlint规则 中文文档: http://eslint.cn/docs/rules/
*/
module.exports = {
'env': {
'browser': true,
'commonjs': true,
'es6': true
},
'extends': ['react-app'],
'parserOptions': {
"allowImportExportEverywhere": true,
'sourceType': 'module',
'ecmaVersion': 8,
'ecmaFeatures': {
'jsx': true,
}
},
'plugins': [
'react'
],
// React-eslint
'settings': {
'react': {
'createClass': 'createReactClass', // Regex for Component Factory to use, default to 'createReactClass'
'pragma': 'React', // Pragma to use, default to 'React'
'version': '15.0' // React version, default to the latest React stable release
}
},
// 自定义编码规范,慎重修改
'rules': {
// 关闭数组,对象最后一个元素后的逗号检查
'comma-dangle': 0,
'max-len': [
'error', {
// 代码长度
'code': 120,
// 忽略正则表达式匹配的行;可以只匹配单行,而且在 YAML 或 JSON 中需要双重转义
// 'ignorePattern': true,
// 忽略所有拖尾注释和行内注释
'ignoreComments': true,
// 强制注释的最大长度;默认长度同 code, 暂未生效,因此加入上方的规则
'comments': 120
}
],
// console警告
'no-console': 0,
// 允许未定义
'no-undef': 0,
// 允许new
'no-new': 0,
// 禁止变量声明覆盖外层作用域的变量
'no-shadow': ['error', { 'allow': ['state'] }],
// 允许修改传入的参数
'no-param-reassign': 0,
// 允许嵌套三元表达式
'no-nested-ternary': 0,
// 允许无用的构造函数
'no-useless-constructor': 0,
// 允许图片不存在alt
'a11y-img-has-alt': 0,
// 关闭超链接检查
'jsx-a11y/anchor-is-valid': 'off',
// 关闭img标签检查
'jsx-a11y/alt-text': 'off',
// 允许不存在默认的抛出
'import/prefer-default-export': 0,
// allow optionalDependencies
'import/no-extraneous-dependencies': ['error', {
'optionalDependencies': ['test/unit/index.js']
}],
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
// allow global require
'global-require': 0,
}
};