From 3912f3a225c12bfb5ce9b7ba26c2b5301e6275bd Mon Sep 17 00:00:00 2001 From: Francesco Trotta Date: Thu, 8 Jun 2023 19:24:02 +0200 Subject: [PATCH] docs: Improve `ignores` documentation (#17239) * docs: Improve `ignores` documentation * Another note about `dir/` vs. `dir/**` in non-global patterns * Update docs/src/use/configure/configuration-files-new.md Clarifiy a sentence Co-authored-by: Milos Djermanovic --------- Co-authored-by: Milos Djermanovic --- docs/src/use/configure/configuration-files-new.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/src/use/configure/configuration-files-new.md b/docs/src/use/configure/configuration-files-new.md index a57bbf0f235..083be3d93c9 100644 --- a/docs/src/use/configure/configuration-files-new.md +++ b/docs/src/use/configure/configuration-files-new.md @@ -116,7 +116,9 @@ export default [ Here, the configuration object excludes files ending with `.config.js` except for `eslint.config.js`. That file still has `semi` applied. -If `ignores` is used without `files` and any other setting, then the configuration object applies to all files except the ones specified in `ignores`, for example: +Non-global `ignores` patterns can only match file names. A pattern like `"dir-to-exclude/"` will not ignore anything. To ignore everything in a particular directory, a pattern like `"dir-to-exclude/**"` should be used instead. + +If `ignores` is used without `files` and there are other keys (such as `rules`), then the configuration object applies to all files except the ones specified in `ignores`, for example: ```js export default [ @@ -145,6 +147,9 @@ export default [ This configuration specifies that all of the files in the `.config` directory should be ignored. This pattern is added after the default patterns, which are `["**/node_modules/**", ".git/**"]`. +Note that only global `ignores` patterns can match directories. +`ignores` patterns that are specific to a configuration will only match file names. + #### Cascading configuration objects When more than one configuration object matches a given filename, the configuration objects are merged with later objects overriding previous objects when there is a conflict. For example: