astro-eslint-parser is a specialized parser that enables ESLint to understand and lint `.astro` component files. It allows developers to integrate Astro projects with their existing ESLint configurations, providing linting for scripts embedded within Astro components, including client-side scripts and component scripts. The current stable version is 1.4.0, with regular patch and minor releases to improve compatibility with newer Astro compiler versions, ESLint, and TypeScript-ESLint. Its primary differentiator is its dedicated support for the unique syntax of Astro files, making it a crucial component for maintaining code quality in Astro projects, often used in conjunction with `eslint-plugin-astro` for a complete linting solution.
npm install astro-eslint-parserVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to install `astro-eslint-parser` and configure ESLint, including `eslint-plugin-astro` and TypeScript support, to lint Astro files.
Stay updated with releases and test configurations thoroughly after upgrades. Report issues to the GitHub repository.
Ensure `astro-eslint-parser` is updated to a version explicitly supporting your `@astrojs/compiler` version, as indicated in release notes (e.g., v1.4.0 added support for `@astrojs/compiler` v3).
It is highly recommended to use `eslint-plugin-astro` alongside this parser, as it provides rules and configurations to correctly lint all script contexts within Astro components, including `<script>` tags.
Keep `astro-eslint-parser` updated to its latest version to ensure compatibility. For example, v1.3.0 improved compatibility with ESLint v10, and v1.0.3 fixed support for `typescript-eslint@8`.
Ensure `parserOptions.sourceType` is set to `module` in your `.eslintrc` file, especially within the `overrides` section for `*.astro` files.
Install the TypeScript ESLint parser: `npm install --save-dev @typescript-eslint/parser`.
Ensure `astro-eslint-parser` is correctly specified as the `parser` for `*.astro` files in your ESLint configuration's `overrides` section.
Update `astro-eslint-parser` to the latest version. Check the Astro component for valid HTML/JSX structure, and report specific cases to the maintainers if the issue persists with valid code.