Skip to content

Commit

Permalink
Fix links and add shareable config docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nzakas committed Dec 22, 2023
1 parent f66e077 commit 3496368
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs/src/use/command-line-interface.md
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
48 changes: 45 additions & 3 deletions docs/src/use/configure/configuration-files.md
Expand Up @@ -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:

Expand All @@ -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:

Expand Down Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion docs/src/use/configure/index.md
Expand Up @@ -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)

Expand Down

0 comments on commit 3496368

Please sign in to comment.