turbopack-230802.1
wbinnssmith
tagged this
01 Aug 18:52
ast-grep[0] is a tool that uses tree-sitter[1] and a pattern language to match against code using its ast. It implements code transformation, querying, and linting. Since clippy isn't extensible for project-specific lints, this adds a first ast-grep lint disallowing `context` as a variable name. Currently it's set to warning as usage is addressed. To run, install ast-grep, then run `ast-grep scan`. Example output: ``` warning[no-context]: Don't name variables `context`. ┌─ ./crates/turbopack-ecmascript-hmr-protocol/src/lib.rs:132:9 │ 132 │ pub context: &'a str, │ ----^^^^^^^--------- │ = Use a more specific name, such as chunking_context, asset_context, etc. ``` [0] https://ast-grep.github.io [1] https://tree-sitter.github.io/tree-sitter/