-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(turbo-tasks): Add a lint for
Vc<T>
in turbo-tasks types (#73298)
### What? Add a lint for `Vc<T>` in structs or enums with `#[turbo_tasks::value]`. ### Why? We need to change them to `ResolvedVc<T>` so I'm adding a lint to check make it easier. ### How? I asked a question of `ast-grep` discord. - https://discord.com/channels/1107749847722889217/1113524796316200980/1311549077275676753
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/ast-grep/ast-grep/main/schemas/rule.json | ||
|
||
id: no-vc-struct | ||
message: Don't use a Vc directly in a struct | ||
note: 'Prefer using ResolvedVc, or add a `// no-resolved-vc(<AUTHOR>): <REASON>` comment' | ||
severity: warning | ||
language: rust | ||
|
||
rule: | ||
pattern: | ||
context: 'let x: Vc<$A> = 1;' | ||
selector: generic_type | ||
inside: | ||
stopBy: end | ||
not: | ||
follows: | ||
kind: line_comment | ||
regex: \s*//\s*no-resolved-vc\((.+)\):.+ | ||
inside: | ||
inside: | ||
any: | ||
- kind: struct_item | ||
follows: | ||
stopBy: | ||
not: | ||
kind: attribute_item | ||
kind: attribute_item | ||
has: | ||
kind: attribute | ||
regex: '^turbo_tasks::value(\(.*\))?$' | ||
- inside: | ||
kind: enum_variant_list | ||
inside: | ||
follows: | ||
stopBy: | ||
not: | ||
kind: attribute_item | ||
kind: attribute_item | ||
has: | ||
kind: attribute | ||
regex: '^turbo_tasks::value(\(.*\))?$' | ||
fix: ResolvedVc<$A> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters