ESLint--配置
程序员文章站
2022-06-14 08:22:54
...
其他网址
官网
配置文件
其他网址
简介
使用 JavaScript、JSON 或者 YAML 文件为整个目录(处理你的主目录)和它的子目录指定配置信息。
可以配置一个独立的
.eslintrc.*
文件,或者直接在package.json
文件里的eslintConfig字段指定配置,ESLint 会查找和自动读取它们,再者,你可以在命令行运行时指定一个任意的配置文件。
JSON配置文件示例(.eslintrc.json)
ESLint的JSON文件允许JavaScript风格的注释。
{ "name": "three", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC", "devDependencies": { "eslint": "^6.6.0" } }
JS配置文件示例(.eslintrc.js)
module.exports = { "env": { "browser": true, "es6": true, "node": true }, "extends": "eslint:recommended", "globals": { "Atomics": "readonly", "SharedArrayBuffer": "readonly" }, "parserOptions": { "ecmaVersion": 2018, "sourceType": "module" }, "rules": { } };
package.json配置文件示例
{ "name": "mypackage", "version": "0.0.1", "eslintConfig": { "env": { "browser": true, "node": true } } }