When I run this tool, I get a crash.
λ 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)
λ 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.