Files
next.js/.config/ast-grep/rules/no-context-format.yml
Niklas MischkulnigandGitHub 19ff1babf0 Lint against .context(format!(...)) (#91122)
There are unfortunately a few false-positives, because this isn't aware of type information of course.
2026-03-11 10:31:51 +01:00

21 lines
728 B
YAML

# yaml-language-server: $schema=https://raw.githubusercontent.com/ast-grep/ast-grep/main/schemas/rule.json
id: no-context-format
message: Use `.with_context(|| format!(...))` instead of `.context(format!(...))`.
note: >
`.context(format!(...))` eagerly allocates the formatted string even when there is no error.
Use `.with_context(|| format!(...))` for lazy evaluation.
severity: error
language: Rust
rule:
pattern: $OBJ.context(format!($$$ARGS))
fix: $OBJ.with_context(|| format!($$$ARGS))
---
id: no-context-turbofmt
message: >
`.context(turbofmt!(...).await?)` eagerly creates the formatted string even when there is no error.
severity: error
language: Rust
rule:
pattern: $OBJ.context(turbofmt!($$$ARGS).await?)