astro-eslint-parser 1.2.2 → 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 +56 -12
- package/lib/index.mjs +56 -15
- package/package.json +5 -5
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
|
);
|
|
@@ -2551,18 +2595,18 @@ function remap(result, normalized, originalCode, ctxForAstro) {
|
|
|
2551
2595
|
}
|
|
2552
2596
|
|
|
2553
2597
|
// src/context/parser-options.ts
|
|
2554
|
-
var
|
|
2598
|
+
var import_path5 = __toESM(require("path"));
|
|
2555
2599
|
var import_fs2 = __toESM(require("fs"));
|
|
2556
2600
|
|
|
2557
2601
|
// src/context/resolve-parser/espree.ts
|
|
2558
|
-
var
|
|
2559
|
-
var
|
|
2602
|
+
var import_module4 = require("module");
|
|
2603
|
+
var import_path4 = __toESM(require("path"));
|
|
2560
2604
|
var espreeCache = null;
|
|
2561
2605
|
function isLinterPath(p) {
|
|
2562
2606
|
return (
|
|
2563
2607
|
// ESLint 6 and above
|
|
2564
|
-
p.includes(`eslint${
|
|
2565
|
-
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`)
|
|
2566
2610
|
);
|
|
2567
2611
|
}
|
|
2568
2612
|
function getEspree() {
|
|
@@ -2570,7 +2614,7 @@ function getEspree() {
|
|
|
2570
2614
|
const linterPath = Object.keys(require.cache || {}).find(isLinterPath);
|
|
2571
2615
|
if (linterPath) {
|
|
2572
2616
|
try {
|
|
2573
|
-
espreeCache = (0,
|
|
2617
|
+
espreeCache = (0, import_module4.createRequire)(linterPath)("espree");
|
|
2574
2618
|
} catch {
|
|
2575
2619
|
}
|
|
2576
2620
|
}
|
|
@@ -2666,7 +2710,7 @@ var ParserOptionsContext = class {
|
|
|
2666
2710
|
if (TS_PARSER_NAMES.some((nm) => parserName.includes(nm))) {
|
|
2667
2711
|
let targetPath = parserName;
|
|
2668
2712
|
while (targetPath) {
|
|
2669
|
-
const pkgPath =
|
|
2713
|
+
const pkgPath = import_path5.default.join(targetPath, "package.json");
|
|
2670
2714
|
if (import_fs2.default.existsSync(pkgPath)) {
|
|
2671
2715
|
try {
|
|
2672
2716
|
const pkgName = JSON.parse(import_fs2.default.readFileSync(pkgPath, "utf-8"))?.name;
|
|
@@ -2681,7 +2725,7 @@ var ParserOptionsContext = class {
|
|
|
2681
2725
|
return null;
|
|
2682
2726
|
}
|
|
2683
2727
|
}
|
|
2684
|
-
const parent =
|
|
2728
|
+
const parent = import_path5.default.dirname(targetPath);
|
|
2685
2729
|
if (targetPath === parent) {
|
|
2686
2730
|
break;
|
|
2687
2731
|
}
|
|
@@ -2830,7 +2874,7 @@ __export(meta_exports, {
|
|
|
2830
2874
|
|
|
2831
2875
|
// package.json
|
|
2832
2876
|
var name = "astro-eslint-parser";
|
|
2833
|
-
var version = "1.
|
|
2877
|
+
var version = "1.3.0";
|
|
2834
2878
|
|
|
2835
2879
|
// src/index.ts
|
|
2836
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
|
);
|
|
@@ -2529,18 +2570,18 @@ function remap(result, normalized, originalCode, ctxForAstro) {
|
|
|
2529
2570
|
}
|
|
2530
2571
|
|
|
2531
2572
|
// src/context/parser-options.ts
|
|
2532
|
-
import
|
|
2573
|
+
import path7 from "path";
|
|
2533
2574
|
import fs3 from "fs";
|
|
2534
2575
|
|
|
2535
2576
|
// src/context/resolve-parser/espree.ts
|
|
2536
|
-
import { createRequire as
|
|
2537
|
-
import
|
|
2577
|
+
import { createRequire as createRequire4 } from "module";
|
|
2578
|
+
import path6 from "path";
|
|
2538
2579
|
var espreeCache = null;
|
|
2539
2580
|
function isLinterPath(p) {
|
|
2540
2581
|
return (
|
|
2541
2582
|
// ESLint 6 and above
|
|
2542
|
-
p.includes(`eslint${
|
|
2543
|
-
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`)
|
|
2544
2585
|
);
|
|
2545
2586
|
}
|
|
2546
2587
|
function getEspree() {
|
|
@@ -2548,7 +2589,7 @@ function getEspree() {
|
|
|
2548
2589
|
const linterPath = Object.keys(__require.cache || {}).find(isLinterPath);
|
|
2549
2590
|
if (linterPath) {
|
|
2550
2591
|
try {
|
|
2551
|
-
espreeCache =
|
|
2592
|
+
espreeCache = createRequire4(linterPath)("espree");
|
|
2552
2593
|
} catch {
|
|
2553
2594
|
}
|
|
2554
2595
|
}
|
|
@@ -2644,7 +2685,7 @@ var ParserOptionsContext = class {
|
|
|
2644
2685
|
if (TS_PARSER_NAMES.some((nm) => parserName.includes(nm))) {
|
|
2645
2686
|
let targetPath = parserName;
|
|
2646
2687
|
while (targetPath) {
|
|
2647
|
-
const pkgPath =
|
|
2688
|
+
const pkgPath = path7.join(targetPath, "package.json");
|
|
2648
2689
|
if (fs3.existsSync(pkgPath)) {
|
|
2649
2690
|
try {
|
|
2650
2691
|
const pkgName = JSON.parse(fs3.readFileSync(pkgPath, "utf-8"))?.name;
|
|
@@ -2659,7 +2700,7 @@ var ParserOptionsContext = class {
|
|
|
2659
2700
|
return null;
|
|
2660
2701
|
}
|
|
2661
2702
|
}
|
|
2662
|
-
const parent =
|
|
2703
|
+
const parent = path7.dirname(targetPath);
|
|
2663
2704
|
if (targetPath === parent) {
|
|
2664
2705
|
break;
|
|
2665
2706
|
}
|
|
@@ -2808,7 +2849,7 @@ __export(meta_exports, {
|
|
|
2808
2849
|
|
|
2809
2850
|
// package.json
|
|
2810
2851
|
var name = "astro-eslint-parser";
|
|
2811
|
-
var version = "1.
|
|
2852
|
+
var version = "1.3.0";
|
|
2812
2853
|
|
|
2813
2854
|
// src/index.ts
|
|
2814
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",
|
|
@@ -96,7 +96,7 @@
|
|
|
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",
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
"tsup": "^8.0.0",
|
|
118
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"
|