基本上我已经从这里安装了 ESLint
http://eslint.org/docs/user-guide/getting-started
.eslintrs.json 看起来像这样
{
"extends": ["eslint:recommended",
"angular",
"plugin:jasmine/recommended"],
"installedESLint": true,
"plugins": [
"standard",
"promise",
"jasmine"
],
"rules": {
"strict": 0,
"indent": [2, 4],
"quotes": [2, "single"],
"no-unused-vars": 1,
"no-underscore-dangle": 1
},
"env": {
"jasmine": true
},
"globals": {
"navigator": true
}
}
基本上,我需要检查一些 .js
文件是否有多余的空格和不必要的行。也是如此
eslint myfile.js
这就是我得到的 自动配置失败。无法解析任何文件。
如何使用ESLint删除js文件中不必要的空格和行?
最佳答案
配置文件应该是.eslintrc.*
,或者只是.eslintrc
http://eslint.org/docs/user-guide/configuring
Configuration Files - use a JavaScript, JSON or YAML file to specify configuration information for an entire directory and all of its subdirectories. This can be in the form of an .eslintrc.* file or an eslintConfig field in a package.json file, both of which ESLint will look for and read automatically, or you can specify a configuration file on the command line.
编辑:
您可以附加 --fix
来要求 ESLint 自动修复发现的问题。
例如。
eslint myfile.js mydir --fix
关于javascript - 如何使用 ESLint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44793688/