ToC
- https://hacpai.com/article/1496906863683
- https://hacpai.com/article/1497002998658
- https://hacpai.com/article/1497235254333
添加依赖
"devDependencies": {
"babel-eslint": "^7.2.3",
"eslint": "^4.0.0",
"eslint-config-airbnb-base": "^11.2.0",
"eslint-formatter-pretty": "^1.1.0",
"eslint-plugin-import": "^2.3.0",
"eslint-plugin-react": "^7.1.0",
"eslint-plugin-react-native": "^2.3.2"
},
添加命令
"scripts": {
"lint": "eslint . --fix --format=node_modules/eslint-formatter-pretty --quiet"
}
添加规则 .eslintrc
{
"parser": "babel-eslint",
"extends": "airbnb-base",
"env": {
"jest": true
},
"plugins": [
"react",
"react-native"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
"react/jsx-uses-vars": 2,
"react/jsx-uses-react": 2,
"comma-dangle": [
"error",
{
"arrays": "never",
"objects": "never"
}
],
"no-underscore-dangle": [
"error",
{
"allowAfterThis": true
}
]
},
"globals": {
"fetch": true
}
}
添加不需要检测的文件 .eslintignore
__tests__/
具体修改可参见 :rotating_light: add eslint · b3log/SymApp@f8505e7