-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add project-specific lints with ast-grep #5637
Conversation
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/
The latest updates on your projects. Learn more about Vercel for Git ↗︎
9 Ignored Deployments
|
|
I've been following ast-grep so it's neat that we're using it here. Are we hooking this up to CI? |
Yeah, I'll add that here. |
✅ This change can build |
Linux Benchmark for 746c94fClick to view benchmark
|
MacOS Benchmark for 746c94f
Click to view full benchmark
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. We're intentionally having the ast-grep output be warnings and not errors, right?
It moves to error + ignore allowlist in #5640 |
* vercel/turborepo#5582 * vercel/turborepo#5633 * vercel/turborepo#5637 * vercel/turborepo#5648 <!-- OJ Kwon - test(turbopack): run daily with --experimental --> * vercel/turborepo#5618 * vercel/turborepo#5624 * vercel/turborepo#5597 * vercel/turborepo#5632 * vercel/turborepo#5636 * vercel/turborepo#5666
Hi Vercel team. It is my honor that turbo is using ast-grep for project-specific linting. I really appreciate your trust! By the way, ast-grep supported a new argument This page has a screenshot of the option. |
This uses the official ast-grep GitHub Action [0] instead of installing it from npm in the clippy job. Thanks for the suggestion from @HerringtonDarkholme! [0] https://github.com/ast-grep/action [1] #5637 (comment)
This uses the official ast-grep GitHub Action [0] instead of installing it from npm in the clippy job. Thanks for the suggestion from @HerringtonDarkholme! [0] https://github.com/ast-grep/action [1] #5637 (comment)
This uses the official ast-grep GitHub Action [0] instead of installing it from npm in the clippy job. Thanks for the suggestion from @HerringtonDarkholme! [0] https://github.com/ast-grep/action [1] #5637 (comment)
This uses the official ast-grep GitHub Action [0] instead of installing it from npm in the clippy job. Thanks for the suggestion from @HerringtonDarkholme! [0] https://github.com/ast-grep/action [1] #5637 (comment)
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/
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:[0] https://ast-grep.github.io
[1] https://tree-sitter.github.io/tree-sitter/