-
Notifications
You must be signed in to change notification settings - Fork 3
/
.eslintrc.js
84 lines (76 loc) · 2.65 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
module.exports = {
root: true,
globals: {
wx: true,
flex: true
},
env: {
browser: true,
commonjs: true,
es6: true,
node: true
},
settings: {
"import/resolver": {
"babel-module": {}
}
},
// https://npm.taobao.org/package/babel-eslint
// babel-eslint 你使用 babel-eslint 的唯一理由就是你在使用类型检查工具,
// 比如Flow,抑或使用了一些Babel支持的实验性的 但Eslint 还不支持的语法 。
parser: "babel-eslint",
// https://npm.taobao.org/package/eslint-plugin-babel
// eslint-plugin-babel 解决babel-eslint不能解决的使内置规则支持实验性语法特性的问题,
// 总之这是一款和 babel-eslint 配套使用的 eslint 规则插件。
plugins: ["babel"],
// https://npm.taobao.org/package/eslint-config-airbnb
// airbnb 高度集成了 eslint, eslint-plugin-import, eslint-plugin-react, eslint-plugin-jsx-a11y
// https://npm.taobao.org/package/eslint-plugin-import
// eslint-plugin-import 旨在解决 ES6 中 import/export 语法问题,和路径太长易拼错的问题。
// https://github.com/yannickcr/eslint-plugin-react
// eslint-plugin-react 一个指定的React 语法规则检查工具。
// https://github.com/evcohen/eslint-plugin-jsx-a11y
// eslint-plugin-jsx-a11y 对JSX 元素上可访问属性的静态检查 。
extends: "airbnb",
parserOptions: {
ecmaVersion: 6,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true
},
sourceType: "module"
},
// https://eslint.org/docs/rules/
// 0 1 2 -> off warn error
rules: {
indent: 0,
"linebreak-style": ["error", "unix"],
"no-console": ["error", { allow: ["warn", "error", "info"] }],
quotes: ["error", "double"],
semi: 0,
curly: 0,
camelcase: 0,
"max-len": ["error", 300],
"comma-dangle": 0,
"arrow-parens": 0,
"object-curly-newline": 0,
"function-paren-newline": 0,
"no-shadow": "off", // 解构需要,比如 const { getUser } = this.props
"no-return-assign": "off", // 这与 react 中获取元素的方式冲突, ref = {ele => this.input = ele}
"no-nested-ternary": "off", // 习惯了在jsx语法各种三元操作了。。。
"react/jsx-filename-extension": ["error", { extensions: [".js", ".jsx"] }],
"react/jsx-indent": 0,
"react/jsx-indent-props": ["error", 2],
"react/prop-types": 0,
"react/no-danger": "off",
"react/react-in-jsx-scope": 0,
"jsx-a11y/anchor-is-valid": [
"error",
{
components: [""],
specialLink: ["hrefLeft", "hrefRight"],
aspects: ["noHref", "invalidHref", "preferButton"]
}
]
}
};