image.png
此时会在终端执行以下命令, 并按提示进行选择:
d:\Project\vue-demo-project>node_modules.bin\eslint.cmd --init
? How would you like to configure ESLint? Answer questions about your style
? Which version of ECMAScript do you use? ES2015
? Are you using ES6 modules? Yes
? Where will your code run? Browser
? Do you use CommonJS? Yes
? Do you use JSX? Yes
? Do you use React? Yes
? What style of indentation do you use? Tabs
? What quotes do you use for strings? Double
? What line endings do you use? Windows
? Do you require semicolons? No
? What format do you want your config file to be in? JSON
The config that you've selected requires the following dependencies:
eslint-plugin-react@latest
Successfully created .eslintrc.json file in d:\Project\vue-demo-project
d:\Project\vue-demo-project>
完成以上动作后, 会在当前工程目录下生成一个 .eslintrc.json文件
image.png
若有出错, 一般会给出提示, 按提示处理就好了。 2. 报错: Expected linebreaks to be 'CRLF' but found 'LF'. (linebreak-style)
有时会出现报错信息: Expected linebreaks to be 'CRLF' but found 'LF'. (linebreak-style)
不同的操作系统下,甚至是不同编辑器,不同工具处理过的文件可能都会导致换行符的改变。
如果实在找不出原因, 或者无法解决, 可以先关闭此项检测。
// 统一换行符,"\n" unix(for LF) and "\r\n" for windows(CRLF),默认unix
// off或0: 禁用规则
'linebreak-style': 'off'