{"id":19689,"library":"eslint-plugin-ast-grep","title":"eslint-plugin-ast-grep","description":"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.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","eslint","eslint-plugin","ast-grep"],"install":[{"cmd":"npm install eslint-plugin-ast-grep","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-ast-grep","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-ast-grep","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency, ESLint plugin API used","package":"eslint","optional":false},{"reason":"peer dependency, provides ast-grep pattern matching","package":"@ast-grep/napi","optional":false}],"imports":[{"note":"ESM-only; no default export for commonjs. Plugin object contains `rules` and `configs`.","wrong":"const plugin = require('eslint-plugin-ast-grep')","symbol":"rules","correct":"import plugin from 'eslint-plugin-ast-grep'"},{"note":"Access rule via `rules` property; no named export for individual rules.","wrong":"import { noRestrictedSyntax } from 'eslint-plugin-ast-grep'","symbol":"no-restricted-syntax","correct":"import { rules } from 'eslint-plugin-ast-grep'; rules['no-restricted-syntax']"}],"quickstart":{"code":"import plugin from 'eslint-plugin-ast-grep';\n\nexport default [\n  {\n    plugins: { 'ast-grep': plugin },\n    rules: {\n      'ast-grep/no-restricted-syntax': ['error', 'console.log', 'console.warn']\n    }\n  }\n];","lang":"typescript","description":"Basic ESLint flat config using the plugin to ban console.log and console.warn via ast-grep patterns."},"warnings":[{"fix":"Upgrade ESLint to >=9.0.0 and migrate to flat config.","message":"ESLint plugin with ast-grep requires ESLint 9.0.0 or higher (flat config only).","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use `import` syntax; if in CommonJS project, use dynamic import or switch to ESM.","message":"Plugin is ESM-only; does not support CommonJS require().","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Replace ESLint selectors with ast-grep pattern syntax.","message":"The `no-restricted-syntax` rule does not support ESLint's built-in AST selectors; use ast-grep patterns instead.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install -D eslint-plugin-ast-grep'.","cause":"Plugin not installed or not in node_modules.","error":"Error: Cannot find module 'eslint-plugin-ast-grep'"},{"fix":"Migrate to eslint.config.js flat config (see docs).","cause":"Using old .eslintrc format; plugin requires ESLint flat config (eslint.config.js).","error":"Error: ESLint configuration in .eslintrc is deprecated: Unable to extend from 'plugin:ast-grep/recommended'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}