今天配置下Webstorm下面的Eslint。node
1,先看下本地安装的Node,NPM版本,2017-11-23日这个节点最新版本。git
>node -v v8.9.1 >npm -v 5.5.1
2,使用Webstorm快捷键Alt + F12,进入Terminal窗口,以下图es6
3,执行全局安装eslintnpm
npm install -g eslintapp
4,执行 eslint --init测试
初始化eslint配置文件,每一步根据本身须要选择YES or NO,ui
C:\Users\XXXXXXX\WebstormProjects\es6tutorial>eslint --init ? How would you like to configure ESLint? Answer questions about your style ? Are you using ECMAScript 6 features? Yes ? Are you using ES6 modules? Yes ? Where will your code run? Browser ? Do you use CommonJS? No ? Do you use JSX? No ? What style of indentation do you use? Tabs ? What quotes do you use for strings? Single ? What line endings do you use? Unix ? Do you require semicolons? Yes ? What format do you want your config file to be in? JavaScript
最后将会生成一份.eslintrc.js 文件,spa
5,在本身项目里,执行 eslint learning/chap02-let.js,eslint
eslint将会根据配置的规则进行JS验证并在控制台打印出提示消息code
PS:我在安装测试过程当中,发生以下错误,大概意思是:要确保ESLint全局安装。
Oops! Something went wrong! :( ESLint: 4.11.0. ESLint couldn't find the plugin "eslint-plugin-jsx-a11y". This can happen for a couple different reasons: 1. If ESLint is installed globally, then make sure eslint-plugin-jsx-a11y is also installed globally. A globally-installed ESLint cannot find a locally-installed plugin. 2. If ESLint is installed locally, then it's likely that the plugin isn't installed correctly. Try reinstalling by running the following: npm i eslint-plugin-jsx-a11y@latest --save-dev If you still can't figure out the problem, please stop by https://gitter.im/eslint/eslint to chat with the team.