From 3496368b1650a93657ad5b08f7fe5eda906cc577 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Wed, 13 Dec 2023 12:07:07 -0500 Subject: [PATCH] Fix links and add shareable config docs --- docs/src/use/command-line-interface.md | 4 +- docs/src/use/configure/configuration-files.md | 48 +++++++++++++++++-- docs/src/use/configure/index.md | 1 - 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/docs/src/use/command-line-interface.md b/docs/src/use/command-line-interface.md index 472619a524b..bfa149a1c32 100644 --- a/docs/src/use/command-line-interface.md +++ b/docs/src/use/command-line-interface.md @@ -166,7 +166,7 @@ If `.eslintrc.*` and/or `package.json` files are also used for configuration (i. * **Argument Type**: String. One of the available environments. * **Multiple Arguments**: Yes -Details about the global variables defined by each environment are available in the [Specifying Environments](configure/language-options#specifying-environments) documentation. This option only enables environments. It does not disable environments set in other configuration files. To specify multiple environments, separate them using commas, or use the option multiple times. +Details about the global variables defined by each environment are available in the [Specifying Environments](configure/language-options-deprecated#specifying-environments) documentation. This option only enables environments. It does not disable environments set in other configuration files. To specify multiple environments, separate them using commas, or use the option multiple times. ##### `--env` example @@ -391,7 +391,7 @@ npx eslint --fix --fix-type suggestion,layout . * **Multiple Arguments**: No * **Default Value**: By default, ESLint looks for `.eslintignore` in the current working directory. -**Note:** `--ignore-path` is not supported when using [flat configuration](./configure/configuration-files-new) (`eslint.config.js`). +**Note:** `--ignore-path` is only supported when using [deprecated configuration](./configure/configuration-files-deprecated). ##### `--ignore-path` example diff --git a/docs/src/use/configure/configuration-files.md b/docs/src/use/configure/configuration-files.md index 7f1d8d3be75..112eda02630 100644 --- a/docs/src/use/configure/configuration-files.md +++ b/docs/src/use/configure/configuration-files.md @@ -215,11 +215,11 @@ export default [ Using this configuration, all JavaScript files define a custom global object defined called `MY_CUSTOM_GLOBAL` while those JavaScript files in the `tests` directory have `it` and `describe` defined as global objects in addition to `MY_CUSTOM_GLOBAL`. For any JavaScript file in the tests directory, both configuration objects are applied, so `languageOptions.globals` are merged to create a final result. -### Configuring linter options +### Configuring Linter Options Options specific to the linting process can be configured using the `linterOptions` object. These effect how linting proceeds and does not affect how the source code of the file is interpreted. -#### Disabling inline configuration +#### Disabling Inline Configuration Inline configuration is implemented using an `/*eslint*/` comment, such as `/*eslint semi: error*/`. You can disallow inline configuration by setting `noInlineConfig` to `true`. When enabled, all inline configuration is ignored. Here's an example: @@ -235,7 +235,7 @@ export default [ ]; ``` -#### Reporting unused disable directives +#### Reporting Unused Disable Directives Disable and enable directives such as `/*eslint-disable*/`, `/*eslint-enable*/` and `/*eslint-disable-next-line*/` are used to disable ESLint rules around certain portions of code. As code changes, it's possible for these directives to no longer be needed because the code has changed in such a way that the rule is no longer triggered. You can enable reporting of these unused disable directives by setting the `reportUnusedDisableDirectives` option to `true`, as in this example: @@ -339,6 +339,48 @@ export default [ ]; ``` +## Using a Shareable Configuration Package + +A sharable configuration is an npm package that exports a configuration object or array. This package should be installed as a dependency in your project and then reference from inside of your `eslint.config.js` file. For example, to use a shareable configuration named `eslint-config-example`, your configuration file would look like this: + +```js +// eslint.config.js +import exampleConfig from "eslint-config-example"; + +export default [ + exampleConfig, + + // your modifications + { + rules: { + "no-unused-vars": "warn" + } + } +]; +``` + +In this example, `exampleConfig` is an object, so you insert it directly into the configuration array. + +Some shareable configurations will export an array instead, in which case you'll need to use the spread operator to insert those items into the configuration array. For example: + +```js +// eslint.config.js +import exampleConfigs from "eslint-config-example"; + +export default [ + ...exampleConfigs, + + // your modifications + { + rules: { + "no-unused-vars": "warn" + } + } +]; +``` + +Please refer to the documentation for the shareable configuration package you're using to determine whether it is exporting an object or an array. + ## Configuration File Resolution When ESLint is run on the command line, it first checks the current working directory for `eslint.config.js`. If the file is not found, it looks to the next parent directory for the file. This search continues until either the file is found or the root directory is reached. diff --git a/docs/src/use/configure/index.md b/docs/src/use/configure/index.md index 591f95e7253..d5e8d07a0cc 100644 --- a/docs/src/use/configure/index.md +++ b/docs/src/use/configure/index.md @@ -29,7 +29,6 @@ All of these options give you fine-grained control over how ESLint treats your c * [Configuration Objects](./configuration-files#configuration-objects) * [Configuring Shared Settings](./configuration-files#configuring-shared-settings) * [Configuration File Resolution](./configuration-files#configuration-file-resolution) -* [Configuration Based on Glob Patterns](./configuration-files#configuration-based-on-glob-patterns) [**Configure Language Options**](language-options)