GithubHelp home page GithubHelp logo

Comments (4)

HerringtonDarkholme avatar HerringtonDarkholme commented on June 8, 2024

Sorry I didn't get your point.

If you need a rule to convert identifier, https://ast-grep.github.io/reference/yaml/transformation.html#convert can do that already.

from ast-grep.

milahu avatar milahu commented on June 8, 2024

convert can do that already

aah! also Use transform in Rewrite. but the docs have no full example

i just cant get this working... this should rename some_var to someVar
ast-grep always shows the interactive screen, but it should just patch input.py

cat >input.py <<'EOF'
some_var = 1
print(some_var)
EOF

cat >rules.yaml <<'EOF'
id: fix-case
language: python
rule:
  pattern: $X
  kind: identifier
transform:
  X2:
    convert:
      toCase: camelCase
      source: $X
# edit: fix was missing
fix: $X2
EOF

ast-grep scan -U -r rules.yaml input.py

from ast-grep.

HerringtonDarkholme avatar HerringtonDarkholme commented on June 8, 2024

You also need a fix field to apply the fix. https://ast-grep.github.io/reference/yaml/fix.html

id: fix-case
language: python
rule:
  pattern: $X
  kind: identifier
transform:
  X2:
    convert:
      toCase: camelCase
      source: $X
fix: $X2

Please read the doc. https://ast-grep.github.io/guide/rewrite-code.html

from ast-grep.

milahu avatar milahu commented on June 8, 2024

aah ^^ thanks : )

from ast-grep.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.