日期:2020-07-12 阅读:471
dmandwp系统 - wordpress系统和DM系统区块建站>>
The extension uses the ESLint library installed in the opened workspace folder. If the folder doesn't provide one the extension looks for a global install version.
If you haven't installed ESLint either locally or globally do so by running npm install eslint in the workspace folder for a local install
or npm install -g eslint for a global install.
On new folders you might also need to create a .eslintrc configuration file.
You can do this by either using the VS Code command Create ESLint configuration or by running the eslint command in a terminal.
If you have installed ESLint globally (see above) then run eslint --init in a terminal.
If you have installed ESLint locally then run .\node_modules\.bin\eslint --init under Windows and ./node_modules/.bin/eslint --init under Linux and Mac.
-------------
关于自动修复
现在代码都比较严格,可能包含缩进是 2 个空格,是否在语句最后加逗号的情况。不可能自己手动去一个个修正。
eslint ./src --fix
加上 --fix 可以自动修正一些明显的问题。
配置 VS Code 自动修复,安装 ESLint VS Code 插件。 View -> Command Palette -> install extension.
首选项 -> 设置 -> 搜索 "autofix". Auto Fix On Save。 就可以在保存的时候自动修正了。