Gathering detailed insights and metrics for astro-eslint-parser
Gathering detailed insights and metrics for astro-eslint-parser
Gathering detailed insights and metrics for astro-eslint-parser
Gathering detailed insights and metrics for astro-eslint-parser
typescript-eslint-parser-for-extra-files
An experimental ESLint custom parser for Vue, Svelte, and Astro for use with TypeScript. It provides type information in combination with each framework's ESLint custom parser.
@omegion1npm/maxime-eius-cumque
[![build status](https://img.shields.io/travis/astro/@omegion1npm/maxime-eius-cumque/master.svg?style=flat-square)](https://travis-ci.org/astro/@omegion1npm/maxime-eius-cumque/branches) [![js-standard-style](https://img.shields.io/badge/code%20style-stand
npm install astro-eslint-parser
Typescript
Module System
Min. Node Version
Node Version
NPM Version
73
Supply Chain
97.6
Quality
83.4
Maintenance
100
Vulnerability
98.9
License
TypeScript (67.83%)
Svelte (16.28%)
JavaScript (12.25%)
Astro (2.88%)
Dockerfile (0.76%)
Total Downloads
5,618,792
Last Day
9,150
Last Week
107,064
Last Month
480,039
Last Year
4,172,359
76 Stars
433 Commits
2 Forks
4 Watching
8 Branches
4 Contributors
Latest Version
1.1.0
Package Id
astro-eslint-parser@1.1.0
Unpacked Size
212.31 kB
Size
43.99 kB
File Count
7
NPM Version
10.7.0
Node Version
18.20.4
Publised On
12 Nov 2024
Cumulative downloads
Total Downloads
Last day
-59.3%
9,150
Compared to previous day
Last week
-18%
107,064
Compared to previous week
Last month
23.5%
480,039
Compared to previous month
Last year
217.9%
4,172,359
Compared to previous year
13
52
Astro component parser for ESLint.
You can check it on Online DEMO.
This parser is in the experimental stages of development.
At least it works fine with a withastro/docs repository.
This parser allows us to lint the script of .astro
files.
Note that this parser alone will not lint the scripts inside the
<script>
tag. Use eslint-plugin-astro to lint the script inside the<script>
tag as well.
ESLint plugin for Astro component.
1npm install --save-dev eslint astro-eslint-parser
First, we recommend using eslint-plugin-astro rather than just the parser.
The 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.
Write overrides[*].parser
option into your .eslintrc.*
file.
1{ 2 "extends": "eslint:recommended", 3 "overrides": [ 4 { 5 "files": ["*.astro"], 6 "parser": "astro-eslint-parser" 7 } 8 ] 9}
If you have specified the extension in the CLI, add .astro
as well.
1$ eslint "src/**/*.{js,astro}" 2# or 3$ eslint src --ext .js,.astro
The commit diff here is an example of introducing this parser to the astro.build
repository.
parserOptions
has the same properties as what espree, the default parser of ESLint, is supporting.
For example:
1{ 2 "parser": "astro-eslint-parser", 3 "parserOptions": { 4 "sourceType": "module", 5 "ecmaVersion": 2021, 6 "ecmaFeatures": { 7 "globalReturn": false, 8 "impliedStrict": false, 9 "jsx": false 10 } 11 } 12}
You can use parserOptions.parser
property to specify a custom parser to parse scripts.
Other properties than parser would be given to the specified parser.
For example:
1{ 2 "parser": "astro-eslint-parser", 3 "parserOptions": { 4 "parser": "@typescript-eslint/parser" 5 } 6}
For 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.
1module.exports = { 2 // ... 3 parser: "@typescript-eslint/parser", 4 parserOptions: { 5 // ... 6 project: "path/to/your/tsconfig.json", 7 extraFileExtensions: [".astro"], // This is a required setting in `@typescript-eslint/parser` v5. 8 }, 9 overrides: [ 10 { 11 files: ["*.astro"], 12 parser: "astro-eslint-parser", 13 // Parse the script in `.astro` as TypeScript by adding the following configuration. 14 parserOptions: { 15 parser: "@typescript-eslint/parser", 16 }, 17 }, 18 // ... 19 ], 20 // ... 21}
When using JavaScript configuration (.eslintrc.js
), you can also give the parser object directly.
1const tsParser = require("@typescript-eslint/parser") 2 3module.exports = { 4 parser: "astro-eslint-parser", 5 parserOptions: { 6 parser: tsParser, 7 }, 8}
Use the dbaeumer.vscode-eslint extension that Microsoft provides officially.
You 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.
Example .vscode/settings.json:
1{ 2 "eslint.validate": [ 3 "javascript", 4 "javascriptreact", 5 "astro" 6 ] 7}
Most of the rules in the ESLint core work for the script part, but some rules are incompatible.
This 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.
For example, the react/jsx-no-target-blank rule works fine.
If 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.
This parser works by converting the .astro
file to JSX and letting the JavaScript parser parse it.
Since @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.
See also @typescript-eslint/parser
readme.
Welcome contributing!
Please use GitHub's Issues/PRs.
If you are willing to see that this package continues to be maintained, please consider sponsoring me.
See the LICENSE file for license rights and limitations (MIT).
No vulnerabilities found.
No security vulnerabilities found.