Registry / testing / eslint-plugin-astro

eslint-plugin-astro

JSON →
library1.7.0jsnpmunverified

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.

npm install eslint-plugin-astro
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-ASTR
E
eslint-plugin-astro
testingjavascriptv1.7.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.

eslintPluginAstro
import eslintPluginAstro from 'eslint-plugin-astro';
const eslintPluginAstro = require('eslint-plugin-astro');
Default export for flat config. ESM-only; no CommonJS export.
astro.configs.recommended
import eslintPluginAstro from 'eslint-plugin-astro'; export default [...eslintPluginAstro.configs.recommended];
const { configs: { recommended } } = require('eslint-plugin-astro');
Access configs from the default import. Legacy .eslintrc uses 'extends': ['plugin:astro/recommended'].
rules
import eslintPluginAstro from 'eslint-plugin-astro'; const rules = eslintPluginAstro.rules;
const { rules } = require('eslint-plugin-astro');
Rules are on the default export object. TypeScript: import type { Rule } from 'eslint-plugin-astro'.

Shows flat config setup with recommended Astro rules and TypeScript integration.

// eslint.config.js (flat config) import eslintPluginAstro from 'eslint-plugin-astro'; import js from '@eslint/js'; import tseslint from 'typescript-eslint'; export default [ js.configs.recommended, ...eslintPluginAstro.configs.recommended, ...tseslint.configs.recommended, { rules: { 'astro/no-unsafe-inline-scripts': 'error', }, }, ]; // .astro file example // Comment: also works with .eslintrc.cjs: module.exports = { extends: ['plugin:astro/recommended'] }
Debug
Known issues
gotchaFlat 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.
fix
For flat config: import eslintPluginAstro from 'eslint-plugin-astro' and spread configs. For legacy: use 'extends': ['plugin:astro/recommended'].
affects: >=0.20.0
breakingESM only since v1.0.0. No CommonJS export; require() will fail.
fix
Use import syntax (ESM). If you must use require, install an older version (e.g., 0.x).
affects: >=1.0.0
deprecatedSome rules are marked as deprecated in future versions; check docs.
fix
Review rule documentation and migrate to recommended replacements.
affects: >=1.0.0
gotchaTypeScript support requires @typescript-eslint/parser; without it, TypeScript frontmatter is not parsed.
fix
Install @typescript-eslint/parser and include it in parser options for .astro files.
affects: >=0.8.0
gotchaA11Y rules require optional dependency eslint-plugin-jsx-a11y; if not installed, those rules will error at runtime.
fix
Install eslint-plugin-jsx-a11y or disable the A11Y rules.
affects: >=0.0.1
Errors
Common errors & fixes
Error: Cannot find module 'eslint-plugin-astro'
Missing installed plugin or incorrect import in CJS context.
fix
npm install --save-dev eslint-plugin-astro (ESM). If using require(), switch to import or downgrade to 0.x.
Error: 'astro/no-unsafe-inline-scripts' rule is not defined
Rule added in v1.4.0; using older version.
fix
Upgrade eslint-plugin-astro to >=1.4.0: npm install eslint-plugin-astro@latest
Parsing error: The keyword 'export' is reserved
Using ESLint parser that doesn't understand Astro syntax (e.g., default parser).
fix
Use the plugin's bundled parser: in flat config, include eslintPluginAstro.configs.recommended. In legacy config, set 'parser': 'astro-eslint-parser'.
TypeError: eslintPluginAstro.configs.recommended is not iterable
Using spread operator on configs object in flat config, but configs might not be array?
fix
Ensure you are spreading an array: ...eslintPluginAstro.configs['flat/recommended'] (or check version).
Upgrade
Version history
1.7.0latest on npm
Audit
Dependencies
eslintrequiredPeer dependency, required core.
@typescript-eslint/parseroptionalRequired for TypeScript support in Astro components.
eslint-plugin-jsx-a11yoptionalOptional, needed for accessibility (A11Y) rules.
Agent activity
2 hits · last 30 days
node
2
Resources
eslint-plugin-astro — npm install eslint-plugin-astro · libregistry