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/guide/project/severity.md
+31Lines changed: 31 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -61,7 +61,38 @@ These are the rules for suppression comments:
61
61
* You can turn off multiple rules by providing a comma-separated list in the comment. e.g. `ast-grep-ignore: rule-1, rule-2`
62
62
* Suppression comments will suppress the next line diagnostic if and only if there is no preceding ASTs on the same line.
63
63
64
+
## File Level Suppression
64
65
66
+
You can also suppress all diagnostics in a file by adding a suppression comment at the top of the file followed by an empty line. This is useful when you want to ignore all diagnostics in a file.
67
+
68
+
For example, in JavaScript:
69
+
70
+
:::code-group
71
+
```javascript [Disable all rules]
72
+
// ast-grep-ignore
73
+
74
+
// This file will not be scanned by ast-grep
75
+
// note the empty line after the suppression comment.
76
+
debugger// this line will not be scanned
77
+
console.debug('debugging') // this line will not be scanned
78
+
```
79
+
80
+
```javascript{6} [Disable sepcific rules]
81
+
// ast-grep-ignore: no-debugger
82
+
83
+
// This file will not be scanned by ast-grep
84
+
// note the empty line after the suppression comment.
85
+
debugger // this line will not trigger error
86
+
console.debug('debugging') // this line will trigger error
87
+
```
88
+
89
+
:::
90
+
91
+
To suppress the whole file, there must be [two conditions](https://github.com/ast-grep/ast-grep/issues/1541#issuecomment-2573212686) met:
92
+
* The suppression comment is on the very first line of the file.
93
+
* AND the next line (second line in file) is empty
94
+
95
+
These conditions are designed for backward compatibility.
0 commit comments