We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESLint 是用来检查我们写的 JavaScript 代码是否满足指定规则的静态代码检查工具。
通过用 ESLint 来检查一些规则,我们可以:
npm install --save-dev eslint
如果项目种还没有配置文件(.eslintrc)的话,可以通过指定--init参数来生成一个新的配置文件:
eslint --init
在生成的配置文件(.eslintrc)文件中配置一些规则。
{ "env": { "browser": true, "commonjs": true, "es6": true }, "parserOptions": { "ecmaVersion": 6 }, "rules": { "indent": ["error", 2], "no-mixed-spaces-and-tabs": "error" "camelcase": "error", "eqeqeq": "warn", "curly": "error", "no-undef": "error", "no-unused-vars": "warn", "max-params": "warn" } }
env 指定代码运行的环境。
parserOptions 指定 JavaScript 相关的选项。ecmaVersion 指定用哪个 ECMAScript 的版本,默认是 3 和 5。
rules 指定具体检查的规则。默认情况下,如果不设置检查的规则,ESLint 不会检查任何规则。
规则的错误等级有三种: 0:关闭规则。 1:打开规则,并且作为一个警告(不影响exit code)。 2:打开规则,并且作为一个错误(exit code将会是1)。
更多规则说明详见官网
The text was updated successfully, but these errors were encountered:
No branches or pull requests
简介
ESLint 是用来检查我们写的 JavaScript 代码是否满足指定规则的静态代码检查工具。
通过用 ESLint 来检查一些规则,我们可以:
安装
使用方法
如果项目种还没有配置文件(.eslintrc)的话,可以通过指定--init参数来生成一个新的配置文件:
配置
在生成的配置文件(.eslintrc)文件中配置一些规则。
env 指定代码运行的环境。
parserOptions 指定 JavaScript 相关的选项。ecmaVersion 指定用哪个 ECMAScript 的版本,默认是 3 和 5。
rules 指定具体检查的规则。默认情况下,如果不设置检查的规则,ESLint 不会检查任何规则。
规则的错误等级有三种:
0:关闭规则。
1:打开规则,并且作为一个警告(不影响exit code)。
2:打开规则,并且作为一个错误(exit code将会是1)。
更多规则说明详见官网
The text was updated successfully, but these errors were encountered: