You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/use/configure/configuration-files.md
+32-10Lines changed: 32 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -208,26 +208,48 @@ Filenames starting with a dot, such as `.gitignore`, are considered to have only
208
208
209
209
#### Globally ignoring files with `ignores`
210
210
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`
213
225
214
226
```js
215
227
// eslint.config.js
228
+
229
+
// Example of global ignores
216
230
exportdefault [
217
231
{
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
220
236
];
221
-
```
222
237
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
+
exportdefault [
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
+
```
224
250
225
251
For more information and examples on configuring rules regarding `ignores`, see [Ignore Files](ignore).
226
252
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
-
231
253
#### Cascading Configuration Objects
232
254
233
255
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