Skip to content

Commit 1b1aa95

Browse files
committedMar 14, 2025
Add ast-grep rule for suspicious non-terminal res.ok
1 parent 82ad880 commit 1b1aa95

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
id: no-non-terminal-res-inside-condition
2+
message: Potentially suspicious non-terminal response inside condition
3+
severity: hint
4+
language: typescript
5+
rule:
6+
all:
7+
- pattern: res.$A($$$B)
8+
- kind: call_expression
9+
- not:
10+
inside:
11+
kind: return_statement
12+
stopBy: end
13+
- inside:
14+
kind: if_statement
15+
stopBy: end
16+
fix: return res.$A($$$B)
17+
constraints:
18+
A:
19+
any:
20+
- regex: badRequest
21+
- regex: conflict
22+
- regex: forbidden
23+
- regex: invalidGocardlessToken
24+
- regex: methodNotAllowed
25+
- regex: notFound
26+
- regex: serverError
27+
- regex: serviceUnavailable
28+
- regex: unauthorized

0 commit comments

Comments
 (0)
Please sign in to comment.