Skip to content

Commit c6efc51

Browse files
authored
docs: semi-big rewrite
1 parent c184913 commit c6efc51

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

docs/src/use/configure/configuration-files.md

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,26 +208,48 @@ Filenames starting with a dot, such as `.gitignore`, are considered to have only
208208

209209
#### Globally ignoring files with `ignores`
210210

211-
If you want to globally ignores some directory/files, and apply this directive to all configuration objects of the array, `global ignores` is exactly made for this scenario.
212-
If `ignores` is used without any other keys in the configuration object, then the patterns act as global ignores. Here's an example:
211+
Depending on how the `ignores` property is used, it can behave as non-global `ignores` or as global `ignores`.
212+
213+
* If `ignores` is used without any other keys in the configuration object, then the patterns act as global ignores. This way it gets apply to every configuration object (not only to the configration object in which is defined). Global `ignores` allows you not to have to copy and keep the `ignores` property synchronized in more than one configuration object.
214+
* If `ignores` is used in conjunction with other properties in the same configuration object, then the patterns act as non-global ignores. This way `ignores` applies only that configuration object
215+
216+
Global and non-global `ignores` have some usage differences:
217+
218+
* patterns in non-global `ignores` only match the files (`dir/filename.js`) or files within directories (`dir/**`)
219+
* patterns in global `ignores` can also match directories (`dir/`), other than files like "non-global".
220+
221+
In any case (non-global or global):
222+
223+
* the glob patterns you define are added after the default patterns, which are `["**/node_modules/", ".git/"]`
224+
* glob patterns always match files and directories that begin with a dot, such as `.foo.js` or `.fixtures`, unless those files are explicitly ignored. The only dot directory ignored by default is `.git`
213225

214226
```js
215227
// eslint.config.js
228+
229+
// Example of global ignores
216230
export default [
217231
{
218-
ignores: [".config/*"]
219-
}
232+
ignores: [".config/", "dist/", "tsconfig.json"] // acts as global ignores, due to the absence of other properties
233+
},
234+
{ ... }, // ... other configuration object, inherit global ignores
235+
{ ... }, // ... other configuration object inherit global ignores
220236
];
221-
```
222237

223-
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/"]`.
238+
// Example of non-global ignores
239+
export default [
240+
{
241+
ignores: [".config/**", "dir1/script1.js"],
242+
rules: { ... } // the presence of this property dictates non-global ignores
243+
},
244+
{
245+
ignores: ["other-dir/**", "dist/script2.js"],
246+
rules: { ... } // the presence of this property dictates non-global ignores
247+
},
248+
];
249+
```
224250

225251
For more information and examples on configuring rules regarding `ignores`, see [Ignore Files](ignore).
226252

227-
::: important
228-
Glob patterns always match files and directories that begin with a dot, such as `.foo.js` or `.fixtures`, unless those files are explicitly ignored. The only dot directory ignored by default is `.git`.
229-
:::
230-
231253
#### Cascading Configuration Objects
232254

233255
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:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy