astro-eslint-parser 0.6.3 → 0.7.1
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 +17 -8
- package/lib/index.mjs +17 -8
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -1208,18 +1208,27 @@ 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, severity } of result.diagnostics || []) {
|
|
1213
|
+
if (severity === 1) {
|
|
1214
|
+
ctx.originalAST = result.ast;
|
|
1215
|
+
throw new ParseError(`${text} [${code2}]`, location.length, ctx);
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
if (!result.ast.children) {
|
|
1219
|
+
result.ast.children = [];
|
|
1214
1220
|
}
|
|
1215
|
-
const htmlElement = ast.children.find(
|
|
1221
|
+
const htmlElement = result.ast.children.find(
|
|
1216
1222
|
(n) => n.type === "element" && n.name === "html"
|
|
1217
1223
|
);
|
|
1218
|
-
if (
|
|
1219
|
-
|
|
1224
|
+
if (!result._adjusted) {
|
|
1225
|
+
if (htmlElement) {
|
|
1226
|
+
adjustHTML(result.ast, htmlElement, ctx);
|
|
1227
|
+
}
|
|
1228
|
+
fixLocations(result.ast, ctx);
|
|
1229
|
+
result._adjusted = true;
|
|
1220
1230
|
}
|
|
1221
|
-
|
|
1222
|
-
return { ast };
|
|
1231
|
+
return result;
|
|
1223
1232
|
}
|
|
1224
1233
|
function adjustHTML(ast, htmlElement, ctx) {
|
|
1225
1234
|
var _a;
|
package/lib/index.mjs
CHANGED
|
@@ -1179,18 +1179,27 @@ 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, severity } of result.diagnostics || []) {
|
|
1184
|
+
if (severity === 1) {
|
|
1185
|
+
ctx.originalAST = result.ast;
|
|
1186
|
+
throw new ParseError(`${text} [${code2}]`, location.length, ctx);
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
if (!result.ast.children) {
|
|
1190
|
+
result.ast.children = [];
|
|
1185
1191
|
}
|
|
1186
|
-
const htmlElement = ast.children.find(
|
|
1192
|
+
const htmlElement = result.ast.children.find(
|
|
1187
1193
|
(n) => n.type === "element" && n.name === "html"
|
|
1188
1194
|
);
|
|
1189
|
-
if (
|
|
1190
|
-
|
|
1195
|
+
if (!result._adjusted) {
|
|
1196
|
+
if (htmlElement) {
|
|
1197
|
+
adjustHTML(result.ast, htmlElement, ctx);
|
|
1198
|
+
}
|
|
1199
|
+
fixLocations(result.ast, ctx);
|
|
1200
|
+
result._adjusted = true;
|
|
1191
1201
|
}
|
|
1192
|
-
|
|
1193
|
-
return { ast };
|
|
1202
|
+
return result;
|
|
1194
1203
|
}
|
|
1195
1204
|
function adjustHTML(ast, htmlElement, ctx) {
|
|
1196
1205
|
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.1",
|
|
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"
|