Create-React-App项目外使用它的eslint配置
2018-03-07 23:43
1191 查看
概述
使用Create-React-App脚手架感觉它的eslint配置有点好用,于是考虑不用Create-React-App脚手架该怎么使用这些配置。我于是eject了Create-React-App脚手架,查看它的详细配置和官方文档,总结了使用它的eslint配置的方法,记录如下,供以后开发时参考,相信对其它人也有用。
配置
(1)首先安装依赖:npm install eslint --save-dev npm install babel-eslint --save-dev npm install eslint-plugin-flowtype --save-dev npm install eslint-plugin-jsx-a11y --save-dev
(2)然后配置
package.json文件。(不需要配置.eslintrc.js文件,详见Eslint Configuring文档)
"eslintConfig": { "parser": "babel-eslint", "extends": [ "plugin:flowtype/recommended", "plugin:jsx-a11y/recommended" ], "plugins": [ "flowtype", "jsx-a11y" ] }
(3)在主目录下面输入eslint + 文件名即可。比如
eslint test.js。
测试是否生效
测试内容如下,如果有5个报错,那么证明是生效的。type X = bool // Message: Use "boolean", not "bool" // Options: ["boolean"] type X = bool // Message: Use "boolean", not "bool" // Options: ["bool"] type X = boolean // Message: Use "bool", not "boolean"
感想
以前用eslint的时候感觉每次要配置.eslintrc.js文件超级麻烦,现在才发现可以直接在
package.json配置,真的很方便。
相关文章推荐
- create-react-app创建react项目,使用axios跨域
- 详解create-react-app 自定义 eslint 配置
- 最新-使用create-react-app 生成项目怎么处理scss预处理器
- 在create-react-app创建的React项目应用中配置JQ、Sass
- create-react-app项目添加less配置
- 使用create-react-app创建项目
- Create-react-app+Antd+Less 在项目yarn eject 的情况下进行配置
- 使用create-react-app自动构建react项目
- 使用create-reate-app创建的项目中代理的配置
- react---学习笔记:使用create-react-app快速构建开发环境并创建项目
- 使用create-react-app或者antd创建一个React项目
- 在基于 create-react-app 的React项目中进行代码分片、按需加载(code splitting)/ 免webpack配置
- create-react-app创建项目报错SyntaxError: Unexpected end of JSON input while parsing near '...ttachment":false,"tar' npm代理
- Create-React-App创建React项目
- create-react-app + antd-mobile配置
- heroku 自动部署create-react-app项目
- 以create-react-app为基础创建项目
- create-react-app搭建的项目中添加bootstrap
- creact-react-app创建react项目配置scss
- react create app ,nginx服务器配置