npm i eslint -g
npm i eslint-plugin-react -g
npm i eslint-config-react-app -g
npm i eslint-plugin-import -g
npm i eslint-loader -g
npm i eslint-plugin-flowtype -g
npm i eslint-plugin-jsx-a11y -g
npm i babel-eslint -g
2.webstorm 配置 eslint
Preference->Tools->External Tools, Click "+“
3.Record the macro Edit > Macros > Start Macro recording
i. Cmd+Alt+L (使用editorconfig格式化代码)
ii. Cmd+Alt+S (保存)
iii. Tools->External Tools->ESlint Fix
Stop recording the macro clicking on the Stop button on the bottom right of the page. Give this macro a name like "Format(editorconfig+eslint) and Save"
4.Assing Ctrl+S to "Format(editorconfig+eslint) and Save" open WebStorm->Preferences; search for "keymap" and open it; search "Format(editorconfig+eslint) and Save" and double click the action "Format(editorconfig+eslint) and Save"; select "Add Keyboard Shortcut"; select "Cmd+S" as first stroke. it will report conflicts. Ignore it and click OK button WebStorm will show a warning "The shortcut is already assigned to other actions. Do you want to remove other assignments?" Click "Remove" button
5.webstorm的自动格式化需要特殊设置:勾选 Keep when reformatting->Simple methods in one line
否则会把下面的一行
console.groupEnd = console.groupEnd || function () {}
变成两行,
console.groupEnd = console.groupEnd || function () {
}
丑陋而且没有必要
3.Record the macro Edit > Macros > Start Macro recording Tools->External Tools->prettier,and then cmd+4, and then cmd+4 , and then cmd+alt+s Stop recording the macro clicking on the Stop button on the bottom right of the page. Give this macro a name like "Format(prettier) and Save"
4.Assing Ctrl+S to "Format(prettier) and Save" open WebStorm->Preferences; search for "keymap" and open it; search "Format(prettier) and Save" and double click the action "Format(prettier) and Save"; select "Add Keyboard Shortcut"; select "Cmd+S" as first stroke. it will report conflicts. Ignore it and click OK button WebStorm will show a warning "The shortcut is already assigned to other actions. Do you want to remove other assignments?" Click "Remove" button