Giter Site home page Giter Site logo

jiangwen0105 / gritql Goto Github PK

View Code? Open in Web Editor NEW

This project forked from webpro/gritql

0.0 0.0 0.0 13.85 MB

GritQL is a query language for searching, linting, and modifying code.

License: MIT License

Shell 0.01% JavaScript 0.95% Ruby 0.01% C++ 0.10% Scheme 0.04% Python 0.24% C 96.44% Java 0.01% Go 0.16% C# 0.01% Rust 1.40% TypeScript 0.32% CSS 0.22% Swift 0.01% Nix 0.01% Makefile 0.07% HTML 0.02% CMake 0.01% PLSQL 0.01% RenderScript 0.01%

gritql's Introduction

GritQL

CI Status MIT License Discord

GritQL is a declarative query language for searching and modifying source code. GritQL focuses on a few areas:

  • ๐Ÿ“– Start simply without learning AST details: any code snippet is a valid GritQL query
  • โšก๏ธ Use Rust and query optimization to scale up to 10M+ line repositories
  • ๐Ÿ“ฆ Use Grit's built-in module system to reuse 200+ standard patterns or share your own
  • โ™ป๏ธ Once you learn GritQL, you can use it to rewrite any target language: JavaScript/TypeScript, Python, JSON, Java, Terraform, Solidity, CSS, Markdown, YAML, Rust, Go, or SQL
  • ๐Ÿ”ง GritQL makes it easy to include auto-fix rules for faster remediation

Read the docs or try any query in the studio.

Getting started

Read the documentation, interactive tutorial, or run grit --help.

Installation

Install the Grit CLI:

curl -fsSL https://docs.grit.io/install | bash

Usage

Find all your console.log calls:

grit apply '`console.log($_)`'

Replace console.log with winston.log:

grit apply '`console.log($msg)` => `winston.log($msg)`'

Save the pattern to a grit.yaml file and exclude test cases:

cat << 'EOF' > .grit/grit.yaml
patterns:
  - name: use_winston
    level: error
    body: |
      `console.log($msg)` => `winston.log($msg)` where {
        $msg <: not within or { `it($_, $_)`, `test($_, $_)`, `describe($_, $_)` }
      }
EOF
grit apply use_winston

Run grit check to enforce your patterns as custom lints.

grit check

Acknowledgements

GritQL uses tree sitter for all language parsers and benefits greatly from the Rust ecosystem.

GritQL is released under the MIT license.

Contributing

Contributions are welcome. To get started, check out the contributing guidelines.

You can also join us on Discord.

gritql's People

Contributors

morgante avatar ilevyor avatar

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.