{"id":19690,"library":"eslint-plugin-astro","title":"eslint-plugin-astro","description":"An ESLint plugin for linting Astro components. Version 1.7.0 is the latest stable release, with active development and releases roughly monthly. It lints frontmatter, HTML templates, JSX-like expressions, client-side scripts, and directives. Supports both flat config (eslint.config.js) and legacy config (.eslintrc). Ships TypeScript types. Requires eslint >=8.57.0 and Node.js ^18.18.0 || ^20.9.0 || >=21.1.0. Differentiators: official AST-based parsing for Astro, rules for sort-attributes, no-unsafe-inline-scripts, and no-prerender-export-outside-pages. Community-maintained by ota-meshi.","status":"active","version":"1.7.0","language":"javascript","source_language":"en","source_url":"https://github.com/ota-meshi/eslint-plugin-astro","tags":["javascript","eslint","eslint-plugin","eslintplugin","astro","astrojs","typescript"],"install":[{"cmd":"npm install eslint-plugin-astro","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-astro","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-astro","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency, required core.","package":"eslint","optional":false},{"reason":"Required for TypeScript support in Astro components.","package":"@typescript-eslint/parser","optional":true},{"reason":"Optional, needed for accessibility (A11Y) rules.","package":"eslint-plugin-jsx-a11y","optional":true}],"imports":[{"note":"Default export for flat config. ESM-only; no CommonJS export.","wrong":"const eslintPluginAstro = require('eslint-plugin-astro');","symbol":"eslintPluginAstro","correct":"import eslintPluginAstro from 'eslint-plugin-astro';"},{"note":"Access configs from the default import. Legacy .eslintrc uses 'extends': ['plugin:astro/recommended'].","wrong":"const { configs: { recommended } } = require('eslint-plugin-astro');","symbol":"astro.configs.recommended","correct":"import eslintPluginAstro from 'eslint-plugin-astro';\nexport default [...eslintPluginAstro.configs.recommended];"},{"note":"Rules are on the default export object. TypeScript: import type { Rule } from 'eslint-plugin-astro'.","wrong":"const { rules } = require('eslint-plugin-astro');","symbol":"rules","correct":"import eslintPluginAstro from 'eslint-plugin-astro';\nconst rules = eslintPluginAstro.rules;"}],"quickstart":{"code":"// eslint.config.js (flat config)\nimport eslintPluginAstro from 'eslint-plugin-astro';\nimport js from '@eslint/js';\nimport tseslint from 'typescript-eslint';\n\nexport default [\n  js.configs.recommended,\n  ...eslintPluginAstro.configs.recommended,\n  ...tseslint.configs.recommended,\n  {\n    rules: {\n      'astro/no-unsafe-inline-scripts': 'error',\n    },\n  },\n];\n\n// .astro file example\n// Comment: also works with .eslintrc.cjs: module.exports = { extends: ['plugin:astro/recommended'] }","lang":"javascript","description":"Shows flat config setup with recommended Astro rules and TypeScript integration."},"warnings":[{"fix":"For flat config: import eslintPluginAstro from 'eslint-plugin-astro' and spread configs. For legacy: use 'extends': ['plugin:astro/recommended'].","message":"Flat config (eslint.config.js) vs legacy (.eslintrc) – the plugin supports both, but default export is for flat config; legacy uses 'plugin:astro/recommended' in extends.","severity":"gotcha","affected_versions":">=0.20.0"},{"fix":"Use import syntax (ESM). If you must use require, install an older version (e.g., 0.x).","message":"ESM only since v1.0.0. No CommonJS export; require() will fail.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Review rule documentation and migrate to recommended replacements.","message":"Some rules are marked as deprecated in future versions; check docs.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Install @typescript-eslint/parser and include it in parser options for .astro files.","message":"TypeScript support requires @typescript-eslint/parser; without it, TypeScript frontmatter is not parsed.","severity":"gotcha","affected_versions":">=0.8.0"},{"fix":"Install eslint-plugin-jsx-a11y or disable the A11Y rules.","message":"A11Y rules require optional dependency eslint-plugin-jsx-a11y; if not installed, those rules will error at runtime.","severity":"gotcha","affected_versions":">=0.0.1"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install --save-dev eslint-plugin-astro (ESM). If using require(), switch to import or downgrade to 0.x.","cause":"Missing installed plugin or incorrect import in CJS context.","error":"Error: Cannot find module 'eslint-plugin-astro'"},{"fix":"Upgrade eslint-plugin-astro to >=1.4.0: npm install eslint-plugin-astro@latest","cause":"Rule added in v1.4.0; using older version.","error":"Error: 'astro/no-unsafe-inline-scripts' rule is not defined"},{"fix":"Use the plugin's bundled parser: in flat config, include eslintPluginAstro.configs.recommended. In legacy config, set 'parser': 'astro-eslint-parser'.","cause":"Using ESLint parser that doesn't understand Astro syntax (e.g., default parser).","error":"Parsing error: The keyword 'export' is reserved"},{"fix":"Ensure you are spreading an array: ...eslintPluginAstro.configs['flat/recommended'] (or check version).","cause":"Using spread operator on configs object in flat config, but configs might not be array?","error":"TypeError: eslintPluginAstro.configs.recommended is not iterable"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}