Coder Social home page Coder Social logo

esquery-cli's Introduction

esquery-cli

Usage

npx esquery-cli <selector> [glob]

Queries files for a given AST selector based on `esquery`. Selector documentatio
n can be found at https://github.com/estools/esquery

Positionals:
  selector  CSS like                                                    [string]
  glob      Files to search. Note that files listed in the .gitignore in the cur
            rent working directory are ignored by default.
                              [string] [default: "**/*.{cjs,js,jsx,mjs,ts,tsx}"]

Options:
  --version            Show version number                             [boolean]
  --help               Show help                                       [boolean]
  --verbose            Logs additional information    [boolean] [default: false]
  --include-code-frame  Logs the codeframe of each query result.
                                                      [boolean] [default: false]

Examples:
  esquery-cli.js "TSAsExpression"

esquery-cli's People

Contributors

eps1lon avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

esquery-cli's Issues

Does not work

When I run this tool, I get a crash.

Node 14:

λ npx esquery-cli 'CallExpression > Identifier[name="require"]:not(Program > VariableDeclaration Identifier[name="require"])' 'tools/**/*.js'
npx: installed 102 in 8.705s
file:///Users/nheiner/.npm/_npx/4856/lib/node_modules/esquery-cli/bin/esquery-cli.js:2
import { codeFrameColumns } from "@babel/code-frame";
         ^^^^^^^^^^^^^^^^
SyntaxError: The requested module '@babel/code-frame' is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export.
For example:
import pkg from '@babel/code-frame';
const { codeFrameColumns } = pkg;
    at ModuleJob._instantiate (internal/modules/esm/module_job.js:98:21)
    at async ModuleJob.run (internal/modules/esm/module_job.js:137:5)
    at async Loader.import (internal/modules/esm/loader.js:165:24)
    at async Object.loadESM (internal/process/esm_loader.js:68:5)

Node 12:

λ npx esquery-cli 'CallExpression > Identifier[name="require"]:not(Program > VariableDeclaration Identifier[name="require"])' 'tools/**/*.js'
npx: installed 102 in 8.776s
Cannot use import statement outside a module
(node:4604) Warning: require() of ES modules is not supported.
require() of /Users/nheiner/.npm/_npx/4604/lib/node_modules/esquery-cli/bin/esquery-cli.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename esquery-cli.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/nheiner/.npm/_npx/4604/lib/node_modules/esquery-cli/package.json.

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.