eslint配置注意事项
2017-11-20 19:28
603 查看
1).
确保.eslintrc文件存在,并且内容为
2).
如下所示错误代码,是因为最新的eslint需要重新配置,按照下面路径方法配置即可:eslint-config-airbnb-base安装配置
3).
Unexpected top-level property,我的原因是没有将规则写对地方,
错误的写法如下所示:
正确的写法如下所示:
4).
Use the
也就是在.eslintrc中添加
安装依赖包:npm install babel-eslint –save
5).
我们从github上拉别人项目的时候。有时候会遇到这个报错:
这就是eslint的报错了,可能是原作者用的是linux系统。
只需在eslintrc文件里面将
linebreak-style: [“error”, “unix”]
改成
linebreak-style: [“error”, “windows”](我用的是windows)即可
4:1 error Parsing error: The keyword 'import' is reserved
确保.eslintrc文件存在,并且内容为
{ "extends": "airbnb", "plugins": ["react"] }
2).
Value "data["0"].VariableDeclarator" has additional properties.
如下所示错误代码,是因为最新的eslint需要重新配置,按照下面路径方法配置即可:eslint-config-airbnb-base安装配置
ERROR in ./src/index.js Module build failed: Error: /home/suwu150/WebStormProject/electron-desktop-tools/node_modules/eslint-config-airbnb-base/rules/es6.js: Configuration for rule "prefer-destructuring" is invalid: Value "data["0"].VariableDeclarator" has additional properties. Value "data["0"].AssignmentExpression" has additional properties. Referenced from: /home/suwu150/WebStormProject/electron-desktop-tools/node_modules/eslint-config-airbnb-base/index.js Referenced from: airbnb Referenced from: /home/suwu150/WebStormProject/electron-desktop-tools/.eslintrc at validateRuleOptions (/home/suwu150/WebStormProject/electron-desktop-tools/node_modules/eslint/lib/config/config-validator.js:109:15)
3).
- Unexpected top-level property "comma-dangle".
ERROR in ./src/index.js Module build failed: Error: ESLint configuration in /home/suwu150/WebStormProject/electron-desktop-tools/.eslintrc is invalid: - Unexpected top-level property "comma-dangle". at validateConfigSchema (/home/suwu150/WebStormProject/electron-desktop-tools/node_modules/eslint/lib/config/config-validator.js:214:15) at Object.validate (/home/suwu150/WebStormProject/electron-desktop-tools/node_modules/eslint/lib/config/config-validator.js:231:5)
Unexpected top-level property,我的原因是没有将规则写对地方,
错误的写法如下所示:
{ "parserOptions": { "ecmaVersion": 6, "sourceType": "module", "ecmaFeatures": { "jsx": true, "experimentalObjectRestSpread": true } }, "rules": { "semi": 2 }, "comma-dangle": [1,"always-multiline"], "plugins": ["react"], "extends": "airbnb" }
正确的写法如下所示:
{ "parserOptions": { "ecmaVersion": 6, "sourceType": "module", "ecmaFeatures": { "jsx": true, "experimentalObjectRestSpread": true } }, "rules": { "semi": 2, "comma-dangle": ["off"] }, "plugins": ["react"], "extends": "airbnb" }
4).
Parsing error: Unexpected token :或者
Parsing error: Unexpected token =
34:52 error Parsing error: Unexpected token : ✖ 1 problem (1 error, 0 warnings) @ ./src/store/configureStore.js 6:19-58 @ ./src/index.js @ multi webpack-hot-middleware/client?path=http://localhost:3000/__webpack_hmr babel-polyfill ./src/index.js
Use the
babel-eslintparser in your ESLint configuration.
也就是在.eslintrc中添加
"parser": "babel-eslint",即可
安装依赖包:npm install babel-eslint –save
{ "parser": "babel-eslint", "plugins": ["react"], ... }
5).
error: Expected linebreaks to be ‘LF’ but found ‘CRLF’
我们从github上拉别人项目的时候。有时候会遇到这个报错:
error: Expected linebreaks to be ‘LF’ but found ‘CRLF’
这就是eslint的报错了,可能是原作者用的是linux系统。
只需在eslintrc文件里面将
linebreak-style: [“error”, “unix”]
改成
linebreak-style: [“error”, “windows”](我用的是windows)即可
相关文章推荐
- FastDFS Tracker端配置文件详解及启动注意事项
- UEditor在线编辑器配置及注意事项
- CollabNet Subversion-server-1.5.0在windows下的安装配置的注意事项
- SpringBoot开发详解(三)--SpringBoot配置文件YML注意事项
- Hadoop之——CentOS配置ssh无密码登录注意事项
- 配置config.bib的注意事项以及错误分析
- SharePoint 2013 Workflow Manager 工作流配置注意事项
- 配置路线图RouteMap注意事项
- import-module的注意事项与NDK_MODULE_PATH的配置
- tomcat配置gzip压缩注意事项
- ssh中监听器配置的注意事项
- iis7.5配置.net mvc注意事项
- 关于Struts2.5的配置的一些注意事项
- 数据库安装、配置注意事项
- ObjectARX Map3D开发环境配置注意事项
- iOS10权限配置问题及上传Itunes审核注意事项
- jdk环境配置 eclipse环境配置 android源码编译注意事项
- struts2注解配置注意事项
- 关于配置文件的一些注意事项
- linux nfs服务配置挂载以及oracle使用nfs存储挂载注意事项