From 3cc50a295891ec11f2008b3aca0c8e6fd258f728 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 11:29:42 +0500 Subject: [PATCH 01/96] Create Configuration Files --- docs/user-guide/Configuring ESLint/Configuration Files | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/user-guide/Configuring ESLint/Configuration Files diff --git a/docs/user-guide/Configuring ESLint/Configuration Files b/docs/user-guide/Configuring ESLint/Configuration Files new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/docs/user-guide/Configuring ESLint/Configuration Files @@ -0,0 +1 @@ + From 0f4fc07b866219b37ab361137994cf978dd7db3c Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 11:34:47 +0500 Subject: [PATCH 02/96] Create Index File --- docs/user-guide/Configuring ESLint/README.md | 47 ++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 docs/user-guide/Configuring ESLint/README.md diff --git a/docs/user-guide/Configuring ESLint/README.md b/docs/user-guide/Configuring ESLint/README.md new file mode 100644 index 00000000000..5b0b897a5ef --- /dev/null +++ b/docs/user-guide/Configuring ESLint/README.md @@ -0,0 +1,47 @@ +# Configuring ESLint +ESLint is designed to be completely configurable. 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 make ESLint perfect for your project. There are two primary ways to configure ESLint: + +1. **Configuration Comments** - use JavaScript comments to embed configuration information directly into a file. +1. **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.*`](./configuring-files#configuration-file-formats) file or an `eslintConfig` field in a [`package.json`](https://docs.npmjs.com/files/package.json) file, both of which ESLint will look for and read automatically, or you can specify a configuration file on the [command line](https://eslint.org/docs/user-guide/command-line-interface). + +Following are some of the important pieces of information that you can configure in ESLint: + +* [**Environments**](./language-options#specifying-environments) - which environments your script is designed to run in. Each environment brings with it a certain set of predefined global variables. +* [**Globals**](./language-options#specifying-globals) - the additional global variables your script accesses during execution. +* [**Rules**](rules) - which rules are enabled and at what error level. +* [**Plugins**](plugins) - the use of third-party plugins in ESLint. + +All of these options give you fine-grained control over how ESLint treats your code. + +## Table of Contents + +[**Configuration Files**](configuring-files) +* [Configuration File Formats](./configuring-files#configuration-file-formats) +* [Using Configuration Files](./configuring-files#using-configuration-files) +* [Adding Shared Settings](./configuring-files#adding-shared-settings) +* [Cascading and Hierarchy](./configuring-files#cascading-and-hierarchy) +* [Extending Configuration Files](./configuring-files#extending-configuration-files) +* [Configuration Based on Glob Patterns](./configuring-files#configuration-based-on-glon-patterns) +* [Personal Configuration Files](./configuring-files#personal-configuration-files) + +[**Language Options**](language-options) +* [Specifying Environments](./language-options#specifying-environments) +* [Specifying Globals](./language-options#specifying-globals) +* [Specifying Parser Options](./language-options#specifying-parser-options) + +[**Rules**](rules) +* [Configuring Rules](./rules#configuring-rules) +* [Disabling Rules](./rules#disabling-rules) + +[**Plugins**](plugins) +* [Specifying Parser](./plugins#specifying-parser) +* [Specifying Processor](./plugins#specifying-processor) +* [Configuring Plugins](./plugins#configuring-plugins) + +[**Ignoring Code**](ignoring-code) +* [`ignorePatterns` in config files](./ignoring-code#ignorepatterns-in-config-files) +* [`.eslintignore`](./ignoring-code#eslintignore) +* [Using an Alternate File](./ignoring-code#using-an-alternate-file) +* [Using eslintIgnore in package.json](./ignoring-code#using-eslintignore-in-package.json) +* [Ignored File Warnings](./ignoring-code#ignored-file-warnings) +* [Disabling Comments](./ignoring-code#disabling-comments) From 16442632bd44ee504e663b2ed04fbf2cf765554f Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 11:35:49 +0500 Subject: [PATCH 03/96] Create Configuration Files --- .../Configuring ESLint/Configuration Files | 395 ++++++++++++++++++ 1 file changed, 395 insertions(+) diff --git a/docs/user-guide/Configuring ESLint/Configuration Files b/docs/user-guide/Configuring ESLint/Configuration Files index 8b137891791..b322ba801e5 100644 --- a/docs/user-guide/Configuring ESLint/Configuration Files +++ b/docs/user-guide/Configuring ESLint/Configuration Files @@ -1 +1,396 @@ +# Configuration Files +Some intro about config files here + +* [Configuration File Formats](#configuration-file-formats) +* [Using Configuration Files](#using-configuration-files) +* [Adding Shared Settings](#adding-shared-settings) +* [Cascading and Hierarchy](#cascading-and-hierarchy) +* [Extending Configuration Files](#extending-configuration-files) +* [Configuration Based on Glob Patterns](#configuration-based-on-glob-patterns) +* [Personal Configuration Files](#personal-configuration-files) + +## Configuration File Formats + +ESLint supports configuration files in several formats: + +* **JavaScript** - use `.eslintrc.js` and export an object containing your configuration. +* **JavaScript (ESM)** - use `.eslintrc.cjs` when running ESLint in JavaScript packages that specify `"type":"module"` in their `package.json`. Note that ESLint does not support ESM configuration at this time. +* **YAML** - use `.eslintrc.yaml` or `.eslintrc.yml` to define the configuration structure. +* **JSON** - use `.eslintrc.json` to define the configuration structure. ESLint's JSON files also allow JavaScript-style comments. +* **Deprecated** - use `.eslintrc`, which can be either JSON or YAML. +* **package.json** - create an `eslintConfig` property in your `package.json` file and define your configuration there. + +If there are multiple configuration files in the same directory, ESLint will only use one. The priority order is as follows: + +1. `.eslintrc.js` +1. `.eslintrc.cjs` +1. `.eslintrc.yaml` +1. `.eslintrc.yml` +1. `.eslintrc.json` +1. `.eslintrc` +1. `package.json` + +## Using Configuration Files + +There are two ways to use configuration files. + +The first way to use configuration files is via `.eslintrc.*` and `package.json` files. ESLint will automatically look for them in the directory of the file to be linted, and in successive parent directories all the way up to the root directory of the filesystem (unless `root: true` is specified). This option is useful when you want different configurations for different parts of a project or when you want others to be able to use ESLint directly without needing to remember to pass in the configuration file. + +The second is to save the file wherever you would like and pass its location to the CLI using the `-c` option, such as: + + eslint -c myconfig.json myfiletotest.js + +If you are using one configuration file and want ESLint to ignore any `.eslintrc.*` files, make sure to use `--no-eslintrc` along with the `-c` flag. + +In each case, the settings in the configuration file override default settings. + +### Comments in configuration files + +Both the JSON and YAML configuration file formats support comments (`package.json` files should not include them). You can use JavaScript-style comments or YAML-style comments in either type of file and ESLint will safely ignore them. This allows your configuration files to be more human-friendly. For example: + +```js +{ + "env": { + "browser": true + }, + "rules": { + // Override our default settings just for this directory + "eqeqeq": "warn", + "strict": "off" + } +} +``` + +## Adding Shared Settings + +ESLint supports adding shared settings into configuration files. You can add `settings` object to ESLint configuration file and it will be supplied to every rule being executed. This may be useful if you are adding custom rules and want them to have access to the same information and be easily configurable. + +In JSON: + +```json +{ + "settings": { + "sharedData": "Hello" + } +} +``` + +And in YAML: + +```yaml +--- + settings: + sharedData: "Hello" + +## Cascading and Hierarchy + +When using `.eslintrc.*` and `package.json` files for configuration, you can take advantage of configuration cascading. Suppose you have the following structure: + +```text +your-project +├── .eslintrc +├── lib +│ └── source.js +└─┬ tests + ├── .eslintrc + └── test.js +``` + +The configuration cascade works by using the closest `.eslintrc` file to the file being linted as the highest priority, then any configuration files in the parent directory, and so on. When you run ESLint on this project, all files in `lib/` will use the `.eslintrc` file at the root of the project as their configuration. When ESLint traverses into the `tests/` directory, it will then use `your-project/tests/.eslintrc` in addition to `your-project/.eslintrc`. So `your-project/tests/test.js` is linted based on the combination of the two `.eslintrc` files in its directory hierarchy, with the closest one taking priority. In this way, you can have project-level ESLint settings and also have directory-specific overrides. + +In the same way, if there is a `package.json` file in the root directory with an `eslintConfig` field, the configuration it describes will apply to all subdirectories beneath it, but the configuration described by the `.eslintrc` file in the tests directory will override it where there are conflicting specifications. + +```text +your-project +├── package.json +├── lib +│ └── source.js +└─┬ tests + ├── .eslintrc + └── test.js +``` + +If there is an `.eslintrc` and a `package.json` file found in the same directory, `.eslintrc` will take a priority and `package.json` file will not be used. + +By default, ESLint will look for configuration files in all parent folders up to the root directory. This can be useful if you want all of your projects to follow a certain convention, but can sometimes lead to unexpected results. To limit ESLint to a specific project, place `"root": true` inside the `eslintConfig` field of the `package.json` file or in the `.eslintrc.*` file at your project's root level. ESLint will stop looking in parent folders once it finds a configuration with `"root": true`. + +```js +{ + "root": true +} +``` + +And in YAML: + +```yaml +--- + root: true +``` + +For example, consider `projectA` which has `"root": true` set in the `.eslintrc` file in the `lib/` directory. In this case, while linting `main.js`, the configurations within `lib/` will be used, but the `.eslintrc` file in `projectA/` will not. + +```text +home +└── user + └── projectA + ├── .eslintrc <- Not used + └── lib + ├── .eslintrc <- { "root": true } + └── main.js +``` + +The complete configuration hierarchy, from highest precedence to lowest precedence, is as follows: + +1. Inline configuration + 1. `/*eslint-disable*/` and `/*eslint-enable*/` + 1. `/*global*/` + 1. `/*eslint*/` + 1. `/*eslint-env*/` +1. Command line options (or CLIEngine equivalents): + 1. `--global` + 1. `--rule` + 1. `--env` + 1. `-c`, `--config` +1. Project-level configuration: + 1. `.eslintrc.*` or `package.json` file in the same directory as linted file + 1. Continue searching for `.eslintrc` and `package.json` files in ancestor directories (parent has the highest precedence, then grandparent, etc.), up to and including the root directory or until a config with `"root": true` is found. + +## Extending Configuration Files + +A configuration file can extend the set of enabled rules from base configurations. + +The `extends` property value is either: + +* a string that specifies a configuration (either a path to a config file, the name of a shareable config, `eslint:recommended`, or `eslint:all`) +* an array of strings: each additional configuration extends the preceding configurations + +ESLint extends configurations recursively, so a base configuration can also have an `extends` property. Relative paths and shareable config names in an `extends` property are resolved from the location of the config file where they appear. + +The `rules` property can do any of the following to extend (or override) the set of rules: + +* enable additional rules +* change an inherited rule's severity without changing its options: + * Base config: `"eqeqeq": ["error", "allow-null"]` + * Derived config: `"eqeqeq": "warn"` + * Resulting actual config: `"eqeqeq": ["warn", "allow-null"]` +* override options for rules from base configurations: + * Base config: `"quotes": ["error", "single", "avoid-escape"]` + * Derived config: `"quotes": ["error", "single"]` + * Resulting actual config: `"quotes": ["error", "single"] + +### Using eslint-recommended + +An `extends` property value `"eslint:recommended"` enables a subset of core rules that report common problems, which have a checkmark (recommended) on the [rules page](https://eslint.org/docs/rules/). The recommended subset can change only at major versions of ESLint. + +If your configuration extends the recommended rules: after you upgrade to a newer major version of ESLint, review the reported problems before you use the `--fix` option on the [command line]((https://eslint.org/docs/user-guide/command-line-interface)#fix), so you know if a new fixable recommended rule will make changes to the code. + +The `eslint --init` command can create a configuration so you can extend the recommended rules. + +Example of a configuration file in JavaScript format: + +```js +module.exports = { + "extends": "eslint:recommended", + "rules": { + // enable additional rules + "indent": ["error", 4], + "linebreak-style": ["error", "unix"], + "quotes": ["error", "double"], + "semi": ["error", "always"], + + // override default options for rules from base configurations + "comma-dangle": ["error", "always"], + "no-cond-assign": ["error", "always"], + + // disable rules from base configurations + "no-console": "off", + } +} +``` + +### Using a shareable configuration package + +A [sharable configuration](https://eslint.org/docs/developer-guide/shareable-configs) is an npm package that exports a configuration object. Make sure the package has been installed to a directory where ESLint can require it. + +The `extends` property value can omit the `eslint-config-` prefix of the package name. + +The `eslint --init` command can create a configuration so you can extend a popular style guide (for example, `eslint-config-standard`). + +Example of a configuration file in YAML format: + +```yaml +extends: standard +rules: + comma-dangle: + - error + - always + no-empty: warn +``` + +### Using the configuration from a plugin + +A [plugin](https://eslint.org/docs/developer-guide/working-with-plugins) is an npm package that usually exports rules. Some plugins also export one or more named [configurations](https://eslint.org/docs/developer-guide/working-with-plugins#configs-in-plugins). Make sure the package has been installed in a directory where ESLint can require it. + +The `plugins` [property value](./plugins#configuring-plugins) can omit the `eslint-plugin-` prefix of the package name. + +The `extends` property value can consist of: + +* `plugin:` +* the package name (from which you can omit the prefix, for example, `react`) +* `/` +* the configuration name (for example, `recommended`) + +Example of a configuration file in JSON format: + +```json +{ + "plugins": [ + "react" + ], + "extends": [ + "eslint:recommended", + "plugin:react/recommended" + ], + "rules": { + "react/no-set-state": "off" + } +} +``` + +### Using a configuration file + +The `extends` property value can be an absolute or relative path to a base [configuration file](#using-configuration-files). ESLint resolves a relative path to a base configuration file relative to the configuration file that uses it. + +Example of a configuration file in JSON format: + +```json +{ + "extends": [ + "./node_modules/coding-standard/eslintDefaults.js", + "./node_modules/coding-standard/.eslintrc-es6", + "./node_modules/coding-standard/.eslintrc-jsx" + ], + "rules": { + "eqeqeq": "warn" + } +} +``` + +### Using `"eslint:all"` + +The `extends` property value can be `"eslint:all"` to enable all core rules in the currently installed version of ESLint. The set of core rules can change at any minor or major version of ESLint. + +**Important:** This configuration is **not recommended for production use** because it changes with every minor and major version of ESLint. Use it at your own risk. + +If you configure ESLint to automatically enable new rules when you upgrade, ESLint can report new problems when there are no changes to source code, therefore any newer minor version of ESLint can behave as if it has breaking changes. + +You might enable all core rules as a shortcut to explore rules and options while you decide on the configuration for a project, especially if you rarely override options or disable rules. The default options for rules are not endorsements by ESLint (for example, the default option for the [`quotes`](https://eslint.org/docs/rules/quotes) rule does not mean double quotes are better than single quotes). + +If your configuration extends all core rules: after you upgrade to a newer major or minor version of ESLint, review the reported problems before you use the `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fix), so you know if a new fixable rule will make changes to the code. + +Example of a configuration file in JavaScript format: + +```js +module.exports = { + "extends": "eslint:all", + "rules": { + // override default options + "comma-dangle": ["error", "always"], + "indent": ["error", 2], + "no-cond-assign": ["error", "always"], + + // disable now, but enable in the future + "one-var": "off", // ["error", "never"] + + // disable + "init-declarations": "off", + "no-console": "off", + "no-inline-comments": "off", + } +} +``` + +## Configuration Based on Glob Patterns + +v4.1.0+. Sometimes a more fine-controlled configuration is necessary, for example, if the configuration for files within the same directory has to be different. Therefore you can provide configurations under the `overrides` key that will only apply to files that match specific glob patterns, using the same format you would pass on the command line (e.g., `app/**/*.test.js`). + +### How does it work + +* The patterns are applied against the file path relative to the directory of the config file. For example, if your config file has the path `/Users/john/workspace/any-project/.eslintrc.js` and the file you want to lint has the path `/Users/john/workspace/any-project/lib/util.js`, then the pattern provided in `.eslintrc.js` will be executed against the relative path `lib/util.js`. +* Glob pattern overrides have higher precedence than the regular configuration in the same config file. Multiple overrides within the same config are applied in order. That is, the last override block in a config file always has the highest precedence. +* A glob specific configuration works almost the same as any other ESLint config. Override blocks can contain any configuration options that are valid in a regular config, with the exception of `root` and `ignorePatterns`. + * A glob specific configuration can have an `extends` setting, but the `root` property in the extended configs is ignored. The `ignorePatterns` property in the extended configs is used only for the files the glob specific configuration matched. + * Nested `overrides` setting will be applied only if the glob patterns of both of the parent config and the child config matched. This is the same when the extended configs have an `overrides` setting. +* Multiple glob patterns can be provided within a single override block. A file must match at least one of the supplied patterns for the configuration to apply. +* Override blocks can also specify patterns to exclude from matches. If a file matches any of the excluded patterns, the configuration won't apply. + +### Relative glob patterns + +``` +project-root +├── app +│ ├── lib +│ │ ├── foo.js +│ │ ├── fooSpec.js +│ ├── components +│ │ ├── bar.js +│ │ ├── barSpec.js +│ ├── .eslintrc.json +├── server +│ ├── server.js +│ ├── serverSpec.js +├── .eslintrc.json +``` + +The config in `app/.eslintrc.json` defines the glob pattern `**/*Spec.js`. This pattern is relative to the base directory of `app/.eslintrc.json`. So, this pattern would match `app/lib/fooSpec.js` and `app/components/barSpec.js` but **NOT** `server/serverSpec.js`. If you defined the same pattern in the `.eslintrc.json` file within in the `project-root` folder, it would match all three of the `*Spec` files. + +If a config is provided via the `--config` CLI option, the glob patterns in the config are relative to the current working directory rather than the base directory of the given config. For example, if `--config configs/.eslintrc.json` is present, the glob patterns in the config are relative to `.` rather than `./configs`. + +### Example configuration + +In your `.eslintrc.json`: + +```json +{ + "rules": { + "quotes": ["error", "double"] + }, + + "overrides": [ + { + "files": ["bin/*.js", "lib/*.js"], + "excludedFiles": "*.test.js", + "rules": { + "quotes": ["error", "single"] + } + } + ] +} +``` + +### Specifying target files to lint + +If you specified directories with CLI (e.g., `eslint lib`), ESLint searches target files in the directory to lint. The target files are `*.js` or the files that match any of `overrides` entries (but exclude entries that are any of `files` end with `*`). + +If you specified the [`--ext`](https://eslint.org/docs/user-guide/command-line-interface#ext) command line option along with directories, the target files are only the files that have specified file extensions regardless of `overrides` entries. + +## Personal Configuration Files (deprecated) + +⚠️ **This feature has been deprecated**. This feature will be removed in the 8.0.0 release. If you want to continue to use personal configuration files, please use the [`--config` CLI option](https://eslint.org/docs/user-guide/command-line-interface#-c---config). For more information regarding this decision, please see [RFC 28](https://github.com/eslint/rfcs/pull/28) and [RFC 32](https://github.com/eslint/rfcs/pull/32). + +`~/` refers to [the home directory of the current user on your preferred operating system](https://nodejs.org/api/os.html#os_os_homedir). The personal configuration file being referred to here is `~/.eslintrc.*` file, which is currently handled differently than other configuration files. + +### How does ESLint find personal configuration files + +If `eslint` could not find any configuration file in the project, `eslint` loads `~/.eslintrc.*` file. + +If `eslint` could find configuration files in the project, `eslint` ignores `~/.eslintrc.*` file even if it's in an ancestor directory of the project directory. + +### How do personal configuration files behave + +`~/.eslintrc.*` files behave similarly to regular configuration files, with some exceptions: + +`~/.eslintrc.*` files load shareable configs and custom parsers from `~/node_modules/` – similarly to `require()` – in the user's home directory. Please note that it doesn't load global-installed packages. + +`~/.eslintrc.*` files load plugins from `$CWD/node_modules` by default in order to identify plugins uniquely. If you want to use plugins with `~/.eslintrc.*` files, plugins must be installed locally per project. Alternatively, you can use the [`--resolve-plugins-relative-to` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--resolve-plugins-relative-to) to change the location from which ESLint loads plugins. From 3faeb4cc05b40dff7a95903da08881a0467bfe3b Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 11:36:28 +0500 Subject: [PATCH 04/96] Delete Configuration Files --- .../Configuring ESLint/Configuration Files | 396 ------------------ 1 file changed, 396 deletions(-) delete mode 100644 docs/user-guide/Configuring ESLint/Configuration Files diff --git a/docs/user-guide/Configuring ESLint/Configuration Files b/docs/user-guide/Configuring ESLint/Configuration Files deleted file mode 100644 index b322ba801e5..00000000000 --- a/docs/user-guide/Configuring ESLint/Configuration Files +++ /dev/null @@ -1,396 +0,0 @@ - -# Configuration Files -Some intro about config files here - -* [Configuration File Formats](#configuration-file-formats) -* [Using Configuration Files](#using-configuration-files) -* [Adding Shared Settings](#adding-shared-settings) -* [Cascading and Hierarchy](#cascading-and-hierarchy) -* [Extending Configuration Files](#extending-configuration-files) -* [Configuration Based on Glob Patterns](#configuration-based-on-glob-patterns) -* [Personal Configuration Files](#personal-configuration-files) - -## Configuration File Formats - -ESLint supports configuration files in several formats: - -* **JavaScript** - use `.eslintrc.js` and export an object containing your configuration. -* **JavaScript (ESM)** - use `.eslintrc.cjs` when running ESLint in JavaScript packages that specify `"type":"module"` in their `package.json`. Note that ESLint does not support ESM configuration at this time. -* **YAML** - use `.eslintrc.yaml` or `.eslintrc.yml` to define the configuration structure. -* **JSON** - use `.eslintrc.json` to define the configuration structure. ESLint's JSON files also allow JavaScript-style comments. -* **Deprecated** - use `.eslintrc`, which can be either JSON or YAML. -* **package.json** - create an `eslintConfig` property in your `package.json` file and define your configuration there. - -If there are multiple configuration files in the same directory, ESLint will only use one. The priority order is as follows: - -1. `.eslintrc.js` -1. `.eslintrc.cjs` -1. `.eslintrc.yaml` -1. `.eslintrc.yml` -1. `.eslintrc.json` -1. `.eslintrc` -1. `package.json` - -## Using Configuration Files - -There are two ways to use configuration files. - -The first way to use configuration files is via `.eslintrc.*` and `package.json` files. ESLint will automatically look for them in the directory of the file to be linted, and in successive parent directories all the way up to the root directory of the filesystem (unless `root: true` is specified). This option is useful when you want different configurations for different parts of a project or when you want others to be able to use ESLint directly without needing to remember to pass in the configuration file. - -The second is to save the file wherever you would like and pass its location to the CLI using the `-c` option, such as: - - eslint -c myconfig.json myfiletotest.js - -If you are using one configuration file and want ESLint to ignore any `.eslintrc.*` files, make sure to use `--no-eslintrc` along with the `-c` flag. - -In each case, the settings in the configuration file override default settings. - -### Comments in configuration files - -Both the JSON and YAML configuration file formats support comments (`package.json` files should not include them). You can use JavaScript-style comments or YAML-style comments in either type of file and ESLint will safely ignore them. This allows your configuration files to be more human-friendly. For example: - -```js -{ - "env": { - "browser": true - }, - "rules": { - // Override our default settings just for this directory - "eqeqeq": "warn", - "strict": "off" - } -} -``` - -## Adding Shared Settings - -ESLint supports adding shared settings into configuration files. You can add `settings` object to ESLint configuration file and it will be supplied to every rule being executed. This may be useful if you are adding custom rules and want them to have access to the same information and be easily configurable. - -In JSON: - -```json -{ - "settings": { - "sharedData": "Hello" - } -} -``` - -And in YAML: - -```yaml ---- - settings: - sharedData: "Hello" - -## Cascading and Hierarchy - -When using `.eslintrc.*` and `package.json` files for configuration, you can take advantage of configuration cascading. Suppose you have the following structure: - -```text -your-project -├── .eslintrc -├── lib -│ └── source.js -└─┬ tests - ├── .eslintrc - └── test.js -``` - -The configuration cascade works by using the closest `.eslintrc` file to the file being linted as the highest priority, then any configuration files in the parent directory, and so on. When you run ESLint on this project, all files in `lib/` will use the `.eslintrc` file at the root of the project as their configuration. When ESLint traverses into the `tests/` directory, it will then use `your-project/tests/.eslintrc` in addition to `your-project/.eslintrc`. So `your-project/tests/test.js` is linted based on the combination of the two `.eslintrc` files in its directory hierarchy, with the closest one taking priority. In this way, you can have project-level ESLint settings and also have directory-specific overrides. - -In the same way, if there is a `package.json` file in the root directory with an `eslintConfig` field, the configuration it describes will apply to all subdirectories beneath it, but the configuration described by the `.eslintrc` file in the tests directory will override it where there are conflicting specifications. - -```text -your-project -├── package.json -├── lib -│ └── source.js -└─┬ tests - ├── .eslintrc - └── test.js -``` - -If there is an `.eslintrc` and a `package.json` file found in the same directory, `.eslintrc` will take a priority and `package.json` file will not be used. - -By default, ESLint will look for configuration files in all parent folders up to the root directory. This can be useful if you want all of your projects to follow a certain convention, but can sometimes lead to unexpected results. To limit ESLint to a specific project, place `"root": true` inside the `eslintConfig` field of the `package.json` file or in the `.eslintrc.*` file at your project's root level. ESLint will stop looking in parent folders once it finds a configuration with `"root": true`. - -```js -{ - "root": true -} -``` - -And in YAML: - -```yaml ---- - root: true -``` - -For example, consider `projectA` which has `"root": true` set in the `.eslintrc` file in the `lib/` directory. In this case, while linting `main.js`, the configurations within `lib/` will be used, but the `.eslintrc` file in `projectA/` will not. - -```text -home -└── user - └── projectA - ├── .eslintrc <- Not used - └── lib - ├── .eslintrc <- { "root": true } - └── main.js -``` - -The complete configuration hierarchy, from highest precedence to lowest precedence, is as follows: - -1. Inline configuration - 1. `/*eslint-disable*/` and `/*eslint-enable*/` - 1. `/*global*/` - 1. `/*eslint*/` - 1. `/*eslint-env*/` -1. Command line options (or CLIEngine equivalents): - 1. `--global` - 1. `--rule` - 1. `--env` - 1. `-c`, `--config` -1. Project-level configuration: - 1. `.eslintrc.*` or `package.json` file in the same directory as linted file - 1. Continue searching for `.eslintrc` and `package.json` files in ancestor directories (parent has the highest precedence, then grandparent, etc.), up to and including the root directory or until a config with `"root": true` is found. - -## Extending Configuration Files - -A configuration file can extend the set of enabled rules from base configurations. - -The `extends` property value is either: - -* a string that specifies a configuration (either a path to a config file, the name of a shareable config, `eslint:recommended`, or `eslint:all`) -* an array of strings: each additional configuration extends the preceding configurations - -ESLint extends configurations recursively, so a base configuration can also have an `extends` property. Relative paths and shareable config names in an `extends` property are resolved from the location of the config file where they appear. - -The `rules` property can do any of the following to extend (or override) the set of rules: - -* enable additional rules -* change an inherited rule's severity without changing its options: - * Base config: `"eqeqeq": ["error", "allow-null"]` - * Derived config: `"eqeqeq": "warn"` - * Resulting actual config: `"eqeqeq": ["warn", "allow-null"]` -* override options for rules from base configurations: - * Base config: `"quotes": ["error", "single", "avoid-escape"]` - * Derived config: `"quotes": ["error", "single"]` - * Resulting actual config: `"quotes": ["error", "single"] - -### Using eslint-recommended - -An `extends` property value `"eslint:recommended"` enables a subset of core rules that report common problems, which have a checkmark (recommended) on the [rules page](https://eslint.org/docs/rules/). The recommended subset can change only at major versions of ESLint. - -If your configuration extends the recommended rules: after you upgrade to a newer major version of ESLint, review the reported problems before you use the `--fix` option on the [command line]((https://eslint.org/docs/user-guide/command-line-interface)#fix), so you know if a new fixable recommended rule will make changes to the code. - -The `eslint --init` command can create a configuration so you can extend the recommended rules. - -Example of a configuration file in JavaScript format: - -```js -module.exports = { - "extends": "eslint:recommended", - "rules": { - // enable additional rules - "indent": ["error", 4], - "linebreak-style": ["error", "unix"], - "quotes": ["error", "double"], - "semi": ["error", "always"], - - // override default options for rules from base configurations - "comma-dangle": ["error", "always"], - "no-cond-assign": ["error", "always"], - - // disable rules from base configurations - "no-console": "off", - } -} -``` - -### Using a shareable configuration package - -A [sharable configuration](https://eslint.org/docs/developer-guide/shareable-configs) is an npm package that exports a configuration object. Make sure the package has been installed to a directory where ESLint can require it. - -The `extends` property value can omit the `eslint-config-` prefix of the package name. - -The `eslint --init` command can create a configuration so you can extend a popular style guide (for example, `eslint-config-standard`). - -Example of a configuration file in YAML format: - -```yaml -extends: standard -rules: - comma-dangle: - - error - - always - no-empty: warn -``` - -### Using the configuration from a plugin - -A [plugin](https://eslint.org/docs/developer-guide/working-with-plugins) is an npm package that usually exports rules. Some plugins also export one or more named [configurations](https://eslint.org/docs/developer-guide/working-with-plugins#configs-in-plugins). Make sure the package has been installed in a directory where ESLint can require it. - -The `plugins` [property value](./plugins#configuring-plugins) can omit the `eslint-plugin-` prefix of the package name. - -The `extends` property value can consist of: - -* `plugin:` -* the package name (from which you can omit the prefix, for example, `react`) -* `/` -* the configuration name (for example, `recommended`) - -Example of a configuration file in JSON format: - -```json -{ - "plugins": [ - "react" - ], - "extends": [ - "eslint:recommended", - "plugin:react/recommended" - ], - "rules": { - "react/no-set-state": "off" - } -} -``` - -### Using a configuration file - -The `extends` property value can be an absolute or relative path to a base [configuration file](#using-configuration-files). ESLint resolves a relative path to a base configuration file relative to the configuration file that uses it. - -Example of a configuration file in JSON format: - -```json -{ - "extends": [ - "./node_modules/coding-standard/eslintDefaults.js", - "./node_modules/coding-standard/.eslintrc-es6", - "./node_modules/coding-standard/.eslintrc-jsx" - ], - "rules": { - "eqeqeq": "warn" - } -} -``` - -### Using `"eslint:all"` - -The `extends` property value can be `"eslint:all"` to enable all core rules in the currently installed version of ESLint. The set of core rules can change at any minor or major version of ESLint. - -**Important:** This configuration is **not recommended for production use** because it changes with every minor and major version of ESLint. Use it at your own risk. - -If you configure ESLint to automatically enable new rules when you upgrade, ESLint can report new problems when there are no changes to source code, therefore any newer minor version of ESLint can behave as if it has breaking changes. - -You might enable all core rules as a shortcut to explore rules and options while you decide on the configuration for a project, especially if you rarely override options or disable rules. The default options for rules are not endorsements by ESLint (for example, the default option for the [`quotes`](https://eslint.org/docs/rules/quotes) rule does not mean double quotes are better than single quotes). - -If your configuration extends all core rules: after you upgrade to a newer major or minor version of ESLint, review the reported problems before you use the `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fix), so you know if a new fixable rule will make changes to the code. - -Example of a configuration file in JavaScript format: - -```js -module.exports = { - "extends": "eslint:all", - "rules": { - // override default options - "comma-dangle": ["error", "always"], - "indent": ["error", 2], - "no-cond-assign": ["error", "always"], - - // disable now, but enable in the future - "one-var": "off", // ["error", "never"] - - // disable - "init-declarations": "off", - "no-console": "off", - "no-inline-comments": "off", - } -} -``` - -## Configuration Based on Glob Patterns - -v4.1.0+. Sometimes a more fine-controlled configuration is necessary, for example, if the configuration for files within the same directory has to be different. Therefore you can provide configurations under the `overrides` key that will only apply to files that match specific glob patterns, using the same format you would pass on the command line (e.g., `app/**/*.test.js`). - -### How does it work - -* The patterns are applied against the file path relative to the directory of the config file. For example, if your config file has the path `/Users/john/workspace/any-project/.eslintrc.js` and the file you want to lint has the path `/Users/john/workspace/any-project/lib/util.js`, then the pattern provided in `.eslintrc.js` will be executed against the relative path `lib/util.js`. -* Glob pattern overrides have higher precedence than the regular configuration in the same config file. Multiple overrides within the same config are applied in order. That is, the last override block in a config file always has the highest precedence. -* A glob specific configuration works almost the same as any other ESLint config. Override blocks can contain any configuration options that are valid in a regular config, with the exception of `root` and `ignorePatterns`. - * A glob specific configuration can have an `extends` setting, but the `root` property in the extended configs is ignored. The `ignorePatterns` property in the extended configs is used only for the files the glob specific configuration matched. - * Nested `overrides` setting will be applied only if the glob patterns of both of the parent config and the child config matched. This is the same when the extended configs have an `overrides` setting. -* Multiple glob patterns can be provided within a single override block. A file must match at least one of the supplied patterns for the configuration to apply. -* Override blocks can also specify patterns to exclude from matches. If a file matches any of the excluded patterns, the configuration won't apply. - -### Relative glob patterns - -``` -project-root -├── app -│ ├── lib -│ │ ├── foo.js -│ │ ├── fooSpec.js -│ ├── components -│ │ ├── bar.js -│ │ ├── barSpec.js -│ ├── .eslintrc.json -├── server -│ ├── server.js -│ ├── serverSpec.js -├── .eslintrc.json -``` - -The config in `app/.eslintrc.json` defines the glob pattern `**/*Spec.js`. This pattern is relative to the base directory of `app/.eslintrc.json`. So, this pattern would match `app/lib/fooSpec.js` and `app/components/barSpec.js` but **NOT** `server/serverSpec.js`. If you defined the same pattern in the `.eslintrc.json` file within in the `project-root` folder, it would match all three of the `*Spec` files. - -If a config is provided via the `--config` CLI option, the glob patterns in the config are relative to the current working directory rather than the base directory of the given config. For example, if `--config configs/.eslintrc.json` is present, the glob patterns in the config are relative to `.` rather than `./configs`. - -### Example configuration - -In your `.eslintrc.json`: - -```json -{ - "rules": { - "quotes": ["error", "double"] - }, - - "overrides": [ - { - "files": ["bin/*.js", "lib/*.js"], - "excludedFiles": "*.test.js", - "rules": { - "quotes": ["error", "single"] - } - } - ] -} -``` - -### Specifying target files to lint - -If you specified directories with CLI (e.g., `eslint lib`), ESLint searches target files in the directory to lint. The target files are `*.js` or the files that match any of `overrides` entries (but exclude entries that are any of `files` end with `*`). - -If you specified the [`--ext`](https://eslint.org/docs/user-guide/command-line-interface#ext) command line option along with directories, the target files are only the files that have specified file extensions regardless of `overrides` entries. - -## Personal Configuration Files (deprecated) - -⚠️ **This feature has been deprecated**. This feature will be removed in the 8.0.0 release. If you want to continue to use personal configuration files, please use the [`--config` CLI option](https://eslint.org/docs/user-guide/command-line-interface#-c---config). For more information regarding this decision, please see [RFC 28](https://github.com/eslint/rfcs/pull/28) and [RFC 32](https://github.com/eslint/rfcs/pull/32). - -`~/` refers to [the home directory of the current user on your preferred operating system](https://nodejs.org/api/os.html#os_os_homedir). The personal configuration file being referred to here is `~/.eslintrc.*` file, which is currently handled differently than other configuration files. - -### How does ESLint find personal configuration files - -If `eslint` could not find any configuration file in the project, `eslint` loads `~/.eslintrc.*` file. - -If `eslint` could find configuration files in the project, `eslint` ignores `~/.eslintrc.*` file even if it's in an ancestor directory of the project directory. - -### How do personal configuration files behave - -`~/.eslintrc.*` files behave similarly to regular configuration files, with some exceptions: - -`~/.eslintrc.*` files load shareable configs and custom parsers from `~/node_modules/` – similarly to `require()` – in the user's home directory. Please note that it doesn't load global-installed packages. - -`~/.eslintrc.*` files load plugins from `$CWD/node_modules` by default in order to identify plugins uniquely. If you want to use plugins with `~/.eslintrc.*` files, plugins must be installed locally per project. Alternatively, you can use the [`--resolve-plugins-relative-to` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--resolve-plugins-relative-to) to change the location from which ESLint loads plugins. From 6994600070314afbd1703f76ca514f4c4f9e1aae Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 11:36:57 +0500 Subject: [PATCH 05/96] Create Configuration Files --- .../Configuring ESLint/Configuration Files.md | 395 ++++++++++++++++++ 1 file changed, 395 insertions(+) create mode 100644 docs/user-guide/Configuring ESLint/Configuration Files.md diff --git a/docs/user-guide/Configuring ESLint/Configuration Files.md b/docs/user-guide/Configuring ESLint/Configuration Files.md new file mode 100644 index 00000000000..ecb01857acf --- /dev/null +++ b/docs/user-guide/Configuring ESLint/Configuration Files.md @@ -0,0 +1,395 @@ +# Configuration Files +Some intro about config files here + +* [Configuration File Formats](#configuration-file-formats) +* [Using Configuration Files](#using-configuration-files) +* [Adding Shared Settings](#adding-shared-settings) +* [Cascading and Hierarchy](#cascading-and-hierarchy) +* [Extending Configuration Files](#extending-configuration-files) +* [Configuration Based on Glob Patterns](#configuration-based-on-glob-patterns) +* [Personal Configuration Files](#personal-configuration-files) + +## Configuration File Formats + +ESLint supports configuration files in several formats: + +* **JavaScript** - use `.eslintrc.js` and export an object containing your configuration. +* **JavaScript (ESM)** - use `.eslintrc.cjs` when running ESLint in JavaScript packages that specify `"type":"module"` in their `package.json`. Note that ESLint does not support ESM configuration at this time. +* **YAML** - use `.eslintrc.yaml` or `.eslintrc.yml` to define the configuration structure. +* **JSON** - use `.eslintrc.json` to define the configuration structure. ESLint's JSON files also allow JavaScript-style comments. +* **Deprecated** - use `.eslintrc`, which can be either JSON or YAML. +* **package.json** - create an `eslintConfig` property in your `package.json` file and define your configuration there. + +If there are multiple configuration files in the same directory, ESLint will only use one. The priority order is as follows: + +1. `.eslintrc.js` +1. `.eslintrc.cjs` +1. `.eslintrc.yaml` +1. `.eslintrc.yml` +1. `.eslintrc.json` +1. `.eslintrc` +1. `package.json` + +## Using Configuration Files + +There are two ways to use configuration files. + +The first way to use configuration files is via `.eslintrc.*` and `package.json` files. ESLint will automatically look for them in the directory of the file to be linted, and in successive parent directories all the way up to the root directory of the filesystem (unless `root: true` is specified). This option is useful when you want different configurations for different parts of a project or when you want others to be able to use ESLint directly without needing to remember to pass in the configuration file. + +The second is to save the file wherever you would like and pass its location to the CLI using the `-c` option, such as: + + eslint -c myconfig.json myfiletotest.js + +If you are using one configuration file and want ESLint to ignore any `.eslintrc.*` files, make sure to use `--no-eslintrc` along with the `-c` flag. + +In each case, the settings in the configuration file override default settings. + +### Comments in configuration files + +Both the JSON and YAML configuration file formats support comments (`package.json` files should not include them). You can use JavaScript-style comments or YAML-style comments in either type of file and ESLint will safely ignore them. This allows your configuration files to be more human-friendly. For example: + +```js +{ + "env": { + "browser": true + }, + "rules": { + // Override our default settings just for this directory + "eqeqeq": "warn", + "strict": "off" + } +} +``` + +## Adding Shared Settings + +ESLint supports adding shared settings into configuration files. You can add `settings` object to ESLint configuration file and it will be supplied to every rule being executed. This may be useful if you are adding custom rules and want them to have access to the same information and be easily configurable. + +In JSON: + +```json +{ + "settings": { + "sharedData": "Hello" + } +} +``` + +And in YAML: + +```yaml +--- + settings: + sharedData: "Hello" + +## Cascading and Hierarchy + +When using `.eslintrc.*` and `package.json` files for configuration, you can take advantage of configuration cascading. Suppose you have the following structure: + +```text +your-project +├── .eslintrc +├── lib +│ └── source.js +└─┬ tests + ├── .eslintrc + └── test.js +``` + +The configuration cascade works by using the closest `.eslintrc` file to the file being linted as the highest priority, then any configuration files in the parent directory, and so on. When you run ESLint on this project, all files in `lib/` will use the `.eslintrc` file at the root of the project as their configuration. When ESLint traverses into the `tests/` directory, it will then use `your-project/tests/.eslintrc` in addition to `your-project/.eslintrc`. So `your-project/tests/test.js` is linted based on the combination of the two `.eslintrc` files in its directory hierarchy, with the closest one taking priority. In this way, you can have project-level ESLint settings and also have directory-specific overrides. + +In the same way, if there is a `package.json` file in the root directory with an `eslintConfig` field, the configuration it describes will apply to all subdirectories beneath it, but the configuration described by the `.eslintrc` file in the tests directory will override it where there are conflicting specifications. + +```text +your-project +├── package.json +├── lib +│ └── source.js +└─┬ tests + ├── .eslintrc + └── test.js +``` + +If there is an `.eslintrc` and a `package.json` file found in the same directory, `.eslintrc` will take a priority and `package.json` file will not be used. + +By default, ESLint will look for configuration files in all parent folders up to the root directory. This can be useful if you want all of your projects to follow a certain convention, but can sometimes lead to unexpected results. To limit ESLint to a specific project, place `"root": true` inside the `eslintConfig` field of the `package.json` file or in the `.eslintrc.*` file at your project's root level. ESLint will stop looking in parent folders once it finds a configuration with `"root": true`. + +```js +{ + "root": true +} +``` + +And in YAML: + +```yaml +--- + root: true +``` + +For example, consider `projectA` which has `"root": true` set in the `.eslintrc` file in the `lib/` directory. In this case, while linting `main.js`, the configurations within `lib/` will be used, but the `.eslintrc` file in `projectA/` will not. + +```text +home +└── user + └── projectA + ├── .eslintrc <- Not used + └── lib + ├── .eslintrc <- { "root": true } + └── main.js +``` + +The complete configuration hierarchy, from highest precedence to lowest precedence, is as follows: + +1. Inline configuration + 1. `/*eslint-disable*/` and `/*eslint-enable*/` + 1. `/*global*/` + 1. `/*eslint*/` + 1. `/*eslint-env*/` +1. Command line options (or CLIEngine equivalents): + 1. `--global` + 1. `--rule` + 1. `--env` + 1. `-c`, `--config` +1. Project-level configuration: + 1. `.eslintrc.*` or `package.json` file in the same directory as linted file + 1. Continue searching for `.eslintrc` and `package.json` files in ancestor directories (parent has the highest precedence, then grandparent, etc.), up to and including the root directory or until a config with `"root": true` is found. + +## Extending Configuration Files + +A configuration file can extend the set of enabled rules from base configurations. + +The `extends` property value is either: + +* a string that specifies a configuration (either a path to a config file, the name of a shareable config, `eslint:recommended`, or `eslint:all`) +* an array of strings: each additional configuration extends the preceding configurations + +ESLint extends configurations recursively, so a base configuration can also have an `extends` property. Relative paths and shareable config names in an `extends` property are resolved from the location of the config file where they appear. + +The `rules` property can do any of the following to extend (or override) the set of rules: + +* enable additional rules +* change an inherited rule's severity without changing its options: + * Base config: `"eqeqeq": ["error", "allow-null"]` + * Derived config: `"eqeqeq": "warn"` + * Resulting actual config: `"eqeqeq": ["warn", "allow-null"]` +* override options for rules from base configurations: + * Base config: `"quotes": ["error", "single", "avoid-escape"]` + * Derived config: `"quotes": ["error", "single"]` + * Resulting actual config: `"quotes": ["error", "single"] + +### Using eslint-recommended + +An `extends` property value `"eslint:recommended"` enables a subset of core rules that report common problems, which have a checkmark (recommended) on the [rules page](https://eslint.org/docs/rules/). The recommended subset can change only at major versions of ESLint. + +If your configuration extends the recommended rules: after you upgrade to a newer major version of ESLint, review the reported problems before you use the `--fix` option on the [command line]((https://eslint.org/docs/user-guide/command-line-interface)#fix), so you know if a new fixable recommended rule will make changes to the code. + +The `eslint --init` command can create a configuration so you can extend the recommended rules. + +Example of a configuration file in JavaScript format: + +```js +module.exports = { + "extends": "eslint:recommended", + "rules": { + // enable additional rules + "indent": ["error", 4], + "linebreak-style": ["error", "unix"], + "quotes": ["error", "double"], + "semi": ["error", "always"], + + // override default options for rules from base configurations + "comma-dangle": ["error", "always"], + "no-cond-assign": ["error", "always"], + + // disable rules from base configurations + "no-console": "off", + } +} +``` + +### Using a shareable configuration package + +A [sharable configuration](https://eslint.org/docs/developer-guide/shareable-configs) is an npm package that exports a configuration object. Make sure the package has been installed to a directory where ESLint can require it. + +The `extends` property value can omit the `eslint-config-` prefix of the package name. + +The `eslint --init` command can create a configuration so you can extend a popular style guide (for example, `eslint-config-standard`). + +Example of a configuration file in YAML format: + +```yaml +extends: standard +rules: + comma-dangle: + - error + - always + no-empty: warn +``` + +### Using the configuration from a plugin + +A [plugin](https://eslint.org/docs/developer-guide/working-with-plugins) is an npm package that usually exports rules. Some plugins also export one or more named [configurations](https://eslint.org/docs/developer-guide/working-with-plugins#configs-in-plugins). Make sure the package has been installed in a directory where ESLint can require it. + +The `plugins` [property value](./plugins#configuring-plugins) can omit the `eslint-plugin-` prefix of the package name. + +The `extends` property value can consist of: + +* `plugin:` +* the package name (from which you can omit the prefix, for example, `react`) +* `/` +* the configuration name (for example, `recommended`) + +Example of a configuration file in JSON format: + +```json +{ + "plugins": [ + "react" + ], + "extends": [ + "eslint:recommended", + "plugin:react/recommended" + ], + "rules": { + "react/no-set-state": "off" + } +} +``` + +### Using a configuration file + +The `extends` property value can be an absolute or relative path to a base [configuration file](#using-configuration-files). ESLint resolves a relative path to a base configuration file relative to the configuration file that uses it. + +Example of a configuration file in JSON format: + +```json +{ + "extends": [ + "./node_modules/coding-standard/eslintDefaults.js", + "./node_modules/coding-standard/.eslintrc-es6", + "./node_modules/coding-standard/.eslintrc-jsx" + ], + "rules": { + "eqeqeq": "warn" + } +} +``` + +### Using `"eslint:all"` + +The `extends` property value can be `"eslint:all"` to enable all core rules in the currently installed version of ESLint. The set of core rules can change at any minor or major version of ESLint. + +**Important:** This configuration is **not recommended for production use** because it changes with every minor and major version of ESLint. Use it at your own risk. + +If you configure ESLint to automatically enable new rules when you upgrade, ESLint can report new problems when there are no changes to source code, therefore any newer minor version of ESLint can behave as if it has breaking changes. + +You might enable all core rules as a shortcut to explore rules and options while you decide on the configuration for a project, especially if you rarely override options or disable rules. The default options for rules are not endorsements by ESLint (for example, the default option for the [`quotes`](https://eslint.org/docs/rules/quotes) rule does not mean double quotes are better than single quotes). + +If your configuration extends all core rules: after you upgrade to a newer major or minor version of ESLint, review the reported problems before you use the `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fix), so you know if a new fixable rule will make changes to the code. + +Example of a configuration file in JavaScript format: + +```js +module.exports = { + "extends": "eslint:all", + "rules": { + // override default options + "comma-dangle": ["error", "always"], + "indent": ["error", 2], + "no-cond-assign": ["error", "always"], + + // disable now, but enable in the future + "one-var": "off", // ["error", "never"] + + // disable + "init-declarations": "off", + "no-console": "off", + "no-inline-comments": "off", + } +} +``` + +## Configuration Based on Glob Patterns + +v4.1.0+. Sometimes a more fine-controlled configuration is necessary, for example, if the configuration for files within the same directory has to be different. Therefore you can provide configurations under the `overrides` key that will only apply to files that match specific glob patterns, using the same format you would pass on the command line (e.g., `app/**/*.test.js`). + +### How does it work + +* The patterns are applied against the file path relative to the directory of the config file. For example, if your config file has the path `/Users/john/workspace/any-project/.eslintrc.js` and the file you want to lint has the path `/Users/john/workspace/any-project/lib/util.js`, then the pattern provided in `.eslintrc.js` will be executed against the relative path `lib/util.js`. +* Glob pattern overrides have higher precedence than the regular configuration in the same config file. Multiple overrides within the same config are applied in order. That is, the last override block in a config file always has the highest precedence. +* A glob specific configuration works almost the same as any other ESLint config. Override blocks can contain any configuration options that are valid in a regular config, with the exception of `root` and `ignorePatterns`. + * A glob specific configuration can have an `extends` setting, but the `root` property in the extended configs is ignored. The `ignorePatterns` property in the extended configs is used only for the files the glob specific configuration matched. + * Nested `overrides` setting will be applied only if the glob patterns of both of the parent config and the child config matched. This is the same when the extended configs have an `overrides` setting. +* Multiple glob patterns can be provided within a single override block. A file must match at least one of the supplied patterns for the configuration to apply. +* Override blocks can also specify patterns to exclude from matches. If a file matches any of the excluded patterns, the configuration won't apply. + +### Relative glob patterns + +``` +project-root +├── app +│ ├── lib +│ │ ├── foo.js +│ │ ├── fooSpec.js +│ ├── components +│ │ ├── bar.js +│ │ ├── barSpec.js +│ ├── .eslintrc.json +├── server +│ ├── server.js +│ ├── serverSpec.js +├── .eslintrc.json +``` + +The config in `app/.eslintrc.json` defines the glob pattern `**/*Spec.js`. This pattern is relative to the base directory of `app/.eslintrc.json`. So, this pattern would match `app/lib/fooSpec.js` and `app/components/barSpec.js` but **NOT** `server/serverSpec.js`. If you defined the same pattern in the `.eslintrc.json` file within in the `project-root` folder, it would match all three of the `*Spec` files. + +If a config is provided via the `--config` CLI option, the glob patterns in the config are relative to the current working directory rather than the base directory of the given config. For example, if `--config configs/.eslintrc.json` is present, the glob patterns in the config are relative to `.` rather than `./configs`. + +### Example configuration + +In your `.eslintrc.json`: + +```json +{ + "rules": { + "quotes": ["error", "double"] + }, + + "overrides": [ + { + "files": ["bin/*.js", "lib/*.js"], + "excludedFiles": "*.test.js", + "rules": { + "quotes": ["error", "single"] + } + } + ] +} +``` + +### Specifying target files to lint + +If you specified directories with CLI (e.g., `eslint lib`), ESLint searches target files in the directory to lint. The target files are `*.js` or the files that match any of `overrides` entries (but exclude entries that are any of `files` end with `*`). + +If you specified the [`--ext`](https://eslint.org/docs/user-guide/command-line-interface#ext) command line option along with directories, the target files are only the files that have specified file extensions regardless of `overrides` entries. + +## Personal Configuration Files (deprecated) + +⚠️ **This feature has been deprecated**. This feature will be removed in the 8.0.0 release. If you want to continue to use personal configuration files, please use the [`--config` CLI option](https://eslint.org/docs/user-guide/command-line-interface#-c---config). For more information regarding this decision, please see [RFC 28](https://github.com/eslint/rfcs/pull/28) and [RFC 32](https://github.com/eslint/rfcs/pull/32). + +`~/` refers to [the home directory of the current user on your preferred operating system](https://nodejs.org/api/os.html#os_os_homedir). The personal configuration file being referred to here is `~/.eslintrc.*` file, which is currently handled differently than other configuration files. + +### How does ESLint find personal configuration files + +If `eslint` could not find any configuration file in the project, `eslint` loads `~/.eslintrc.*` file. + +If `eslint` could find configuration files in the project, `eslint` ignores `~/.eslintrc.*` file even if it's in an ancestor directory of the project directory. + +### How do personal configuration files behave + +`~/.eslintrc.*` files behave similarly to regular configuration files, with some exceptions: + +`~/.eslintrc.*` files load shareable configs and custom parsers from `~/node_modules/` – similarly to `require()` – in the user's home directory. Please note that it doesn't load global-installed packages. + +`~/.eslintrc.*` files load plugins from `$CWD/node_modules` by default in order to identify plugins uniquely. If you want to use plugins with `~/.eslintrc.*` files, plugins must be installed locally per project. Alternatively, you can use the [`--resolve-plugins-relative-to` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--resolve-plugins-relative-to) to change the location from which ESLint loads plugins. From 87bdf0f464b442ea8d9bfee13a84d52206b4a72a Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 11:37:55 +0500 Subject: [PATCH 06/96] Create Language Options --- .../Configuring ESLint/Language Options.md | 215 ++++++++++++++++++ 1 file changed, 215 insertions(+) create mode 100644 docs/user-guide/Configuring ESLint/Language Options.md diff --git a/docs/user-guide/Configuring ESLint/Language Options.md b/docs/user-guide/Configuring ESLint/Language Options.md new file mode 100644 index 00000000000..273d6730ca4 --- /dev/null +++ b/docs/user-guide/Configuring ESLint/Language Options.md @@ -0,0 +1,215 @@ +# Language Options + +Some basic intro to the section + +* [Specifying Environments](#specifying-environments) +* [Specifying Globals](#specifying-globals) +* [Specifying Parser Options](#specifying-parser-options) + +## Specifying Environments + +An environment defines global variables that are predefined. The available environments are: + +* `browser` - browser global variables. +* `node` - Node.js global variables and Node.js scoping. +* `commonjs` - CommonJS global variables and CommonJS scoping (use this for browser-only code that uses Browserify/WebPack). +* `shared-node-browser` - Globals common to both Node.js and Browser. +* `es6` - enable all ECMAScript 6 features except for modules (this automatically sets the `ecmaVersion` parser option to 6). +* `es2017` - adds all ECMAScript 2017 globals and automatically sets the `ecmaVersion` parser option to 8. +* `es2020` - adds all ECMAScript 2020 globals and automatically sets the `ecmaVersion` parser option to 11. +* `es2021` - adds all ECMAScript 2021 globals and automatically sets the `ecmaVersion` parser option to 12. +* `worker` - web workers global variables. +* `amd` - defines `require()` and `define()` as global variables as per the [amd](https://github.com/amdjs/amdjs-api/wiki/AMD) spec. +* `mocha` - adds all of the Mocha testing global variables. +* `jasmine` - adds all of the Jasmine testing global variables for version 1.3 and 2.0. +* `jest` - Jest global variables. +* `phantomjs` - PhantomJS global variables. +* `protractor` - Protractor global variables. +* `qunit` - QUnit global variables. +* `jquery` - jQuery global variables. +* `prototypejs` - Prototype.js global variables. +* `shelljs` - ShellJS global variables. +* `meteor` - Meteor global variables. +* `mongo` - MongoDB global variables. +* `applescript` - AppleScript global variables. +* `nashorn` - Java 8 Nashorn global variables. +* `serviceworker` - Service Worker global variables. +* `atomtest` - Atom test helper globals. +* `embertest` - Ember test helper globals. +* `webextensions` - WebExtensions globals. +* `greasemonkey` - GreaseMonkey globals. + +These environments are not mutually exclusive, so you can define more than one at a time. + +Environments can be specified inside of a file, in configuration files or using the `--env` [command line](https://eslint.org/docs/user-guide/command-line-interface) flag. + +### Using configuration comments + +To specify environments using a comment inside of your JavaScript file, use the following format: + +```js +/* eslint-env node, mocha */ +``` + +This enables Node.js and Mocha environments. + +### Using configuration files + +To specify environments in a configuration file, use the `env` key and specify which environments you want to enable by setting each to `true`. For example, the following enables the browser and Node.js environments: + +```json +{ + "env": { + "browser": true, + "node": true + } +} +``` + +Or in a `package.json` file + +```json +{ + "name": "mypackage", + "version": "0.0.1", + "eslintConfig": { + "env": { + "browser": true, + "node": true + } + } +} +``` + +And in YAML: + +```yaml +--- + env: + browser: true + node: true +``` + +### Using a plugin + +If you want to use an environment from a plugin, be sure to specify the plugin name in the `plugins` array and then use the unprefixed plugin name, followed by a slash, followed by the environment name. For example: + +```json +{ + "plugins": ["example"], + "env": { + "example/custom": true + } +} +``` + +Or in a `package.json` file + +```json +{ + "name": "mypackage", + "version": "0.0.1", + "eslintConfig": { + "plugins": ["example"], + "env": { + "example/custom": true + } + } +} +``` + +## Specifying Globals + +The [no-undef](https://eslint.org/docs/rules/no-undef) rule will warn on variables that are accessed but not defined within the same file. If you are using global variables inside of a file then it's worthwhile to define those globals so that ESLint will not warn about their usage. You can define global variables either using comments inside of a file or in the configuration file. + +### Using configuration comments + +To specify globals using a comment inside of your JavaScript file, use the following format: + +```js +/* global var1, var2 */ +``` + +This defines two global variables, `var1` and `var2`. If you want to optionally specify that these global variables can be written to (rather than only being read), then you can set each with a `"writable"` flag: + +```js +/* global var1:writable, var2:writable */ +``` + +### Using configuration files + +To configure global variables inside of a configuration file, set the `globals` configuration property to an object containing keys named for each of the global variables you want to use. For each global variable key, set the corresponding value equal to `"writable"` to allow the variable to be overwritten or `"readonly"` to disallow overwriting. For example: + +```json +{ + "globals": { + "var1": "writable", + "var2": "readonly" + } +} +``` + +And in YAML: + +```yaml +--- + globals: + var1: writable + var2: readonly +``` + +These examples allow `var1` to be overwritten in your code, but disallow it for `var2`. + +Globals can be disabled with the string `"off"`. For example, in an environment where most ES2015 globals are available but `Promise` is unavailable, you might use this config: + +```json +{ + "env": { + "es6": true + }, + "globals": { + "Promise": "off" + } +} +``` + +For historical reasons, the boolean value `false` and the string value `"readable"` are equivalent to `"readonly"`. Similarly, the boolean value `true` and the string value `"writeable"` are equivalent to `"writable"`. However, the use of older values is deprecated. + +**Note:** Enable the [no-global-assign](https://eslint.org/docs/rules/no-global-assign) rule to disallow modifications to read-only global variables in your code. + +## Specifying Parser Options + +ESLint allows you to specify the JavaScript language options you want to support. By default, ESLint expects ECMAScript 5 syntax. You can override that setting to enable support for other ECMAScript versions as well as JSX by using parser options. + +Please note that supporting JSX syntax is not the same as supporting React. React applies specific semantics to JSX syntax that ESLint doesn't recognize. We recommend using [eslint-plugin-react](https://github.com/yannickcr/eslint-plugin-react) if you are using React and want React semantics. +By the same token, supporting ES6 syntax is not the same as supporting new ES6 globals (e.g., new types such as +`Set`). +For ES6 syntax, use `{ "parserOptions": { "ecmaVersion": 6 } }`; for new ES6 global variables, use `{ "env": +{ "es6": true } }`. `{ "env": { "es6": true } }` enables ES6 syntax automatically, but `{ "parserOptions": { "ecmaVersion": 6 } }` does not enable ES6 globals automatically. +Parser options are set in your `.eslintrc.*` file by using the `parserOptions` property. The available options are: + +* `ecmaVersion` - set to 3, 5 (default), 6, 7, 8, 9, 10, 11, or 12 to specify the version of ECMAScript syntax you want to use. You can also set to 2015 (same as 6), 2016 (same as 7), 2017 (same as 8), 2018 (same as 9), 2019 (same as 10), 2020 (same as 11), or 2021 (same as 12) to use the year-based naming. +* `sourceType` - set to `"script"` (default) or `"module"` if your code is in ECMAScript modules. +* `ecmaFeatures` - an object indicating which additional language features you'd like to use: + * `globalReturn` - allow `return` statements in the global scope + * `impliedStrict` - enable global [strict mode](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode) (if `ecmaVersion` is 5 or greater) + * `jsx` - enable [JSX](https://facebook.github.io/jsx/) + +Here's an example `.eslintrc.json` file: + +```json +{ + "parserOptions": { + "ecmaVersion": 6, + "sourceType": "module", + "ecmaFeatures": { + "jsx": true + } + }, + "rules": { + "semi": "error" + } +} +``` + +Setting parser options helps ESLint determine what is a parsing error. All language options are `false` by default. From 57502e5c0b11d4f06995232eb4af55b6f71669b7 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 11:38:25 +0500 Subject: [PATCH 07/96] Create Rules --- docs/user-guide/Configuring ESLint/Rules.md | 239 ++++++++++++++++++++ 1 file changed, 239 insertions(+) create mode 100644 docs/user-guide/Configuring ESLint/Rules.md diff --git a/docs/user-guide/Configuring ESLint/Rules.md b/docs/user-guide/Configuring ESLint/Rules.md new file mode 100644 index 00000000000..23322d97eec --- /dev/null +++ b/docs/user-guide/Configuring ESLint/Rules.md @@ -0,0 +1,239 @@ +# Rules + +Some intro to the section with a link to the Rules page here + +* Configuring Rules +* Disabling Rules + +## Configuring Rules + +ESLint comes with a large number of rules. You can modify which rules your project uses either using configuration comments or configuration files. To change a rule setting, you must set the rule ID equal to one of these values: + +* `"off"` or `0` - turn the rule off +* `"warn"` or `1` - turn the rule on as a warning (doesn't affect exit code) +* `"error"` or `2` - turn the rule on as an error (exit code is 1 when triggered) + +### Using configuration comments + +To configure rules inside of a file using configuration comments, use a comment in the following format: + +```js +/* eslint eqeqeq: "off", curly: "error" */ +``` + +In this example, [`eqeqeq`](https://eslint.org/docs/rules/eqeqeq) is turned off and [`curly`](.https://eslint.org/docs/rules/curly) is turned on as an error. You can also use the numeric equivalent for the rule severity: + +```js +/* eslint eqeqeq: 0, curly: 2 */ +``` + +This example is the same as the last example, only it uses the numeric codes instead of the string values. The `eqeqeq` rule is off and the `curly` rule is set to be an error. + +If a rule has additional options, you can specify them using array literal syntax, such as: + +```js +/* eslint quotes: ["error", "double"], curly: 2 */ +``` + +This comment specifies the "double" option for the [`quotes`](https://eslint.org/docs/rules/quotes) rule. The first item in the array is always the rule severity (number or string). + +Configuration comments can include descriptions to explain why the comment is necessary. The description must occur after the configuration and is separated from the configuration by two or more consecutive `-` characters. For example: + +```js +/* eslint eqeqeq: "off", curly: "error" -- Here's a description about why this configuration is necessary. */ +``` + +```js +/* eslint eqeqeq: "off", curly: "error" + -------- + Here's a description about why this configuration is necessary. */ +``` + +```js +/* eslint eqeqeq: "off", curly: "error" + * -------- + * This will not work due to the line above starting with a '*' character. + */ +``` + +### Using configuration files + +To configure rules inside of a configuration file, use the `rules` key along with an error level and any options you want to use. For example: + +```json +{ + "rules": { + "eqeqeq": "off", + "curly": "error", + "quotes": ["error", "double"] + } +} +``` + +And in YAML: + +```yaml +--- +rules: + eqeqeq: off + curly: error + quotes: + - error + - double +``` + +To configure a rule which is defined within a plugin you have to prefix the rule ID with the plugin name and a `/`. For example: + +```json +{ + "plugins": [ + "plugin1" + ], + "rules": { + "eqeqeq": "off", + "curly": "error", + "quotes": ["error", "double"], + "plugin1/rule1": "error" + } +} +``` + +And in YAML: + +```yaml +--- +plugins: + - plugin1 +rules: + eqeqeq: 0 + curly: error + quotes: + - error + - "double" + plugin1/rule1: error +``` + +In these configuration files, the rule `plugin1/rule1` comes from the plugin named `plugin1`. You can also use this format with configuration comments, such as: + +```js +/* eslint "plugin1/rule1": "error" */ +``` + +**Note:** When specifying rules from plugins, make sure to omit `eslint-plugin-`. ESLint uses only the unprefixed name internally to locate rules. + +## Disabling Rules + +### Using configuration comments + +To temporarily disable rule warnings in your file, use block comments in the following format: + +```js +/* eslint-disable */ + +alert('foo'); + +/* eslint-enable */ +``` + +You can also disable or enable warnings for specific rules: + +```js +/* eslint-disable no-alert, no-console */ + +alert('foo'); +console.log('bar'); + +/* eslint-enable no-alert, no-console */ +``` + +To disable rule warnings in an entire file, put a `/* eslint-disable */` block comment at the top of the file: + +```js +/* eslint-disable */ + +alert('foo'); +``` + +You can also disable or enable specific rules for an entire file: + +```js +/* eslint-disable no-alert */ + +alert('foo'); +``` + +To disable all rules on a specific line, use a line or block comment in one of the following formats: + +```js +alert('foo'); // eslint-disable-line + +// eslint-disable-next-line +alert('foo'); + +/* eslint-disable-next-line */ +alert('foo'); + +alert('foo'); /* eslint-disable-line */ +``` + +To disable a specific rule on a specific line: + +```js +alert('foo'); // eslint-disable-line no-alert + +// eslint-disable-next-line no-alert +alert('foo'); + +alert('foo'); /* eslint-disable-line no-alert */ + +/* eslint-disable-next-line no-alert */ +alert('foo'); +``` + +To disable multiple rules on a specific line: + +```js +alert('foo'); // eslint-disable-line no-alert, quotes, semi + +// eslint-disable-next-line no-alert, quotes, semi +alert('foo'); + +alert('foo'); /* eslint-disable-line no-alert, quotes, semi */ + +/* eslint-disable-next-line no-alert, quotes, semi */ +alert('foo'); +``` + +All of the above methods also work for plugin rules. For example, to disable `eslint-plugin-example`'s `rule-name` rule, combine the plugin's name (`example`) and the rule's name (`rule-name`) into `example/rule-name`: + +```js +foo(); // eslint-disable-line example/rule-name +foo(); /* eslint-disable-line example/rule-name */ +``` + +Configuration comments can include descriptions to explain why the comment is necessary. The description must come after the configuration and needs to be separated from the configuration by two or more consecutive `-` characters. For example: + +```js +// eslint-disable-next-line no-console -- Here's a description about why this configuration is necessary. +console.log('hello'); +``` + +**Note:** Comments that disable warnings for a portion of a file tell ESLint not to report rule violations for the disabled code. ESLint still parses the entire file, however, so disabled code still needs to be syntactically valid JavaScript. + +### Using configuration files + +To disable rules inside of a configuration file for a group of files, use the `overrides` key along with a `files` key. For example: + +```json +{ + "rules": {...}, + "overrides": [ + { + "files": ["*-test.js","*.spec.js"], + "rules": { + "no-unused-expressions": "off" + } + } + ] +} +``` From 2c3597667a73131e13d3df392c85e9d52b8cf5e5 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 11:38:56 +0500 Subject: [PATCH 08/96] Create Plugins --- docs/user-guide/Configuring ESLint/Plugins.md | 178 ++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100644 docs/user-guide/Configuring ESLint/Plugins.md diff --git a/docs/user-guide/Configuring ESLint/Plugins.md b/docs/user-guide/Configuring ESLint/Plugins.md new file mode 100644 index 00000000000..fd8b2aded97 --- /dev/null +++ b/docs/user-guide/Configuring ESLint/Plugins.md @@ -0,0 +1,178 @@ +# Plugins + +Some intro to the section + +* Specifying Parser +* Specifying Processor +* Configuring Plugins + +## Specifying Parser + +By default, ESLint uses [Espree](https://github.com/eslint/espree) as its parser. You can optionally specify that a different parser should be used in your configuration file so long as the parser meets the following requirements: + +1. It must be a Node module loadable from the config file where it appears. Usually, this means you should install the parser package separately using npm. +1. It must conform to the [parser interface](https://eslint.org/docs/developer-guide/working-with-custom-parsers). + +Note that even with these compatibilities, there are no guarantees that an external parser will work correctly with ESLint and ESLint will not fix bugs related to incompatibilities with other parsers. + +To indicate the npm module to use as your parser, specify it using the `parser` option in your `.eslintrc` file. For example, the following specifies to use Esprima instead of Espree: + +```json +{ + "parser": "esprima", + "rules": { + "semi": "error" + } +} +``` + +The following parsers are compatible with ESLint: + +* [Esprima](https://www.npmjs.com/package/esprima) +* [@babel/eslint-parser](https://www.npmjs.com/package/@babel/eslint-parser) - A wrapper around the [Babel](https://babeljs.io) parser that makes it compatible with ESLint. +* [@typescript-eslint/parser](https://www.npmjs.com/package/@typescript-eslint/parser) - A parser that converts TypeScript into an ESTree-compatible form so it can be used in ESLint. + +Note when using a custom parser, the `parserOptions` configuration property is still required for ESLint to work properly with features not in ECMAScript 5 by default. Parsers are all passed `parserOptions` and may or may not use them to determine which features to enable. + +## Specifying Processor + +Plugins may provide processors. Processors can extract JavaScript code from other kinds of files, then let ESLint lint the JavaScript code or processors can convert JavaScript code in preprocessing for some purpose. + +To specify processors in a configuration file, use the `processor` key with the concatenated string of a plugin name and a processor name by a slash. For example, the following enables the processor `a-processor` that the plugin `a-plugin` provided: + +```json +{ + "plugins": ["a-plugin"], + "processor": "a-plugin/a-processor" +} +``` + +To specify processors for specific kinds of files, use the combination of the `overrides` key and the `processor` key. For example, the following uses the processor `a-plugin/markdown` for `*.md` files. + +```json +{ + "plugins": ["a-plugin"], + "overrides": [ + { + "files": ["*.md"], + "processor": "a-plugin/markdown" + } + ] +} +``` + +Processors may make named code blocks such as `0.js` and `1.js`. ESLint handles such a named code block as a child file of the original file. You can specify additional configurations for named code blocks in the `overrides` section of the config. For example, the following disables the 'strict` rule for the named code blocks which end with `.js` in markdown files. + +```json +{ + "plugins": ["a-plugin"], + "overrides": [ + { + "files": ["*.md"], + "processor": "a-plugin/markdown" + }, + { + "files": ["**/*.md/*.js"], + "rules": { + "strict": "off" + } + } + ] +} +``` + +ESLint checks the file path of named code blocks then ignores those if any `overrides` entry didn't match the file path. Be sure to make `overrides` entry if you wanted to lint named code blocks other than `*.js`. + +## Configuring Plugins + +ESLint supports the use of third-party plugins. Before using the plugin, you have to install it using npm. + +To configure plugins inside of a configuration file, use the `plugins` key, which contains a list of plugin names. The `eslint-plugin-` prefix can be omitted from the plugin name. + +```json +{ + "plugins": [ + "plugin1", + "eslint-plugin-plugin2" + ] +} +``` + +And in YAML: + +```yaml +--- + plugins: + - plugin1 + - eslint-plugin-plugin2 +``` + +**Notes:** + +1. Plugins are resolved relative to the config file. In other words, ESLint will load the plugin as a user would obtain by running `require('eslint-plugin-pluginname')` in the config file. +2. Plugins in the base configuration (loaded by `extends` setting) are relative to the derived config file. For example, if `./.eslintrc` has `extends: ["foo"]` and the `eslint-config-foo` has `plugins: ["bar"]`, ESLint finds the `eslint-plugin-bar` from `./node_modules/` (rather than `./node_modules/eslint-config-foo/node_modules/`) or ancestor directories. Thus every plugin in the config file and base configurations is resolved uniquely. + +### Naming convention + +#### Include a plugin + +The `eslint-plugin-` prefix can be omitted for non-scoped packages + +```js +{ + // ... + "plugins": [ + "jquery", // means eslint-plugin-jquery + ] + // ... +} +``` + +The same rule does apply to scoped packages: + +```js +{ + // ... + "plugins": [ + "@jquery/jquery", // means @jquery/eslint-plugin-jquery + "@foobar" // means @foobar/eslint-plugin + ] + // ... +} +``` + +#### Use a plugin + +When using rules, environments or configs defined by plugins, they must be referenced following the convention: + +* `eslint-plugin-foo` → `foo/a-rule` +* `@foo/eslint-plugin` → `@foo/a-config` +* `@foo/eslint-plugin-bar` → `@foo/bar/a-environment` + +For example: + +```js +{ + // ... + "plugins": [ + "jquery", // eslint-plugin-jquery + "@foo/foo", // @foo/eslint-plugin-foo + "@bar" // @bar/eslint-plugin + ], + "extends": [ + "plugin:@foo/foo/recommended", + "plugin:@bar/recommended" + ], + "rules": { + "jquery/a-rule": "error", + "@foo/foo/some-rule": "error", + "@bar/another-rule": "error" + }, + "env": { + "jquery/jquery": true, + "@foo/foo/env-foo": true, + "@bar/env-bar": true, + } + // ... +} +``` From 92ed6d1a25b316298decc13c76de1b35e9ca2f90 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 11:39:27 +0500 Subject: [PATCH 09/96] Create Ignoring Code --- .../Configuring ESLint/Ignoring Code.md | 183 ++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 docs/user-guide/Configuring ESLint/Ignoring Code.md diff --git a/docs/user-guide/Configuring ESLint/Ignoring Code.md b/docs/user-guide/Configuring ESLint/Ignoring Code.md new file mode 100644 index 00000000000..c006043776b --- /dev/null +++ b/docs/user-guide/Configuring ESLint/Ignoring Code.md @@ -0,0 +1,183 @@ +# Ignoring Code + +Some intro to the section + +* `ignorePatterns` in config files +* `.eslintignore` +* Using an Alternate File +* Using eslintIgnore in package.json +* Ignored File Warnings +* Disabling Comments + +## `ignorePatterns` in config files + +You can tell ESLint to ignore specific files and directories by `ignorePatterns` in your config files. Each value of `ignorePatterns` is the same pattern as each line of `.eslintignore` in the next section. + +```json +{ + "ignorePatterns": ["temp.js", "**/vendor/*.js"], + "rules": { + //... + } +} +``` + +* The `ignorePatterns` property affects only the directory that the config file is placed in. +* You cannot write `ignorePatterns` property under `overrides` property. +* `.eslintignore` can override the `ignorePatterns` property of config files. + +If a glob pattern starts with `/`, the pattern is relative to the base directory of the config file. For example, `/foo.js` in `lib/.eslintrc.json` matches to `lib/foo.js` but not `lib/subdir/foo.js`. + +If a config is provided via the `--config` CLI option, the ignore patterns that start with `/` in the config are relative to the current working directory rather than the base directory of the given config. For example, if `--config configs/.eslintrc.json` is present, the ignore patterns in the config are relative to `.` rather than `./configs`. + +## `.eslintignore` + +You can tell ESLint to ignore specific files and directories by creating an `.eslintignore` file in your project's root directory. The `.eslintignore` file is a plain text file where each line is a glob pattern indicating which paths should be omitted from linting. For example, the following will omit all JavaScript files: + +```text +**/*.js +``` + +When ESLint is run, it looks in the current working directory to find an `.eslintignore` file before determining which files to lint. If this file is found, then those preferences are applied when traversing directories. Only one `.eslintignore` file can be used at a time, so `.eslintignore` files other than the one in the current working directory will not be used. + +Globs are matched using [node-ignore](https://github.com/kaelzhang/node-ignore), so a number of features are available: + +* Lines beginning with `#` are treated as comments and do not affect the ignore patterns. +* Paths are relative to the current working directory. This is also true of paths passed in via the `--ignore-pattern` [command](https://eslint.org/docs/user-guide/command-line-interface#--ignore-pattern). +* Lines preceded by `!` are negated patterns that re-include a pattern that was ignored by an earlier pattern. +* Ignore patterns behave according to the `.gitignore` [specification](https://git-scm.com/docs/gitignore). + +Of particular note is that like `.gitignore` files, all paths used as patterns for both `.eslintignore` and `--ignore-pattern` must use forward slashes as their path separators. + +```text +# Valid +/root/src/*.js + +# Invalid +\root\src\*.js +``` + +Please see [`.gitignore`](https://git-scm.com/docs/gitignore)'s specification for further examples of valid syntax. + +In addition to any patterns in the `.eslintignore` file, ESLint always follows a couple of implicit ignore rules even if the `--no-ignore` flag is passed. The implicit rules are as follows: + +* `node_modules/` is ignored. +* Dotfiles (except for `.eslintrc.*`), as well as Dotfolders and their contents, are ignored. + +There are also some exceptions to these rules: + +* If the path to lint is a glob pattern or directory path and contains a Dotfolder, all Dotfiles and Dotfolders will be linted. This includes sub-dotfiles and sub-dotfolders that are buried deeper in the directory structure. + + For example, `eslint .config/` will lint all Dotfolders and Dotfiles in the `.config` directory, including immediate children as well as children that are deeper in the directory structure. + +* If the path to lint is a specific file path and the `--no-ignore` flag has been passed, ESLint will lint the file regardless of the implicit ignore rules. + + For example, `eslint .config/my-config-file.js --no-ignore` will cause `my-config-file.js` to be linted. It should be noted that the same command without the `--no-ignore` line will not lint the `my-config-file.js` file. + +* Allowlist and denylist rules specified via `--ignore-pattern` or `.eslintignore` are prioritized above implicit ignore rules. + + For example, in this scenario, `.build/test.js` is the desired file to allowlist. Because all Dotfolders and their children are ignored by default, `.build` must first be allowlisted so that eslint because aware of its children. Then, `.build/test.js` must be explicitly allowlisted, while the rest of the content is denylisted. This is done with the following `.eslintignore` file: + + ```text + # Allowlist 'test.js' in the '.build' folder + # But do not allow anything else in the '.build' folder to be linted + !.build + .build/* + !.build/test.js + ``` + + The following `--ignore-pattern` is also equivalent: + + eslint --ignore-pattern '!.build' --ignore-pattern '.build/*' --ignore-pattern '!.build/test.js' parent-folder/ + +## Using an Alternate File + +If you'd prefer to use a different file than the `.eslintignore` in the current working directory, you can specify it on the command line using the `--ignore-path` option. For example, you can use `.jshintignore` file because it has the same format: + + eslint --ignore-path .jshintignore file.js + +You can also use your `.gitignore` file: + + eslint --ignore-path .gitignore file.js + +Any file that follows the standard ignore file format can be used. Keep in mind that specifying `--ignore-path` means that any existing `.eslintignore` file will not be used. Note that globbing rules in `.eslintignore` follow those of `.gitignore`. + +## Using eslintIgnore in package.json + +If an `.eslintignore` file is not found and an alternate file is not specified, ESLint will look in package.json for an `eslintIgnore` key to check for files to ignore. + + { + "name": "mypackage", + "version": "0.0.1", + "eslintConfig": { + "env": { + "browser": true, + "node": true + } + }, + "eslintIgnore": ["hello.js", "world.js"] + } + +## Ignored File Warnings + +When you pass directories to ESLint, files and directories are silently ignored. If you pass a specific file to ESLint, then you will see a warning indicating that the file was skipped. For example, suppose you have an `.eslintignore` file that looks like this: + +```text +foo.js +``` + +And then you run: + + eslint foo.js + +You'll see this warning: + +```text +foo.js + 0:0 warning File ignored because of a matching ignore pattern. Use "--no-ignore" to override. + +✖ 1 problem (0 errors, 1 warning) +``` + +This message occurs because ESLint is unsure if you wanted to actually lint the file or not. As the message indicates, you can use `--no-ignore` to omit using the ignore rules. + +Consider another scenario where you may want to run ESLint on a specific Dotfile or Dotfolder, but have forgotten to specifically allow those files in your `.eslintignore` file. You would run something like this: + + eslint .config/foo.js + +You would see this warning: + +```text +.config/foo.js + 0:0 warning File ignored by default. Use a negated ignore pattern (like "--ignore-pattern '!'") to override + +✖ 1 problem (0 errors, 1 warning) +``` + +This message occurs because, normally, this file would be ignored by ESLint's implicit ignore rules (as mentioned above). A negated ignore rule in your `.eslintignore` file would override the implicit rule and reinclude this file for linting. Additionally, in this specific case, `--no-ignore` could be used to lint the file as well. + +## Disabling Inline Comments + +To disable all inline config comments, use the `noInlineConfig` setting. For example: + +```json +{ + "rules": {...}, + "noInlineConfig": true +} +``` + +This setting is similar to [--no-inline-config](https://eslint.org/docs/user-guide/command-line-interface#--no-inline-config) CLI option. + +### Report unused `eslint-disable` comments + +To report unused `eslint-disable` comments, use the `reportUnusedDisableDirectives` setting. For example: + +```json +{ + "rules": {...}, + "reportUnusedDisableDirectives": true +} +``` + +This setting is similar to [--report-unused-disable-directives](https://eslint.org/docs/user-guide/command-line-interface#--report-unused-disable-directives) CLI option, but doesn't fail linting (reports as `"warn"` severity). From 5a03df5a1e6ea9d6abb970ad99b5c1ceea3a1734 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 11:42:00 +0500 Subject: [PATCH 10/96] Update README.md --- docs/user-guide/Configuring ESLint/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/user-guide/Configuring ESLint/README.md b/docs/user-guide/Configuring ESLint/README.md index 5b0b897a5ef..ac5d4577a27 100644 --- a/docs/user-guide/Configuring ESLint/README.md +++ b/docs/user-guide/Configuring ESLint/README.md @@ -15,14 +15,14 @@ All of these options give you fine-grained control over how ESLint treats your c ## Table of Contents -[**Configuration Files**](configuring-files) -* [Configuration File Formats](./configuring-files#configuration-file-formats) +[**Configuration Files**](configuration-files) +* [Configuration File Formats](./configuration-files#configuration-file-formats) * [Using Configuration Files](./configuring-files#using-configuration-files) -* [Adding Shared Settings](./configuring-files#adding-shared-settings) -* [Cascading and Hierarchy](./configuring-files#cascading-and-hierarchy) +* [Adding Shared Settings](./configuration-files#adding-shared-settings) +* [Cascading and Hierarchy](./configuration-files#cascading-and-hierarchy) * [Extending Configuration Files](./configuring-files#extending-configuration-files) -* [Configuration Based on Glob Patterns](./configuring-files#configuration-based-on-glon-patterns) -* [Personal Configuration Files](./configuring-files#personal-configuration-files) +* [Configuration Based on Glob Patterns](./configuration-files#configuration-based-on-glon-patterns) +* [Personal Configuration Files](./configuration-files#personal-configuration-files) [**Language Options**](language-options) * [Specifying Environments](./language-options#specifying-environments) From 2865483a42d642d837dba8e1d59c50b3f2bea9a1 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 11:48:09 +0500 Subject: [PATCH 11/96] Update README.md --- docs/user-guide/Configuring ESLint/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/user-guide/Configuring ESLint/README.md b/docs/user-guide/Configuring ESLint/README.md index ac5d4577a27..6c1718078e3 100644 --- a/docs/user-guide/Configuring ESLint/README.md +++ b/docs/user-guide/Configuring ESLint/README.md @@ -15,7 +15,7 @@ All of these options give you fine-grained control over how ESLint treats your c ## Table of Contents -[**Configuration Files**](configuration-files) +[**Configuration Files**](configuration-files.md) * [Configuration File Formats](./configuration-files#configuration-file-formats) * [Using Configuration Files](./configuring-files#using-configuration-files) * [Adding Shared Settings](./configuration-files#adding-shared-settings) @@ -24,21 +24,21 @@ All of these options give you fine-grained control over how ESLint treats your c * [Configuration Based on Glob Patterns](./configuration-files#configuration-based-on-glon-patterns) * [Personal Configuration Files](./configuration-files#personal-configuration-files) -[**Language Options**](language-options) +[**Language Options**](language-options.md) * [Specifying Environments](./language-options#specifying-environments) * [Specifying Globals](./language-options#specifying-globals) * [Specifying Parser Options](./language-options#specifying-parser-options) -[**Rules**](rules) +[**Rules**](rules.md) * [Configuring Rules](./rules#configuring-rules) * [Disabling Rules](./rules#disabling-rules) -[**Plugins**](plugins) +[**Plugins**](plugins.md) * [Specifying Parser](./plugins#specifying-parser) * [Specifying Processor](./plugins#specifying-processor) * [Configuring Plugins](./plugins#configuring-plugins) -[**Ignoring Code**](ignoring-code) +[**Ignoring Code**](ignoring-code.md) * [`ignorePatterns` in config files](./ignoring-code#ignorepatterns-in-config-files) * [`.eslintignore`](./ignoring-code#eslintignore) * [Using an Alternate File](./ignoring-code#using-an-alternate-file) From 5725f9514735ec3257e7bf9fade315357c74d94e Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 11:52:49 +0500 Subject: [PATCH 12/96] Rename Language Options.md to language-options.md --- .../{Language Options.md => language-options.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/user-guide/Configuring ESLint/{Language Options.md => language-options.md} (100%) diff --git a/docs/user-guide/Configuring ESLint/Language Options.md b/docs/user-guide/Configuring ESLint/language-options.md similarity index 100% rename from docs/user-guide/Configuring ESLint/Language Options.md rename to docs/user-guide/Configuring ESLint/language-options.md From d81fc30104acf3d37057caae849a25bb697a1de3 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 11:53:10 +0500 Subject: [PATCH 13/96] Rename Configuration Files.md to configuration-files.md --- .../{Configuration Files.md => configuration-files.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/user-guide/Configuring ESLint/{Configuration Files.md => configuration-files.md} (100%) diff --git a/docs/user-guide/Configuring ESLint/Configuration Files.md b/docs/user-guide/Configuring ESLint/configuration-files.md similarity index 100% rename from docs/user-guide/Configuring ESLint/Configuration Files.md rename to docs/user-guide/Configuring ESLint/configuration-files.md From 33fcf7cd7ba609d08e767b24d3f545c831727a11 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 11:53:41 +0500 Subject: [PATCH 14/96] Rename Rules.md to rules.md --- docs/user-guide/Configuring ESLint/{Rules.md => rules.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/user-guide/Configuring ESLint/{Rules.md => rules.md} (100%) diff --git a/docs/user-guide/Configuring ESLint/Rules.md b/docs/user-guide/Configuring ESLint/rules.md similarity index 100% rename from docs/user-guide/Configuring ESLint/Rules.md rename to docs/user-guide/Configuring ESLint/rules.md From ec2e327e13ae6a595de5fd96213b6ac7ccb51fd4 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 11:53:57 +0500 Subject: [PATCH 15/96] Rename Plugins.md to plugins.md --- docs/user-guide/Configuring ESLint/{Plugins.md => plugins.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/user-guide/Configuring ESLint/{Plugins.md => plugins.md} (100%) diff --git a/docs/user-guide/Configuring ESLint/Plugins.md b/docs/user-guide/Configuring ESLint/plugins.md similarity index 100% rename from docs/user-guide/Configuring ESLint/Plugins.md rename to docs/user-guide/Configuring ESLint/plugins.md From 17026efea2c08170dcb643601be08df0afb5ba79 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 11:54:27 +0500 Subject: [PATCH 16/96] Rename Ignoring Code.md to ignoring-code.md --- .../Configuring ESLint/{Ignoring Code.md => ignoring-code.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/user-guide/Configuring ESLint/{Ignoring Code.md => ignoring-code.md} (100%) diff --git a/docs/user-guide/Configuring ESLint/Ignoring Code.md b/docs/user-guide/Configuring ESLint/ignoring-code.md similarity index 100% rename from docs/user-guide/Configuring ESLint/Ignoring Code.md rename to docs/user-guide/Configuring ESLint/ignoring-code.md From 693897d083985382a0e2e383544cc0a1631bbe00 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 11:55:14 +0500 Subject: [PATCH 17/96] Rename docs/user-guide/Configuring ESLint/README.md to docs/user-guide/configuring-ESLint/README.md --- .../{Configuring ESLint => configuring-ESLint}/README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/user-guide/{Configuring ESLint => configuring-ESLint}/README.md (100%) diff --git a/docs/user-guide/Configuring ESLint/README.md b/docs/user-guide/configuring-ESLint/README.md similarity index 100% rename from docs/user-guide/Configuring ESLint/README.md rename to docs/user-guide/configuring-ESLint/README.md From 1df671ec9d1edfb1cac582c52efc527a5e2c0575 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 11:56:26 +0500 Subject: [PATCH 18/96] Rename docs/user-guide/Configuring ESLint/configuration-files.md to docs/user-guide/configuring-ESLint/configuration-files.md --- .../configuration-files.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/user-guide/{Configuring ESLint => configuring-ESLint}/configuration-files.md (100%) diff --git a/docs/user-guide/Configuring ESLint/configuration-files.md b/docs/user-guide/configuring-ESLint/configuration-files.md similarity index 100% rename from docs/user-guide/Configuring ESLint/configuration-files.md rename to docs/user-guide/configuring-ESLint/configuration-files.md From 970bf85d999742a449ba0d266997e1e59530230e Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 11:58:32 +0500 Subject: [PATCH 19/96] Rename docs/user-guide/Configuring ESLint/ignoring-code.md to docs/user-guide/configuring-ESLint/ignoring-code.md --- .../{Configuring ESLint => configuring-ESLint}/ignoring-code.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/user-guide/{Configuring ESLint => configuring-ESLint}/ignoring-code.md (100%) diff --git a/docs/user-guide/Configuring ESLint/ignoring-code.md b/docs/user-guide/configuring-ESLint/ignoring-code.md similarity index 100% rename from docs/user-guide/Configuring ESLint/ignoring-code.md rename to docs/user-guide/configuring-ESLint/ignoring-code.md From 386c03262f368ed2cc8354602808e67c51464068 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 11:59:04 +0500 Subject: [PATCH 20/96] Rename docs/user-guide/Configuring ESLint/language-options.md to docs/user-guide/configuring-ESLint/language-options.md --- .../language-options.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/user-guide/{Configuring ESLint => configuring-ESLint}/language-options.md (100%) diff --git a/docs/user-guide/Configuring ESLint/language-options.md b/docs/user-guide/configuring-ESLint/language-options.md similarity index 100% rename from docs/user-guide/Configuring ESLint/language-options.md rename to docs/user-guide/configuring-ESLint/language-options.md From 68ed8f653f1b22b702cc43c3593b22eebbdef667 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 11:59:24 +0500 Subject: [PATCH 21/96] Rename docs/user-guide/Configuring ESLint/plugins.md to docs/user-guide/configuring-ESLint/plugins.md --- .../{Configuring ESLint => configuring-ESLint}/plugins.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/user-guide/{Configuring ESLint => configuring-ESLint}/plugins.md (100%) diff --git a/docs/user-guide/Configuring ESLint/plugins.md b/docs/user-guide/configuring-ESLint/plugins.md similarity index 100% rename from docs/user-guide/Configuring ESLint/plugins.md rename to docs/user-guide/configuring-ESLint/plugins.md From e180e1cbad56546b3fdd8f95eec8eb2865733328 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 12:00:01 +0500 Subject: [PATCH 22/96] Rename docs/user-guide/Configuring ESLint/rules.md to docs/user-guide/configuring-ESLint/rules.md --- .../{Configuring ESLint => configuring-ESLint}/rules.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/user-guide/{Configuring ESLint => configuring-ESLint}/rules.md (100%) diff --git a/docs/user-guide/Configuring ESLint/rules.md b/docs/user-guide/configuring-ESLint/rules.md similarity index 100% rename from docs/user-guide/Configuring ESLint/rules.md rename to docs/user-guide/configuring-ESLint/rules.md From 126966bd734ec6719caa2194c370a1fcbc2ce514 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 12:02:17 +0500 Subject: [PATCH 23/96] Update README.md --- docs/user-guide/configuring-ESLint/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/user-guide/configuring-ESLint/README.md b/docs/user-guide/configuring-ESLint/README.md index 6c1718078e3..afdec75247c 100644 --- a/docs/user-guide/configuring-ESLint/README.md +++ b/docs/user-guide/configuring-ESLint/README.md @@ -8,8 +8,8 @@ Following are some of the important pieces of information that you can configure * [**Environments**](./language-options#specifying-environments) - which environments your script is designed to run in. Each environment brings with it a certain set of predefined global variables. * [**Globals**](./language-options#specifying-globals) - the additional global variables your script accesses during execution. -* [**Rules**](rules) - which rules are enabled and at what error level. -* [**Plugins**](plugins) - the use of third-party plugins in ESLint. +* [**Rules**](rules.md) - which rules are enabled and at what error level. +* [**Plugins**](plugins.md) - the use of third-party plugins in ESLint. All of these options give you fine-grained control over how ESLint treats your code. From b7f21b5e548318c40f9791904872d57607945164 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 12:02:59 +0500 Subject: [PATCH 24/96] Update README.md --- docs/user-guide/configuring-ESLint/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring-ESLint/README.md b/docs/user-guide/configuring-ESLint/README.md index afdec75247c..bbc71f2a4d1 100644 --- a/docs/user-guide/configuring-ESLint/README.md +++ b/docs/user-guide/configuring-ESLint/README.md @@ -7,7 +7,7 @@ ESLint is designed to be completely configurable. You can turn off every rule an Following are some of the important pieces of information that you can configure in ESLint: * [**Environments**](./language-options#specifying-environments) - which environments your script is designed to run in. Each environment brings with it a certain set of predefined global variables. -* [**Globals**](./language-options#specifying-globals) - the additional global variables your script accesses during execution. +* [**Globals**](./language-options.md#specifying-globals) - the additional global variables your script accesses during execution. * [**Rules**](rules.md) - which rules are enabled and at what error level. * [**Plugins**](plugins.md) - the use of third-party plugins in ESLint. From 6f3ad1891c79637a6127cfcce78607d2feb91a5b Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 12:04:39 +0500 Subject: [PATCH 25/96] Update README.md --- docs/user-guide/configuring-ESLint/README.md | 44 ++++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/docs/user-guide/configuring-ESLint/README.md b/docs/user-guide/configuring-ESLint/README.md index bbc71f2a4d1..7ef2052a5de 100644 --- a/docs/user-guide/configuring-ESLint/README.md +++ b/docs/user-guide/configuring-ESLint/README.md @@ -6,7 +6,7 @@ ESLint is designed to be completely configurable. You can turn off every rule an Following are some of the important pieces of information that you can configure in ESLint: -* [**Environments**](./language-options#specifying-environments) - which environments your script is designed to run in. Each environment brings with it a certain set of predefined global variables. +* [**Environments**](./language-options.md#specifying-environments) - which environments your script is designed to run in. Each environment brings with it a certain set of predefined global variables. * [**Globals**](./language-options.md#specifying-globals) - the additional global variables your script accesses during execution. * [**Rules**](rules.md) - which rules are enabled and at what error level. * [**Plugins**](plugins.md) - the use of third-party plugins in ESLint. @@ -16,32 +16,32 @@ All of these options give you fine-grained control over how ESLint treats your c ## Table of Contents [**Configuration Files**](configuration-files.md) -* [Configuration File Formats](./configuration-files#configuration-file-formats) -* [Using Configuration Files](./configuring-files#using-configuration-files) -* [Adding Shared Settings](./configuration-files#adding-shared-settings) -* [Cascading and Hierarchy](./configuration-files#cascading-and-hierarchy) -* [Extending Configuration Files](./configuring-files#extending-configuration-files) -* [Configuration Based on Glob Patterns](./configuration-files#configuration-based-on-glon-patterns) -* [Personal Configuration Files](./configuration-files#personal-configuration-files) +* [Configuration File Formats](./configuration-files.md#configuration-file-formats) +* [Using Configuration Files](./configuration-files.md#using-configuration-files) +* [Adding Shared Settings](./configuration-files.md#adding-shared-settings) +* [Cascading and Hierarchy](./configuration-files.md#cascading-and-hierarchy) +* [Extending Configuration Files](./configuring-files.md#extending-configuration-files) +* [Configuration Based on Glob Patterns](./configuration-files.md#configuration-based-on-glon-patterns) +* [Personal Configuration Files](./configuration-files.md#personal-configuration-files) [**Language Options**](language-options.md) -* [Specifying Environments](./language-options#specifying-environments) -* [Specifying Globals](./language-options#specifying-globals) -* [Specifying Parser Options](./language-options#specifying-parser-options) +* [Specifying Environments](./language-options.md#specifying-environments) +* [Specifying Globals](./language-options.md#specifying-globals) +* [Specifying Parser Options](./language-options.md#specifying-parser-options) [**Rules**](rules.md) -* [Configuring Rules](./rules#configuring-rules) -* [Disabling Rules](./rules#disabling-rules) +* [Configuring Rules](./rules.md#configuring-rules) +* [Disabling Rules](./rules.md#disabling-rules) [**Plugins**](plugins.md) -* [Specifying Parser](./plugins#specifying-parser) -* [Specifying Processor](./plugins#specifying-processor) -* [Configuring Plugins](./plugins#configuring-plugins) +* [Specifying Parser](./plugins.md#specifying-parser) +* [Specifying Processor](./plugins.md#specifying-processor) +* [Configuring Plugins](./plugins.md#configuring-plugins) [**Ignoring Code**](ignoring-code.md) -* [`ignorePatterns` in config files](./ignoring-code#ignorepatterns-in-config-files) -* [`.eslintignore`](./ignoring-code#eslintignore) -* [Using an Alternate File](./ignoring-code#using-an-alternate-file) -* [Using eslintIgnore in package.json](./ignoring-code#using-eslintignore-in-package.json) -* [Ignored File Warnings](./ignoring-code#ignored-file-warnings) -* [Disabling Comments](./ignoring-code#disabling-comments) +* [`ignorePatterns` in config files](./ignoring-code.md#ignorepatterns-in-config-files) +* [`.eslintignore`](./ignoring-code.md#eslintignore) +* [Using an Alternate File](./ignoring-code.md#using-an-alternate-file) +* [Using eslintIgnore in package.json](./ignoring-code.md#using-eslintignore-in-package.json) +* [Ignored File Warnings](./ignoring-code.md#ignored-file-warnings) +* [Disabling Comments](./ignoring-code.md#disabling-comments) From b7a6ffbcfaa8d6521797aa4f74fd012901e5d26e Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 12:12:20 +0500 Subject: [PATCH 26/96] Update configuration-files.md --- docs/user-guide/configuring-ESLint/configuration-files.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring-ESLint/configuration-files.md b/docs/user-guide/configuring-ESLint/configuration-files.md index ecb01857acf..698e86178c1 100644 --- a/docs/user-guide/configuring-ESLint/configuration-files.md +++ b/docs/user-guide/configuring-ESLint/configuration-files.md @@ -231,7 +231,7 @@ rules: A [plugin](https://eslint.org/docs/developer-guide/working-with-plugins) is an npm package that usually exports rules. Some plugins also export one or more named [configurations](https://eslint.org/docs/developer-guide/working-with-plugins#configs-in-plugins). Make sure the package has been installed in a directory where ESLint can require it. -The `plugins` [property value](./plugins#configuring-plugins) can omit the `eslint-plugin-` prefix of the package name. +The `plugins` [property value](./plugins.md#configuring-plugins) can omit the `eslint-plugin-` prefix of the package name. The `extends` property value can consist of: From f67bf8e930882235bd8d5c823b02e247234148d1 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 12:14:55 +0500 Subject: [PATCH 27/96] Update ignoring-code.md --- docs/user-guide/configuring-ESLint/ignoring-code.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/user-guide/configuring-ESLint/ignoring-code.md b/docs/user-guide/configuring-ESLint/ignoring-code.md index c006043776b..2bda808d637 100644 --- a/docs/user-guide/configuring-ESLint/ignoring-code.md +++ b/docs/user-guide/configuring-ESLint/ignoring-code.md @@ -2,12 +2,12 @@ Some intro to the section -* `ignorePatterns` in config files -* `.eslintignore` -* Using an Alternate File -* Using eslintIgnore in package.json -* Ignored File Warnings -* Disabling Comments +* `ignorePatterns` in config files (#ignorepatterns-in-config-files) +* `.eslintignore` (#.eslintignore) +* Using an Alternate File (#using-an-alternate-file) +* Using eslintIgnore in package.json (#using-eslintignore-in-package.json) +* Ignored File Warnings (#ignored-file-warnings) +* Disabling Comments (#disabling-comments) ## `ignorePatterns` in config files From 075ee4f1d05fd0f4f5d80be11397227b4204df67 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 12:15:52 +0500 Subject: [PATCH 28/96] Update ignoring-code.md --- docs/user-guide/configuring-ESLint/ignoring-code.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/user-guide/configuring-ESLint/ignoring-code.md b/docs/user-guide/configuring-ESLint/ignoring-code.md index 2bda808d637..369d582bc54 100644 --- a/docs/user-guide/configuring-ESLint/ignoring-code.md +++ b/docs/user-guide/configuring-ESLint/ignoring-code.md @@ -2,12 +2,12 @@ Some intro to the section -* `ignorePatterns` in config files (#ignorepatterns-in-config-files) -* `.eslintignore` (#.eslintignore) -* Using an Alternate File (#using-an-alternate-file) -* Using eslintIgnore in package.json (#using-eslintignore-in-package.json) -* Ignored File Warnings (#ignored-file-warnings) -* Disabling Comments (#disabling-comments) +* [`ignorePatterns` in config files] (#ignorepatterns-in-config-files) +* [`.eslintignore`] (#.eslintignore) +* [Using an Alternate File] (#using-an-alternate-file) +* [Using eslintIgnore in package.json] (#using-eslintignore-in-package.json) +* [Ignored File Warnings] (#ignored-file-warnings) +* [Disabling Comments] (#disabling-comments) ## `ignorePatterns` in config files From 512176107ad95f150be94cc9a425eebd47e05942 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 12:16:26 +0500 Subject: [PATCH 29/96] Update ignoring-code.md --- docs/user-guide/configuring-ESLint/ignoring-code.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/user-guide/configuring-ESLint/ignoring-code.md b/docs/user-guide/configuring-ESLint/ignoring-code.md index 369d582bc54..d788f9179cc 100644 --- a/docs/user-guide/configuring-ESLint/ignoring-code.md +++ b/docs/user-guide/configuring-ESLint/ignoring-code.md @@ -2,12 +2,12 @@ Some intro to the section -* [`ignorePatterns` in config files] (#ignorepatterns-in-config-files) -* [`.eslintignore`] (#.eslintignore) -* [Using an Alternate File] (#using-an-alternate-file) -* [Using eslintIgnore in package.json] (#using-eslintignore-in-package.json) -* [Ignored File Warnings] (#ignored-file-warnings) -* [Disabling Comments] (#disabling-comments) +* [`ignorePatterns` in config files](#ignorepatterns-in-config-files) +* [`.eslintignore`](#.eslintignore) +* [Using an Alternate File](#using-an-alternate-file) +* [Using eslintIgnore in package.json](#using-eslintignore-in-package.json) +* [Ignored File Warnings](#ignored-file-warnings) +* [Disabling Comments](#disabling-comments) ## `ignorePatterns` in config files From c85bf880673b94fcd9706c9526f4ce1ea92092c5 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 12:17:27 +0500 Subject: [PATCH 30/96] Update ignoring-code.md --- docs/user-guide/configuring-ESLint/ignoring-code.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/user-guide/configuring-ESLint/ignoring-code.md b/docs/user-guide/configuring-ESLint/ignoring-code.md index d788f9179cc..289988aff5f 100644 --- a/docs/user-guide/configuring-ESLint/ignoring-code.md +++ b/docs/user-guide/configuring-ESLint/ignoring-code.md @@ -3,11 +3,11 @@ Some intro to the section * [`ignorePatterns` in config files](#ignorepatterns-in-config-files) -* [`.eslintignore`](#.eslintignore) +* [`.eslintignore`](#eslintignore) * [Using an Alternate File](#using-an-alternate-file) -* [Using eslintIgnore in package.json](#using-eslintignore-in-package.json) +* [Using eslintIgnore in package.json](#using-eslintignore-in-packagejson) * [Ignored File Warnings](#ignored-file-warnings) -* [Disabling Comments](#disabling-comments) +* [Disabling Inline Comments](#disabling-inline-comments) ## `ignorePatterns` in config files From 89d9b3737ead7163b608a950d6681b070621ce47 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 12:20:13 +0500 Subject: [PATCH 31/96] Update README.md --- docs/user-guide/configuring-ESLint/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring-ESLint/README.md b/docs/user-guide/configuring-ESLint/README.md index 7ef2052a5de..b4ac318f678 100644 --- a/docs/user-guide/configuring-ESLint/README.md +++ b/docs/user-guide/configuring-ESLint/README.md @@ -44,4 +44,4 @@ All of these options give you fine-grained control over how ESLint treats your c * [Using an Alternate File](./ignoring-code.md#using-an-alternate-file) * [Using eslintIgnore in package.json](./ignoring-code.md#using-eslintignore-in-package.json) * [Ignored File Warnings](./ignoring-code.md#ignored-file-warnings) -* [Disabling Comments](./ignoring-code.md#disabling-comments) +* [Disabling Inline Comments](./ignoring-code.md#disabling-inline-comments) From ba70eb851a76d0eb2ffe12c3f193417d9faebf13 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 12:24:28 +0500 Subject: [PATCH 32/96] Update plugins.md --- docs/user-guide/configuring-ESLint/plugins.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/user-guide/configuring-ESLint/plugins.md b/docs/user-guide/configuring-ESLint/plugins.md index fd8b2aded97..975236607df 100644 --- a/docs/user-guide/configuring-ESLint/plugins.md +++ b/docs/user-guide/configuring-ESLint/plugins.md @@ -2,9 +2,9 @@ Some intro to the section -* Specifying Parser -* Specifying Processor -* Configuring Plugins +* [Specifying Parser](#specifying-parser) +* [Specifying Processor](#specifying-processor) +* [Configuring Plugins](#configuring-plugins) ## Specifying Parser From f92373f741c778c6b23e0473b98b04eb9092500c Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 12:27:31 +0500 Subject: [PATCH 33/96] Update rules.md --- docs/user-guide/configuring-ESLint/rules.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/user-guide/configuring-ESLint/rules.md b/docs/user-guide/configuring-ESLint/rules.md index 23322d97eec..f61404e31d5 100644 --- a/docs/user-guide/configuring-ESLint/rules.md +++ b/docs/user-guide/configuring-ESLint/rules.md @@ -2,8 +2,8 @@ Some intro to the section with a link to the Rules page here -* Configuring Rules -* Disabling Rules +* [Configuring Rules](#configuring-rules) +* [Disabling Rules](#disabling-rules) ## Configuring Rules From 866372a548aa8aa88ce2aee5989b33a3223ff669 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 14:26:24 +0500 Subject: [PATCH 34/96] Update configuration-files.md --- docs/user-guide/configuring-ESLint/configuration-files.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/user-guide/configuring-ESLint/configuration-files.md b/docs/user-guide/configuring-ESLint/configuration-files.md index 698e86178c1..f23b6f99252 100644 --- a/docs/user-guide/configuring-ESLint/configuration-files.md +++ b/docs/user-guide/configuring-ESLint/configuration-files.md @@ -1,5 +1,4 @@ # Configuration Files -Some intro about config files here * [Configuration File Formats](#configuration-file-formats) * [Using Configuration Files](#using-configuration-files) From 7c5b47282ae5ddc51c18e42e58b5a43035337e23 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 14:27:03 +0500 Subject: [PATCH 35/96] Update language-options.md --- docs/user-guide/configuring-ESLint/language-options.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/user-guide/configuring-ESLint/language-options.md b/docs/user-guide/configuring-ESLint/language-options.md index 273d6730ca4..5e1a1ff9f9a 100644 --- a/docs/user-guide/configuring-ESLint/language-options.md +++ b/docs/user-guide/configuring-ESLint/language-options.md @@ -1,6 +1,5 @@ # Language Options -Some basic intro to the section * [Specifying Environments](#specifying-environments) * [Specifying Globals](#specifying-globals) From c91c8966aa4e36bd3f804c8422d930a9582af02f Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 14:27:31 +0500 Subject: [PATCH 36/96] Update rules.md --- docs/user-guide/configuring-ESLint/rules.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/user-guide/configuring-ESLint/rules.md b/docs/user-guide/configuring-ESLint/rules.md index f61404e31d5..7bd24373bf9 100644 --- a/docs/user-guide/configuring-ESLint/rules.md +++ b/docs/user-guide/configuring-ESLint/rules.md @@ -1,6 +1,5 @@ # Rules -Some intro to the section with a link to the Rules page here * [Configuring Rules](#configuring-rules) * [Disabling Rules](#disabling-rules) From 6287fb6fb857486726554be17babd2579c9e4ee0 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 14:27:55 +0500 Subject: [PATCH 37/96] Update plugins.md --- docs/user-guide/configuring-ESLint/plugins.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/user-guide/configuring-ESLint/plugins.md b/docs/user-guide/configuring-ESLint/plugins.md index 975236607df..af3f2fc53c1 100644 --- a/docs/user-guide/configuring-ESLint/plugins.md +++ b/docs/user-guide/configuring-ESLint/plugins.md @@ -1,6 +1,5 @@ # Plugins -Some intro to the section * [Specifying Parser](#specifying-parser) * [Specifying Processor](#specifying-processor) From 2edfd30fb449f79ee8c2705addbeff645146753f Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 12 Nov 2020 14:28:16 +0500 Subject: [PATCH 38/96] Update ignoring-code.md --- docs/user-guide/configuring-ESLint/ignoring-code.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/user-guide/configuring-ESLint/ignoring-code.md b/docs/user-guide/configuring-ESLint/ignoring-code.md index 289988aff5f..70852c203b2 100644 --- a/docs/user-guide/configuring-ESLint/ignoring-code.md +++ b/docs/user-guide/configuring-ESLint/ignoring-code.md @@ -1,6 +1,5 @@ # Ignoring Code -Some intro to the section * [`ignorePatterns` in config files](#ignorepatterns-in-config-files) * [`.eslintignore`](#eslintignore) From 34925dfcfcd14171296d82ffcbe0309127803069 Mon Sep 17 00:00:00 2001 From: klkhan Date: Sat, 14 Nov 2020 10:16:06 +0500 Subject: [PATCH 39/96] Docs: Update Configurating ESLint README.md Added space before and after the list items to remove an error. --- docs/user-guide/configuring-ESLint/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/user-guide/configuring-ESLint/README.md b/docs/user-guide/configuring-ESLint/README.md index b4ac318f678..e9e9572f13d 100644 --- a/docs/user-guide/configuring-ESLint/README.md +++ b/docs/user-guide/configuring-ESLint/README.md @@ -16,6 +16,7 @@ All of these options give you fine-grained control over how ESLint treats your c ## Table of Contents [**Configuration Files**](configuration-files.md) + * [Configuration File Formats](./configuration-files.md#configuration-file-formats) * [Using Configuration Files](./configuration-files.md#using-configuration-files) * [Adding Shared Settings](./configuration-files.md#adding-shared-settings) @@ -25,20 +26,24 @@ All of these options give you fine-grained control over how ESLint treats your c * [Personal Configuration Files](./configuration-files.md#personal-configuration-files) [**Language Options**](language-options.md) + * [Specifying Environments](./language-options.md#specifying-environments) * [Specifying Globals](./language-options.md#specifying-globals) * [Specifying Parser Options](./language-options.md#specifying-parser-options) [**Rules**](rules.md) + * [Configuring Rules](./rules.md#configuring-rules) * [Disabling Rules](./rules.md#disabling-rules) [**Plugins**](plugins.md) + * [Specifying Parser](./plugins.md#specifying-parser) * [Specifying Processor](./plugins.md#specifying-processor) * [Configuring Plugins](./plugins.md#configuring-plugins) [**Ignoring Code**](ignoring-code.md) + * [`ignorePatterns` in config files](./ignoring-code.md#ignorepatterns-in-config-files) * [`.eslintignore`](./ignoring-code.md#eslintignore) * [Using an Alternate File](./ignoring-code.md#using-an-alternate-file) From cca0ea5f1921a7f87835d236463bb7f09e407e2b Mon Sep 17 00:00:00 2001 From: klkhan Date: Sat, 14 Nov 2020 10:20:40 +0500 Subject: [PATCH 40/96] Docs: Update Plugins.md in Configuring ESLint Updated the file to remove the error in line 63. --- docs/user-guide/configuring-ESLint/plugins.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring-ESLint/plugins.md b/docs/user-guide/configuring-ESLint/plugins.md index af3f2fc53c1..c4dc1e9ce7b 100644 --- a/docs/user-guide/configuring-ESLint/plugins.md +++ b/docs/user-guide/configuring-ESLint/plugins.md @@ -60,7 +60,7 @@ To specify processors for specific kinds of files, use the combination of the `o } ``` -Processors may make named code blocks such as `0.js` and `1.js`. ESLint handles such a named code block as a child file of the original file. You can specify additional configurations for named code blocks in the `overrides` section of the config. For example, the following disables the 'strict` rule for the named code blocks which end with `.js` in markdown files. +Processors may make named code blocks such as `0.js` and `1.js`. ESLint handles such a named code block as a child file of the original file. You can specify additional configurations for named code blocks in the `overrides` section of the config. For example, the following disables the `strict` rule for the named code blocks which end with `.js` in markdown files. ```json { From cbf8eb951d079816d69d1f1839e5e3d440283088 Mon Sep 17 00:00:00 2001 From: klkhan Date: Sat, 14 Nov 2020 10:23:49 +0500 Subject: [PATCH 41/96] Docs: Update README.md in Configuring ESLint Updated the heading to remove the error in line 1. --- docs/user-guide/configuring-ESLint/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/user-guide/configuring-ESLint/README.md b/docs/user-guide/configuring-ESLint/README.md index e9e9572f13d..7e6229b0a80 100644 --- a/docs/user-guide/configuring-ESLint/README.md +++ b/docs/user-guide/configuring-ESLint/README.md @@ -1,4 +1,5 @@ # Configuring ESLint + ESLint is designed to be completely configurable. 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 make ESLint perfect for your project. There are two primary ways to configure ESLint: 1. **Configuration Comments** - use JavaScript comments to embed configuration information directly into a file. From 46a2e5edf229483911d6e8ec3fc23c2101407526 Mon Sep 17 00:00:00 2001 From: klkhan Date: Sat, 14 Nov 2020 10:30:51 +0500 Subject: [PATCH 42/96] Docs: Renamed the directory to configuring-eslint Renamed parent directory to remove the uppercase letters from the name. --- .../{configuring-ESLint => configuring-eslint}/README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/user-guide/{configuring-ESLint => configuring-eslint}/README.md (100%) diff --git a/docs/user-guide/configuring-ESLint/README.md b/docs/user-guide/configuring-eslint/README.md similarity index 100% rename from docs/user-guide/configuring-ESLint/README.md rename to docs/user-guide/configuring-eslint/README.md From 9711bfcc32cfac61f96f91c65b0d594482eac7a0 Mon Sep 17 00:00:00 2001 From: klkhan Date: Sat, 14 Nov 2020 10:31:37 +0500 Subject: [PATCH 43/96] Docs: Renamed the directory to configuring-eslint Renamed the parent directory to remove the uppercase letters from the name. --- .../configuration-files.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/user-guide/{configuring-ESLint => configuring-eslint}/configuration-files.md (100%) diff --git a/docs/user-guide/configuring-ESLint/configuration-files.md b/docs/user-guide/configuring-eslint/configuration-files.md similarity index 100% rename from docs/user-guide/configuring-ESLint/configuration-files.md rename to docs/user-guide/configuring-eslint/configuration-files.md From 31b6aea53dc359a13c7e45a720ce5e2c1bcfd438 Mon Sep 17 00:00:00 2001 From: klkhan Date: Sat, 14 Nov 2020 10:32:08 +0500 Subject: [PATCH 44/96] Docs: Renamed the directory to configuring-eslint Renamed the parent directory to remove the uppercase letters from the name. --- .../{configuring-ESLint => configuring-eslint}/ignoring-code.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/user-guide/{configuring-ESLint => configuring-eslint}/ignoring-code.md (100%) diff --git a/docs/user-guide/configuring-ESLint/ignoring-code.md b/docs/user-guide/configuring-eslint/ignoring-code.md similarity index 100% rename from docs/user-guide/configuring-ESLint/ignoring-code.md rename to docs/user-guide/configuring-eslint/ignoring-code.md From c757bee8b507849ef9351b46ca28d9d6ee15b736 Mon Sep 17 00:00:00 2001 From: klkhan Date: Sat, 14 Nov 2020 10:32:37 +0500 Subject: [PATCH 45/96] Docs: Renamed the directory to configuring-eslint Renamed the parent directory to remove the uppercase letters from the name. --- .../language-options.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/user-guide/{configuring-ESLint => configuring-eslint}/language-options.md (100%) diff --git a/docs/user-guide/configuring-ESLint/language-options.md b/docs/user-guide/configuring-eslint/language-options.md similarity index 100% rename from docs/user-guide/configuring-ESLint/language-options.md rename to docs/user-guide/configuring-eslint/language-options.md From 8c69df98bbcf745759dbb14dfe48dd7cadb08f39 Mon Sep 17 00:00:00 2001 From: klkhan Date: Sat, 14 Nov 2020 10:33:08 +0500 Subject: [PATCH 46/96] Docs: Renamed the directory to configuring-eslint Renamed the parent directory to remove the uppercase letters from the name. --- .../{configuring-ESLint => configuring-eslint}/plugins.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/user-guide/{configuring-ESLint => configuring-eslint}/plugins.md (100%) diff --git a/docs/user-guide/configuring-ESLint/plugins.md b/docs/user-guide/configuring-eslint/plugins.md similarity index 100% rename from docs/user-guide/configuring-ESLint/plugins.md rename to docs/user-guide/configuring-eslint/plugins.md From eade6b0a7cfbb08f5a8d2b8145f978409bec2647 Mon Sep 17 00:00:00 2001 From: klkhan Date: Sat, 14 Nov 2020 10:33:34 +0500 Subject: [PATCH 47/96] Docs: Renamed the directory to configuring-eslint Renamed the parent directory to remove the uppercase letters from the name. --- .../{configuring-ESLint => configuring-eslint}/rules.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/user-guide/{configuring-ESLint => configuring-eslint}/rules.md (100%) diff --git a/docs/user-guide/configuring-ESLint/rules.md b/docs/user-guide/configuring-eslint/rules.md similarity index 100% rename from docs/user-guide/configuring-ESLint/rules.md rename to docs/user-guide/configuring-eslint/rules.md From 37fef903d952e33d6449097ed99c5aef5b1dc7d0 Mon Sep 17 00:00:00 2001 From: klkhan Date: Tue, 17 Nov 2020 14:29:10 +0500 Subject: [PATCH 48/96] Docs: Update README.md for configuring ESLint Updated the directory name by changing it from 'configuring-eslint' to 'configuring' to use the already-available directory. --- docs/user-guide/{configuring-eslint => configuring}/README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/user-guide/{configuring-eslint => configuring}/README.md (100%) diff --git a/docs/user-guide/configuring-eslint/README.md b/docs/user-guide/configuring/README.md similarity index 100% rename from docs/user-guide/configuring-eslint/README.md rename to docs/user-guide/configuring/README.md From 9d296e1bd8ffb2f57b169b13ff1e15453b5ad383 Mon Sep 17 00:00:00 2001 From: klkhan Date: Tue, 17 Nov 2020 14:30:12 +0500 Subject: [PATCH 49/96] Docs: Update configuration files Updated the directory name by changing it from 'configuring-eslint' to 'configuring' to use the already-available directory. --- .../{configuring-eslint => configuring}/configuration-files.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/user-guide/{configuring-eslint => configuring}/configuration-files.md (100%) diff --git a/docs/user-guide/configuring-eslint/configuration-files.md b/docs/user-guide/configuring/configuration-files.md similarity index 100% rename from docs/user-guide/configuring-eslint/configuration-files.md rename to docs/user-guide/configuring/configuration-files.md From 7f3eec5faaa0569dbbe9675b859440f7029d1ad4 Mon Sep 17 00:00:00 2001 From: klkhan Date: Tue, 17 Nov 2020 14:30:56 +0500 Subject: [PATCH 50/96] Docs: Update ignoring-code.md Updated the directory name by changing it from 'configuring-eslint' to 'configuring' to use the already-available directory. --- .../{configuring-eslint => configuring}/ignoring-code.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/user-guide/{configuring-eslint => configuring}/ignoring-code.md (100%) diff --git a/docs/user-guide/configuring-eslint/ignoring-code.md b/docs/user-guide/configuring/ignoring-code.md similarity index 100% rename from docs/user-guide/configuring-eslint/ignoring-code.md rename to docs/user-guide/configuring/ignoring-code.md From 162535b7eb1e8c1e7716f8fdef3b7056228064dd Mon Sep 17 00:00:00 2001 From: klkhan Date: Tue, 17 Nov 2020 14:31:32 +0500 Subject: [PATCH 51/96] Docs: Update language-options.md Updated the directory name by changing it from 'configuring-eslint' to 'configuring' to use the already-available directory. --- .../{configuring-eslint => configuring}/language-options.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/user-guide/{configuring-eslint => configuring}/language-options.md (100%) diff --git a/docs/user-guide/configuring-eslint/language-options.md b/docs/user-guide/configuring/language-options.md similarity index 100% rename from docs/user-guide/configuring-eslint/language-options.md rename to docs/user-guide/configuring/language-options.md From 2bcaac22dec318812ef1096090ade023ae6787bc Mon Sep 17 00:00:00 2001 From: klkhan Date: Tue, 17 Nov 2020 14:32:10 +0500 Subject: [PATCH 52/96] Docs: Update plugins.md Updated the directory name by changing it from 'configuring-eslint' to 'configuring' to use the already-available directory. --- docs/user-guide/{configuring-eslint => configuring}/plugins.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/user-guide/{configuring-eslint => configuring}/plugins.md (100%) diff --git a/docs/user-guide/configuring-eslint/plugins.md b/docs/user-guide/configuring/plugins.md similarity index 100% rename from docs/user-guide/configuring-eslint/plugins.md rename to docs/user-guide/configuring/plugins.md From 84e409b3bff9fd8963754ca5ee085398a0223444 Mon Sep 17 00:00:00 2001 From: klkhan Date: Tue, 17 Nov 2020 14:32:40 +0500 Subject: [PATCH 53/96] Docs: Update rules.md Updated the directory name by changing it from 'configuring-eslint' to 'configuring' to use the already-available directory. --- docs/user-guide/{configuring-eslint => configuring}/rules.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/user-guide/{configuring-eslint => configuring}/rules.md (100%) diff --git a/docs/user-guide/configuring-eslint/rules.md b/docs/user-guide/configuring/rules.md similarity index 100% rename from docs/user-guide/configuring-eslint/rules.md rename to docs/user-guide/configuring/rules.md From 65d14a64357c19e759849ca4a7f808064eda9aa3 Mon Sep 17 00:00:00 2001 From: klkhan Date: Wed, 18 Nov 2020 10:50:00 +0500 Subject: [PATCH 54/96] Docs: Update docs/user-guide/configuring/README.md Accepted a suggestion on the README.md file. Co-authored-by: Nicholas C. Zakas --- docs/user-guide/configuring/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/README.md b/docs/user-guide/configuring/README.md index 7e6229b0a80..2ad82d37dc1 100644 --- a/docs/user-guide/configuring/README.md +++ b/docs/user-guide/configuring/README.md @@ -5,7 +5,7 @@ ESLint is designed to be completely configurable. You can turn off every rule an 1. **Configuration Comments** - use JavaScript comments to embed configuration information directly into a file. 1. **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.*`](./configuring-files#configuration-file-formats) file or an `eslintConfig` field in a [`package.json`](https://docs.npmjs.com/files/package.json) file, both of which ESLint will look for and read automatically, or you can specify a configuration file on the [command line](https://eslint.org/docs/user-guide/command-line-interface). -Following are some of the important pieces of information that you can configure in ESLint: +Here are some of the options that you can configure in ESLint: * [**Environments**](./language-options.md#specifying-environments) - which environments your script is designed to run in. Each environment brings with it a certain set of predefined global variables. * [**Globals**](./language-options.md#specifying-globals) - the additional global variables your script accesses during execution. From 6fe34887dfbe3e413297eb530abc48f93b2203cb Mon Sep 17 00:00:00 2001 From: klkhan Date: Wed, 18 Nov 2020 10:52:02 +0500 Subject: [PATCH 55/96] Docs: Update docs/user-guide/configuring/README.md Accepted a suggested change in the README.md file. Co-authored-by: Nicholas C. Zakas --- docs/user-guide/configuring/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/README.md b/docs/user-guide/configuring/README.md index 2ad82d37dc1..3909a48c3c7 100644 --- a/docs/user-guide/configuring/README.md +++ b/docs/user-guide/configuring/README.md @@ -10,7 +10,7 @@ Here are some of the options that you can configure in ESLint: * [**Environments**](./language-options.md#specifying-environments) - which environments your script is designed to run in. Each environment brings with it a certain set of predefined global variables. * [**Globals**](./language-options.md#specifying-globals) - the additional global variables your script accesses during execution. * [**Rules**](rules.md) - which rules are enabled and at what error level. -* [**Plugins**](plugins.md) - the use of third-party plugins in ESLint. +* [**Plugins**](plugins.md) - which third-party plugins define additional rules, environments, configs, etc. for ESLint to use. All of these options give you fine-grained control over how ESLint treats your code. From 249f0f325e79237bd4d686ab361f9453a0b86777 Mon Sep 17 00:00:00 2001 From: klkhan Date: Wed, 18 Nov 2020 10:56:30 +0500 Subject: [PATCH 56/96] Docs: Update docs/user-guide/configuring/configuration-files.md Accepted a suggested change to configuration-files.md Co-authored-by: Nicholas C. Zakas --- docs/user-guide/configuring/configuration-files.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/configuration-files.md b/docs/user-guide/configuring/configuration-files.md index f23b6f99252..4ee7f1fd288 100644 --- a/docs/user-guide/configuring/configuration-files.md +++ b/docs/user-guide/configuring/configuration-files.md @@ -35,7 +35,7 @@ There are two ways to use configuration files. The first way to use configuration files is via `.eslintrc.*` and `package.json` files. ESLint will automatically look for them in the directory of the file to be linted, and in successive parent directories all the way up to the root directory of the filesystem (unless `root: true` is specified). This option is useful when you want different configurations for different parts of a project or when you want others to be able to use ESLint directly without needing to remember to pass in the configuration file. -The second is to save the file wherever you would like and pass its location to the CLI using the `-c` option, such as: +The second way to use configuration files is to save the file wherever you would like and pass its location to the CLI using the `-c` option, such as: eslint -c myconfig.json myfiletotest.js From b1a158b24ffbedcdc9a5f32a7fee1e74cff77550 Mon Sep 17 00:00:00 2001 From: klkhan Date: Wed, 18 Nov 2020 10:57:47 +0500 Subject: [PATCH 57/96] Docs: Update docs/user-guide/configuring/configuration-files.md Accepted a suggesetd change to configuration-files.md Co-authored-by: Nicholas C. Zakas --- docs/user-guide/configuring/configuration-files.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/configuration-files.md b/docs/user-guide/configuring/configuration-files.md index 4ee7f1fd288..59bcfbb751c 100644 --- a/docs/user-guide/configuring/configuration-files.md +++ b/docs/user-guide/configuring/configuration-files.md @@ -379,7 +379,7 @@ If you specified the [`--ext`](https://eslint.org/docs/user-guide/command-line-i `~/` refers to [the home directory of the current user on your preferred operating system](https://nodejs.org/api/os.html#os_os_homedir). The personal configuration file being referred to here is `~/.eslintrc.*` file, which is currently handled differently than other configuration files. -### How does ESLint find personal configuration files +### How does ESLint find personal configuration files? If `eslint` could not find any configuration file in the project, `eslint` loads `~/.eslintrc.*` file. From c00f183fa0aaf7421a3340d5752bdd1684af49e9 Mon Sep 17 00:00:00 2001 From: klkhan Date: Wed, 18 Nov 2020 11:01:42 +0500 Subject: [PATCH 58/96] Docs: Update docs/user-guide/configuring/configuration-files.md Accepted a suggested change to configuration-files.md Co-authored-by: Nicholas C. Zakas --- docs/user-guide/configuring/configuration-files.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/configuration-files.md b/docs/user-guide/configuring/configuration-files.md index 59bcfbb751c..e66d9a0dcad 100644 --- a/docs/user-guide/configuring/configuration-files.md +++ b/docs/user-guide/configuring/configuration-files.md @@ -161,7 +161,7 @@ A configuration file can extend the set of enabled rules from base configuration The `extends` property value is either: * a string that specifies a configuration (either a path to a config file, the name of a shareable config, `eslint:recommended`, or `eslint:all`) -* an array of strings: each additional configuration extends the preceding configurations +* an array of strings where each additional configuration extends the preceding configurations ESLint extends configurations recursively, so a base configuration can also have an `extends` property. Relative paths and shareable config names in an `extends` property are resolved from the location of the config file where they appear. From 1c2accfefd10a95faa247f8b5b3fb190dae8309c Mon Sep 17 00:00:00 2001 From: klkhan Date: Wed, 18 Nov 2020 11:04:01 +0500 Subject: [PATCH 59/96] Docs: Update docs/user-guide/configuring/configuration-files.md Accepted a suggested change to configuration-files.md Co-authored-by: Nicholas C. Zakas --- docs/user-guide/configuring/configuration-files.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/configuration-files.md b/docs/user-guide/configuring/configuration-files.md index e66d9a0dcad..2e6305cfa31 100644 --- a/docs/user-guide/configuring/configuration-files.md +++ b/docs/user-guide/configuring/configuration-files.md @@ -179,7 +179,7 @@ The `rules` property can do any of the following to extend (or override) the set ### Using eslint-recommended -An `extends` property value `"eslint:recommended"` enables a subset of core rules that report common problems, which have a checkmark (recommended) on the [rules page](https://eslint.org/docs/rules/). The recommended subset can change only at major versions of ESLint. +Using `"eslint:recommended"` in the `extends` property enables a subset of core rules that report common problems (these rules are identified with a checkmark (recommended) on the [rules page](https://eslint.org/docs/rules/)). The `eslint:recommended` config only changes with major versions of ESLint. If your configuration extends the recommended rules: after you upgrade to a newer major version of ESLint, review the reported problems before you use the `--fix` option on the [command line]((https://eslint.org/docs/user-guide/command-line-interface)#fix), so you know if a new fixable recommended rule will make changes to the code. From 93eca30a122013dcb47186677c56e39d29dd3cca Mon Sep 17 00:00:00 2001 From: klkhan Date: Wed, 18 Nov 2020 11:11:19 +0500 Subject: [PATCH 60/96] Docs: Update docs/user-guide/configuring/configuration-files.md Accepted a suggested change to configuration-files.md Co-authored-by: Nicholas C. Zakas --- docs/user-guide/configuring/configuration-files.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/configuration-files.md b/docs/user-guide/configuring/configuration-files.md index 2e6305cfa31..ab96520d9e9 100644 --- a/docs/user-guide/configuring/configuration-files.md +++ b/docs/user-guide/configuring/configuration-files.md @@ -177,7 +177,7 @@ The `rules` property can do any of the following to extend (or override) the set * Derived config: `"quotes": ["error", "single"]` * Resulting actual config: `"quotes": ["error", "single"] -### Using eslint-recommended +### Using `eslint:recommended` Using `"eslint:recommended"` in the `extends` property enables a subset of core rules that report common problems (these rules are identified with a checkmark (recommended) on the [rules page](https://eslint.org/docs/rules/)). The `eslint:recommended` config only changes with major versions of ESLint. From dafbde2f8374e4d336fb2ddfa051f2a7072c5a09 Mon Sep 17 00:00:00 2001 From: klkhan Date: Wed, 18 Nov 2020 11:16:13 +0500 Subject: [PATCH 61/96] Docs: Update docs/user-guide/configuring/configuration-files.md Accepted a suggested change to configuration-files.md Co-authored-by: Nicholas C. Zakas --- docs/user-guide/configuring/configuration-files.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/configuration-files.md b/docs/user-guide/configuring/configuration-files.md index ab96520d9e9..f5f40a02d61 100644 --- a/docs/user-guide/configuring/configuration-files.md +++ b/docs/user-guide/configuring/configuration-files.md @@ -181,7 +181,7 @@ The `rules` property can do any of the following to extend (or override) the set Using `"eslint:recommended"` in the `extends` property enables a subset of core rules that report common problems (these rules are identified with a checkmark (recommended) on the [rules page](https://eslint.org/docs/rules/)). The `eslint:recommended` config only changes with major versions of ESLint. -If your configuration extends the recommended rules: after you upgrade to a newer major version of ESLint, review the reported problems before you use the `--fix` option on the [command line]((https://eslint.org/docs/user-guide/command-line-interface)#fix), so you know if a new fixable recommended rule will make changes to the code. +If your configuration extends the `eslint:recommended`, be sure to review the reported problems after upgrading to a new major version of ESLint before you use the `--fix` option on the [command line]((https://eslint.org/docs/user-guide/command-line-interface)#fix). Doing so ensures you'll be aware of the new changes ESLint might make to your code. The `eslint --init` command can create a configuration so you can extend the recommended rules. From 6765bfd51f68eeada196c6164bf6a3447b1b6770 Mon Sep 17 00:00:00 2001 From: klkhan Date: Wed, 18 Nov 2020 11:16:51 +0500 Subject: [PATCH 62/96] Docs: Update docs/user-guide/configuring/configuration-files.md Accepted a suggested change to configuration-files.md Co-authored-by: Nicholas C. Zakas --- docs/user-guide/configuring/configuration-files.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/configuration-files.md b/docs/user-guide/configuring/configuration-files.md index f5f40a02d61..ee8e732b139 100644 --- a/docs/user-guide/configuring/configuration-files.md +++ b/docs/user-guide/configuring/configuration-files.md @@ -385,7 +385,7 @@ If `eslint` could not find any configuration file in the project, `eslint` loads If `eslint` could find configuration files in the project, `eslint` ignores `~/.eslintrc.*` file even if it's in an ancestor directory of the project directory. -### How do personal configuration files behave +### How do personal configuration files behave? `~/.eslintrc.*` files behave similarly to regular configuration files, with some exceptions: From 1cb80a83233517b1e9d6a86f0169400d61ffa180 Mon Sep 17 00:00:00 2001 From: klkhan Date: Wed, 18 Nov 2020 11:17:39 +0500 Subject: [PATCH 63/96] Docs: Update docs/user-guide/configuring/configuration-files.md Accepted a suggested change to configuration-files.md Co-authored-by: Nicholas C. Zakas --- docs/user-guide/configuring/configuration-files.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/configuration-files.md b/docs/user-guide/configuring/configuration-files.md index ee8e732b139..df0cf96fcbc 100644 --- a/docs/user-guide/configuring/configuration-files.md +++ b/docs/user-guide/configuring/configuration-files.md @@ -285,7 +285,7 @@ If you configure ESLint to automatically enable new rules when you upgrade, ESLi You might enable all core rules as a shortcut to explore rules and options while you decide on the configuration for a project, especially if you rarely override options or disable rules. The default options for rules are not endorsements by ESLint (for example, the default option for the [`quotes`](https://eslint.org/docs/rules/quotes) rule does not mean double quotes are better than single quotes). -If your configuration extends all core rules: after you upgrade to a newer major or minor version of ESLint, review the reported problems before you use the `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fix), so you know if a new fixable rule will make changes to the code. +If your configuration extends `eslint:all`, after you upgrade to a newer major or minor version of ESLint, review the reported problems before you use the `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fix), so you know if a new fixable rule will make changes to the code. Example of a configuration file in JavaScript format: From 0128ceb2dfc953513253747ef6557b4f900563bc Mon Sep 17 00:00:00 2001 From: klkhan Date: Wed, 18 Nov 2020 11:19:47 +0500 Subject: [PATCH 64/96] Docs: Update docs/user-guide/configuring/configuration-files.md Accepted a suggested change to configuration-files.md Co-authored-by: Nicholas C. Zakas --- docs/user-guide/configuring/configuration-files.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/configuration-files.md b/docs/user-guide/configuring/configuration-files.md index df0cf96fcbc..7673b266aa5 100644 --- a/docs/user-guide/configuring/configuration-files.md +++ b/docs/user-guide/configuring/configuration-files.md @@ -226,7 +226,7 @@ rules: no-empty: warn ``` -### Using the configuration from a plugin +### Using a configuration from a plugin A [plugin](https://eslint.org/docs/developer-guide/working-with-plugins) is an npm package that usually exports rules. Some plugins also export one or more named [configurations](https://eslint.org/docs/developer-guide/working-with-plugins#configs-in-plugins). Make sure the package has been installed in a directory where ESLint can require it. From 0ced1609619359dcbaa52f40701f5b59267df871 Mon Sep 17 00:00:00 2001 From: klkhan Date: Wed, 18 Nov 2020 11:21:32 +0500 Subject: [PATCH 65/96] Docs: Update docs/user-guide/configuring/configuration-files.md Accepted a suggested change to configuration-files.md Co-authored-by: Nicholas C. Zakas --- docs/user-guide/configuring/configuration-files.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/configuration-files.md b/docs/user-guide/configuring/configuration-files.md index 7673b266aa5..56f96324024 100644 --- a/docs/user-guide/configuring/configuration-files.md +++ b/docs/user-guide/configuring/configuration-files.md @@ -183,7 +183,7 @@ Using `"eslint:recommended"` in the `extends` property enables a subset of core If your configuration extends the `eslint:recommended`, be sure to review the reported problems after upgrading to a new major version of ESLint before you use the `--fix` option on the [command line]((https://eslint.org/docs/user-guide/command-line-interface)#fix). Doing so ensures you'll be aware of the new changes ESLint might make to your code. -The `eslint --init` command can create a configuration so you can extend the recommended rules. +Here's an example of extending `eslint:recommended` to override some of the default options: Example of a configuration file in JavaScript format: From 5b97d1564f24a6ff35632acaf2e0dae27808b8ac Mon Sep 17 00:00:00 2001 From: klkhan Date: Wed, 18 Nov 2020 11:56:52 +0500 Subject: [PATCH 66/96] Docs: Update configuration-files.md Accepted two suggested changes to configuration-files.md --- docs/user-guide/configuring/configuration-files.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/configuration-files.md b/docs/user-guide/configuring/configuration-files.md index 56f96324024..23f1eb2a734 100644 --- a/docs/user-guide/configuring/configuration-files.md +++ b/docs/user-guide/configuring/configuration-files.md @@ -80,6 +80,7 @@ And in YAML: --- settings: sharedData: "Hello" +``` ## Cascading and Hierarchy @@ -313,7 +314,7 @@ module.exports = { v4.1.0+. Sometimes a more fine-controlled configuration is necessary, for example, if the configuration for files within the same directory has to be different. Therefore you can provide configurations under the `overrides` key that will only apply to files that match specific glob patterns, using the same format you would pass on the command line (e.g., `app/**/*.test.js`). -### How does it work +### How do overrides work? * The patterns are applied against the file path relative to the directory of the config file. For example, if your config file has the path `/Users/john/workspace/any-project/.eslintrc.js` and the file you want to lint has the path `/Users/john/workspace/any-project/lib/util.js`, then the pattern provided in `.eslintrc.js` will be executed against the relative path `lib/util.js`. * Glob pattern overrides have higher precedence than the regular configuration in the same config file. Multiple overrides within the same config are applied in order. That is, the last override block in a config file always has the highest precedence. From f0004ced1f71a53bd8c44819755abe643087a17e Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 19 Nov 2020 11:22:17 +0500 Subject: [PATCH 67/96] Docs: Update configuration-files.md Removed the names of deprecated files (.eslintrc), using '.eslintrc.json' instead. --- docs/user-guide/configuring/configuration-files.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/docs/user-guide/configuring/configuration-files.md b/docs/user-guide/configuring/configuration-files.md index 23f1eb2a734..aa6b80039dc 100644 --- a/docs/user-guide/configuring/configuration-files.md +++ b/docs/user-guide/configuring/configuration-files.md @@ -16,7 +16,6 @@ ESLint supports configuration files in several formats: * **JavaScript (ESM)** - use `.eslintrc.cjs` when running ESLint in JavaScript packages that specify `"type":"module"` in their `package.json`. Note that ESLint does not support ESM configuration at this time. * **YAML** - use `.eslintrc.yaml` or `.eslintrc.yml` to define the configuration structure. * **JSON** - use `.eslintrc.json` to define the configuration structure. ESLint's JSON files also allow JavaScript-style comments. -* **Deprecated** - use `.eslintrc`, which can be either JSON or YAML. * **package.json** - create an `eslintConfig` property in your `package.json` file and define your configuration there. If there are multiple configuration files in the same directory, ESLint will only use one. The priority order is as follows: @@ -26,7 +25,6 @@ If there are multiple configuration files in the same directory, ESLint will onl 1. `.eslintrc.yaml` 1. `.eslintrc.yml` 1. `.eslintrc.json` -1. `.eslintrc` 1. `package.json` ## Using Configuration Files @@ -88,11 +86,11 @@ When using `.eslintrc.*` and `package.json` files for configuration, you can tak ```text your-project -├── .eslintrc +├── .eslintrc.json ├── lib │ └── source.js └─┬ tests - ├── .eslintrc + ├── .eslintrc.json └── test.js ``` @@ -106,7 +104,7 @@ your-project ├── lib │ └── source.js └─┬ tests - ├── .eslintrc + ├── .eslintrc.json └── test.js ``` @@ -133,9 +131,9 @@ For example, consider `projectA` which has `"root": true` set in the `.eslintrc` home └── user └── projectA - ├── .eslintrc <- Not used + ├── .eslintrc.json <- Not used └── lib - ├── .eslintrc <- { "root": true } + ├── .eslintrc.json <- { "root": true } └── main.js ``` From 579f48e5806a3d72e7503c43dfdf407d028d8cd0 Mon Sep 17 00:00:00 2001 From: klkhan Date: Wed, 25 Nov 2020 20:08:01 +0500 Subject: [PATCH 68/96] Docs: Update docs/user-guide/configuring/README.md Accepted a suggestion to improve the README.md file Co-authored-by: Kai Cataldo --- docs/user-guide/configuring/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/README.md b/docs/user-guide/configuring/README.md index 3909a48c3c7..7fda775a984 100644 --- a/docs/user-guide/configuring/README.md +++ b/docs/user-guide/configuring/README.md @@ -1,6 +1,6 @@ # Configuring ESLint -ESLint is designed to be completely configurable. 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 make ESLint perfect for your project. There are two primary ways to configure 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. **Configuration Comments** - use JavaScript comments to embed configuration information directly into a file. 1. **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.*`](./configuring-files#configuration-file-formats) file or an `eslintConfig` field in a [`package.json`](https://docs.npmjs.com/files/package.json) file, both of which ESLint will look for and read automatically, or you can specify a configuration file on the [command line](https://eslint.org/docs/user-guide/command-line-interface). From ce36fc2ea3113f1d49386e36e5c8e260a841c929 Mon Sep 17 00:00:00 2001 From: klkhan Date: Wed, 25 Nov 2020 20:40:17 +0500 Subject: [PATCH 69/96] Docs: Update configuration-files.md Accepted suggestions made to the configuration-files.md file in ESLint Configuration documentation. --- .../configuring/configuration-files.md | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/docs/user-guide/configuring/configuration-files.md b/docs/user-guide/configuring/configuration-files.md index aa6b80039dc..9616b3e08e6 100644 --- a/docs/user-guide/configuring/configuration-files.md +++ b/docs/user-guide/configuring/configuration-files.md @@ -37,9 +37,7 @@ The second way to use configuration files is to save the file wherever you would eslint -c myconfig.json myfiletotest.js -If you are using one configuration file and want ESLint to ignore any `.eslintrc.*` files, make sure to use `--no-eslintrc` along with the `-c` flag. - -In each case, the settings in the configuration file override default settings. +If you are using one configuration file and want ESLint to ignore any `.eslintrc.*` files, make sure to use [`--no-eslintrc`] (https://eslint.org/docs/user-guide/command-line-interface#-no-eslintrc) along with the [`-c`] (https://eslint.org/docs/user-guide/command-line-interface#-c-config) flag. ### Comments in configuration files @@ -96,7 +94,7 @@ your-project The configuration cascade works by using the closest `.eslintrc` file to the file being linted as the highest priority, then any configuration files in the parent directory, and so on. When you run ESLint on this project, all files in `lib/` will use the `.eslintrc` file at the root of the project as their configuration. When ESLint traverses into the `tests/` directory, it will then use `your-project/tests/.eslintrc` in addition to `your-project/.eslintrc`. So `your-project/tests/test.js` is linted based on the combination of the two `.eslintrc` files in its directory hierarchy, with the closest one taking priority. In this way, you can have project-level ESLint settings and also have directory-specific overrides. -In the same way, if there is a `package.json` file in the root directory with an `eslintConfig` field, the configuration it describes will apply to all subdirectories beneath it, but the configuration described by the `.eslintrc` file in the tests directory will override it where there are conflicting specifications. +In the same way, if there is a `package.json` file in the root directory with an `eslintConfig` field, the configuration it describes will apply to all subdirectories beneath it, but the configuration described by the `.eslintrc` file in the `tests/` directory will override it where there are conflicting specifications. ```text your-project @@ -108,9 +106,9 @@ your-project └── test.js ``` -If there is an `.eslintrc` and a `package.json` file found in the same directory, `.eslintrc` will take a priority and `package.json` file will not be used. +If there is an `.eslintrc` and a `package.json` file found in the same directory, `.eslintrc` will take priority and `package.json` file will not be used. -By default, ESLint will look for configuration files in all parent folders up to the root directory. This can be useful if you want all of your projects to follow a certain convention, but can sometimes lead to unexpected results. To limit ESLint to a specific project, place `"root": true` inside the `eslintConfig` field of the `package.json` file or in the `.eslintrc.*` file at your project's root level. ESLint will stop looking in parent folders once it finds a configuration with `"root": true`. +By default, ESLint will look for configuration files in all parent folders up to the root directory. This can be useful if you want all of your projects to follow a certain convention, but can sometimes lead to unexpected results. To limit ESLint to a specific project, place `"root": true` inside the `.eslintrc.*` file or `eslintConfig` field of the `package.json` file or in the `.eslintrc.*` file at your project's root level. ESLint will stop looking in parent folders once it finds a configuration with `"root": true`. ```js { @@ -137,7 +135,7 @@ home └── main.js ``` -The complete configuration hierarchy, from highest precedence to lowest precedence, is as follows: +The complete configuration hierarchy, from highest to lowest precedence, is as follows: 1. Inline configuration 1. `/*eslint-disable*/` and `/*eslint-enable*/` @@ -150,8 +148,8 @@ The complete configuration hierarchy, from highest precedence to lowest preceden 1. `--env` 1. `-c`, `--config` 1. Project-level configuration: - 1. `.eslintrc.*` or `package.json` file in the same directory as linted file - 1. Continue searching for `.eslintrc` and `package.json` files in ancestor directories (parent has the highest precedence, then grandparent, etc.), up to and including the root directory or until a config with `"root": true` is found. + 1. `.eslintrc.*` or `package.json` file in the same directory as the linted file + 1. Continue searching for `.eslintrc.*` and `package.json` files in ancestor directories up to and including the root directory or until a config with `"root": true` is found. ## Extending Configuration Files @@ -178,11 +176,11 @@ The `rules` property can do any of the following to extend (or override) the set ### Using `eslint:recommended` -Using `"eslint:recommended"` in the `extends` property enables a subset of core rules that report common problems (these rules are identified with a checkmark (recommended) on the [rules page](https://eslint.org/docs/rules/)). The `eslint:recommended` config only changes with major versions of ESLint. +Using `"eslint:recommended"` in the `extends` property enables a subset of core rules that report common problems (these rules are identified with a checkmark (recommended) on the [rules page](https://eslint.org/docs/rules/)). If your configuration extends the `eslint:recommended`, be sure to review the reported problems after upgrading to a new major version of ESLint before you use the `--fix` option on the [command line]((https://eslint.org/docs/user-guide/command-line-interface)#fix). Doing so ensures you'll be aware of the new changes ESLint might make to your code. -Here's an example of extending `eslint:recommended` to override some of the default options: +Here's an example of extending `eslint:recommended` and overriding some of the set configuration options: Example of a configuration file in JavaScript format: @@ -196,7 +194,7 @@ module.exports = { "quotes": ["error", "double"], "semi": ["error", "always"], - // override default options for rules from base configurations + // override configuration set by extending "eslint:recommended" "comma-dangle": ["error", "always"], "no-cond-assign": ["error", "always"], From dc2f7693f6186d6ed602e072b4685c572c572264 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 26 Nov 2020 19:59:39 +0500 Subject: [PATCH 70/96] Docs: Update configuration-files.md Accepted a suggestion to edit configuration-files.md --- docs/user-guide/configuring/configuration-files.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/user-guide/configuring/configuration-files.md b/docs/user-guide/configuring/configuration-files.md index 9616b3e08e6..0eeda8e62ff 100644 --- a/docs/user-guide/configuring/configuration-files.md +++ b/docs/user-guide/configuring/configuration-files.md @@ -195,11 +195,11 @@ module.exports = { "semi": ["error", "always"], // override configuration set by extending "eslint:recommended" - "comma-dangle": ["error", "always"], + "for-direction": "off", "no-cond-assign": ["error", "always"], // disable rules from base configurations - "no-console": "off", + "for-direction": "off", } } ``` From caabbf67ddcacf8ec2391ca4f1797eaf4e8d3be4 Mon Sep 17 00:00:00 2001 From: klkhan Date: Sat, 28 Nov 2020 11:18:55 +0500 Subject: [PATCH 71/96] Docs: Update configuration-files.md Accepted suggestions made to the configuration-files. md file in ESLint COnfiguration Documentation. --- .../configuring/configuration-files.md | 73 +++++++++++-------- 1 file changed, 43 insertions(+), 30 deletions(-) diff --git a/docs/user-guide/configuring/configuration-files.md b/docs/user-guide/configuring/configuration-files.md index 0eeda8e62ff..4c4a16a06d3 100644 --- a/docs/user-guide/configuring/configuration-files.md +++ b/docs/user-guide/configuring/configuration-files.md @@ -31,7 +31,7 @@ If there are multiple configuration files in the same directory, ESLint will onl There are two ways to use configuration files. -The first way to use configuration files is via `.eslintrc.*` and `package.json` files. ESLint will automatically look for them in the directory of the file to be linted, and in successive parent directories all the way up to the root directory of the filesystem (unless `root: true` is specified). This option is useful when you want different configurations for different parts of a project or when you want others to be able to use ESLint directly without needing to remember to pass in the configuration file. +The first way to use configuration files is via `.eslintrc.*` and `package.json` files. ESLint will automatically look for them in the directory of the file to be linted, and in successive parent directories all the way up to the root directory of the filesystem (unless `root: true` is specified). Configuration files can be useful when you want different configurations for different parts of a project or when you want others to be able to use ESLint directly without needing to remember to pass in the configuration file. The second way to use configuration files is to save the file wherever you would like and pass its location to the CLI using the `-c` option, such as: @@ -41,7 +41,9 @@ If you are using one configuration file and want ESLint to ignore any `.eslintrc ### Comments in configuration files -Both the JSON and YAML configuration file formats support comments (`package.json` files should not include them). You can use JavaScript-style comments or YAML-style comments in either type of file and ESLint will safely ignore them. This allows your configuration files to be more human-friendly. For example: +Both the JSON and YAML configuration file formats support comments (package.json files should not include them). You can use JavaScript-style comments for JSON files and YAML-style comments for YAML files. ESLint safely ignores comments in configuration files. This allows your configuration files to be more human-friendly. + +For JavaScript-style comments: ```js { @@ -56,9 +58,20 @@ Both the JSON and YAML configuration file formats support comments (`package.jso } ``` +For YAML-style comments: + +```yaml +env: + browser: true +rules: + # Override default settings + eqeqeq: warn + strict: off +``` + ## Adding Shared Settings -ESLint supports adding shared settings into configuration files. You can add `settings` object to ESLint configuration file and it will be supplied to every rule being executed. This may be useful if you are adding custom rules and want them to have access to the same information and be easily configurable. +ESLint supports adding shared settings into configuration files. Plugins use `settings` to specify information that should be shared across all of its rules. You can add `settings` object to ESLint configuration file and it will be supplied to every rule being executed. This may be useful if you are adding custom rules and want them to have access to the same information and be easily configurable. In JSON: @@ -153,7 +166,7 @@ The complete configuration hierarchy, from highest to lowest precedence, is as f ## Extending Configuration Files -A configuration file can extend the set of enabled rules from base configurations. +A configuration file, once extended, can inherit all the traits of another configuration file (including rules, plugins, and language options) and modify all the options. The `extends` property value is either: @@ -178,8 +191,6 @@ The `rules` property can do any of the following to extend (or override) the set Using `"eslint:recommended"` in the `extends` property enables a subset of core rules that report common problems (these rules are identified with a checkmark (recommended) on the [rules page](https://eslint.org/docs/rules/)). -If your configuration extends the `eslint:recommended`, be sure to review the reported problems after upgrading to a new major version of ESLint before you use the `--fix` option on the [command line]((https://eslint.org/docs/user-guide/command-line-interface)#fix). Doing so ensures you'll be aware of the new changes ESLint might make to your code. - Here's an example of extending `eslint:recommended` and overriding some of the set configuration options: Example of a configuration file in JavaScript format: @@ -206,7 +217,7 @@ module.exports = { ### Using a shareable configuration package -A [sharable configuration](https://eslint.org/docs/developer-guide/shareable-configs) is an npm package that exports a configuration object. Make sure the package has been installed to a directory where ESLint can require it. +A [sharable configuration](https://eslint.org/docs/developer-guide/shareable-configs) is an npm package that exports a configuration object. Make sure that you have installed the package in your project root directory, so that ESLint can require it. The `extends` property value can omit the `eslint-config-` prefix of the package name. @@ -225,7 +236,7 @@ rules: ### Using a configuration from a plugin -A [plugin](https://eslint.org/docs/developer-guide/working-with-plugins) is an npm package that usually exports rules. Some plugins also export one or more named [configurations](https://eslint.org/docs/developer-guide/working-with-plugins#configs-in-plugins). Make sure the package has been installed in a directory where ESLint can require it. +A [plugin](https://eslint.org/docs/developer-guide/working-with-plugins) is an npm package that can add various extensions to ESLint. A plugin can perform numerous functions, including but not limited to the export of rules and [configurations](https://eslint.org/docs/developer-guide/working-with-plugins#configs-in-plugins). Make sure the package has been installed in a directory where ESLint can require it. The `plugins` [property value](./plugins.md#configuring-plugins) can omit the `eslint-plugin-` prefix of the package name. @@ -312,6 +323,30 @@ module.exports = { ### How do overrides work? +It is possible to override settings based on file glob patterns in your configuration by using the `overrides` key. An example of using the `overrides` key is as follows: + +In your `.eslintrc.json`: + +```json +{ + "rules": { + "quotes": ["error", "double"] + }, + + "overrides": [ + { + "files": ["bin/*.js", "lib/*.js"], + "excludedFiles": "*.test.js", + "rules": { + "quotes": ["error", "single"] + } + } + ] +} +``` + +Here is how overrides work in a configuration file: + * The patterns are applied against the file path relative to the directory of the config file. For example, if your config file has the path `/Users/john/workspace/any-project/.eslintrc.js` and the file you want to lint has the path `/Users/john/workspace/any-project/lib/util.js`, then the pattern provided in `.eslintrc.js` will be executed against the relative path `lib/util.js`. * Glob pattern overrides have higher precedence than the regular configuration in the same config file. Multiple overrides within the same config are applied in order. That is, the last override block in a config file always has the highest precedence. * A glob specific configuration works almost the same as any other ESLint config. Override blocks can contain any configuration options that are valid in a regular config, with the exception of `root` and `ignorePatterns`. @@ -342,28 +377,6 @@ The config in `app/.eslintrc.json` defines the glob pattern `**/*Spec.js`. This If a config is provided via the `--config` CLI option, the glob patterns in the config are relative to the current working directory rather than the base directory of the given config. For example, if `--config configs/.eslintrc.json` is present, the glob patterns in the config are relative to `.` rather than `./configs`. -### Example configuration - -In your `.eslintrc.json`: - -```json -{ - "rules": { - "quotes": ["error", "double"] - }, - - "overrides": [ - { - "files": ["bin/*.js", "lib/*.js"], - "excludedFiles": "*.test.js", - "rules": { - "quotes": ["error", "single"] - } - } - ] -} -``` - ### Specifying target files to lint If you specified directories with CLI (e.g., `eslint lib`), ESLint searches target files in the directory to lint. The target files are `*.js` or the files that match any of `overrides` entries (but exclude entries that are any of `files` end with `*`). From 481b51d09f134b6ec35bbde75ee81cbb39e8e24f Mon Sep 17 00:00:00 2001 From: klkhan Date: Sat, 28 Nov 2020 11:29:01 +0500 Subject: [PATCH 72/96] Docs: Update docs/user-guide/configuring/rules.md Accepted a suggestion to rules. md file. Co-authored-by: Nicholas C. Zakas --- docs/user-guide/configuring/rules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/rules.md b/docs/user-guide/configuring/rules.md index 7bd24373bf9..19beeb98406 100644 --- a/docs/user-guide/configuring/rules.md +++ b/docs/user-guide/configuring/rules.md @@ -6,7 +6,7 @@ ## Configuring Rules -ESLint comes with a large number of rules. You can modify which rules your project uses either using configuration comments or configuration files. To change a rule setting, you must set the rule ID equal to one of these values: +ESLint comes with a large number of built-in rules and you can add more rules through plugins. You can modify which rules your project uses either using configuration comments or configuration files. To change a rule setting, you must set the rule ID equal to one of these values: * `"off"` or `0` - turn the rule off * `"warn"` or `1` - turn the rule on as a warning (doesn't affect exit code) From 6c0667f2c00a43f9780b0823310c901a9708ed26 Mon Sep 17 00:00:00 2001 From: klkhan Date: Sat, 28 Nov 2020 11:29:42 +0500 Subject: [PATCH 73/96] Docs: Update docs/user-guide/configuring/plugins.md Accepted a suggestion to plugins.md file. Co-authored-by: Nicholas C. Zakas --- docs/user-guide/configuring/plugins.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/plugins.md b/docs/user-guide/configuring/plugins.md index c4dc1e9ce7b..25cf3dafc17 100644 --- a/docs/user-guide/configuring/plugins.md +++ b/docs/user-guide/configuring/plugins.md @@ -9,7 +9,7 @@ By default, ESLint uses [Espree](https://github.com/eslint/espree) as its parser. You can optionally specify that a different parser should be used in your configuration file so long as the parser meets the following requirements: -1. It must be a Node module loadable from the config file where it appears. Usually, this means you should install the parser package separately using npm. +1. It must be a Node module loadable from the config file where the parser is used. Usually, this means you should install the parser package separately using npm. 1. It must conform to the [parser interface](https://eslint.org/docs/developer-guide/working-with-custom-parsers). Note that even with these compatibilities, there are no guarantees that an external parser will work correctly with ESLint and ESLint will not fix bugs related to incompatibilities with other parsers. From 0bd43151b7eca6318db4aeee0ee4dd0b28ad4806 Mon Sep 17 00:00:00 2001 From: klkhan Date: Sat, 28 Nov 2020 11:45:21 +0500 Subject: [PATCH 74/96] Docs: Update docs/user-guide/configuring/language-options.md Accepted a suggestion to language-options.md file. Co-authored-by: Nicholas C. Zakas --- docs/user-guide/configuring/language-options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/language-options.md b/docs/user-guide/configuring/language-options.md index 5e1a1ff9f9a..a51ceb9cf44 100644 --- a/docs/user-guide/configuring/language-options.md +++ b/docs/user-guide/configuring/language-options.md @@ -7,7 +7,7 @@ ## Specifying Environments -An environment defines global variables that are predefined. The available environments are: +An environment provides predefined global variables. The available environments are: * `browser` - browser global variables. * `node` - Node.js global variables and Node.js scoping. From b876d72020e8c88a5f82b9c31503c898d6dea85b Mon Sep 17 00:00:00 2001 From: klkhan Date: Sat, 28 Nov 2020 11:58:31 +0500 Subject: [PATCH 75/96] Docs: Update README.md Updated the Table of Content to change the name of a heading from "eslintignore" to "The eslintignore File" --- docs/user-guide/configuring/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/user-guide/configuring/README.md b/docs/user-guide/configuring/README.md index 7fda775a984..4e5982ba196 100644 --- a/docs/user-guide/configuring/README.md +++ b/docs/user-guide/configuring/README.md @@ -45,8 +45,8 @@ All of these options give you fine-grained control over how ESLint treats your c [**Ignoring Code**](ignoring-code.md) -* [`ignorePatterns` in config files](./ignoring-code.md#ignorepatterns-in-config-files) -* [`.eslintignore`](./ignoring-code.md#eslintignore) +* [`ignorePatterns` in Config Files](./ignoring-code.md#ignorepatterns-in-config-files) +* [The `.eslintignore` File](./ignoring-code.md#the-eslintignore-file) * [Using an Alternate File](./ignoring-code.md#using-an-alternate-file) * [Using eslintIgnore in package.json](./ignoring-code.md#using-eslintignore-in-package.json) * [Ignored File Warnings](./ignoring-code.md#ignored-file-warnings) From c0740aea6a510069c04d86c54d70160a7e00641f Mon Sep 17 00:00:00 2001 From: klkhan Date: Sat, 28 Nov 2020 12:08:19 +0500 Subject: [PATCH 76/96] Docs: Update ingoring-code.md Accepted suggestions to the ignoring-code.md file. --- docs/user-guide/configuring/ignoring-code.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/user-guide/configuring/ignoring-code.md b/docs/user-guide/configuring/ignoring-code.md index 70852c203b2..c94b96cb64b 100644 --- a/docs/user-guide/configuring/ignoring-code.md +++ b/docs/user-guide/configuring/ignoring-code.md @@ -1,16 +1,16 @@ # Ignoring Code -* [`ignorePatterns` in config files](#ignorepatterns-in-config-files) -* [`.eslintignore`](#eslintignore) +* [`ignorePatterns` in Config Files](#ignorepatterns-in-config-files) +* [The `.eslintignore` File](#the-eslintignore-file) * [Using an Alternate File](#using-an-alternate-file) * [Using eslintIgnore in package.json](#using-eslintignore-in-packagejson) * [Ignored File Warnings](#ignored-file-warnings) * [Disabling Inline Comments](#disabling-inline-comments) -## `ignorePatterns` in config files +## `ignorePatterns` in Config Files -You can tell ESLint to ignore specific files and directories by `ignorePatterns` in your config files. Each value of `ignorePatterns` is the same pattern as each line of `.eslintignore` in the next section. +You can tell ESLint to ignore specific files and directories by `ignorePatterns` in your config files. Each value of `ignorePatterns` is a glob pattern similar to what you would use on the command line. ```json { @@ -21,7 +21,7 @@ You can tell ESLint to ignore specific files and directories by `ignorePatterns` } ``` -* The `ignorePatterns` property affects only the directory that the config file is placed in. +* Glob patterns in `ignorePatterns` are relative to the directory that the config file is placed in. * You cannot write `ignorePatterns` property under `overrides` property. * `.eslintignore` can override the `ignorePatterns` property of config files. @@ -29,7 +29,7 @@ If a glob pattern starts with `/`, the pattern is relative to the base directory If a config is provided via the `--config` CLI option, the ignore patterns that start with `/` in the config are relative to the current working directory rather than the base directory of the given config. For example, if `--config configs/.eslintrc.json` is present, the ignore patterns in the config are relative to `.` rather than `./configs`. -## `.eslintignore` +## The `.eslintignore` File You can tell ESLint to ignore specific files and directories by creating an `.eslintignore` file in your project's root directory. The `.eslintignore` file is a plain text file where each line is a glob pattern indicating which paths should be omitted from linting. For example, the following will omit all JavaScript files: From b7945c219720d0f6fb24b8f84d3c06587786171b Mon Sep 17 00:00:00 2001 From: klkhan Date: Mon, 30 Nov 2020 20:24:41 +0500 Subject: [PATCH 77/96] Docs: Update configuration-files.md Accepted suggestions made to configuration-files.md. --- docs/user-guide/configuring/configuration-files.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/user-guide/configuring/configuration-files.md b/docs/user-guide/configuring/configuration-files.md index 4c4a16a06d3..7ef7f20438e 100644 --- a/docs/user-guide/configuring/configuration-files.md +++ b/docs/user-guide/configuring/configuration-files.md @@ -37,7 +37,7 @@ The second way to use configuration files is to save the file wherever you would eslint -c myconfig.json myfiletotest.js -If you are using one configuration file and want ESLint to ignore any `.eslintrc.*` files, make sure to use [`--no-eslintrc`] (https://eslint.org/docs/user-guide/command-line-interface#-no-eslintrc) along with the [`-c`] (https://eslint.org/docs/user-guide/command-line-interface#-c-config) flag. +If you are using one configuration file and want ESLint to ignore any `.eslintrc.*` files, make sure to use [`--no-eslintrc`](https://eslint.org/docs/user-guide/command-line-interface#-no-eslintrc) along with the [`-c`](https://eslint.org/docs/user-guide/command-line-interface#-c-config) flag. ### Comments in configuration files @@ -206,7 +206,7 @@ module.exports = { "semi": ["error", "always"], // override configuration set by extending "eslint:recommended" - "for-direction": "off", + "no-empty": "warn", "no-cond-assign": ["error", "always"], // disable rules from base configurations @@ -236,14 +236,14 @@ rules: ### Using a configuration from a plugin -A [plugin](https://eslint.org/docs/developer-guide/working-with-plugins) is an npm package that can add various extensions to ESLint. A plugin can perform numerous functions, including but not limited to the export of rules and [configurations](https://eslint.org/docs/developer-guide/working-with-plugins#configs-in-plugins). Make sure the package has been installed in a directory where ESLint can require it. +A [plugin](https://eslint.org/docs/developer-guide/working-with-plugins) is an npm package that can add various extensions to ESLint. A plugin can perform numerous functions, including but not limited to adding new rules and exporting [shareable configurations](https://eslint.org/docs/developer-guide/working-with-plugins#configs-in-plugins). Make sure the package has been installed in a directory where ESLint can require it. The `plugins` [property value](./plugins.md#configuring-plugins) can omit the `eslint-plugin-` prefix of the package name. The `extends` property value can consist of: * `plugin:` -* the package name (from which you can omit the prefix, for example, `react`) +* the package name (from which you can omit the prefix, for example, `react` is short for `eslint-plugin-react`) * `/` * the configuration name (for example, `recommended`) From 99a1f1d07bb074de1e2abc06f808cd9961d1b6fd Mon Sep 17 00:00:00 2001 From: klkhan Date: Mon, 30 Nov 2020 20:26:04 +0500 Subject: [PATCH 78/96] Docs: Update docs/user-guide/configuring/language-options.md Accepted a suggestion made to language-options.md Co-authored-by: Brandon Mills --- docs/user-guide/configuring/language-options.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/user-guide/configuring/language-options.md b/docs/user-guide/configuring/language-options.md index a51ceb9cf44..d4a62583d18 100644 --- a/docs/user-guide/configuring/language-options.md +++ b/docs/user-guide/configuring/language-options.md @@ -185,6 +185,7 @@ By the same token, supporting ES6 syntax is not the same as supporting new ES6 g `Set`). For ES6 syntax, use `{ "parserOptions": { "ecmaVersion": 6 } }`; for new ES6 global variables, use `{ "env": { "es6": true } }`. `{ "env": { "es6": true } }` enables ES6 syntax automatically, but `{ "parserOptions": { "ecmaVersion": 6 } }` does not enable ES6 globals automatically. + Parser options are set in your `.eslintrc.*` file by using the `parserOptions` property. The available options are: * `ecmaVersion` - set to 3, 5 (default), 6, 7, 8, 9, 10, 11, or 12 to specify the version of ECMAScript syntax you want to use. You can also set to 2015 (same as 6), 2016 (same as 7), 2017 (same as 8), 2018 (same as 9), 2019 (same as 10), 2020 (same as 11), or 2021 (same as 12) to use the year-based naming. From e7d491d245d6b0863c7beaf78b7dc9d6f5a3fd0a Mon Sep 17 00:00:00 2001 From: klkhan Date: Mon, 30 Nov 2020 20:26:46 +0500 Subject: [PATCH 79/96] Docs: Update docs/user-guide/configuring/plugins.md Accepted a suggestion made to plugins.md Co-authored-by: Brandon Mills --- docs/user-guide/configuring/plugins.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/plugins.md b/docs/user-guide/configuring/plugins.md index 25cf3dafc17..0235586c980 100644 --- a/docs/user-guide/configuring/plugins.md +++ b/docs/user-guide/configuring/plugins.md @@ -80,7 +80,7 @@ Processors may make named code blocks such as `0.js` and `1.js`. ESLint handles } ``` -ESLint checks the file path of named code blocks then ignores those if any `overrides` entry didn't match the file path. Be sure to make `overrides` entry if you wanted to lint named code blocks other than `*.js`. +ESLint checks the file path of named code blocks then ignores those if any `overrides` entry didn't match the file path. Be sure to add an `overrides` entry if you want to lint named code blocks other than `*.js`. ## Configuring Plugins From c968eb153286207801a1ec8c93d85b49f95b63d0 Mon Sep 17 00:00:00 2001 From: klkhan Date: Mon, 30 Nov 2020 20:29:02 +0500 Subject: [PATCH 80/96] Docs: Update ignoring-code.md Accepted suggestions made to ignoring-code.md --- docs/user-guide/configuring/ignoring-code.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/user-guide/configuring/ignoring-code.md b/docs/user-guide/configuring/ignoring-code.md index c94b96cb64b..f4444bba375 100644 --- a/docs/user-guide/configuring/ignoring-code.md +++ b/docs/user-guide/configuring/ignoring-code.md @@ -10,7 +10,7 @@ ## `ignorePatterns` in Config Files -You can tell ESLint to ignore specific files and directories by `ignorePatterns` in your config files. Each value of `ignorePatterns` is a glob pattern similar to what you would use on the command line. +You can tell ESLint to ignore specific files and directories using `ignorePatterns` in your config files. Each value of `ignorePatterns` is a glob pattern similar to what you would use on the command line. ```json { @@ -75,7 +75,7 @@ There are also some exceptions to these rules: * Allowlist and denylist rules specified via `--ignore-pattern` or `.eslintignore` are prioritized above implicit ignore rules. - For example, in this scenario, `.build/test.js` is the desired file to allowlist. Because all Dotfolders and their children are ignored by default, `.build` must first be allowlisted so that eslint because aware of its children. Then, `.build/test.js` must be explicitly allowlisted, while the rest of the content is denylisted. This is done with the following `.eslintignore` file: + For example, in this scenario, `.build/test.js` is the desired file to allowlist. Because all Dotfolders and their children are ignored by default, `.build` must first be allowlisted so that eslint becomes aware of its children. Then, `.build/test.js` must be explicitly allowlisted, while the rest of the content is denylisted. This is done with the following `.eslintignore` file: ```text # Allowlist 'test.js' in the '.build' folder From e06fc3c6cd457e2f0efd1264bbd153fbf068e3b9 Mon Sep 17 00:00:00 2001 From: klkhan Date: Tue, 1 Dec 2020 20:55:07 +0500 Subject: [PATCH 81/96] Docs: Update configuration-files.md Accepted suggestions to configuration-files.md --- .../configuring/configuration-files.md | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/docs/user-guide/configuring/configuration-files.md b/docs/user-guide/configuring/configuration-files.md index 7ef7f20438e..71099904516 100644 --- a/docs/user-guide/configuring/configuration-files.md +++ b/docs/user-guide/configuring/configuration-files.md @@ -33,7 +33,7 @@ There are two ways to use configuration files. The first way to use configuration files is via `.eslintrc.*` and `package.json` files. ESLint will automatically look for them in the directory of the file to be linted, and in successive parent directories all the way up to the root directory of the filesystem (unless `root: true` is specified). Configuration files can be useful when you want different configurations for different parts of a project or when you want others to be able to use ESLint directly without needing to remember to pass in the configuration file. -The second way to use configuration files is to save the file wherever you would like and pass its location to the CLI using the `-c` option, such as: +The second way to use configuration files is to save the file wherever you would like and pass its location to the CLI using the `--config` option, such as: eslint -c myconfig.json myfiletotest.js @@ -166,7 +166,11 @@ The complete configuration hierarchy, from highest to lowest precedence, is as f ## Extending Configuration Files -A configuration file, once extended, can inherit all the traits of another configuration file (including rules, plugins, and language options) and modify all the options. +A configuration file, once extended, can inherit all the traits of another configuration file (including rules, plugins, and language options) and modify all the options. As a result, there are three configurations, as defined below: + +* Base config: the configuration that is extended. +* Derived config: the configuration that extends the base configuration. +* Resulting actual config: the result of merging the derived configuration into the base configuration. The `extends` property value is either: @@ -175,6 +179,8 @@ The `extends` property value is either: ESLint extends configurations recursively, so a base configuration can also have an `extends` property. Relative paths and shareable config names in an `extends` property are resolved from the location of the config file where they appear. +The `eslint-config-` prefix can be omitted from the configuration name. For example, `airbnb` resolves as `eslint-config-airbnb`. + The `rules` property can do any of the following to extend (or override) the set of rules: * enable additional rules @@ -187,6 +193,25 @@ The `rules` property can do any of the following to extend (or override) the set * Derived config: `"quotes": ["error", "single"]` * Resulting actual config: `"quotes": ["error", "single"] +### Using a shareable configuration package + +A [sharable configuration](https://eslint.org/docs/developer-guide/shareable-configs) is an npm package that exports a configuration object. Make sure that you have installed the package in your project root directory, so that ESLint can require it. + +The `extends` property value can omit the `eslint-config-` prefix of the package name. + +The `eslint --init` command can create a configuration so you can extend a popular style guide (for example, `eslint-config-standard`). + +Example of a configuration file in YAML format: + +```yaml +extends: standard +rules: + comma-dangle: + - error + - always + no-empty: warn +``` + ### Using `eslint:recommended` Using `"eslint:recommended"` in the `extends` property enables a subset of core rules that report common problems (these rules are identified with a checkmark (recommended) on the [rules page](https://eslint.org/docs/rules/)). @@ -215,25 +240,6 @@ module.exports = { } ``` -### Using a shareable configuration package - -A [sharable configuration](https://eslint.org/docs/developer-guide/shareable-configs) is an npm package that exports a configuration object. Make sure that you have installed the package in your project root directory, so that ESLint can require it. - -The `extends` property value can omit the `eslint-config-` prefix of the package name. - -The `eslint --init` command can create a configuration so you can extend a popular style guide (for example, `eslint-config-standard`). - -Example of a configuration file in YAML format: - -```yaml -extends: standard -rules: - comma-dangle: - - error - - always - no-empty: warn -``` - ### Using a configuration from a plugin A [plugin](https://eslint.org/docs/developer-guide/working-with-plugins) is an npm package that can add various extensions to ESLint. A plugin can perform numerous functions, including but not limited to adding new rules and exporting [shareable configurations](https://eslint.org/docs/developer-guide/working-with-plugins#configs-in-plugins). Make sure the package has been installed in a directory where ESLint can require it. @@ -289,8 +295,6 @@ The `extends` property value can be `"eslint:all"` to enable all core rules in t **Important:** This configuration is **not recommended for production use** because it changes with every minor and major version of ESLint. Use it at your own risk. -If you configure ESLint to automatically enable new rules when you upgrade, ESLint can report new problems when there are no changes to source code, therefore any newer minor version of ESLint can behave as if it has breaking changes. - You might enable all core rules as a shortcut to explore rules and options while you decide on the configuration for a project, especially if you rarely override options or disable rules. The default options for rules are not endorsements by ESLint (for example, the default option for the [`quotes`](https://eslint.org/docs/rules/quotes) rule does not mean double quotes are better than single quotes). If your configuration extends `eslint:all`, after you upgrade to a newer major or minor version of ESLint, review the reported problems before you use the `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fix), so you know if a new fixable rule will make changes to the code. From cb60479237c060e94b7201cbf4a84dda41ff5112 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Thu, 24 Dec 2020 11:19:04 -0800 Subject: [PATCH 82/96] Update docs/user-guide/configuring/ignoring-code.md Co-authored-by: Kai Cataldo --- docs/user-guide/configuring/ignoring-code.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/ignoring-code.md b/docs/user-guide/configuring/ignoring-code.md index f4444bba375..50d197229cf 100644 --- a/docs/user-guide/configuring/ignoring-code.md +++ b/docs/user-guide/configuring/ignoring-code.md @@ -23,7 +23,7 @@ You can tell ESLint to ignore specific files and directories using `ignorePatter * Glob patterns in `ignorePatterns` are relative to the directory that the config file is placed in. * You cannot write `ignorePatterns` property under `overrides` property. -* `.eslintignore` can override the `ignorePatterns` property of config files. +* Patterns defined in `.eslintignore` take precedence over the `ignorePatterns` property of config files. If a glob pattern starts with `/`, the pattern is relative to the base directory of the config file. For example, `/foo.js` in `lib/.eslintrc.json` matches to `lib/foo.js` but not `lib/subdir/foo.js`. From 56083d0ae44e82ca4ce6a2ecdb4f26da20d82753 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Thu, 24 Dec 2020 11:19:22 -0800 Subject: [PATCH 83/96] Update docs/user-guide/configuring/ignoring-code.md Co-authored-by: Kai Cataldo --- docs/user-guide/configuring/ignoring-code.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/ignoring-code.md b/docs/user-guide/configuring/ignoring-code.md index 50d197229cf..f008db0fa03 100644 --- a/docs/user-guide/configuring/ignoring-code.md +++ b/docs/user-guide/configuring/ignoring-code.md @@ -10,7 +10,7 @@ ## `ignorePatterns` in Config Files -You can tell ESLint to ignore specific files and directories using `ignorePatterns` in your config files. Each value of `ignorePatterns` is a glob pattern similar to what you would use on the command line. +You can tell ESLint to ignore specific files and directories using `ignorePatterns` in your config files. `ignorePatterns` patterns follow the same rules as `.eslintignore`. Please see the [the `.eslintignore` file documentation](./ignoring-code.md#the-eslintignore-file) to learn more. ```json { From 7488f5b4d68d4bb0d0239361d1bbfa8e14d9bb4d Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Thu, 24 Dec 2020 11:22:50 -0800 Subject: [PATCH 84/96] Update docs/user-guide/configuring/language-options.md Co-authored-by: Kai Cataldo --- docs/user-guide/configuring/language-options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/language-options.md b/docs/user-guide/configuring/language-options.md index d4a62583d18..8246edb863b 100644 --- a/docs/user-guide/configuring/language-options.md +++ b/docs/user-guide/configuring/language-options.md @@ -119,7 +119,7 @@ Or in a `package.json` file ## Specifying Globals -The [no-undef](https://eslint.org/docs/rules/no-undef) rule will warn on variables that are accessed but not defined within the same file. If you are using global variables inside of a file then it's worthwhile to define those globals so that ESLint will not warn about their usage. You can define global variables either using comments inside of a file or in the configuration file. +Some of ESLint's core rules rely on knowledge of the global variables available to your code at runtime. Since these can vary greatly between different environments as well as be modified at runtime, ESLint makes no assumptions about what global variables exist in your execution environment. If you would like to use rules that require knowledge of what global variables are available, you can define global variables in your configuration file or by using configuration comments in your source code. ### Using configuration comments From d6bff3f891649edd2eb2fe698da71481785f1c21 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Thu, 24 Dec 2020 11:26:04 -0800 Subject: [PATCH 85/96] Update docs/user-guide/configuring/language-options.md --- docs/user-guide/configuring/language-options.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/user-guide/configuring/language-options.md b/docs/user-guide/configuring/language-options.md index 8246edb863b..eb3fe8a0afe 100644 --- a/docs/user-guide/configuring/language-options.md +++ b/docs/user-guide/configuring/language-options.md @@ -174,7 +174,6 @@ Globals can be disabled with the string `"off"`. For example, in an environment For historical reasons, the boolean value `false` and the string value `"readable"` are equivalent to `"readonly"`. Similarly, the boolean value `true` and the string value `"writeable"` are equivalent to `"writable"`. However, the use of older values is deprecated. -**Note:** Enable the [no-global-assign](https://eslint.org/docs/rules/no-global-assign) rule to disallow modifications to read-only global variables in your code. ## Specifying Parser Options From af80692401e71a291ea080b0ae5c84487fcdad8c Mon Sep 17 00:00:00 2001 From: klkhan Date: Fri, 25 Dec 2020 16:24:41 +0500 Subject: [PATCH 86/96] Update ignoring-code.md Updated ignoring-code.md by incorporating some suggested changes. --- docs/user-guide/configuring/ignoring-code.md | 37 +++----------------- 1 file changed, 5 insertions(+), 32 deletions(-) diff --git a/docs/user-guide/configuring/ignoring-code.md b/docs/user-guide/configuring/ignoring-code.md index f008db0fa03..77b0a50a40b 100644 --- a/docs/user-guide/configuring/ignoring-code.md +++ b/docs/user-guide/configuring/ignoring-code.md @@ -6,7 +6,6 @@ * [Using an Alternate File](#using-an-alternate-file) * [Using eslintIgnore in package.json](#using-eslintignore-in-packagejson) * [Ignored File Warnings](#ignored-file-warnings) -* [Disabling Inline Comments](#disabling-inline-comments) ## `ignorePatterns` in Config Files @@ -61,13 +60,13 @@ Please see [`.gitignore`](https://git-scm.com/docs/gitignore)'s specification fo In addition to any patterns in the `.eslintignore` file, ESLint always follows a couple of implicit ignore rules even if the `--no-ignore` flag is passed. The implicit rules are as follows: * `node_modules/` is ignored. -* Dotfiles (except for `.eslintrc.*`), as well as Dotfolders and their contents, are ignored. +* Dot-files (except for `.eslintrc.*`), as well as Dot-folders and their contents, are ignored. There are also some exceptions to these rules: -* If the path to lint is a glob pattern or directory path and contains a Dotfolder, all Dotfiles and Dotfolders will be linted. This includes sub-dotfiles and sub-dotfolders that are buried deeper in the directory structure. +* If the path to lint is a glob pattern or directory path and contains a Dot-folder, all Dot-files and Dot-folders will be linted. This includes dot-files and dot-folders that are buried deeper in the directory structure. - For example, `eslint .config/` will lint all Dotfolders and Dotfiles in the `.config` directory, including immediate children as well as children that are deeper in the directory structure. + For example, `eslint .config/` will lint all Dot-folders and Dot-files in the `.config` directory, including immediate children as well as children that are deeper in the directory structure. * If the path to lint is a specific file path and the `--no-ignore` flag has been passed, ESLint will lint the file regardless of the implicit ignore rules. @@ -75,7 +74,7 @@ There are also some exceptions to these rules: * Allowlist and denylist rules specified via `--ignore-pattern` or `.eslintignore` are prioritized above implicit ignore rules. - For example, in this scenario, `.build/test.js` is the desired file to allowlist. Because all Dotfolders and their children are ignored by default, `.build` must first be allowlisted so that eslint becomes aware of its children. Then, `.build/test.js` must be explicitly allowlisted, while the rest of the content is denylisted. This is done with the following `.eslintignore` file: + For example, in this scenario, `.build/test.js` is the desired file to allowlist. Because all Dot-folders and their children are ignored by default, `.build` must first be allowlisted so that eslint becomes aware of its children. Then, `.build/test.js` must be explicitly allowlisted, while the rest of the content is denylisted. This is done with the following `.eslintignore` file: ```text # Allowlist 'test.js' in the '.build' folder @@ -140,7 +139,7 @@ foo.js This message occurs because ESLint is unsure if you wanted to actually lint the file or not. As the message indicates, you can use `--no-ignore` to omit using the ignore rules. -Consider another scenario where you may want to run ESLint on a specific Dotfile or Dotfolder, but have forgotten to specifically allow those files in your `.eslintignore` file. You would run something like this: +Consider another scenario where you may want to run ESLint on a specific Dot-file or Dot-folder, but have forgotten to specifically allow those files in your `.eslintignore` file. You would run something like this: eslint .config/foo.js @@ -154,29 +153,3 @@ You would see this warning: ``` This message occurs because, normally, this file would be ignored by ESLint's implicit ignore rules (as mentioned above). A negated ignore rule in your `.eslintignore` file would override the implicit rule and reinclude this file for linting. Additionally, in this specific case, `--no-ignore` could be used to lint the file as well. - -## Disabling Inline Comments - -To disable all inline config comments, use the `noInlineConfig` setting. For example: - -```json -{ - "rules": {...}, - "noInlineConfig": true -} -``` - -This setting is similar to [--no-inline-config](https://eslint.org/docs/user-guide/command-line-interface#--no-inline-config) CLI option. - -### Report unused `eslint-disable` comments - -To report unused `eslint-disable` comments, use the `reportUnusedDisableDirectives` setting. For example: - -```json -{ - "rules": {...}, - "reportUnusedDisableDirectives": true -} -``` - -This setting is similar to [--report-unused-disable-directives](https://eslint.org/docs/user-guide/command-line-interface#--report-unused-disable-directives) CLI option, but doesn't fail linting (reports as `"warn"` severity). From d4240493cc41d9e8566b445dfe1db06254013ff6 Mon Sep 17 00:00:00 2001 From: klkhan Date: Fri, 25 Dec 2020 16:26:47 +0500 Subject: [PATCH 87/96] [Docs] Update rules.md Updated rules.md by moving`Disabling Inline Comments` to this section. --- docs/user-guide/configuring/rules.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/user-guide/configuring/rules.md b/docs/user-guide/configuring/rules.md index 19beeb98406..88e417875c9 100644 --- a/docs/user-guide/configuring/rules.md +++ b/docs/user-guide/configuring/rules.md @@ -236,3 +236,28 @@ To disable rules inside of a configuration file for a group of files, use the `o ] } ``` +### Disabling Inline Comments + +To disable all inline config comments, use the `noInlineConfig` setting. For example: + +```json +{ + "rules": {...}, + "noInlineConfig": true +} +``` + +This setting is similar to [--no-inline-config](https://eslint.org/docs/user-guide/command-line-interface#--no-inline-config) CLI option. + +#### Report unused `eslint-disable` comments + +To report unused `eslint-disable` comments, use the `reportUnusedDisableDirectives` setting. For example: + +```json +{ + "rules": {...}, + "reportUnusedDisableDirectives": true +} +``` + +This setting is similar to [--report-unused-disable-directives](https://eslint.org/docs/user-guide/command-line-interface#--report-unused-disable-directives) CLI option, but doesn't fail linting (reports as `"warn"` severity). From 04493af85183634c212ce152535c467439b096ca Mon Sep 17 00:00:00 2001 From: klkhan Date: Fri, 25 Dec 2020 16:27:41 +0500 Subject: [PATCH 88/96] [Docs] Update README.md Updated the table of contents --- docs/user-guide/configuring/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/user-guide/configuring/README.md b/docs/user-guide/configuring/README.md index 4e5982ba196..0aeaffdd28c 100644 --- a/docs/user-guide/configuring/README.md +++ b/docs/user-guide/configuring/README.md @@ -50,4 +50,3 @@ All of these options give you fine-grained control over how ESLint treats your c * [Using an Alternate File](./ignoring-code.md#using-an-alternate-file) * [Using eslintIgnore in package.json](./ignoring-code.md#using-eslintignore-in-package.json) * [Ignored File Warnings](./ignoring-code.md#ignored-file-warnings) -* [Disabling Inline Comments](./ignoring-code.md#disabling-inline-comments) From 846e4ce427d3136e759f31f0d86e93d64d81d7ea Mon Sep 17 00:00:00 2001 From: klkhan Date: Fri, 25 Dec 2020 16:32:58 +0500 Subject: [PATCH 89/96] [Docs] Update rules.md --- docs/user-guide/configuring/rules.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/user-guide/configuring/rules.md b/docs/user-guide/configuring/rules.md index 88e417875c9..2274b98ed02 100644 --- a/docs/user-guide/configuring/rules.md +++ b/docs/user-guide/configuring/rules.md @@ -236,6 +236,7 @@ To disable rules inside of a configuration file for a group of files, use the `o ] } ``` + ### Disabling Inline Comments To disable all inline config comments, use the `noInlineConfig` setting. For example: From e87d2a3e6ef474f80660946a9fab26b54e1b97b4 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Tue, 29 Dec 2020 10:40:42 -0800 Subject: [PATCH 90/96] Update docs/user-guide/configuring/ignoring-code.md --- docs/user-guide/configuring/ignoring-code.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/ignoring-code.md b/docs/user-guide/configuring/ignoring-code.md index 77b0a50a40b..3257c2cd0a3 100644 --- a/docs/user-guide/configuring/ignoring-code.md +++ b/docs/user-guide/configuring/ignoring-code.md @@ -60,7 +60,7 @@ Please see [`.gitignore`](https://git-scm.com/docs/gitignore)'s specification fo In addition to any patterns in the `.eslintignore` file, ESLint always follows a couple of implicit ignore rules even if the `--no-ignore` flag is passed. The implicit rules are as follows: * `node_modules/` is ignored. -* Dot-files (except for `.eslintrc.*`), as well as Dot-folders and their contents, are ignored. +* dot-files (except for `.eslintrc.*`), as well as dot-folders and their contents, are ignored. There are also some exceptions to these rules: From 7506ec16a6a9bcd1d89fece1d5c6ea1331e6c4ee Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Tue, 29 Dec 2020 10:40:51 -0800 Subject: [PATCH 91/96] Update docs/user-guide/configuring/ignoring-code.md --- docs/user-guide/configuring/ignoring-code.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/ignoring-code.md b/docs/user-guide/configuring/ignoring-code.md index 3257c2cd0a3..9b0166674e0 100644 --- a/docs/user-guide/configuring/ignoring-code.md +++ b/docs/user-guide/configuring/ignoring-code.md @@ -64,7 +64,7 @@ In addition to any patterns in the `.eslintignore` file, ESLint always follows a There are also some exceptions to these rules: -* If the path to lint is a glob pattern or directory path and contains a Dot-folder, all Dot-files and Dot-folders will be linted. This includes dot-files and dot-folders that are buried deeper in the directory structure. +* If the path to lint is a glob pattern or directory path and contains a dot-folder, all dot-files and dot-folders will be linted. This includes dot-files and dot-folders that are buried deeper in the directory structure. For example, `eslint .config/` will lint all Dot-folders and Dot-files in the `.config` directory, including immediate children as well as children that are deeper in the directory structure. From 765d62f4d7c7446bd6c9bb28b914042b1522784a Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Tue, 29 Dec 2020 10:41:09 -0800 Subject: [PATCH 92/96] Update docs/user-guide/configuring/ignoring-code.md --- docs/user-guide/configuring/ignoring-code.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/ignoring-code.md b/docs/user-guide/configuring/ignoring-code.md index 9b0166674e0..9e11e10e978 100644 --- a/docs/user-guide/configuring/ignoring-code.md +++ b/docs/user-guide/configuring/ignoring-code.md @@ -66,7 +66,7 @@ There are also some exceptions to these rules: * If the path to lint is a glob pattern or directory path and contains a dot-folder, all dot-files and dot-folders will be linted. This includes dot-files and dot-folders that are buried deeper in the directory structure. - For example, `eslint .config/` will lint all Dot-folders and Dot-files in the `.config` directory, including immediate children as well as children that are deeper in the directory structure. + For example, `eslint .config/` will lint all dot-folders and dot-files in the `.config` directory, including immediate children as well as children that are deeper in the directory structure. * If the path to lint is a specific file path and the `--no-ignore` flag has been passed, ESLint will lint the file regardless of the implicit ignore rules. From addb6c8829638d4baab853723a6f230eb7d29223 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Tue, 29 Dec 2020 10:41:19 -0800 Subject: [PATCH 93/96] Update docs/user-guide/configuring/ignoring-code.md --- docs/user-guide/configuring/ignoring-code.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/ignoring-code.md b/docs/user-guide/configuring/ignoring-code.md index 9e11e10e978..886db14ce4d 100644 --- a/docs/user-guide/configuring/ignoring-code.md +++ b/docs/user-guide/configuring/ignoring-code.md @@ -139,7 +139,7 @@ foo.js This message occurs because ESLint is unsure if you wanted to actually lint the file or not. As the message indicates, you can use `--no-ignore` to omit using the ignore rules. -Consider another scenario where you may want to run ESLint on a specific Dot-file or Dot-folder, but have forgotten to specifically allow those files in your `.eslintignore` file. You would run something like this: +Consider another scenario where you may want to run ESLint on a specific dot-file or dot-folder, but have forgotten to specifically allow those files in your `.eslintignore` file. You would run something like this: eslint .config/foo.js From 4367199e2f945e9b0922157faf7d69c7281fe58d Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Tue, 29 Dec 2020 10:41:28 -0800 Subject: [PATCH 94/96] Update docs/user-guide/configuring/ignoring-code.md --- docs/user-guide/configuring/ignoring-code.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/ignoring-code.md b/docs/user-guide/configuring/ignoring-code.md index 886db14ce4d..d7b3cfd27c8 100644 --- a/docs/user-guide/configuring/ignoring-code.md +++ b/docs/user-guide/configuring/ignoring-code.md @@ -74,7 +74,7 @@ There are also some exceptions to these rules: * Allowlist and denylist rules specified via `--ignore-pattern` or `.eslintignore` are prioritized above implicit ignore rules. - For example, in this scenario, `.build/test.js` is the desired file to allowlist. Because all Dot-folders and their children are ignored by default, `.build` must first be allowlisted so that eslint becomes aware of its children. Then, `.build/test.js` must be explicitly allowlisted, while the rest of the content is denylisted. This is done with the following `.eslintignore` file: + For example, in this scenario, `.build/test.js` is the desired file to allowlist. Because all dot-folders and their children are ignored by default, `.build` must first be allowlisted so that eslint becomes aware of its children. Then, `.build/test.js` must be explicitly allowlisted, while the rest of the content is denylisted. This is done with the following `.eslintignore` file: ```text # Allowlist 'test.js' in the '.build' folder From 5da27598321905553ddcb87e6a2864bed85821c6 Mon Sep 17 00:00:00 2001 From: klkhan Date: Thu, 21 Jan 2021 15:29:14 +0500 Subject: [PATCH 95/96] Docs: Update configuration-files.md --- docs/user-guide/configuring/configuration-files.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/configuration-files.md b/docs/user-guide/configuring/configuration-files.md index 71099904516..463cb65f05f 100644 --- a/docs/user-guide/configuring/configuration-files.md +++ b/docs/user-guide/configuring/configuration-files.md @@ -105,7 +105,7 @@ your-project └── test.js ``` -The configuration cascade works by using the closest `.eslintrc` file to the file being linted as the highest priority, then any configuration files in the parent directory, and so on. When you run ESLint on this project, all files in `lib/` will use the `.eslintrc` file at the root of the project as their configuration. When ESLint traverses into the `tests/` directory, it will then use `your-project/tests/.eslintrc` in addition to `your-project/.eslintrc`. So `your-project/tests/test.js` is linted based on the combination of the two `.eslintrc` files in its directory hierarchy, with the closest one taking priority. In this way, you can have project-level ESLint settings and also have directory-specific overrides. +The configuration cascade works based on the location of the file being linted. If there is a .eslintrc file in the same directory as the file being linted, then that configuration takes precedence. ESLint then searches up the directory structure, merging any .eslintrc files it finds along the way until reaching either a .eslintrc file with root: true or the root directory. In the same way, if there is a `package.json` file in the root directory with an `eslintConfig` field, the configuration it describes will apply to all subdirectories beneath it, but the configuration described by the `.eslintrc` file in the `tests/` directory will override it where there are conflicting specifications. From bfd3f0e05e1b0fdc968a8af557cc797bc4ead3d7 Mon Sep 17 00:00:00 2001 From: klkhan Date: Fri, 22 Jan 2021 14:24:12 +0500 Subject: [PATCH 96/96] Docs: Update configuration-files.md --- docs/user-guide/configuring/configuration-files.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configuring/configuration-files.md b/docs/user-guide/configuring/configuration-files.md index 463cb65f05f..da0ee1aba1b 100644 --- a/docs/user-guide/configuring/configuration-files.md +++ b/docs/user-guide/configuring/configuration-files.md @@ -105,7 +105,7 @@ your-project └── test.js ``` -The configuration cascade works based on the location of the file being linted. If there is a .eslintrc file in the same directory as the file being linted, then that configuration takes precedence. ESLint then searches up the directory structure, merging any .eslintrc files it finds along the way until reaching either a .eslintrc file with root: true or the root directory. +The configuration cascade works based on the location of the file being linted. If there is a `.eslintrc` file in the same directory as the file being linted, then that configuration takes precedence. ESLint then searches up the directory structure, merging any `.eslintrc` files it finds along the way until reaching either a `.eslintrc` file with `root: true` or the root directory. In the same way, if there is a `package.json` file in the root directory with an `eslintConfig` field, the configuration it describes will apply to all subdirectories beneath it, but the configuration described by the `.eslintrc` file in the `tests/` directory will override it where there are conflicting specifications.