astro-eslint-parser 1.2.2 → 1.3.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.d.mts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +122 -25
- package/lib/index.mjs +122 -28
- package/package.json +21 -21
package/lib/index.d.mts
CHANGED
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -513,7 +513,6 @@ function isTSESLintParserObject(value) {
|
|
|
513
513
|
// src/parser/script.ts
|
|
514
514
|
var import_types = require("@typescript-eslint/types");
|
|
515
515
|
var import_scope_manager2 = require("@typescript-eslint/scope-manager");
|
|
516
|
-
var import_eslint_scope = require("eslint-scope");
|
|
517
516
|
|
|
518
517
|
// src/traverse.ts
|
|
519
518
|
function fallbackKeysFilter(key) {
|
|
@@ -848,7 +847,52 @@ function addReference(list, reference) {
|
|
|
848
847
|
);
|
|
849
848
|
}
|
|
850
849
|
|
|
850
|
+
// src/parser/eslint-scope.ts
|
|
851
|
+
var eslintScope = __toESM(require("eslint-scope"));
|
|
852
|
+
var import_semver2 = __toESM(require("semver"));
|
|
853
|
+
var import_path3 = __toESM(require("path"));
|
|
854
|
+
var import_module3 = require("module");
|
|
855
|
+
var eslintScopeCache = null;
|
|
856
|
+
function getEslintScope() {
|
|
857
|
+
return eslintScopeCache ?? (eslintScopeCache = getNewest());
|
|
858
|
+
}
|
|
859
|
+
function getNewest() {
|
|
860
|
+
let newest = eslintScope;
|
|
861
|
+
const userEslintScope = getEslintScopeFromUser();
|
|
862
|
+
if (userEslintScope && userEslintScope.version != null && import_semver2.default.lte(newest.version, userEslintScope.version)) {
|
|
863
|
+
newest = userEslintScope;
|
|
864
|
+
}
|
|
865
|
+
const eslintEslintScope = getEslintScopeFromEslint();
|
|
866
|
+
if (eslintEslintScope && eslintEslintScope.version != null && import_semver2.default.lte(newest.version, eslintEslintScope.version)) {
|
|
867
|
+
newest = eslintEslintScope;
|
|
868
|
+
}
|
|
869
|
+
return newest;
|
|
870
|
+
}
|
|
871
|
+
function getEslintScopeFromUser() {
|
|
872
|
+
try {
|
|
873
|
+
const cwd = process.cwd();
|
|
874
|
+
const relativeTo = import_path3.default.join(cwd, "__placeholder__.js");
|
|
875
|
+
return (0, import_module3.createRequire)(relativeTo)("eslint-scope");
|
|
876
|
+
} catch {
|
|
877
|
+
return null;
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
function getEslintScopeFromEslint() {
|
|
881
|
+
try {
|
|
882
|
+
const cwd = process.cwd();
|
|
883
|
+
const requireFromUser = (0, import_module3.createRequire)(import_path3.default.join(cwd, "__placeholder__.js"));
|
|
884
|
+
const eslintPackagePath = requireFromUser.resolve("eslint/package.json");
|
|
885
|
+
const requireFromEslint = (0, import_module3.createRequire)(
|
|
886
|
+
eslintPackagePath.replace(/package\.json$/, "__placeholder__.js")
|
|
887
|
+
);
|
|
888
|
+
return requireFromEslint("eslint-scope");
|
|
889
|
+
} catch {
|
|
890
|
+
return null;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
|
|
851
894
|
// src/parser/script.ts
|
|
895
|
+
var eslintScope2 = getEslintScope();
|
|
852
896
|
function parseScript(code, ctx, parserOptionsCtx) {
|
|
853
897
|
const result = parseScriptInternal(code, ctx, parserOptionsCtx);
|
|
854
898
|
const parserOptions = parserOptionsCtx.parserOptions;
|
|
@@ -914,7 +958,7 @@ ${code}`
|
|
|
914
958
|
patchResult?.terminate();
|
|
915
959
|
}
|
|
916
960
|
}
|
|
917
|
-
var Referencer = class extends
|
|
961
|
+
var Referencer = class extends eslintScope2.Referencer {
|
|
918
962
|
JSXAttribute(node) {
|
|
919
963
|
this.visit(node.value);
|
|
920
964
|
}
|
|
@@ -973,7 +1017,7 @@ function analyzeForEcmaScript(tree, providedOptions) {
|
|
|
973
1017
|
},
|
|
974
1018
|
providedOptions
|
|
975
1019
|
);
|
|
976
|
-
const scopeManager = new
|
|
1020
|
+
const scopeManager = new eslintScope2.ScopeManager(
|
|
977
1021
|
// @ts-expect-error -- No typings
|
|
978
1022
|
options
|
|
979
1023
|
);
|
|
@@ -2238,25 +2282,80 @@ function parse2(code, ctx) {
|
|
|
2238
2282
|
}
|
|
2239
2283
|
function adjustHTML(ast, htmlElement, ctx) {
|
|
2240
2284
|
const htmlEnd = ctx.code.indexOf("</html");
|
|
2241
|
-
if (htmlEnd
|
|
2285
|
+
if (htmlEnd < 0) {
|
|
2242
2286
|
return;
|
|
2243
2287
|
}
|
|
2288
|
+
const isOffsetAfter = buildComparableOffsetComparator(ctx.code);
|
|
2244
2289
|
const hasTokenAfter = Boolean(ctx.code.slice(htmlEnd + 7).trim());
|
|
2245
2290
|
const children = [...htmlElement.children];
|
|
2246
2291
|
for (const child of children) {
|
|
2247
2292
|
const offset = child.position?.start.offset;
|
|
2248
2293
|
if (hasTokenAfter && offset != null) {
|
|
2249
|
-
if (htmlEnd
|
|
2294
|
+
if (isOffsetAfter(offset, htmlEnd)) {
|
|
2250
2295
|
htmlElement.children.splice(htmlElement.children.indexOf(child), 1);
|
|
2251
2296
|
ast.children.push(child);
|
|
2252
2297
|
}
|
|
2253
2298
|
}
|
|
2254
2299
|
if (child.type === "element" && child.name === "body") {
|
|
2255
|
-
adjustHTMLBody(
|
|
2300
|
+
adjustHTMLBody(
|
|
2301
|
+
ast,
|
|
2302
|
+
htmlElement,
|
|
2303
|
+
htmlEnd,
|
|
2304
|
+
hasTokenAfter,
|
|
2305
|
+
child,
|
|
2306
|
+
ctx,
|
|
2307
|
+
isOffsetAfter
|
|
2308
|
+
);
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
function buildComparableOffsetComparator(code) {
|
|
2312
|
+
let remapOffset;
|
|
2313
|
+
const comparableOffsetCache = /* @__PURE__ */ new Map();
|
|
2314
|
+
return (offset, threshold) => {
|
|
2315
|
+
if (threshold > offset) {
|
|
2316
|
+
return false;
|
|
2317
|
+
}
|
|
2318
|
+
let comparableOffset = comparableOffsetCache.get(offset);
|
|
2319
|
+
if (comparableOffset == null) {
|
|
2320
|
+
remapOffset || (remapOffset = buildComparableOffsetRemapper(code));
|
|
2321
|
+
comparableOffset = remapOffset(offset);
|
|
2322
|
+
comparableOffsetCache.set(offset, comparableOffset);
|
|
2323
|
+
}
|
|
2324
|
+
return threshold <= comparableOffset;
|
|
2325
|
+
};
|
|
2326
|
+
}
|
|
2327
|
+
function buildComparableOffsetRemapper(code) {
|
|
2328
|
+
if (Buffer.byteLength(code, "utf8") === code.length) {
|
|
2329
|
+
return (offset) => offset;
|
|
2330
|
+
}
|
|
2331
|
+
const byteOffsets = [0];
|
|
2332
|
+
const codeUnitOffsets = [0];
|
|
2333
|
+
for (let index = 0, byteOffset = 0; index < code.length; ) {
|
|
2334
|
+
const codePoint = code.codePointAt(index);
|
|
2335
|
+
index += codePoint > 65535 ? 2 : 1;
|
|
2336
|
+
byteOffset += getUTF8ByteLength(codePoint);
|
|
2337
|
+
byteOffsets.push(byteOffset);
|
|
2338
|
+
codeUnitOffsets.push(index);
|
|
2339
|
+
}
|
|
2340
|
+
return (offset) => {
|
|
2341
|
+
const index = sortedLastIndex(byteOffsets, (target) => target - offset) - 1;
|
|
2342
|
+
return codeUnitOffsets[Math.max(index, 0)];
|
|
2343
|
+
};
|
|
2344
|
+
}
|
|
2345
|
+
function getUTF8ByteLength(codePoint) {
|
|
2346
|
+
if (codePoint <= 127) {
|
|
2347
|
+
return 1;
|
|
2348
|
+
}
|
|
2349
|
+
if (codePoint <= 2047) {
|
|
2350
|
+
return 2;
|
|
2351
|
+
}
|
|
2352
|
+
if (codePoint <= 65535) {
|
|
2353
|
+
return 3;
|
|
2256
2354
|
}
|
|
2355
|
+
return 4;
|
|
2257
2356
|
}
|
|
2258
2357
|
}
|
|
2259
|
-
function adjustHTMLBody(ast, htmlElement, htmlEnd, hasTokenAfterHtmlEnd, bodyElement, ctx) {
|
|
2358
|
+
function adjustHTMLBody(ast, htmlElement, htmlEnd, hasTokenAfterHtmlEnd, bodyElement, ctx, isOffsetAfter) {
|
|
2260
2359
|
const bodyEnd = ctx.code.indexOf("</body");
|
|
2261
2360
|
if (bodyEnd == null) {
|
|
2262
2361
|
return;
|
|
@@ -2268,15 +2367,13 @@ function adjustHTMLBody(ast, htmlElement, htmlEnd, hasTokenAfterHtmlEnd, bodyEle
|
|
|
2268
2367
|
const children = [...bodyElement.children];
|
|
2269
2368
|
for (const child of children) {
|
|
2270
2369
|
const offset = child.position?.start.offset;
|
|
2271
|
-
if (offset != null) {
|
|
2272
|
-
if (
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
htmlElement.children.push(child);
|
|
2279
|
-
}
|
|
2370
|
+
if (offset != null && isOffsetAfter(offset, bodyEnd)) {
|
|
2371
|
+
if (hasTokenAfterHtmlEnd && isOffsetAfter(offset, htmlEnd)) {
|
|
2372
|
+
bodyElement.children.splice(bodyElement.children.indexOf(child), 1);
|
|
2373
|
+
ast.children.push(child);
|
|
2374
|
+
} else if (hasTokenAfter) {
|
|
2375
|
+
bodyElement.children.splice(bodyElement.children.indexOf(child), 1);
|
|
2376
|
+
htmlElement.children.push(child);
|
|
2280
2377
|
}
|
|
2281
2378
|
}
|
|
2282
2379
|
}
|
|
@@ -2551,18 +2648,18 @@ function remap(result, normalized, originalCode, ctxForAstro) {
|
|
|
2551
2648
|
}
|
|
2552
2649
|
|
|
2553
2650
|
// src/context/parser-options.ts
|
|
2554
|
-
var
|
|
2651
|
+
var import_path5 = __toESM(require("path"));
|
|
2555
2652
|
var import_fs2 = __toESM(require("fs"));
|
|
2556
2653
|
|
|
2557
2654
|
// src/context/resolve-parser/espree.ts
|
|
2558
|
-
var
|
|
2559
|
-
var
|
|
2655
|
+
var import_module4 = require("module");
|
|
2656
|
+
var import_path4 = __toESM(require("path"));
|
|
2560
2657
|
var espreeCache = null;
|
|
2561
2658
|
function isLinterPath(p) {
|
|
2562
2659
|
return (
|
|
2563
2660
|
// ESLint 6 and above
|
|
2564
|
-
p.includes(`eslint${
|
|
2565
|
-
p.includes(`eslint${
|
|
2661
|
+
p.includes(`eslint${import_path4.default.sep}lib${import_path4.default.sep}linter${import_path4.default.sep}linter.js`) || // ESLint 5
|
|
2662
|
+
p.includes(`eslint${import_path4.default.sep}lib${import_path4.default.sep}linter.js`)
|
|
2566
2663
|
);
|
|
2567
2664
|
}
|
|
2568
2665
|
function getEspree() {
|
|
@@ -2570,7 +2667,7 @@ function getEspree() {
|
|
|
2570
2667
|
const linterPath = Object.keys(require.cache || {}).find(isLinterPath);
|
|
2571
2668
|
if (linterPath) {
|
|
2572
2669
|
try {
|
|
2573
|
-
espreeCache = (0,
|
|
2670
|
+
espreeCache = (0, import_module4.createRequire)(linterPath)("espree");
|
|
2574
2671
|
} catch {
|
|
2575
2672
|
}
|
|
2576
2673
|
}
|
|
@@ -2666,7 +2763,7 @@ var ParserOptionsContext = class {
|
|
|
2666
2763
|
if (TS_PARSER_NAMES.some((nm) => parserName.includes(nm))) {
|
|
2667
2764
|
let targetPath = parserName;
|
|
2668
2765
|
while (targetPath) {
|
|
2669
|
-
const pkgPath =
|
|
2766
|
+
const pkgPath = import_path5.default.join(targetPath, "package.json");
|
|
2670
2767
|
if (import_fs2.default.existsSync(pkgPath)) {
|
|
2671
2768
|
try {
|
|
2672
2769
|
const pkgName = JSON.parse(import_fs2.default.readFileSync(pkgPath, "utf-8"))?.name;
|
|
@@ -2681,7 +2778,7 @@ var ParserOptionsContext = class {
|
|
|
2681
2778
|
return null;
|
|
2682
2779
|
}
|
|
2683
2780
|
}
|
|
2684
|
-
const parent =
|
|
2781
|
+
const parent = import_path5.default.dirname(targetPath);
|
|
2685
2782
|
if (targetPath === parent) {
|
|
2686
2783
|
break;
|
|
2687
2784
|
}
|
|
@@ -2830,7 +2927,7 @@ __export(meta_exports, {
|
|
|
2830
2927
|
|
|
2831
2928
|
// package.json
|
|
2832
2929
|
var name = "astro-eslint-parser";
|
|
2833
|
-
var version = "1.
|
|
2930
|
+
var version = "1.3.1";
|
|
2834
2931
|
|
|
2835
2932
|
// src/index.ts
|
|
2836
2933
|
function parseForESLint2(code, options) {
|
package/lib/index.mjs
CHANGED
|
@@ -485,10 +485,6 @@ import {
|
|
|
485
485
|
analyze as analyzeForTypeScript,
|
|
486
486
|
Reference
|
|
487
487
|
} from "@typescript-eslint/scope-manager";
|
|
488
|
-
import {
|
|
489
|
-
Referencer as BaseReferencer,
|
|
490
|
-
ScopeManager
|
|
491
|
-
} from "eslint-scope";
|
|
492
488
|
|
|
493
489
|
// src/traverse.ts
|
|
494
490
|
function fallbackKeysFilter(key) {
|
|
@@ -826,7 +822,52 @@ function addReference(list, reference) {
|
|
|
826
822
|
);
|
|
827
823
|
}
|
|
828
824
|
|
|
825
|
+
// src/parser/eslint-scope.ts
|
|
826
|
+
import * as eslintScope from "eslint-scope";
|
|
827
|
+
import semver from "semver";
|
|
828
|
+
import path5 from "path";
|
|
829
|
+
import { createRequire as createRequire3 } from "module";
|
|
830
|
+
var eslintScopeCache = null;
|
|
831
|
+
function getEslintScope() {
|
|
832
|
+
return eslintScopeCache ?? (eslintScopeCache = getNewest());
|
|
833
|
+
}
|
|
834
|
+
function getNewest() {
|
|
835
|
+
let newest = eslintScope;
|
|
836
|
+
const userEslintScope = getEslintScopeFromUser();
|
|
837
|
+
if (userEslintScope && userEslintScope.version != null && semver.lte(newest.version, userEslintScope.version)) {
|
|
838
|
+
newest = userEslintScope;
|
|
839
|
+
}
|
|
840
|
+
const eslintEslintScope = getEslintScopeFromEslint();
|
|
841
|
+
if (eslintEslintScope && eslintEslintScope.version != null && semver.lte(newest.version, eslintEslintScope.version)) {
|
|
842
|
+
newest = eslintEslintScope;
|
|
843
|
+
}
|
|
844
|
+
return newest;
|
|
845
|
+
}
|
|
846
|
+
function getEslintScopeFromUser() {
|
|
847
|
+
try {
|
|
848
|
+
const cwd = process.cwd();
|
|
849
|
+
const relativeTo = path5.join(cwd, "__placeholder__.js");
|
|
850
|
+
return createRequire3(relativeTo)("eslint-scope");
|
|
851
|
+
} catch {
|
|
852
|
+
return null;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
function getEslintScopeFromEslint() {
|
|
856
|
+
try {
|
|
857
|
+
const cwd = process.cwd();
|
|
858
|
+
const requireFromUser = createRequire3(path5.join(cwd, "__placeholder__.js"));
|
|
859
|
+
const eslintPackagePath = requireFromUser.resolve("eslint/package.json");
|
|
860
|
+
const requireFromEslint = createRequire3(
|
|
861
|
+
eslintPackagePath.replace(/package\.json$/, "__placeholder__.js")
|
|
862
|
+
);
|
|
863
|
+
return requireFromEslint("eslint-scope");
|
|
864
|
+
} catch {
|
|
865
|
+
return null;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
|
|
829
869
|
// src/parser/script.ts
|
|
870
|
+
var eslintScope2 = getEslintScope();
|
|
830
871
|
function parseScript(code, ctx, parserOptionsCtx) {
|
|
831
872
|
const result = parseScriptInternal(code, ctx, parserOptionsCtx);
|
|
832
873
|
const parserOptions = parserOptionsCtx.parserOptions;
|
|
@@ -892,7 +933,7 @@ ${code}`
|
|
|
892
933
|
patchResult?.terminate();
|
|
893
934
|
}
|
|
894
935
|
}
|
|
895
|
-
var Referencer = class extends
|
|
936
|
+
var Referencer = class extends eslintScope2.Referencer {
|
|
896
937
|
JSXAttribute(node) {
|
|
897
938
|
this.visit(node.value);
|
|
898
939
|
}
|
|
@@ -951,7 +992,7 @@ function analyzeForEcmaScript(tree, providedOptions) {
|
|
|
951
992
|
},
|
|
952
993
|
providedOptions
|
|
953
994
|
);
|
|
954
|
-
const scopeManager = new ScopeManager(
|
|
995
|
+
const scopeManager = new eslintScope2.ScopeManager(
|
|
955
996
|
// @ts-expect-error -- No typings
|
|
956
997
|
options
|
|
957
998
|
);
|
|
@@ -2216,25 +2257,80 @@ function parse2(code, ctx) {
|
|
|
2216
2257
|
}
|
|
2217
2258
|
function adjustHTML(ast, htmlElement, ctx) {
|
|
2218
2259
|
const htmlEnd = ctx.code.indexOf("</html");
|
|
2219
|
-
if (htmlEnd
|
|
2260
|
+
if (htmlEnd < 0) {
|
|
2220
2261
|
return;
|
|
2221
2262
|
}
|
|
2263
|
+
const isOffsetAfter = buildComparableOffsetComparator(ctx.code);
|
|
2222
2264
|
const hasTokenAfter = Boolean(ctx.code.slice(htmlEnd + 7).trim());
|
|
2223
2265
|
const children = [...htmlElement.children];
|
|
2224
2266
|
for (const child of children) {
|
|
2225
2267
|
const offset = child.position?.start.offset;
|
|
2226
2268
|
if (hasTokenAfter && offset != null) {
|
|
2227
|
-
if (htmlEnd
|
|
2269
|
+
if (isOffsetAfter(offset, htmlEnd)) {
|
|
2228
2270
|
htmlElement.children.splice(htmlElement.children.indexOf(child), 1);
|
|
2229
2271
|
ast.children.push(child);
|
|
2230
2272
|
}
|
|
2231
2273
|
}
|
|
2232
2274
|
if (child.type === "element" && child.name === "body") {
|
|
2233
|
-
adjustHTMLBody(
|
|
2275
|
+
adjustHTMLBody(
|
|
2276
|
+
ast,
|
|
2277
|
+
htmlElement,
|
|
2278
|
+
htmlEnd,
|
|
2279
|
+
hasTokenAfter,
|
|
2280
|
+
child,
|
|
2281
|
+
ctx,
|
|
2282
|
+
isOffsetAfter
|
|
2283
|
+
);
|
|
2234
2284
|
}
|
|
2235
2285
|
}
|
|
2286
|
+
function buildComparableOffsetComparator(code) {
|
|
2287
|
+
let remapOffset;
|
|
2288
|
+
const comparableOffsetCache = /* @__PURE__ */ new Map();
|
|
2289
|
+
return (offset, threshold) => {
|
|
2290
|
+
if (threshold > offset) {
|
|
2291
|
+
return false;
|
|
2292
|
+
}
|
|
2293
|
+
let comparableOffset = comparableOffsetCache.get(offset);
|
|
2294
|
+
if (comparableOffset == null) {
|
|
2295
|
+
remapOffset || (remapOffset = buildComparableOffsetRemapper(code));
|
|
2296
|
+
comparableOffset = remapOffset(offset);
|
|
2297
|
+
comparableOffsetCache.set(offset, comparableOffset);
|
|
2298
|
+
}
|
|
2299
|
+
return threshold <= comparableOffset;
|
|
2300
|
+
};
|
|
2301
|
+
}
|
|
2302
|
+
function buildComparableOffsetRemapper(code) {
|
|
2303
|
+
if (Buffer.byteLength(code, "utf8") === code.length) {
|
|
2304
|
+
return (offset) => offset;
|
|
2305
|
+
}
|
|
2306
|
+
const byteOffsets = [0];
|
|
2307
|
+
const codeUnitOffsets = [0];
|
|
2308
|
+
for (let index = 0, byteOffset = 0; index < code.length; ) {
|
|
2309
|
+
const codePoint = code.codePointAt(index);
|
|
2310
|
+
index += codePoint > 65535 ? 2 : 1;
|
|
2311
|
+
byteOffset += getUTF8ByteLength(codePoint);
|
|
2312
|
+
byteOffsets.push(byteOffset);
|
|
2313
|
+
codeUnitOffsets.push(index);
|
|
2314
|
+
}
|
|
2315
|
+
return (offset) => {
|
|
2316
|
+
const index = sortedLastIndex(byteOffsets, (target) => target - offset) - 1;
|
|
2317
|
+
return codeUnitOffsets[Math.max(index, 0)];
|
|
2318
|
+
};
|
|
2319
|
+
}
|
|
2320
|
+
function getUTF8ByteLength(codePoint) {
|
|
2321
|
+
if (codePoint <= 127) {
|
|
2322
|
+
return 1;
|
|
2323
|
+
}
|
|
2324
|
+
if (codePoint <= 2047) {
|
|
2325
|
+
return 2;
|
|
2326
|
+
}
|
|
2327
|
+
if (codePoint <= 65535) {
|
|
2328
|
+
return 3;
|
|
2329
|
+
}
|
|
2330
|
+
return 4;
|
|
2331
|
+
}
|
|
2236
2332
|
}
|
|
2237
|
-
function adjustHTMLBody(ast, htmlElement, htmlEnd, hasTokenAfterHtmlEnd, bodyElement, ctx) {
|
|
2333
|
+
function adjustHTMLBody(ast, htmlElement, htmlEnd, hasTokenAfterHtmlEnd, bodyElement, ctx, isOffsetAfter) {
|
|
2238
2334
|
const bodyEnd = ctx.code.indexOf("</body");
|
|
2239
2335
|
if (bodyEnd == null) {
|
|
2240
2336
|
return;
|
|
@@ -2246,15 +2342,13 @@ function adjustHTMLBody(ast, htmlElement, htmlEnd, hasTokenAfterHtmlEnd, bodyEle
|
|
|
2246
2342
|
const children = [...bodyElement.children];
|
|
2247
2343
|
for (const child of children) {
|
|
2248
2344
|
const offset = child.position?.start.offset;
|
|
2249
|
-
if (offset != null) {
|
|
2250
|
-
if (
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
htmlElement.children.push(child);
|
|
2257
|
-
}
|
|
2345
|
+
if (offset != null && isOffsetAfter(offset, bodyEnd)) {
|
|
2346
|
+
if (hasTokenAfterHtmlEnd && isOffsetAfter(offset, htmlEnd)) {
|
|
2347
|
+
bodyElement.children.splice(bodyElement.children.indexOf(child), 1);
|
|
2348
|
+
ast.children.push(child);
|
|
2349
|
+
} else if (hasTokenAfter) {
|
|
2350
|
+
bodyElement.children.splice(bodyElement.children.indexOf(child), 1);
|
|
2351
|
+
htmlElement.children.push(child);
|
|
2258
2352
|
}
|
|
2259
2353
|
}
|
|
2260
2354
|
}
|
|
@@ -2529,18 +2623,18 @@ function remap(result, normalized, originalCode, ctxForAstro) {
|
|
|
2529
2623
|
}
|
|
2530
2624
|
|
|
2531
2625
|
// src/context/parser-options.ts
|
|
2532
|
-
import
|
|
2626
|
+
import path7 from "path";
|
|
2533
2627
|
import fs3 from "fs";
|
|
2534
2628
|
|
|
2535
2629
|
// src/context/resolve-parser/espree.ts
|
|
2536
|
-
import { createRequire as
|
|
2537
|
-
import
|
|
2630
|
+
import { createRequire as createRequire4 } from "module";
|
|
2631
|
+
import path6 from "path";
|
|
2538
2632
|
var espreeCache = null;
|
|
2539
2633
|
function isLinterPath(p) {
|
|
2540
2634
|
return (
|
|
2541
2635
|
// ESLint 6 and above
|
|
2542
|
-
p.includes(`eslint${
|
|
2543
|
-
p.includes(`eslint${
|
|
2636
|
+
p.includes(`eslint${path6.sep}lib${path6.sep}linter${path6.sep}linter.js`) || // ESLint 5
|
|
2637
|
+
p.includes(`eslint${path6.sep}lib${path6.sep}linter.js`)
|
|
2544
2638
|
);
|
|
2545
2639
|
}
|
|
2546
2640
|
function getEspree() {
|
|
@@ -2548,7 +2642,7 @@ function getEspree() {
|
|
|
2548
2642
|
const linterPath = Object.keys(__require.cache || {}).find(isLinterPath);
|
|
2549
2643
|
if (linterPath) {
|
|
2550
2644
|
try {
|
|
2551
|
-
espreeCache =
|
|
2645
|
+
espreeCache = createRequire4(linterPath)("espree");
|
|
2552
2646
|
} catch {
|
|
2553
2647
|
}
|
|
2554
2648
|
}
|
|
@@ -2644,7 +2738,7 @@ var ParserOptionsContext = class {
|
|
|
2644
2738
|
if (TS_PARSER_NAMES.some((nm) => parserName.includes(nm))) {
|
|
2645
2739
|
let targetPath = parserName;
|
|
2646
2740
|
while (targetPath) {
|
|
2647
|
-
const pkgPath =
|
|
2741
|
+
const pkgPath = path7.join(targetPath, "package.json");
|
|
2648
2742
|
if (fs3.existsSync(pkgPath)) {
|
|
2649
2743
|
try {
|
|
2650
2744
|
const pkgName = JSON.parse(fs3.readFileSync(pkgPath, "utf-8"))?.name;
|
|
@@ -2659,7 +2753,7 @@ var ParserOptionsContext = class {
|
|
|
2659
2753
|
return null;
|
|
2660
2754
|
}
|
|
2661
2755
|
}
|
|
2662
|
-
const parent =
|
|
2756
|
+
const parent = path7.dirname(targetPath);
|
|
2663
2757
|
if (targetPath === parent) {
|
|
2664
2758
|
break;
|
|
2665
2759
|
}
|
|
@@ -2808,7 +2902,7 @@ __export(meta_exports, {
|
|
|
2808
2902
|
|
|
2809
2903
|
// package.json
|
|
2810
2904
|
var name = "astro-eslint-parser";
|
|
2811
|
-
var version = "1.
|
|
2905
|
+
var version = "1.3.1";
|
|
2812
2906
|
|
|
2813
2907
|
// src/index.ts
|
|
2814
2908
|
function parseForESLint2(code, options) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro-eslint-parser",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Astro component parser for ESLint",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.mjs",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"cover": "nyc --reporter=lcov npm run test",
|
|
22
22
|
"debug": "npm run mocha -- \"tests/src/**/*.ts\" --reporter dot --timeout 60000",
|
|
23
23
|
"preversion": "npm run lint && npm test",
|
|
24
|
-
"update-fixtures": "env-cmd -e debug npm run ts -- ./tools/update-fixtures.ts",
|
|
24
|
+
"update-fixtures": "env-cmd -e debug -- npm run ts -- ./tools/update-fixtures.ts",
|
|
25
25
|
"debug-parser": "npm run ts -- ./tools/parser-test.ts",
|
|
26
26
|
"eslint-playground": "eslint tests/fixtures --ext .astro --config .eslintrc-for-playground.js --format codeframe",
|
|
27
27
|
"benchmark": "npm run ts -- benchmark/index.ts",
|
|
28
|
-
"ts": "env-cmd -e basic node -r esbuild-register",
|
|
28
|
+
"ts": "env-cmd -e basic -- node -r esbuild-register",
|
|
29
29
|
"mocha": "npm run ts -- ./node_modules/mocha/bin/mocha.js",
|
|
30
30
|
"prerelease": "npm run clean && npm run build",
|
|
31
31
|
"release": "changeset publish"
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@typescript-eslint/types": "^7.0.0 || ^8.0.0",
|
|
54
54
|
"astrojs-compiler-sync": "^1.0.0",
|
|
55
55
|
"debug": "^4.3.4",
|
|
56
|
-
"entities": "^
|
|
56
|
+
"entities": "^7.0.0",
|
|
57
57
|
"eslint-scope": "^8.0.1",
|
|
58
58
|
"eslint-visitor-keys": "^4.0.0",
|
|
59
59
|
"espree": "^10.0.0",
|
|
@@ -62,62 +62,62 @@
|
|
|
62
62
|
"semver": "^7.3.8"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@changesets/changelog-github": "^0.
|
|
65
|
+
"@changesets/changelog-github": "^0.6.0",
|
|
66
66
|
"@changesets/cli": "^2.24.2",
|
|
67
67
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.3.0",
|
|
68
|
-
"@ota-meshi/eslint-plugin": "^0.
|
|
68
|
+
"@ota-meshi/eslint-plugin": "^0.20.0",
|
|
69
69
|
"@types/benchmark": "^2.1.1",
|
|
70
70
|
"@types/chai": "^5.0.0",
|
|
71
71
|
"@types/debug": "^4.1.7",
|
|
72
72
|
"@types/eslint": "^9.0.0",
|
|
73
|
-
"@types/eslint-scope": "^
|
|
73
|
+
"@types/eslint-scope": "^8.0.0",
|
|
74
74
|
"@types/eslint-visitor-keys": "^3.0.0",
|
|
75
75
|
"@types/is-glob": "^4.0.4",
|
|
76
76
|
"@types/mocha": "^10.0.0",
|
|
77
|
-
"@types/node": "^
|
|
77
|
+
"@types/node": "^24.0.0",
|
|
78
78
|
"@types/semver": "^7.3.9",
|
|
79
79
|
"@typescript-eslint/eslint-plugin": "^8.21.0",
|
|
80
80
|
"@typescript-eslint/parser": "^8.21.0",
|
|
81
81
|
"@typescript-eslint/typescript-estree": "^8.21.0",
|
|
82
|
-
"astro": "^
|
|
82
|
+
"astro": "^6.0.0",
|
|
83
83
|
"astro-eslint-parser": ">=0.1.0",
|
|
84
84
|
"benchmark": "^2.1.4",
|
|
85
|
-
"chai": "^
|
|
86
|
-
"env-cmd": "^
|
|
87
|
-
"esbuild": "^0.
|
|
85
|
+
"chai": "^6.0.0",
|
|
86
|
+
"env-cmd": "^11.0.0",
|
|
87
|
+
"esbuild": "^0.27.0",
|
|
88
88
|
"esbuild-register": "^3.3.3",
|
|
89
89
|
"eslint": "^9.19.0",
|
|
90
90
|
"eslint-config-prettier": "^10.0.0",
|
|
91
91
|
"eslint-formatter-codeframe": "^7.32.1",
|
|
92
92
|
"eslint-plugin-astro": "^1.0.0",
|
|
93
93
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
94
|
-
"eslint-plugin-jsdoc": "^
|
|
95
|
-
"eslint-plugin-json-schema-validator": "^
|
|
96
|
-
"eslint-plugin-jsonc": "^
|
|
94
|
+
"eslint-plugin-jsdoc": "^62.0.0",
|
|
95
|
+
"eslint-plugin-json-schema-validator": "^6.0.0",
|
|
96
|
+
"eslint-plugin-jsonc": "^3.0.0",
|
|
97
97
|
"eslint-plugin-jsx-a11y": "^6.5.1",
|
|
98
98
|
"eslint-plugin-n": "^17.0.0",
|
|
99
|
-
"eslint-plugin-node-dependencies": "^0.
|
|
99
|
+
"eslint-plugin-node-dependencies": "^2.0.0",
|
|
100
100
|
"eslint-plugin-prettier": "^5.0.0",
|
|
101
101
|
"eslint-plugin-react": "^7.29.4",
|
|
102
|
-
"eslint-plugin-regexp": "^
|
|
102
|
+
"eslint-plugin-regexp": "^3.0.0",
|
|
103
103
|
"eslint-plugin-simple-import-sort": "^12.0.0",
|
|
104
104
|
"eslint-plugin-svelte": "^3.0.0-0",
|
|
105
105
|
"estree-walker": "^3.0.0",
|
|
106
|
-
"globals": "^
|
|
106
|
+
"globals": "^17.0.0",
|
|
107
107
|
"locate-character": "^3.0.0",
|
|
108
108
|
"magic-string": "^0.30.0",
|
|
109
109
|
"mocha": "^11.0.0",
|
|
110
110
|
"mocha-chai-jest-snapshot": "^1.1.3",
|
|
111
|
-
"nyc": "^
|
|
111
|
+
"nyc": "^18.0.0",
|
|
112
112
|
"prettier": "^3.0.0",
|
|
113
113
|
"prettier-plugin-astro": "^0.14.0",
|
|
114
114
|
"prettier-plugin-svelte": "^3.0.0",
|
|
115
115
|
"string-replace-loader": "^3.0.3",
|
|
116
116
|
"svelte": "^5.19.3",
|
|
117
117
|
"tsup": "^8.0.0",
|
|
118
|
-
"typescript": "~5.
|
|
118
|
+
"typescript": "~5.9.0",
|
|
119
119
|
"typescript-eslint": "^8.21.0",
|
|
120
|
-
"typescript-eslint-parser-for-extra-files": "^0.
|
|
120
|
+
"typescript-eslint-parser-for-extra-files": "^0.9.0"
|
|
121
121
|
},
|
|
122
122
|
"publishConfig": {
|
|
123
123
|
"access": "public"
|