ESLint–使用/配置

原文网址:ESLint--使用/配置_IT利刃出鞘的博客-CSDN博客

简介

        本文介绍代码检查工具ESLint的用法和配置。

关闭ESLint的方法

见:ESLint--关闭的方法_IT利刃出鞘的博客-CSDN博客

配置

        使用 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
    }
  }
}

我的配置

ESLint规则大全

eslint的规则设置_TionSu的博客-CSDN博客

关闭eslint方法总结_huangpb的博客-CSDN博客_eslint关闭

其他网址

ESLint配置文件.eslintrc参数说明 - SegmentFault 思否

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
THE END
分享
二维码
< <上一篇
下一篇>>