astro-eslint-parser 1.0.2 → 1.1.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 +17 -17
- package/lib/index.mjs +18 -19
- package/package.json +14 -14
package/lib/index.d.mts
CHANGED
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -123,8 +123,7 @@ var TSService = class {
|
|
|
123
123
|
filePath: normalized
|
|
124
124
|
};
|
|
125
125
|
for (const { filePath: targetPath } of [this.currTarget, lastTarget]) {
|
|
126
|
-
if (!targetPath)
|
|
127
|
-
continue;
|
|
126
|
+
if (!targetPath) continue;
|
|
128
127
|
this.fileWatchCallbacks.get(targetPath)?.update();
|
|
129
128
|
}
|
|
130
129
|
const program = this.watch.getProgram().getProgram();
|
|
@@ -496,12 +495,10 @@ function getTSParserNameFromObject(value) {
|
|
|
496
495
|
return null;
|
|
497
496
|
}
|
|
498
497
|
function isTSESLintParserObject(value) {
|
|
499
|
-
if (!isEnhancedParserObject(value))
|
|
500
|
-
return false;
|
|
498
|
+
if (!isEnhancedParserObject(value)) return false;
|
|
501
499
|
if (value.name === "typescript-eslint-parser-for-extra-files")
|
|
502
500
|
return true;
|
|
503
|
-
if (value.meta?.name === "typescript-eslint/parser")
|
|
504
|
-
return true;
|
|
501
|
+
if (value.meta?.name === "typescript-eslint/parser") return true;
|
|
505
502
|
try {
|
|
506
503
|
const result = value.parseForESLint("", {});
|
|
507
504
|
const services = result.services;
|
|
@@ -755,8 +752,7 @@ function removeIdentifierVariable(node, scope) {
|
|
|
755
752
|
if (variable.defs.length === 0) {
|
|
756
753
|
referencesToThrough(variable.references, scope);
|
|
757
754
|
variable.references.forEach((r) => {
|
|
758
|
-
if (r.init)
|
|
759
|
-
r.init = false;
|
|
755
|
+
if (r.init) r.init = false;
|
|
760
756
|
r.resolved = null;
|
|
761
757
|
});
|
|
762
758
|
scope.variables.splice(varIndex, 1);
|
|
@@ -891,6 +887,14 @@ function parseScriptInternal(code, _ctx, parserOptionsCtx) {
|
|
|
891
887
|
const parserOptions = parserOptionsCtx.parserOptions;
|
|
892
888
|
if (parserOptionsCtx.isTypeScript() && parserOptions.filePath && parserOptions.project) {
|
|
893
889
|
patchResult = tsPatch(parserOptions, parserOptionsCtx.getTSParserName());
|
|
890
|
+
} else if (parserOptionsCtx.isTypeScript() && parserOptions.filePath && parserOptions.projectService) {
|
|
891
|
+
console.warn(
|
|
892
|
+
"`astro-eslint-parser` does not support the `projectService` option, it will parse it as `project: true` instead."
|
|
893
|
+
);
|
|
894
|
+
patchResult = tsPatch(
|
|
895
|
+
{ ...parserOptions, project: true },
|
|
896
|
+
parserOptionsCtx.getTSParserName()
|
|
897
|
+
);
|
|
894
898
|
}
|
|
895
899
|
const result = isEnhancedParserObject(parser) ? patchResult?.parse ? patchResult.parse(code, parser) : parser.parseForESLint(code, parserOptions) : parser.parse(code, parserOptions);
|
|
896
900
|
if ("ast" in result && result.ast != null) {
|
|
@@ -1161,12 +1165,9 @@ function getEndOffset(node, ctx) {
|
|
|
1161
1165
|
if (node.position.end?.offset != null) {
|
|
1162
1166
|
return node.position.end.offset;
|
|
1163
1167
|
}
|
|
1164
|
-
if (isTag(node))
|
|
1165
|
-
|
|
1166
|
-
if (node.type === "
|
|
1167
|
-
return calcExpressionEndOffset(node, ctx);
|
|
1168
|
-
if (node.type === "comment")
|
|
1169
|
-
return calcCommentEndOffset(node, ctx);
|
|
1168
|
+
if (isTag(node)) return calcTagEndOffset(node, ctx);
|
|
1169
|
+
if (node.type === "expression") return calcExpressionEndOffset(node, ctx);
|
|
1170
|
+
if (node.type === "comment") return calcCommentEndOffset(node, ctx);
|
|
1170
1171
|
if (node.type === "frontmatter") {
|
|
1171
1172
|
const start = node.position.start.offset;
|
|
1172
1173
|
return ctx.code.indexOf("---", start + 3) + 3;
|
|
@@ -1344,8 +1345,7 @@ function getTokenInfo(ctx, tokens, position) {
|
|
|
1344
1345
|
};
|
|
1345
1346
|
function getHTMLEntity(position3) {
|
|
1346
1347
|
let codeOffset2 = position3;
|
|
1347
|
-
if (ctx.code[codeOffset2++] !== "&")
|
|
1348
|
-
return null;
|
|
1348
|
+
if (ctx.code[codeOffset2++] !== "&") return null;
|
|
1349
1349
|
let entity = "";
|
|
1350
1350
|
const entityDecoder = new import_decode.EntityDecoder(
|
|
1351
1351
|
import_decode.htmlDecodeTree,
|
|
@@ -2818,7 +2818,7 @@ __export(meta_exports, {
|
|
|
2818
2818
|
|
|
2819
2819
|
// package.json
|
|
2820
2820
|
var name = "astro-eslint-parser";
|
|
2821
|
-
var version = "1.0
|
|
2821
|
+
var version = "1.1.0";
|
|
2822
2822
|
|
|
2823
2823
|
// src/index.ts
|
|
2824
2824
|
function parseForESLint2(code, options) {
|
package/lib/index.mjs
CHANGED
|
@@ -2,8 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
3
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
4
|
}) : x)(function(x) {
|
|
5
|
-
if (typeof require !== "undefined")
|
|
6
|
-
return require.apply(this, arguments);
|
|
5
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
7
6
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
8
7
|
});
|
|
9
8
|
var __export = (target, all) => {
|
|
@@ -93,8 +92,7 @@ var TSService = class {
|
|
|
93
92
|
filePath: normalized
|
|
94
93
|
};
|
|
95
94
|
for (const { filePath: targetPath } of [this.currTarget, lastTarget]) {
|
|
96
|
-
if (!targetPath)
|
|
97
|
-
continue;
|
|
95
|
+
if (!targetPath) continue;
|
|
98
96
|
this.fileWatchCallbacks.get(targetPath)?.update();
|
|
99
97
|
}
|
|
100
98
|
const program = this.watch.getProgram().getProgram();
|
|
@@ -466,12 +464,10 @@ function getTSParserNameFromObject(value) {
|
|
|
466
464
|
return null;
|
|
467
465
|
}
|
|
468
466
|
function isTSESLintParserObject(value) {
|
|
469
|
-
if (!isEnhancedParserObject(value))
|
|
470
|
-
return false;
|
|
467
|
+
if (!isEnhancedParserObject(value)) return false;
|
|
471
468
|
if (value.name === "typescript-eslint-parser-for-extra-files")
|
|
472
469
|
return true;
|
|
473
|
-
if (value.meta?.name === "typescript-eslint/parser")
|
|
474
|
-
return true;
|
|
470
|
+
if (value.meta?.name === "typescript-eslint/parser") return true;
|
|
475
471
|
try {
|
|
476
472
|
const result = value.parseForESLint("", {});
|
|
477
473
|
const services = result.services;
|
|
@@ -734,8 +730,7 @@ function removeIdentifierVariable(node, scope) {
|
|
|
734
730
|
if (variable.defs.length === 0) {
|
|
735
731
|
referencesToThrough(variable.references, scope);
|
|
736
732
|
variable.references.forEach((r) => {
|
|
737
|
-
if (r.init)
|
|
738
|
-
r.init = false;
|
|
733
|
+
if (r.init) r.init = false;
|
|
739
734
|
r.resolved = null;
|
|
740
735
|
});
|
|
741
736
|
scope.variables.splice(varIndex, 1);
|
|
@@ -870,6 +865,14 @@ function parseScriptInternal(code, _ctx, parserOptionsCtx) {
|
|
|
870
865
|
const parserOptions = parserOptionsCtx.parserOptions;
|
|
871
866
|
if (parserOptionsCtx.isTypeScript() && parserOptions.filePath && parserOptions.project) {
|
|
872
867
|
patchResult = tsPatch(parserOptions, parserOptionsCtx.getTSParserName());
|
|
868
|
+
} else if (parserOptionsCtx.isTypeScript() && parserOptions.filePath && parserOptions.projectService) {
|
|
869
|
+
console.warn(
|
|
870
|
+
"`astro-eslint-parser` does not support the `projectService` option, it will parse it as `project: true` instead."
|
|
871
|
+
);
|
|
872
|
+
patchResult = tsPatch(
|
|
873
|
+
{ ...parserOptions, project: true },
|
|
874
|
+
parserOptionsCtx.getTSParserName()
|
|
875
|
+
);
|
|
873
876
|
}
|
|
874
877
|
const result = isEnhancedParserObject(parser) ? patchResult?.parse ? patchResult.parse(code, parser) : parser.parseForESLint(code, parserOptions) : parser.parse(code, parserOptions);
|
|
875
878
|
if ("ast" in result && result.ast != null) {
|
|
@@ -1144,12 +1147,9 @@ function getEndOffset(node, ctx) {
|
|
|
1144
1147
|
if (node.position.end?.offset != null) {
|
|
1145
1148
|
return node.position.end.offset;
|
|
1146
1149
|
}
|
|
1147
|
-
if (isTag(node))
|
|
1148
|
-
|
|
1149
|
-
if (node.type === "
|
|
1150
|
-
return calcExpressionEndOffset(node, ctx);
|
|
1151
|
-
if (node.type === "comment")
|
|
1152
|
-
return calcCommentEndOffset(node, ctx);
|
|
1150
|
+
if (isTag(node)) return calcTagEndOffset(node, ctx);
|
|
1151
|
+
if (node.type === "expression") return calcExpressionEndOffset(node, ctx);
|
|
1152
|
+
if (node.type === "comment") return calcCommentEndOffset(node, ctx);
|
|
1153
1153
|
if (node.type === "frontmatter") {
|
|
1154
1154
|
const start = node.position.start.offset;
|
|
1155
1155
|
return ctx.code.indexOf("---", start + 3) + 3;
|
|
@@ -1327,8 +1327,7 @@ function getTokenInfo(ctx, tokens, position) {
|
|
|
1327
1327
|
};
|
|
1328
1328
|
function getHTMLEntity(position3) {
|
|
1329
1329
|
let codeOffset2 = position3;
|
|
1330
|
-
if (ctx.code[codeOffset2++] !== "&")
|
|
1331
|
-
return null;
|
|
1330
|
+
if (ctx.code[codeOffset2++] !== "&") return null;
|
|
1332
1331
|
let entity = "";
|
|
1333
1332
|
const entityDecoder = new EntityDecoder(
|
|
1334
1333
|
htmlDecodeTree,
|
|
@@ -2801,7 +2800,7 @@ __export(meta_exports, {
|
|
|
2801
2800
|
|
|
2802
2801
|
// package.json
|
|
2803
2802
|
var name = "astro-eslint-parser";
|
|
2804
|
-
var version = "1.0
|
|
2803
|
+
var version = "1.1.0";
|
|
2805
2804
|
|
|
2806
2805
|
// src/index.ts
|
|
2807
2806
|
function parseForESLint2(code, options) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro-eslint-parser",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Astro component parser for ESLint",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.mjs",
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
"homepage": "https://github.com/ota-meshi/astro-eslint-parser#readme",
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@astrojs/compiler": "^2.0.0",
|
|
52
|
-
"@typescript-eslint/scope-manager": "^7.0.0",
|
|
53
|
-
"@typescript-eslint/types": "^7.0.0",
|
|
54
|
-
"@typescript-eslint/typescript-estree": "^7.0.0",
|
|
52
|
+
"@typescript-eslint/scope-manager": "^7.0.0 || ^8.0.0",
|
|
53
|
+
"@typescript-eslint/types": "^7.0.0 || ^8.0.0",
|
|
54
|
+
"@typescript-eslint/typescript-estree": "^7.0.0 || ^8.0.0",
|
|
55
55
|
"astrojs-compiler-sync": "^1.0.0",
|
|
56
56
|
"debug": "^4.3.4",
|
|
57
57
|
"entities": "^4.5.0",
|
|
@@ -67,23 +67,23 @@
|
|
|
67
67
|
"@changesets/cli": "^2.24.2",
|
|
68
68
|
"@ota-meshi/eslint-plugin": "^0.15.0",
|
|
69
69
|
"@types/benchmark": "^2.1.1",
|
|
70
|
-
"@types/chai": "^
|
|
70
|
+
"@types/chai": "^5.0.0",
|
|
71
71
|
"@types/debug": "^4.1.7",
|
|
72
|
-
"@types/eslint": "^
|
|
72
|
+
"@types/eslint": "^9.0.0",
|
|
73
73
|
"@types/eslint-scope": "^3.7.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": "^22.0.0",
|
|
78
78
|
"@types/semver": "^7.3.9",
|
|
79
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
80
|
-
"@typescript-eslint/parser": "^
|
|
79
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
80
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
81
81
|
"astro": "^4.0.0",
|
|
82
82
|
"astro-eslint-parser": ">=0.1.0",
|
|
83
83
|
"benchmark": "^2.1.4",
|
|
84
84
|
"chai": "^5.0.0",
|
|
85
85
|
"env-cmd": "^10.1.0",
|
|
86
|
-
"esbuild": "^0.
|
|
86
|
+
"esbuild": "^0.24.0",
|
|
87
87
|
"esbuild-register": "^3.3.3",
|
|
88
88
|
"eslint": "^8.15.0",
|
|
89
89
|
"eslint-config-prettier": "^9.0.0",
|
|
@@ -106,15 +106,15 @@
|
|
|
106
106
|
"magic-string": "^0.30.0",
|
|
107
107
|
"mocha": "^10.0.0",
|
|
108
108
|
"mocha-chai-jest-snapshot": "^1.1.3",
|
|
109
|
-
"nyc": "^
|
|
109
|
+
"nyc": "^17.0.0",
|
|
110
110
|
"prettier": "^3.0.0",
|
|
111
|
-
"prettier-plugin-astro": "^0.
|
|
111
|
+
"prettier-plugin-astro": "^0.14.0",
|
|
112
112
|
"prettier-plugin-svelte": "^3.0.0",
|
|
113
113
|
"string-replace-loader": "^3.0.3",
|
|
114
114
|
"svelte": "^4.0.0",
|
|
115
115
|
"tsup": "^8.0.0",
|
|
116
|
-
"typescript": "~5.
|
|
117
|
-
"typescript-eslint-parser-for-extra-files": "^0.
|
|
116
|
+
"typescript": "~5.6.0",
|
|
117
|
+
"typescript-eslint-parser-for-extra-files": "^0.7.0"
|
|
118
118
|
},
|
|
119
119
|
"publishConfig": {
|
|
120
120
|
"access": "public"
|