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: website/reference/yaml.md
+15-7Lines changed: 15 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -232,15 +232,21 @@ Please also see [label guide](/guide/project/lint-rule.html#customize-code-highl
232
232
* type: `Array<String>`
233
233
* required: false
234
234
235
-
Glob patterns to specify that the rule only applies to matching files. It takes priority over `ignores`.
235
+
Glob patterns to specify that the rule only applies to matching files. It is tested if `ignores` does not exist or a file does not match any `ignores` glob.
236
+
237
+
**Example:**
236
238
237
-
Example:
238
239
```yaml
239
240
files:
240
241
- src/**/*.js
241
242
- src/**/*.ts
242
243
```
243
244
245
+
:::warning Don't add `./`
246
+
Be sure to remove `./` to the beginning of your rules. ast-grep will not recognize the paths if you add `./`.
247
+
:::
248
+
249
+
244
250
### `ignores`
245
251
* type: `Array<String>`
246
252
* required: false
@@ -251,18 +257,20 @@ ignores:
251
257
- test/**/*.ts
252
258
```
253
259
254
-
Glob patterns that exclude rules from applying to files. It is superseded by `files` if both are specified.
260
+
Glob patterns that exclude rules from applying to files. A file is tested against `ignores` list before matching `files`.
261
+
262
+
A typical globing process works as follows:
263
+
264
+
1. If `ignores` is configured, a file will be skipped if it matches any of the glob in the list(`files` will not be tested).
265
+
2. If `files` is configured, a file will be included if and only if it matches one of the glob in the list.
266
+
3. If neither `ignores`/`files` is configured, a file is included by default.
255
267
256
268
:::warning `ignores` in YAML is different from `--no-ignore` in CLI
257
269
ast-grep respects common ignore files like `.gitignore` and hidden files by default.
258
270
To disable this behavior, use [`--no-ignore`](/reference/cli.html#scan) in CLI.
259
271
`ignores`is a rule-wise configuration that only filters files that are not ignored by the CLI.
260
272
:::
261
273
262
-
:::warning Don't add `./`
263
-
Be sure to remove `./` to the beginning of your rules. ast-grep will not recognize the paths if you add `./`.
0 commit comments