astro-eslint-parser 1.2.1 → 1.3.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.d.mts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +64 -12
- package/lib/index.mjs +64 -15
- package/package.json +8 -8
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
|
);
|
|
@@ -1327,6 +1371,14 @@ function getTokenInfo(ctx, tokens, position) {
|
|
|
1327
1371
|
while (searchOffset < search.length) {
|
|
1328
1372
|
const searchChar = search[searchOffset];
|
|
1329
1373
|
if (ctx.code[codeOffset] === searchChar) {
|
|
1374
|
+
if (searchChar === "&") {
|
|
1375
|
+
const entityCandidate = ctx.code.slice(codeOffset, codeOffset + 5);
|
|
1376
|
+
if (entityCandidate === "&" || entityCandidate === "&") {
|
|
1377
|
+
codeOffset += 5;
|
|
1378
|
+
searchOffset++;
|
|
1379
|
+
continue;
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1330
1382
|
codeOffset++;
|
|
1331
1383
|
searchOffset++;
|
|
1332
1384
|
continue;
|
|
@@ -2543,18 +2595,18 @@ function remap(result, normalized, originalCode, ctxForAstro) {
|
|
|
2543
2595
|
}
|
|
2544
2596
|
|
|
2545
2597
|
// src/context/parser-options.ts
|
|
2546
|
-
var
|
|
2598
|
+
var import_path5 = __toESM(require("path"));
|
|
2547
2599
|
var import_fs2 = __toESM(require("fs"));
|
|
2548
2600
|
|
|
2549
2601
|
// src/context/resolve-parser/espree.ts
|
|
2550
|
-
var
|
|
2551
|
-
var
|
|
2602
|
+
var import_module4 = require("module");
|
|
2603
|
+
var import_path4 = __toESM(require("path"));
|
|
2552
2604
|
var espreeCache = null;
|
|
2553
2605
|
function isLinterPath(p) {
|
|
2554
2606
|
return (
|
|
2555
2607
|
// ESLint 6 and above
|
|
2556
|
-
p.includes(`eslint${
|
|
2557
|
-
p.includes(`eslint${
|
|
2608
|
+
p.includes(`eslint${import_path4.default.sep}lib${import_path4.default.sep}linter${import_path4.default.sep}linter.js`) || // ESLint 5
|
|
2609
|
+
p.includes(`eslint${import_path4.default.sep}lib${import_path4.default.sep}linter.js`)
|
|
2558
2610
|
);
|
|
2559
2611
|
}
|
|
2560
2612
|
function getEspree() {
|
|
@@ -2562,7 +2614,7 @@ function getEspree() {
|
|
|
2562
2614
|
const linterPath = Object.keys(require.cache || {}).find(isLinterPath);
|
|
2563
2615
|
if (linterPath) {
|
|
2564
2616
|
try {
|
|
2565
|
-
espreeCache = (0,
|
|
2617
|
+
espreeCache = (0, import_module4.createRequire)(linterPath)("espree");
|
|
2566
2618
|
} catch {
|
|
2567
2619
|
}
|
|
2568
2620
|
}
|
|
@@ -2658,7 +2710,7 @@ var ParserOptionsContext = class {
|
|
|
2658
2710
|
if (TS_PARSER_NAMES.some((nm) => parserName.includes(nm))) {
|
|
2659
2711
|
let targetPath = parserName;
|
|
2660
2712
|
while (targetPath) {
|
|
2661
|
-
const pkgPath =
|
|
2713
|
+
const pkgPath = import_path5.default.join(targetPath, "package.json");
|
|
2662
2714
|
if (import_fs2.default.existsSync(pkgPath)) {
|
|
2663
2715
|
try {
|
|
2664
2716
|
const pkgName = JSON.parse(import_fs2.default.readFileSync(pkgPath, "utf-8"))?.name;
|
|
@@ -2673,7 +2725,7 @@ var ParserOptionsContext = class {
|
|
|
2673
2725
|
return null;
|
|
2674
2726
|
}
|
|
2675
2727
|
}
|
|
2676
|
-
const parent =
|
|
2728
|
+
const parent = import_path5.default.dirname(targetPath);
|
|
2677
2729
|
if (targetPath === parent) {
|
|
2678
2730
|
break;
|
|
2679
2731
|
}
|
|
@@ -2822,7 +2874,7 @@ __export(meta_exports, {
|
|
|
2822
2874
|
|
|
2823
2875
|
// package.json
|
|
2824
2876
|
var name = "astro-eslint-parser";
|
|
2825
|
-
var version = "1.
|
|
2877
|
+
var version = "1.3.0";
|
|
2826
2878
|
|
|
2827
2879
|
// src/index.ts
|
|
2828
2880
|
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
|
);
|
|
@@ -1305,6 +1346,14 @@ function getTokenInfo(ctx, tokens, position) {
|
|
|
1305
1346
|
while (searchOffset < search.length) {
|
|
1306
1347
|
const searchChar = search[searchOffset];
|
|
1307
1348
|
if (ctx.code[codeOffset] === searchChar) {
|
|
1349
|
+
if (searchChar === "&") {
|
|
1350
|
+
const entityCandidate = ctx.code.slice(codeOffset, codeOffset + 5);
|
|
1351
|
+
if (entityCandidate === "&" || entityCandidate === "&") {
|
|
1352
|
+
codeOffset += 5;
|
|
1353
|
+
searchOffset++;
|
|
1354
|
+
continue;
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1308
1357
|
codeOffset++;
|
|
1309
1358
|
searchOffset++;
|
|
1310
1359
|
continue;
|
|
@@ -2521,18 +2570,18 @@ function remap(result, normalized, originalCode, ctxForAstro) {
|
|
|
2521
2570
|
}
|
|
2522
2571
|
|
|
2523
2572
|
// src/context/parser-options.ts
|
|
2524
|
-
import
|
|
2573
|
+
import path7 from "path";
|
|
2525
2574
|
import fs3 from "fs";
|
|
2526
2575
|
|
|
2527
2576
|
// src/context/resolve-parser/espree.ts
|
|
2528
|
-
import { createRequire as
|
|
2529
|
-
import
|
|
2577
|
+
import { createRequire as createRequire4 } from "module";
|
|
2578
|
+
import path6 from "path";
|
|
2530
2579
|
var espreeCache = null;
|
|
2531
2580
|
function isLinterPath(p) {
|
|
2532
2581
|
return (
|
|
2533
2582
|
// ESLint 6 and above
|
|
2534
|
-
p.includes(`eslint${
|
|
2535
|
-
p.includes(`eslint${
|
|
2583
|
+
p.includes(`eslint${path6.sep}lib${path6.sep}linter${path6.sep}linter.js`) || // ESLint 5
|
|
2584
|
+
p.includes(`eslint${path6.sep}lib${path6.sep}linter.js`)
|
|
2536
2585
|
);
|
|
2537
2586
|
}
|
|
2538
2587
|
function getEspree() {
|
|
@@ -2540,7 +2589,7 @@ function getEspree() {
|
|
|
2540
2589
|
const linterPath = Object.keys(__require.cache || {}).find(isLinterPath);
|
|
2541
2590
|
if (linterPath) {
|
|
2542
2591
|
try {
|
|
2543
|
-
espreeCache =
|
|
2592
|
+
espreeCache = createRequire4(linterPath)("espree");
|
|
2544
2593
|
} catch {
|
|
2545
2594
|
}
|
|
2546
2595
|
}
|
|
@@ -2636,7 +2685,7 @@ var ParserOptionsContext = class {
|
|
|
2636
2685
|
if (TS_PARSER_NAMES.some((nm) => parserName.includes(nm))) {
|
|
2637
2686
|
let targetPath = parserName;
|
|
2638
2687
|
while (targetPath) {
|
|
2639
|
-
const pkgPath =
|
|
2688
|
+
const pkgPath = path7.join(targetPath, "package.json");
|
|
2640
2689
|
if (fs3.existsSync(pkgPath)) {
|
|
2641
2690
|
try {
|
|
2642
2691
|
const pkgName = JSON.parse(fs3.readFileSync(pkgPath, "utf-8"))?.name;
|
|
@@ -2651,7 +2700,7 @@ var ParserOptionsContext = class {
|
|
|
2651
2700
|
return null;
|
|
2652
2701
|
}
|
|
2653
2702
|
}
|
|
2654
|
-
const parent =
|
|
2703
|
+
const parent = path7.dirname(targetPath);
|
|
2655
2704
|
if (targetPath === parent) {
|
|
2656
2705
|
break;
|
|
2657
2706
|
}
|
|
@@ -2800,7 +2849,7 @@ __export(meta_exports, {
|
|
|
2800
2849
|
|
|
2801
2850
|
// package.json
|
|
2802
2851
|
var name = "astro-eslint-parser";
|
|
2803
|
-
var version = "1.
|
|
2852
|
+
var version = "1.3.0";
|
|
2804
2853
|
|
|
2805
2854
|
// src/index.ts
|
|
2806
2855
|
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.0",
|
|
4
4
|
"description": "Astro component parser for ESLint",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.mjs",
|
|
@@ -65,12 +65,12 @@
|
|
|
65
65
|
"@changesets/changelog-github": "^0.5.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",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"benchmark": "^2.1.4",
|
|
85
85
|
"chai": "^5.0.0",
|
|
86
86
|
"env-cmd": "^10.1.0",
|
|
87
|
-
"esbuild": "^0.
|
|
87
|
+
"esbuild": "^0.25.0",
|
|
88
88
|
"esbuild-register": "^3.3.3",
|
|
89
89
|
"eslint": "^9.19.0",
|
|
90
90
|
"eslint-config-prettier": "^10.0.0",
|
|
@@ -96,14 +96,14 @@
|
|
|
96
96
|
"eslint-plugin-jsonc": "^2.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": "^1.0.0",
|
|
100
100
|
"eslint-plugin-prettier": "^5.0.0",
|
|
101
101
|
"eslint-plugin-react": "^7.29.4",
|
|
102
102
|
"eslint-plugin-regexp": "^2.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": "^16.0.0",
|
|
107
107
|
"locate-character": "^3.0.0",
|
|
108
108
|
"magic-string": "^0.30.0",
|
|
109
109
|
"mocha": "^11.0.0",
|
|
@@ -115,9 +115,9 @@
|
|
|
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.8.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"
|