astro-eslint-parser 0.6.3 → 0.7.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/lib/index.js +15 -8
- package/lib/index.mjs +15 -8
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -1208,18 +1208,25 @@ function sortedLastIndex(array, value) {
|
|
|
1208
1208
|
// src/parser/astro-parser/parse.ts
|
|
1209
1209
|
var service = __toESM(require("astrojs-compiler-sync"));
|
|
1210
1210
|
function parse2(code, ctx) {
|
|
1211
|
-
const
|
|
1212
|
-
|
|
1213
|
-
|
|
1211
|
+
const result = service.parse(code, { position: true });
|
|
1212
|
+
for (const { code: code2, text, location } of result.diagnostics || []) {
|
|
1213
|
+
ctx.originalAST = result.ast;
|
|
1214
|
+
throw new ParseError(`[${code2}]: ${text}`, location.length, ctx);
|
|
1214
1215
|
}
|
|
1215
|
-
|
|
1216
|
+
if (!result.ast.children) {
|
|
1217
|
+
result.ast.children = [];
|
|
1218
|
+
}
|
|
1219
|
+
const htmlElement = result.ast.children.find(
|
|
1216
1220
|
(n) => n.type === "element" && n.name === "html"
|
|
1217
1221
|
);
|
|
1218
|
-
if (
|
|
1219
|
-
|
|
1222
|
+
if (!result._adjusted) {
|
|
1223
|
+
if (htmlElement) {
|
|
1224
|
+
adjustHTML(result.ast, htmlElement, ctx);
|
|
1225
|
+
}
|
|
1226
|
+
fixLocations(result.ast, ctx);
|
|
1227
|
+
result._adjusted = true;
|
|
1220
1228
|
}
|
|
1221
|
-
|
|
1222
|
-
return { ast };
|
|
1229
|
+
return result;
|
|
1223
1230
|
}
|
|
1224
1231
|
function adjustHTML(ast, htmlElement, ctx) {
|
|
1225
1232
|
var _a;
|
package/lib/index.mjs
CHANGED
|
@@ -1179,18 +1179,25 @@ function sortedLastIndex(array, value) {
|
|
|
1179
1179
|
// src/parser/astro-parser/parse.ts
|
|
1180
1180
|
import * as service from "astrojs-compiler-sync";
|
|
1181
1181
|
function parse2(code, ctx) {
|
|
1182
|
-
const
|
|
1183
|
-
|
|
1184
|
-
|
|
1182
|
+
const result = service.parse(code, { position: true });
|
|
1183
|
+
for (const { code: code2, text, location } of result.diagnostics || []) {
|
|
1184
|
+
ctx.originalAST = result.ast;
|
|
1185
|
+
throw new ParseError(`[${code2}]: ${text}`, location.length, ctx);
|
|
1185
1186
|
}
|
|
1186
|
-
|
|
1187
|
+
if (!result.ast.children) {
|
|
1188
|
+
result.ast.children = [];
|
|
1189
|
+
}
|
|
1190
|
+
const htmlElement = result.ast.children.find(
|
|
1187
1191
|
(n) => n.type === "element" && n.name === "html"
|
|
1188
1192
|
);
|
|
1189
|
-
if (
|
|
1190
|
-
|
|
1193
|
+
if (!result._adjusted) {
|
|
1194
|
+
if (htmlElement) {
|
|
1195
|
+
adjustHTML(result.ast, htmlElement, ctx);
|
|
1196
|
+
}
|
|
1197
|
+
fixLocations(result.ast, ctx);
|
|
1198
|
+
result._adjusted = true;
|
|
1191
1199
|
}
|
|
1192
|
-
|
|
1193
|
-
return { ast };
|
|
1200
|
+
return result;
|
|
1194
1201
|
}
|
|
1195
1202
|
function adjustHTML(ast, htmlElement, ctx) {
|
|
1196
1203
|
var _a;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro-eslint-parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Astro component parser for ESLint",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.mjs",
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
},
|
|
48
48
|
"homepage": "https://github.com/ota-meshi/astro-eslint-parser#readme",
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@astrojs/compiler": "
|
|
50
|
+
"@astrojs/compiler": "^0.27.0",
|
|
51
51
|
"@typescript-eslint/types": "^5.25.0",
|
|
52
|
-
"astrojs-compiler-sync": "^0.
|
|
52
|
+
"astrojs-compiler-sync": "^0.3.0",
|
|
53
53
|
"debug": "^4.3.4",
|
|
54
54
|
"eslint-visitor-keys": "^3.0.0",
|
|
55
55
|
"espree": "^9.0.0"
|