Registry / testing / eslint-plugin-ast-grep

eslint-plugin-ast-grep

JSON →
library1.0.0jsnpmunverified

ESLint plugin leveraging ast-grep for pattern-based syntax restriction. Current stable version: 1.0.0. Released under MIT license. Key differentiator: uses ast-grep's powerful pattern matching instead of ESLint's built-in AST selectors, enabling more flexible and concise rule definitions. Requires ESLint >=9.0.0 and @ast-grep/napi >=0.30.0. Provides a single rule `no-restricted-syntax` that accepts string patterns or objects with custom messages. Adheres to ESLint's flat config and is ESM-only.

npm install eslint-plugin-ast-grep
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-AST-
E
eslint-plugin-ast-grep
testingjavascriptv1.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

rules
import plugin from 'eslint-plugin-ast-grep'
const plugin = require('eslint-plugin-ast-grep')
ESM-only; no default export for commonjs. Plugin object contains `rules` and `configs`.
no-restricted-syntax
import { rules } from 'eslint-plugin-ast-grep'; rules['no-restricted-syntax']
import { noRestrictedSyntax } from 'eslint-plugin-ast-grep'
Access rule via `rules` property; no named export for individual rules.

Basic ESLint flat config using the plugin to ban console.log and console.warn via ast-grep patterns.

import plugin from 'eslint-plugin-ast-grep'; export default [ { plugins: { 'ast-grep': plugin }, rules: { 'ast-grep/no-restricted-syntax': ['error', 'console.log', 'console.warn'] } } ];
Debug
Known issues
breakingESLint plugin with ast-grep requires ESLint 9.0.0 or higher (flat config only).
fix
Upgrade ESLint to >=9.0.0 and migrate to flat config.
affects: >=1.0.0
breakingPlugin is ESM-only; does not support CommonJS require().
fix
Use `import` syntax; if in CommonJS project, use dynamic import or switch to ESM.
affects: >=1.0.0
deprecatedThe `no-restricted-syntax` rule does not support ESLint's built-in AST selectors; use ast-grep patterns instead.
fix
Replace ESLint selectors with ast-grep pattern syntax.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'eslint-plugin-ast-grep'
Plugin not installed or not in node_modules.
fix
Run 'npm install -D eslint-plugin-ast-grep'.
Error: ESLint configuration in .eslintrc is deprecated: Unable to extend from 'plugin:ast-grep/recommended'
Using old .eslintrc format; plugin requires ESLint flat config (eslint.config.js).
fix
Migrate to eslint.config.js flat config (see docs).
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
eslintrequiredpeer dependency, ESLint plugin API used
@ast-grep/napirequiredpeer dependency, provides ast-grep pattern matching
Agent activity
4 hits · last 30 days
node
4
Resources
eslint-plugin-ast-grep — npm install eslint-plugin-ast-grep · libregistry