Code Demo for all supported languages? #364
Replies: 21 comments
-
JavaScript:
sg -p 'useState<number>($A)' -r 'useState($A)'
sg -p 'useState<string>($A)' -r 'useState($A)'
sg -p 'useState<boolean>($A)' -r 'useState($A)' |
Beta Was this translation helpful? Give feedback.
-
Avoid wrong usage of jsx id: do-what-brooooooklyn-said
language: Tsx
severity: error
rule:
kind: jsx_expression
has:
pattern: $A && $B
not:
inside:
kind: jsx_attribute
fix: "{$A ? $B : null}" |
Beta Was this translation helpful? Give feedback.
-
Replace console.log sg -p 'console.log' -r 'console.debug' |
Beta Was this translation helpful? Give feedback.
-
HTML extractor https://twitter.com/trevmanz/status/1671572111582978049?s=20 |
Beta Was this translation helpful? Give feedback.
-
check no-non-null-asserted-optional-chain
https://twitter.com/hd_nvim/status/1676018922066411520/photo/1 |
Beta Was this translation helpful? Give feedback.
-
A to B Inferred TransformsPattern $LIST.select { |$V| $V.$METHOD } Rewrite $LIST.select(&:$METHOD) Example [1, 2, 3].select { |v| v.even? }
[1, 2, 3].select(&:even?) Adapted from https://dev.to/baweaver/future-of-ruby-ast-tooling-9i1 |
Beta Was this translation helpful? Give feedback.
-
Migrate action_filter in RoRMigrate |
Beta Was this translation helpful? Give feedback.
-
Rust |
Beta Was this translation helpful? Give feedback.
-
Rust |
Beta Was this translation helpful? Give feedback.
-
A python example https://engineering.soroco.com/abstract-syntax-tree-for-patching-code-and-assessing-code-quality/ |
Beta Was this translation helpful? Give feedback.
-
Rewriting Mobx https://twitter.com/meetliby/status/1698601672568901723?s=20 |
Beta Was this translation helpful? Give feedback.
-
C example and JS example |
Beta Was this translation helpful? Give feedback.
-
no inline await in promise all array https://twitter.com/alvarlagerlof/status/1720182566135779582 |
Beta Was this translation helpful? Give feedback.
-
console.error in catch block |
Beta Was this translation helpful? Give feedback.
-
Migrate openai python library |
Beta Was this translation helpful? Give feedback.
-
Rewrite import/export to export |
Beta Was this translation helpful? Give feedback.
-
add color prop if there's no existing color or variant prop. |
Beta Was this translation helpful? Give feedback.
-
Migrate Laravel DB expression |
Beta Was this translation helpful? Give feedback.
-
Rewrite yoda style |
Beta Was this translation helpful? Give feedback.
-
rewrite object.asign to object spread
|
Beta Was this translation helpful? Give feedback.
-
What's your favorite hello-world code in your programming language?
We can showcase ast-grep's pattern in your favorite language!
I'm planning to add them as playground links in the homepage.
Beta Was this translation helpful? Give feedback.
All reactions