astro-eslint-parser 1.3.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -59
- package/lib/index.d.mts +199 -230
- package/lib/index.mjs +2301 -2801
- package/lib/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/package.json +37 -36
- package/lib/index.d.ts +0 -331
- package/lib/index.js +0 -2960
package/README.md
CHANGED
|
@@ -19,7 +19,6 @@ This parser is in the ***experimental stages*** of development.
|
|
|
19
19
|
|
|
20
20
|
At least it works fine with a [withastro/docs](https://github.com/withastro/docs) repository.
|
|
21
21
|
|
|
22
|
-
[@astrojs/compiler]: https://github.com/withastro/compiler
|
|
23
22
|
|
|
24
23
|
## :checkered_flag: Motivation
|
|
25
24
|
|
|
@@ -39,23 +38,27 @@ ESLint plugin for Astro component.
|
|
|
39
38
|
npm install --save-dev eslint astro-eslint-parser
|
|
40
39
|
```
|
|
41
40
|
|
|
41
|
+
This package is ESM-only. Use `import` to load it from JavaScript config files.
|
|
42
|
+
CommonJS `require("astro-eslint-parser")` is not supported.
|
|
43
|
+
|
|
42
44
|
## 📖 Usage
|
|
43
45
|
|
|
44
46
|
**First, we recommend using [eslint-plugin-astro] rather than just the parser.**
|
|
45
|
-
The following
|
|
47
|
+
The following examples are for introducing only the parser. This is not useful for most people. It can be useful if you create your own plugin.
|
|
46
48
|
|
|
47
|
-
1.
|
|
49
|
+
1. Configure `languageOptions.parser` for `.astro` files in your `eslint.config.*` file.
|
|
48
50
|
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
```js
|
|
52
|
+
import * as astroParser from "astro-eslint-parser"
|
|
53
|
+
|
|
54
|
+
export default [
|
|
55
|
+
{
|
|
56
|
+
files: ["**/*.astro"],
|
|
57
|
+
languageOptions: {
|
|
58
|
+
parser: astroParser,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
]
|
|
59
62
|
```
|
|
60
63
|
|
|
61
64
|
2. If you have specified the extension in the CLI, add `.astro` as well.
|
|
@@ -68,24 +71,39 @@ The following usage it are for introducing only the parser. This is not useful f
|
|
|
68
71
|
|
|
69
72
|
The 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.
|
|
70
73
|
|
|
74
|
+
### Public API
|
|
75
|
+
|
|
76
|
+
Import this package from the package root:
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
import * as astroParser from "astro-eslint-parser"
|
|
80
|
+
```
|
|
81
|
+
|
|
71
82
|
## 🔧 Options
|
|
72
83
|
|
|
73
84
|
`parserOptions` has the same properties as what [espree](https://github.com/eslint/espree#usage), the default parser of ESLint, is supporting.
|
|
74
85
|
For example:
|
|
75
86
|
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
"
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
```js
|
|
88
|
+
import * as astroParser from "astro-eslint-parser"
|
|
89
|
+
|
|
90
|
+
export default [
|
|
91
|
+
{
|
|
92
|
+
files: ["**/*.astro"],
|
|
93
|
+
languageOptions: {
|
|
94
|
+
parser: astroParser,
|
|
95
|
+
parserOptions: {
|
|
96
|
+
sourceType: "module",
|
|
97
|
+
ecmaVersion: 2021,
|
|
98
|
+
ecmaFeatures: {
|
|
99
|
+
globalReturn: false,
|
|
100
|
+
impliedStrict: false,
|
|
101
|
+
jsx: false,
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
]
|
|
89
107
|
```
|
|
90
108
|
|
|
91
109
|
### parserOptions.parser
|
|
@@ -94,52 +112,63 @@ You can use `parserOptions.parser` property to specify a custom parser to parse
|
|
|
94
112
|
Other properties than parser would be given to the specified parser.
|
|
95
113
|
For example:
|
|
96
114
|
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
115
|
+
```js
|
|
116
|
+
import * as astroParser from "astro-eslint-parser"
|
|
117
|
+
|
|
118
|
+
export default [
|
|
119
|
+
{
|
|
120
|
+
files: ["**/*.astro"],
|
|
121
|
+
languageOptions: {
|
|
122
|
+
parser: astroParser,
|
|
123
|
+
parserOptions: {
|
|
124
|
+
parser: "@typescript-eslint/parser",
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
]
|
|
104
129
|
```
|
|
105
130
|
|
|
106
131
|
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.
|
|
107
132
|
|
|
108
133
|
```js
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
// ...
|
|
114
|
-
project: "path/to/your/tsconfig.json",
|
|
115
|
-
extraFileExtensions: [".astro"], // This is a required setting in `@typescript-eslint/parser` v5.
|
|
116
|
-
},
|
|
117
|
-
overrides: [
|
|
134
|
+
import tsParser from "@typescript-eslint/parser"
|
|
135
|
+
import * as astroParser from "astro-eslint-parser"
|
|
136
|
+
|
|
137
|
+
export default [
|
|
118
138
|
{
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
139
|
+
files: ["**/*.astro"],
|
|
140
|
+
languageOptions: {
|
|
141
|
+
parser: astroParser,
|
|
142
|
+
parserOptions: {
|
|
143
|
+
parser: tsParser,
|
|
144
|
+
project: "path/to/your/tsconfig.json",
|
|
145
|
+
extraFileExtensions: [".astro"],
|
|
146
|
+
},
|
|
147
|
+
},
|
|
125
148
|
},
|
|
126
|
-
|
|
127
|
-
],
|
|
128
|
-
// ...
|
|
129
|
-
}
|
|
149
|
+
]
|
|
130
150
|
```
|
|
131
151
|
|
|
132
|
-
|
|
152
|
+
You can also give different parsers for different languages.
|
|
133
153
|
|
|
134
154
|
```js
|
|
135
|
-
|
|
155
|
+
import tsParser from "@typescript-eslint/parser"
|
|
156
|
+
import * as astroParser from "astro-eslint-parser"
|
|
136
157
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
158
|
+
export default [
|
|
159
|
+
{
|
|
160
|
+
files: ["**/*.astro"],
|
|
161
|
+
languageOptions: {
|
|
162
|
+
parser: astroParser,
|
|
163
|
+
parserOptions: {
|
|
164
|
+
parser: {
|
|
165
|
+
ts: tsParser,
|
|
166
|
+
js: "espree",
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
},
|
|
141
170
|
},
|
|
142
|
-
|
|
171
|
+
]
|
|
143
172
|
```
|
|
144
173
|
|
|
145
174
|
## :computer: Editor Integrations
|