{"id":15641600,"url":"https://github.com/ota-meshi/astro-eslint-parser","last_synced_at":"2026-04-02T11:50:08.709Z","repository":{"id":37213037,"uuid":"485708984","full_name":"ota-meshi/astro-eslint-parser","owner":"ota-meshi","description":"Astro component parser for ESLint","archived":false,"fork":false,"pushed_at":"2026-04-01T17:51:22.000Z","size":4050,"stargazers_count":85,"open_issues_count":8,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-02T04:42:59.323Z","etag":null,"topics":["astro","astrojs","eslint","eslint-custom-parser","eslint-parser","parser"],"latest_commit_sha":null,"homepage":"https://ota-meshi.github.io/astro-eslint-parser/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ota-meshi.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"ota-meshi"}},"created_at":"2022-04-26T09:00:08.000Z","updated_at":"2026-03-27T20:51:13.000Z","dependencies_parsed_at":"2023-02-14T02:46:46.629Z","dependency_job_id":"9bba9c90-8cf3-4a15-a212-5be2f7e353ed","html_url":"https://github.com/ota-meshi/astro-eslint-parser","commit_stats":{"total_commits":431,"total_committers":5,"mean_commits":86.2,"dds":0.5081206496519721,"last_synced_commit":"144bbb7c3462f1f0ad921f149b0115ebfb907104"},"previous_names":[],"tags_count":76,"template":false,"template_full_name":null,"purl":"pkg:github/ota-meshi/astro-eslint-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ota-meshi%2Fastro-eslint-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ota-meshi%2Fastro-eslint-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ota-meshi%2Fastro-eslint-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ota-meshi%2Fastro-eslint-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ota-meshi","download_url":"https://codeload.github.com/ota-meshi/astro-eslint-parser/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ota-meshi%2Fastro-eslint-parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31305809,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T09:48:21.550Z","status":"ssl_error","status_checked_at":"2026-04-02T09:48:19.196Z","response_time":89,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["astro","astrojs","eslint","eslint-custom-parser","eslint-parser","parser"],"created_at":"2024-10-03T11:43:18.869Z","updated_at":"2026-04-02T11:50:08.686Z","avatar_url":"https://github.com/ota-meshi.png","language":"TypeScript","funding_links":["https://github.com/sponsors/ota-meshi"],"categories":[],"sub_categories":[],"readme":"# astro-eslint-parser\n\n[Astro] component parser for [ESLint].  \nYou can check it on [Online DEMO](https://ota-meshi.github.io/astro-eslint-parser/playground).\n\n[![sponsors](https://img.shields.io/badge/-Sponsor-fafbfc?logo=GitHub%20Sponsors)](https://github.com/sponsors/ota-meshi)\n\n[![NPM license](https://img.shields.io/npm/l/astro-eslint-parser.svg)](https://www.npmjs.com/package/astro-eslint-parser)\n[![NPM version](https://img.shields.io/npm/v/astro-eslint-parser.svg)](https://www.npmjs.com/package/astro-eslint-parser)\n[![NPM downloads](https://img.shields.io/badge/dynamic/json.svg?label=downloads\u0026colorB=green\u0026suffix=/day\u0026query=$.downloads\u0026uri=https://api.npmjs.org//downloads/point/last-day/astro-eslint-parser\u0026maxAge=3600)](http://www.npmtrends.com/astro-eslint-parser)\n[![NPM downloads](https://img.shields.io/npm/dw/astro-eslint-parser.svg)](http://www.npmtrends.com/astro-eslint-parser)\n[![NPM downloads](https://img.shields.io/npm/dm/astro-eslint-parser.svg)](http://www.npmtrends.com/astro-eslint-parser)\n[![NPM downloads](https://img.shields.io/npm/dy/astro-eslint-parser.svg)](http://www.npmtrends.com/astro-eslint-parser)\n[![NPM downloads](https://img.shields.io/npm/dt/astro-eslint-parser.svg)](http://www.npmtrends.com/astro-eslint-parser)\n[![Build Status](https://github.com/ota-meshi/astro-eslint-parser/workflows/CI/badge.svg?branch=main)](https://github.com/ota-meshi/astro-eslint-parser/actions?query=workflow%3ACI)\n[![Coverage Status](https://coveralls.io/repos/github/ota-meshi/astro-eslint-parser/badge.svg?branch=main)](https://coveralls.io/github/ota-meshi/astro-eslint-parser?branch=main)\n\nThis parser is in the ***experimental stages*** of development.\n\nAt least it works fine with a [withastro/docs](https://github.com/withastro/docs) repository.\n\n[@astrojs/compiler]: https://github.com/withastro/compiler\n\n## :checkered_flag: Motivation\n\nThis parser allows us to lint the script of `.astro` files.\n\n\u003e Note that this parser alone will not lint the scripts inside the `\u003cscript\u003e` tag. Use [eslint-plugin-astro] to lint the script inside the `\u003cscript\u003e` tag as well.\n\n### ESLint Plugins Using astro-eslint-parser\n\n#### [eslint-plugin-astro]\n\nESLint plugin for Astro component.  \n\n## 💿 Installation\n\n```bash\nnpm install --save-dev eslint astro-eslint-parser\n```\n\n## 📖 Usage\n\n**First, we recommend using [eslint-plugin-astro] rather than just the parser.**  \nThe following usage it are for introducing only the parser. This is not useful for most people. It can be useful if you create your own plugin.\n\n1. Write `overrides[*].parser` option into your `.eslintrc.*` file.\n\n    ```json\n    {\n        \"extends\": \"eslint:recommended\",\n        \"overrides\": [\n            {\n                \"files\": [\"*.astro\"],\n                \"parser\": \"astro-eslint-parser\"\n            }\n        ]\n    }\n    ```\n\n2. If you have specified the extension in the CLI, add `.astro` as well.\n\n    ```console\n    $ eslint \"src/**/*.{js,astro}\"\n    # or\n    $ eslint src --ext .js,.astro\n    ```\n\nThe commit diff [here](https://github.com/withastro/astro.build/compare/main...ota-meshi:eslint) is an example of introducing this parser to the `astro.build` repository.\n\n## 🔧 Options\n\n`parserOptions` has the same properties as what [espree](https://github.com/eslint/espree#usage), the default parser of ESLint, is supporting.\nFor example:\n\n```json\n{\n    \"parser\": \"astro-eslint-parser\",\n    \"parserOptions\": {\n        \"sourceType\": \"module\",\n        \"ecmaVersion\": 2021,\n        \"ecmaFeatures\": {\n            \"globalReturn\": false,\n            \"impliedStrict\": false,\n            \"jsx\": false\n        }\n    }\n}\n```\n\n### parserOptions.parser\n\nYou can use `parserOptions.parser` property to specify a custom parser to parse scripts.\nOther properties than parser would be given to the specified parser.\nFor example:\n\n```json\n{\n    \"parser\": \"astro-eslint-parser\",\n    \"parserOptions\": {\n        \"parser\": \"@typescript-eslint/parser\"\n    }\n}\n```\n\nFor example, if you are using the `\"@typescript-eslint/parser\"`, and if you want to use TypeScript in `.astro`, you need to add more `parserOptions` configuration.\n\n```js\nmodule.exports = {\n  // ...\n  parser: \"@typescript-eslint/parser\",\n  parserOptions: {\n    // ...\n    project: \"path/to/your/tsconfig.json\",\n    extraFileExtensions: [\".astro\"], // This is a required setting in `@typescript-eslint/parser` v5.\n  },\n  overrides: [\n    {\n      files: [\"*.astro\"],\n      parser: \"astro-eslint-parser\",\n      // Parse the script in `.astro` as TypeScript by adding the following configuration.\n      parserOptions: {\n        parser: \"@typescript-eslint/parser\",\n      },\n    },\n    // ...\n  ],\n  // ...\n}\n```\n\nWhen using JavaScript configuration (`.eslintrc.js`), you can also give the parser object directly.\n\n```js\nconst tsParser = require(\"@typescript-eslint/parser\")\n\nmodule.exports = {\n    parser: \"astro-eslint-parser\",\n    parserOptions: {\n        parser: tsParser,\n    },\n}\n```\n\n## :computer: Editor Integrations\n\n### Visual Studio Code\n\nUse the [dbaeumer.vscode-eslint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) extension that Microsoft provides officially.\n\nYou have to configure the `eslint.validate` option of the extension to check `.astro` files, because the extension targets only `*.js` or `*.jsx` files by default.\n\nExample **.vscode/settings.json**:\n\n```json\n{\n    \"eslint.validate\": [\n        \"javascript\",\n        \"javascriptreact\",\n        \"astro\"\n    ]\n}\n```\n\n## :handshake: Compatibility With Existing ESLint Rules\n\nMost of the rules in the ESLint core work for the script part, but some rules are incompatible.  \nThis parser will generate a JSX compatible AST for most of the HTML part of the Astro component. Therefore, some rules of [eslint-plugin-react] may work.\nFor example, the [react/jsx-no-target-blank] rule works fine.  \n\n[eslint-plugin-react]: https://github.com/jsx-eslint/eslint-plugin-react/\n[react/jsx-no-target-blank]: https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md\n\n## :ghost: Limitations\n\nIf this parser is used with `@typescript-eslint/parser` and `parserOptions.project` is set, it will temporarily create a `.tsx` file to parse the `.astro` file.  \nThis parser works by converting the `.astro` file to JSX and letting the JavaScript parser parse it.\nSince `@typescript-eslint/parser` can only parse files with the extension `.tsx` as JSX, it is necessary to temporarily create a `.tsx` file. Temporarily created files will try to be deleted after parses, but if the parsing takes a long time, the files may be visible to you.\n\nSee also [`@typescript-eslint/parser` readme](https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/parser#parseroptionsecmafeaturesjsx).\n\n## :hammer_and_wrench: Usage for Custom Rules / Plugins\n\n\u003c!-- - [AST.md](./docs/AST.md) is AST specification. You can check it on the [Online DEMO](https://ota-meshi.github.io/astro-eslint-parser/). --\u003e\n\n- TBA\n- You can check the AST in the [Online DEMO](https://ota-meshi.github.io/astro-eslint-parser/). However, AST is subject to major changes in the future.\n- I have already [implemented some rules] in the [eslint-plugin-astro]. The source code for these rules will be helpful to you.\n\n## :beers: Contributing\n\nWelcome contributing!\n\nPlease use GitHub's Issues/PRs.\n\n## :heart: Supporting\n\nIf you are willing to see that this package continues to be maintained, please consider sponsoring me.\n\n[![sponsors](https://img.shields.io/badge/-Sponsor-fafbfc?logo=GitHub%20Sponsors)](https://github.com/sponsors/ota-meshi)\n\n## :lock: License\n\nSee the [LICENSE](LICENSE) file for license rights and limitations (MIT).\n\n[Astro]: https://astro.build/\n[ESLint]: https://eslint.org/\n[eslint-plugin-astro]: https://ota-meshi.github.io/eslint-plugin-astro/\n[implemented some rules]: https://ota-meshi.github.io/eslint-plugin-astro/rules/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fota-meshi%2Fastro-eslint-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fota-meshi%2Fastro-eslint-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fota-meshi%2Fastro-eslint-parser/lists"}