Index

配置 ESLint

ESLint 被设计为灵活且可配置以适应你的使用场景。你可以关闭所有规则,仅进行基本语法验证,或将打包规则与自定义规则混合使用,以满足项目的需求。配置 ESLint 主要有两种方式:

🌐 ESLint is designed to be flexible and configurable for your use case. You can turn off every rule and run only with basic syntax validation or mix and match the bundled rules and your custom rules to fit the needs of your project. There are two primary ways to configure ESLint:

  1. 配置注释 - 使用 JavaScript 注释将配置信息直接嵌入到文件中。
  2. 配置文件 - 使用 JavaScript 文件为整个目录及其所有子目录指定配置信息。这可以采用 eslint.config.js 文件的形式,ESLint 会自动查找并读取该文件,或者你可以在 命令行 中指定配置文件。

以下是你可以在 ESLint 中配置的一些选项:

🌐 Here are some of the options that you can configure in ESLint:

  • 全局变量 - 你的脚本在执行过程中访问的额外全局变量。
  • 规则 - 哪些规则被启用以及错误级别是多少。
  • 插件 - 第三方插件,它们为 ESLint 提供额外的规则、语言、配置等。

所有这些选项都让你可以细粒度地控制 ESLint 如何处理你的代码。

🌐 All of these options give you fine-grained control over how ESLint treats your code.

目录

🌐 Table of Contents

配置文件

配置语言选项

配置规则

配置插件

配置解析器

忽略文件