{"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,"search_vec":"'1.7.0':13 '18.18.0':58 '20.9.0':59 '21.1.0':60 '8.57.0':55 'activ':20 'ast':64 'ast-bas':63 'astro':4,10,68,99 'astroj':100 'attribut':73 'base':65 'client':36 'client-sid':35 'communiti':87 'community-maintain':86 'compon':11 'config':44,48 'develop':21 'differenti':61 'direct':40 'eslint':2,6,54,94,96 'eslint-plugin':95 'eslint-plugin-astro':1 'eslint.config.js':45 'eslintplugin':98 'eslintrc':49 'export':83 'express':34 'flat':43 'frontmatt':28 'html':29 'inlin':77 'javascript':93 'jsx':32 'jsx-like':31 'latest':16 'legaci':47 'like':33 'lint':9,27 'maintain':88 'meshi':92 'month':25 'no-prerender-export-outside-pag':80 'no-unsafe-inline-script':74 'node.js':57 'offici':62 'ota':91 'ota-meshi':90 'outsid':84 'page':85 'pars':66 'plugin':3,7,97 'prerend':82 'releas':18,23 'requir':53 'rough':24 'rule':69 'script':38,78 'ship':50 'side':37 'sort':72 'sort-attribut':71 'stabl':17 'support':41 'templat':30 'type':52 'typescript':51,101 'unsaf':76 'version':12","created_at":"2026-04-25T11:19:07.540069+00:00","updated_at":"2026-04-25T11:19:07.540069+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":"https://ota-meshi.github.io/eslint-plugin-astro/","github":"https://github.com/ota-meshi/eslint-plugin-astro","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/eslint-plugin-astro","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}