mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
# What Add an ast-grep rule to use `bail!` rather than `Err(anyhow!(` in a return position. # Why This is slightly more compact, and allows us to port more code over to turbofmt/turbobail. Note: _this PR was previously merged into another branch due to a GH bug_
39 lines
991 B
YAML
39 lines
991 B
YAML
# yaml-language-server: $schema=https://raw.githubusercontent.com/ast-grep/ast-grep/main/schemas/rule.json
|
|
|
|
id: no-err-anyhow
|
|
message: Use `bail!()` instead of `Err(anyhow!())`.
|
|
note: The `bail!` macro from anyhow is more concise and idiomatic.
|
|
severity: error
|
|
language: Rust
|
|
rule:
|
|
all:
|
|
- any:
|
|
- pattern: Err(anyhow!($$$ARGS))
|
|
- pattern: Err(anyhow::anyhow!($$$ARGS))
|
|
- not:
|
|
inside:
|
|
kind: arguments
|
|
stopBy:
|
|
any:
|
|
- kind: block
|
|
- kind: closure_expression
|
|
- not:
|
|
inside:
|
|
kind: assignment_expression
|
|
stopBy:
|
|
any:
|
|
- kind: block
|
|
- kind: closure_expression
|
|
- not:
|
|
inside:
|
|
kind: let_declaration
|
|
stopBy:
|
|
any:
|
|
- kind: block
|
|
- kind: closure_expression
|
|
- not:
|
|
inside:
|
|
kind: field_expression
|
|
stopBy:
|
|
kind: call_expression
|