astro-eslint-parser 0.11.0 → 0.13.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.ts +2 -1
- package/lib/index.js +395 -60
- package/lib/index.mjs +388 -58
- package/package.json +13 -13
package/lib/index.d.ts
CHANGED
|
@@ -348,10 +348,11 @@ declare class ParseError extends SyntaxError {
|
|
|
348
348
|
}, ctx: Context);
|
|
349
349
|
}
|
|
350
350
|
|
|
351
|
+
declare const name = "astro-eslint-parser";
|
|
351
352
|
/**
|
|
352
353
|
* Parse source code
|
|
353
354
|
*/
|
|
354
355
|
declare function parseForESLint(code: string, options?: any): ReturnType<typeof parseForESLint$1>;
|
|
355
356
|
declare const VisitorKeys: eslint.SourceCode.VisitorKeys;
|
|
356
357
|
|
|
357
|
-
export { index as AST, ParseError, ParseTemplateResult, VisitorKeys, parseForESLint, parseTemplate, traverseNodes };
|
|
358
|
+
export { index as AST, ParseError, ParseTemplateResult, VisitorKeys, name, parseForESLint, parseTemplate, traverseNodes };
|
package/lib/index.js
CHANGED
|
@@ -6,8 +6,8 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
-
for (var
|
|
10
|
-
__defProp(target,
|
|
9
|
+
for (var name2 in all)
|
|
10
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
11
11
|
};
|
|
12
12
|
var __copyProps = (to, from, except, desc) => {
|
|
13
13
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -29,6 +33,7 @@ __export(src_exports, {
|
|
|
29
33
|
AST: () => ast_exports,
|
|
30
34
|
ParseError: () => ParseError,
|
|
31
35
|
VisitorKeys: () => VisitorKeys,
|
|
36
|
+
name: () => name,
|
|
32
37
|
parseForESLint: () => parseForESLint2,
|
|
33
38
|
parseTemplate: () => parseTemplate2,
|
|
34
39
|
traverseNodes: () => traverseNodes
|
|
@@ -59,55 +64,327 @@ var debug = (0, import_debug.default)("astro-eslint-parser");
|
|
|
59
64
|
|
|
60
65
|
// src/parser/ts-patch.ts
|
|
61
66
|
var import_module = require("module");
|
|
62
|
-
var
|
|
67
|
+
var import_path3 = __toESM(require("path"));
|
|
68
|
+
var import_fs2 = __toESM(require("fs"));
|
|
69
|
+
var import_semver = require("semver");
|
|
70
|
+
|
|
71
|
+
// src/parser/ts-for-v5/get-project-config-files.ts
|
|
63
72
|
var import_fs = __toESM(require("fs"));
|
|
64
|
-
|
|
73
|
+
var import_path = __toESM(require("path"));
|
|
74
|
+
function getProjectConfigFiles(options) {
|
|
75
|
+
const tsconfigRootDir = typeof options.tsconfigRootDir === "string" ? options.tsconfigRootDir : process.cwd();
|
|
76
|
+
if (options.project !== true) {
|
|
77
|
+
return Array.isArray(options.project) ? options.project : [options.project];
|
|
78
|
+
}
|
|
79
|
+
let directory = import_path.default.dirname(options.filePath);
|
|
80
|
+
const checkedDirectories = [directory];
|
|
81
|
+
do {
|
|
82
|
+
const tsconfigPath = import_path.default.join(directory, "tsconfig.json");
|
|
83
|
+
if (import_fs.default.existsSync(tsconfigPath)) {
|
|
84
|
+
return [tsconfigPath];
|
|
85
|
+
}
|
|
86
|
+
directory = import_path.default.dirname(directory);
|
|
87
|
+
checkedDirectories.push(directory);
|
|
88
|
+
} while (directory.length > 1 && directory.length >= tsconfigRootDir.length);
|
|
89
|
+
throw new Error(
|
|
90
|
+
`project was set to \`true\` but couldn't find any tsconfig.json relative to '${options.filePath}' within '${tsconfigRootDir}'.`
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// src/parser/ts-for-v5/programs.ts
|
|
95
|
+
var import_path2 = __toESM(require("path"));
|
|
96
|
+
var tsServices = /* @__PURE__ */ new Map();
|
|
97
|
+
function getTSProgram(code, options, ts) {
|
|
98
|
+
const tsconfigPath = options.project;
|
|
99
|
+
let service2 = tsServices.get(tsconfigPath);
|
|
100
|
+
if (!service2) {
|
|
101
|
+
service2 = new TSService(tsconfigPath, ts);
|
|
102
|
+
tsServices.set(tsconfigPath, service2);
|
|
103
|
+
}
|
|
104
|
+
return service2.getProgram(code, options.filePath);
|
|
105
|
+
}
|
|
106
|
+
var TSService = class {
|
|
107
|
+
constructor(tsconfigPath, ts) {
|
|
108
|
+
this.patchedHostSet = /* @__PURE__ */ new WeakSet();
|
|
109
|
+
this.currTarget = {
|
|
110
|
+
code: "",
|
|
111
|
+
filePath: ""
|
|
112
|
+
};
|
|
113
|
+
this.fileWatchCallbacks = /* @__PURE__ */ new Map();
|
|
114
|
+
this.ts = ts;
|
|
115
|
+
this.watch = this.createWatch(tsconfigPath);
|
|
116
|
+
}
|
|
117
|
+
getProgram(code, filePath) {
|
|
118
|
+
const normalized = normalizeFileName(this.ts, filePath);
|
|
119
|
+
const lastTarget = this.currTarget;
|
|
120
|
+
this.currTarget = {
|
|
121
|
+
code,
|
|
122
|
+
filePath: normalized
|
|
123
|
+
};
|
|
124
|
+
for (const { filePath: targetPath } of [this.currTarget, lastTarget]) {
|
|
125
|
+
if (!targetPath)
|
|
126
|
+
continue;
|
|
127
|
+
this.fileWatchCallbacks.get(targetPath)?.update();
|
|
128
|
+
}
|
|
129
|
+
const program = this.watch.getProgram().getProgram();
|
|
130
|
+
program.getTypeChecker();
|
|
131
|
+
return program;
|
|
132
|
+
}
|
|
133
|
+
createWatch(tsconfigPath) {
|
|
134
|
+
const { ts } = this;
|
|
135
|
+
const watchCompilerHost = ts.createWatchCompilerHost(
|
|
136
|
+
tsconfigPath,
|
|
137
|
+
{
|
|
138
|
+
noEmit: true,
|
|
139
|
+
jsx: ts.JsxEmit.Preserve,
|
|
140
|
+
// This option is required if `includes` only includes `*.astro` files.
|
|
141
|
+
// However, the option is not in the documentation.
|
|
142
|
+
// https://github.com/microsoft/TypeScript/issues/28447
|
|
143
|
+
allowNonTsExtensions: true
|
|
144
|
+
},
|
|
145
|
+
ts.sys,
|
|
146
|
+
(rootNames, options, argHost, oldProgram, configFileParsingDiagnostics, projectReferences) => {
|
|
147
|
+
const host = argHost;
|
|
148
|
+
if (!this.patchedHostSet.has(host)) {
|
|
149
|
+
this.patchedHostSet.add(host);
|
|
150
|
+
const getTargetSourceFile = (fileName, languageVersionOrOptions) => {
|
|
151
|
+
var _a;
|
|
152
|
+
if (this.currTarget.filePath === normalizeFileName(ts, fileName)) {
|
|
153
|
+
return (_a = this.currTarget).sourceFile ?? (_a.sourceFile = ts.createSourceFile(
|
|
154
|
+
this.currTarget.filePath,
|
|
155
|
+
this.currTarget.code,
|
|
156
|
+
languageVersionOrOptions,
|
|
157
|
+
true,
|
|
158
|
+
ts.ScriptKind.TSX
|
|
159
|
+
));
|
|
160
|
+
}
|
|
161
|
+
return null;
|
|
162
|
+
};
|
|
163
|
+
const original2 = {
|
|
164
|
+
getSourceFile: host.getSourceFile,
|
|
165
|
+
getSourceFileByPath: host.getSourceFileByPath
|
|
166
|
+
};
|
|
167
|
+
host.getSourceFile = (fileName, languageVersionOrOptions, ...args) => {
|
|
168
|
+
return getTargetSourceFile(fileName, languageVersionOrOptions) ?? original2.getSourceFile.call(
|
|
169
|
+
host,
|
|
170
|
+
fileName,
|
|
171
|
+
languageVersionOrOptions,
|
|
172
|
+
...args
|
|
173
|
+
);
|
|
174
|
+
};
|
|
175
|
+
host.getSourceFileByPath = (fileName, path6, languageVersionOrOptions, ...args) => {
|
|
176
|
+
return getTargetSourceFile(fileName, languageVersionOrOptions) ?? original2.getSourceFileByPath.call(
|
|
177
|
+
host,
|
|
178
|
+
fileName,
|
|
179
|
+
path6,
|
|
180
|
+
languageVersionOrOptions,
|
|
181
|
+
...args
|
|
182
|
+
);
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
return ts.createAbstractBuilder(
|
|
186
|
+
rootNames,
|
|
187
|
+
options,
|
|
188
|
+
host,
|
|
189
|
+
oldProgram,
|
|
190
|
+
configFileParsingDiagnostics,
|
|
191
|
+
projectReferences
|
|
192
|
+
);
|
|
193
|
+
},
|
|
194
|
+
(diagnostic) => {
|
|
195
|
+
throw new Error(formatDiagnostics(ts, [diagnostic]));
|
|
196
|
+
},
|
|
197
|
+
() => {
|
|
198
|
+
},
|
|
199
|
+
void 0,
|
|
200
|
+
[
|
|
201
|
+
{
|
|
202
|
+
extension: ".astro",
|
|
203
|
+
isMixedContent: true,
|
|
204
|
+
scriptKind: ts.ScriptKind.Deferred
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
);
|
|
208
|
+
const original = {
|
|
209
|
+
readFile: watchCompilerHost.readFile
|
|
210
|
+
};
|
|
211
|
+
watchCompilerHost.readFile = (fileName, ...args) => {
|
|
212
|
+
const normalized = normalizeFileName(ts, fileName);
|
|
213
|
+
if (this.currTarget.filePath === normalized) {
|
|
214
|
+
return this.currTarget.code;
|
|
215
|
+
}
|
|
216
|
+
return original.readFile.call(watchCompilerHost, fileName, ...args);
|
|
217
|
+
};
|
|
218
|
+
watchCompilerHost.watchFile = (fileName, callback) => {
|
|
219
|
+
const normalized = normalizeFileName(ts, fileName);
|
|
220
|
+
this.fileWatchCallbacks.set(normalized, {
|
|
221
|
+
update: () => callback(fileName, ts.FileWatcherEventKind.Changed)
|
|
222
|
+
});
|
|
223
|
+
return {
|
|
224
|
+
close: () => {
|
|
225
|
+
this.fileWatchCallbacks.delete(normalized);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
watchCompilerHost.watchDirectory = () => {
|
|
230
|
+
return {
|
|
231
|
+
close: () => {
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
watchCompilerHost.afterProgramCreate = (program) => {
|
|
236
|
+
const originalDiagnostics = program.getConfigFileParsingDiagnostics();
|
|
237
|
+
const configFileDiagnostics = originalDiagnostics.filter(
|
|
238
|
+
(diag) => diag.category === ts.DiagnosticCategory.Error && diag.code !== 18003
|
|
239
|
+
);
|
|
240
|
+
if (configFileDiagnostics.length > 0) {
|
|
241
|
+
throw new Error(formatDiagnostics(ts, configFileDiagnostics));
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
const watch = ts.createWatchProgram(watchCompilerHost);
|
|
245
|
+
return watch;
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
function formatDiagnostics(ts, diagnostics) {
|
|
249
|
+
return ts.formatDiagnostics(diagnostics, {
|
|
250
|
+
getCanonicalFileName: (f) => f,
|
|
251
|
+
getCurrentDirectory: () => process.cwd(),
|
|
252
|
+
getNewLine: () => "\n"
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
function normalizeFileName(ts, fileName) {
|
|
256
|
+
let normalized = import_path2.default.normalize(fileName);
|
|
257
|
+
if (normalized.endsWith(import_path2.default.sep)) {
|
|
258
|
+
normalized = normalized.slice(0, -1);
|
|
259
|
+
}
|
|
260
|
+
if (ts.sys.useCaseSensitiveFileNames) {
|
|
261
|
+
return toAbsolutePath(normalized, null);
|
|
262
|
+
}
|
|
263
|
+
return toAbsolutePath(normalized.toLowerCase(), null);
|
|
264
|
+
}
|
|
265
|
+
function toAbsolutePath(filePath, baseDir) {
|
|
266
|
+
return import_path2.default.isAbsolute(filePath) ? filePath : import_path2.default.join(baseDir || process.cwd(), filePath);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// src/parser/ts-for-v5/parse-tsx-for-typescript.ts
|
|
270
|
+
var DEFAULT_EXTRA_FILE_EXTENSIONS = [".vue", ".svelte", ".astro"];
|
|
271
|
+
function parseTsxForTypeScript(code, options, tsEslintParser, ts) {
|
|
272
|
+
const programs = [];
|
|
273
|
+
for (const option of iterateOptions(options)) {
|
|
274
|
+
programs.push(getTSProgram(code, option, ts));
|
|
275
|
+
}
|
|
276
|
+
const parserOptions = {
|
|
277
|
+
...options,
|
|
278
|
+
programs
|
|
279
|
+
};
|
|
280
|
+
return tsEslintParser.parseForESLint(code, parserOptions);
|
|
281
|
+
}
|
|
282
|
+
function* iterateOptions(options) {
|
|
283
|
+
if (!options) {
|
|
284
|
+
throw new Error("`parserOptions` is required.");
|
|
285
|
+
}
|
|
286
|
+
if (!options.filePath) {
|
|
287
|
+
throw new Error("`filePath` is required.");
|
|
288
|
+
}
|
|
289
|
+
if (!options.project) {
|
|
290
|
+
throw new Error(
|
|
291
|
+
"Specify `parserOptions.project`. Otherwise there is no point in using this parser."
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
for (const project of getProjectConfigFiles(options)) {
|
|
295
|
+
yield {
|
|
296
|
+
project,
|
|
297
|
+
filePath: options.filePath,
|
|
298
|
+
extraFileExtensions: options.extraFileExtensions || DEFAULT_EXTRA_FILE_EXTENSIONS
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// src/parser/ts-patch.ts
|
|
304
|
+
function tsPatch(scriptParserOptions, tsParserName) {
|
|
305
|
+
if (tsParserName === "typescript-eslint-parser-for-extra-files") {
|
|
306
|
+
return {
|
|
307
|
+
terminate() {
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
}
|
|
65
311
|
let targetExt = ".astro";
|
|
66
312
|
if (scriptParserOptions.filePath) {
|
|
67
|
-
const ext =
|
|
313
|
+
const ext = import_path3.default.extname(scriptParserOptions.filePath);
|
|
68
314
|
if (ext) {
|
|
69
315
|
targetExt = ext;
|
|
70
316
|
}
|
|
71
317
|
}
|
|
72
318
|
try {
|
|
73
319
|
const cwd = process.cwd();
|
|
74
|
-
const relativeTo =
|
|
320
|
+
const relativeTo = import_path3.default.join(cwd, "__placeholder__.js");
|
|
75
321
|
const ts = (0, import_module.createRequire)(relativeTo)("typescript");
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return ts.ScriptKind.TSX;
|
|
87
|
-
}
|
|
88
|
-
return getScriptKindFromFileName.call(this, fileName, ...args);
|
|
89
|
-
};
|
|
90
|
-
return {
|
|
91
|
-
terminate() {
|
|
92
|
-
ts.ensureScriptKind = ensureScriptKind;
|
|
93
|
-
ts.getScriptKindFromFileName = getScriptKindFromFileName;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
322
|
+
if ((0, import_semver.satisfies)(ts.version, ">=5")) {
|
|
323
|
+
const result = tsPatchForV5(ts, scriptParserOptions);
|
|
324
|
+
if (result) {
|
|
325
|
+
return result;
|
|
326
|
+
}
|
|
327
|
+
} else {
|
|
328
|
+
const result = tsPatchForV4(ts, targetExt);
|
|
329
|
+
if (result) {
|
|
330
|
+
return result;
|
|
331
|
+
}
|
|
96
332
|
}
|
|
97
333
|
} catch {
|
|
98
334
|
}
|
|
99
335
|
const tsxFilePath = `${scriptParserOptions.filePath}.tsx`;
|
|
100
336
|
scriptParserOptions.filePath = tsxFilePath;
|
|
101
|
-
if (!
|
|
102
|
-
|
|
337
|
+
if (!import_fs2.default.existsSync(tsxFilePath)) {
|
|
338
|
+
import_fs2.default.writeFileSync(tsxFilePath, "/* temp for astro-eslint-parser */");
|
|
103
339
|
return {
|
|
104
340
|
terminate() {
|
|
105
|
-
|
|
341
|
+
import_fs2.default.unlinkSync(tsxFilePath);
|
|
106
342
|
}
|
|
107
343
|
};
|
|
108
344
|
}
|
|
109
345
|
return null;
|
|
110
346
|
}
|
|
347
|
+
function tsPatchForV5(ts, scriptParserOptions) {
|
|
348
|
+
return {
|
|
349
|
+
terminate() {
|
|
350
|
+
},
|
|
351
|
+
parse(code, parser) {
|
|
352
|
+
return parseTsxForTypeScript(
|
|
353
|
+
code,
|
|
354
|
+
scriptParserOptions,
|
|
355
|
+
parser,
|
|
356
|
+
ts
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
function tsPatchForV4(ts, targetExt) {
|
|
362
|
+
const { ensureScriptKind, getScriptKindFromFileName } = ts;
|
|
363
|
+
if (typeof ensureScriptKind !== "function" || typeof getScriptKindFromFileName !== "function") {
|
|
364
|
+
return null;
|
|
365
|
+
}
|
|
366
|
+
ts.ensureScriptKind = function(fileName, ...args) {
|
|
367
|
+
if (fileName.endsWith(targetExt)) {
|
|
368
|
+
return ts.ScriptKind.TSX;
|
|
369
|
+
}
|
|
370
|
+
return ensureScriptKind.call(this, fileName, ...args);
|
|
371
|
+
};
|
|
372
|
+
ts.getScriptKindFromFileName = function(fileName, ...args) {
|
|
373
|
+
if (fileName.endsWith(targetExt)) {
|
|
374
|
+
return ts.ScriptKind.TSX;
|
|
375
|
+
}
|
|
376
|
+
return getScriptKindFromFileName.call(this, fileName, ...args);
|
|
377
|
+
};
|
|
378
|
+
if (ts.ensureScriptKind === ensureScriptKind || ts.getScriptKindFromFileName === getScriptKindFromFileName) {
|
|
379
|
+
return null;
|
|
380
|
+
}
|
|
381
|
+
return {
|
|
382
|
+
terminate() {
|
|
383
|
+
ts.ensureScriptKind = ensureScriptKind;
|
|
384
|
+
ts.getScriptKindFromFileName = getScriptKindFromFileName;
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
}
|
|
111
388
|
|
|
112
389
|
// src/context/resolve-parser/parser-object.ts
|
|
113
390
|
function isParserObject(value) {
|
|
@@ -122,9 +399,23 @@ function isBasicParserObject(value) {
|
|
|
122
399
|
function maybeTSESLintParserObject(value) {
|
|
123
400
|
return isEnhancedParserObject(value) && isBasicParserObject(value) && typeof value.createProgram === "function" && typeof value.clearCaches === "function" && typeof value.version === "string";
|
|
124
401
|
}
|
|
402
|
+
function getTSParserNameFromObject(value) {
|
|
403
|
+
if (!isEnhancedParserObject(value)) {
|
|
404
|
+
return null;
|
|
405
|
+
}
|
|
406
|
+
if (value.name === "typescript-eslint-parser-for-extra-files")
|
|
407
|
+
return "typescript-eslint-parser-for-extra-files";
|
|
408
|
+
if (value.meta?.name === "typescript-eslint/parser")
|
|
409
|
+
return "@typescript-eslint/parser";
|
|
410
|
+
return null;
|
|
411
|
+
}
|
|
125
412
|
function isTSESLintParserObject(value) {
|
|
126
413
|
if (!isEnhancedParserObject(value))
|
|
127
414
|
return false;
|
|
415
|
+
if (value.name === "typescript-eslint-parser-for-extra-files")
|
|
416
|
+
return true;
|
|
417
|
+
if (value.meta?.name === "typescript-eslint/parser")
|
|
418
|
+
return true;
|
|
128
419
|
try {
|
|
129
420
|
const result = value.parseForESLint("", {});
|
|
130
421
|
const services = result.services;
|
|
@@ -159,9 +450,9 @@ function parseScriptInternal(code, _ctx, parserOptionsCtx) {
|
|
|
159
450
|
try {
|
|
160
451
|
const parserOptions = parserOptionsCtx.parserOptions;
|
|
161
452
|
if (parserOptionsCtx.isTypeScript() && parserOptions.filePath && parserOptions.project) {
|
|
162
|
-
patchResult = tsPatch(parserOptions);
|
|
453
|
+
patchResult = tsPatch(parserOptions, parserOptionsCtx.getTSParserName());
|
|
163
454
|
}
|
|
164
|
-
const result = isEnhancedParserObject(parser) ? parser.parseForESLint(code, parserOptions) : parser.parse(code, parserOptions);
|
|
455
|
+
const result = isEnhancedParserObject(parser) ? patchResult?.parse ? patchResult.parse(code, parser) : parser.parseForESLint(code, parserOptions) : parser.parse(code, parserOptions);
|
|
165
456
|
if ("ast" in result && result.ast != null) {
|
|
166
457
|
return result;
|
|
167
458
|
}
|
|
@@ -195,6 +486,9 @@ var import_types = require("@typescript-eslint/types");
|
|
|
195
486
|
|
|
196
487
|
// src/errors.ts
|
|
197
488
|
var ParseError = class extends SyntaxError {
|
|
489
|
+
/**
|
|
490
|
+
* Initialize this ParseError instance.
|
|
491
|
+
*/
|
|
198
492
|
constructor(message, offset, ctx) {
|
|
199
493
|
super(message);
|
|
200
494
|
if (typeof offset === "number") {
|
|
@@ -617,6 +911,9 @@ var RestoreContext = class {
|
|
|
617
911
|
}
|
|
618
912
|
this.tokens.push(this.ctx.buildToken(type, range));
|
|
619
913
|
}
|
|
914
|
+
/**
|
|
915
|
+
* Restore AST nodes
|
|
916
|
+
*/
|
|
620
917
|
restore(result) {
|
|
621
918
|
const nodeMap = remapLocationsAndGetNodeMap(result, this.tokens, {
|
|
622
919
|
remapLocation: (n) => this.remapLocation(n),
|
|
@@ -808,6 +1105,7 @@ function processTemplate(ctx, resultTemplate) {
|
|
|
808
1105
|
walkElements(
|
|
809
1106
|
resultTemplate.ast,
|
|
810
1107
|
ctx.code,
|
|
1108
|
+
// eslint-disable-next-line complexity -- X(
|
|
811
1109
|
(node, [parent]) => {
|
|
812
1110
|
if (node.type === "frontmatter") {
|
|
813
1111
|
const start = node.position.start.offset;
|
|
@@ -1261,6 +1559,9 @@ var Context = class {
|
|
|
1261
1559
|
getIndexFromLoc(loc) {
|
|
1262
1560
|
return this.locs.getIndexFromLoc(loc);
|
|
1263
1561
|
}
|
|
1562
|
+
/**
|
|
1563
|
+
* Get the location information of the given indexes.
|
|
1564
|
+
*/
|
|
1264
1565
|
getLocations(start, end) {
|
|
1265
1566
|
return {
|
|
1266
1567
|
range: [start, end],
|
|
@@ -1270,6 +1571,9 @@ var Context = class {
|
|
|
1270
1571
|
}
|
|
1271
1572
|
};
|
|
1272
1573
|
}
|
|
1574
|
+
/**
|
|
1575
|
+
* Build token
|
|
1576
|
+
*/
|
|
1273
1577
|
buildToken(type, range) {
|
|
1274
1578
|
return {
|
|
1275
1579
|
type,
|
|
@@ -1277,6 +1581,9 @@ var Context = class {
|
|
|
1277
1581
|
...this.getLocations(...range)
|
|
1278
1582
|
};
|
|
1279
1583
|
}
|
|
1584
|
+
/**
|
|
1585
|
+
* get text
|
|
1586
|
+
*/
|
|
1280
1587
|
getText(range) {
|
|
1281
1588
|
return this.code.slice(range[0], range[1]);
|
|
1282
1589
|
}
|
|
@@ -1440,6 +1747,7 @@ function fixLocations(node, ctx) {
|
|
|
1440
1747
|
walk(
|
|
1441
1748
|
node,
|
|
1442
1749
|
ctx.code,
|
|
1750
|
+
// eslint-disable-next-line complexity -- X(
|
|
1443
1751
|
(node2, [parent]) => {
|
|
1444
1752
|
if (node2.type === "frontmatter") {
|
|
1445
1753
|
start = node2.position.start.offset = tokenIndex(ctx, "---", start);
|
|
@@ -1704,15 +2012,19 @@ function remap(result, normalized, originalCode, ctxForAstro) {
|
|
|
1704
2012
|
}
|
|
1705
2013
|
|
|
1706
2014
|
// src/context/parser-options.ts
|
|
1707
|
-
var
|
|
1708
|
-
var
|
|
2015
|
+
var import_path5 = __toESM(require("path"));
|
|
2016
|
+
var import_fs3 = __toESM(require("fs"));
|
|
1709
2017
|
|
|
1710
2018
|
// src/context/resolve-parser/espree.ts
|
|
1711
2019
|
var import_module2 = require("module");
|
|
1712
|
-
var
|
|
2020
|
+
var import_path4 = __toESM(require("path"));
|
|
1713
2021
|
var espreeCache = null;
|
|
1714
2022
|
function isLinterPath(p) {
|
|
1715
|
-
return
|
|
2023
|
+
return (
|
|
2024
|
+
// ESLint 6 and above
|
|
2025
|
+
p.includes(`eslint${import_path4.default.sep}lib${import_path4.default.sep}linter${import_path4.default.sep}linter.js`) || // ESLint 5
|
|
2026
|
+
p.includes(`eslint${import_path4.default.sep}lib${import_path4.default.sep}linter.js`)
|
|
2027
|
+
);
|
|
1716
2028
|
}
|
|
1717
2029
|
function getEspree() {
|
|
1718
2030
|
if (!espreeCache) {
|
|
@@ -1773,6 +2085,7 @@ var ParserOptionsContext = class {
|
|
|
1773
2085
|
tokens: true,
|
|
1774
2086
|
comment: true,
|
|
1775
2087
|
eslintVisitorKeys: true,
|
|
2088
|
+
// eslintScopeManager: true,
|
|
1776
2089
|
...options || {}
|
|
1777
2090
|
};
|
|
1778
2091
|
parserOptions.ecmaFeatures = {
|
|
@@ -1788,39 +2101,59 @@ var ParserOptionsContext = class {
|
|
|
1788
2101
|
getParser() {
|
|
1789
2102
|
return getParser({}, this.parserOptions.parser);
|
|
1790
2103
|
}
|
|
1791
|
-
|
|
1792
|
-
if (this.state.
|
|
1793
|
-
return this.state.
|
|
2104
|
+
getTSParserName() {
|
|
2105
|
+
if (this.state.ts != null) {
|
|
2106
|
+
return this.state.ts === false ? null : this.state.ts.parserName;
|
|
1794
2107
|
}
|
|
1795
2108
|
const parserValue = getParserForLang({}, this.parserOptions?.parser);
|
|
1796
2109
|
if (typeof parserValue !== "string") {
|
|
1797
|
-
|
|
2110
|
+
const name2 = getTSParserNameFromObject(parserValue);
|
|
2111
|
+
if (name2) {
|
|
2112
|
+
this.state.ts = { parserName: name2 };
|
|
2113
|
+
return this.state.ts.parserName;
|
|
2114
|
+
}
|
|
2115
|
+
if (maybeTSESLintParserObject(parserValue) || isTSESLintParserObject(parserValue)) {
|
|
2116
|
+
this.state.ts = { parserName: "$unknown$" };
|
|
2117
|
+
return this.state.ts.parserName;
|
|
2118
|
+
}
|
|
2119
|
+
this.state.ts = false;
|
|
2120
|
+
return null;
|
|
1798
2121
|
}
|
|
1799
2122
|
const parserName = parserValue;
|
|
1800
2123
|
if (TS_PARSER_NAMES.includes(parserName)) {
|
|
1801
|
-
|
|
2124
|
+
this.state.ts = { parserName };
|
|
2125
|
+
return this.state.ts.parserName;
|
|
1802
2126
|
}
|
|
1803
2127
|
if (TS_PARSER_NAMES.some((nm) => parserName.includes(nm))) {
|
|
1804
2128
|
let targetPath = parserName;
|
|
1805
2129
|
while (targetPath) {
|
|
1806
|
-
const pkgPath =
|
|
1807
|
-
if (
|
|
2130
|
+
const pkgPath = import_path5.default.join(targetPath, "package.json");
|
|
2131
|
+
if (import_fs3.default.existsSync(pkgPath)) {
|
|
1808
2132
|
try {
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
2133
|
+
const pkgName = JSON.parse(import_fs3.default.readFileSync(pkgPath, "utf-8"))?.name;
|
|
2134
|
+
if (TS_PARSER_NAMES.includes(pkgName)) {
|
|
2135
|
+
this.state.ts = { parserName: pkgName };
|
|
2136
|
+
return this.state.ts.parserName;
|
|
2137
|
+
}
|
|
2138
|
+
this.state.ts = false;
|
|
2139
|
+
return null;
|
|
1812
2140
|
} catch {
|
|
1813
|
-
|
|
2141
|
+
this.state.ts = false;
|
|
2142
|
+
return null;
|
|
1814
2143
|
}
|
|
1815
2144
|
}
|
|
1816
|
-
const parent =
|
|
2145
|
+
const parent = import_path5.default.dirname(targetPath);
|
|
1817
2146
|
if (targetPath === parent) {
|
|
1818
2147
|
break;
|
|
1819
2148
|
}
|
|
1820
2149
|
targetPath = parent;
|
|
1821
2150
|
}
|
|
1822
2151
|
}
|
|
1823
|
-
|
|
2152
|
+
this.state.ts = false;
|
|
2153
|
+
return null;
|
|
2154
|
+
}
|
|
2155
|
+
isTypeScript() {
|
|
2156
|
+
return Boolean(this.getTSParserName());
|
|
1824
2157
|
}
|
|
1825
2158
|
};
|
|
1826
2159
|
|
|
@@ -1875,12 +2208,12 @@ function addVirtualReference(node, variable, scope, readWrite) {
|
|
|
1875
2208
|
}
|
|
1876
2209
|
function addGlobalVariable(reference, scopeManager) {
|
|
1877
2210
|
const globalScope = scopeManager.globalScope;
|
|
1878
|
-
const
|
|
1879
|
-
let variable = globalScope.set.get(
|
|
2211
|
+
const name2 = reference.identifier.name;
|
|
2212
|
+
let variable = globalScope.set.get(name2);
|
|
1880
2213
|
if (!variable) {
|
|
1881
|
-
variable = new import_scope_manager2.Variable(
|
|
2214
|
+
variable = new import_scope_manager2.Variable(name2, globalScope);
|
|
1882
2215
|
globalScope.variables.push(variable);
|
|
1883
|
-
globalScope.set.set(
|
|
2216
|
+
globalScope.set.set(name2, variable);
|
|
1884
2217
|
}
|
|
1885
2218
|
reference.resolved = variable;
|
|
1886
2219
|
variable.references.push(reference);
|
|
@@ -1888,13 +2221,13 @@ function addGlobalVariable(reference, scopeManager) {
|
|
|
1888
2221
|
}
|
|
1889
2222
|
function removeReferenceFromThrough(reference, baseScope) {
|
|
1890
2223
|
const variable = reference.resolved;
|
|
1891
|
-
const
|
|
2224
|
+
const name2 = reference.identifier.name;
|
|
1892
2225
|
let scope = baseScope;
|
|
1893
2226
|
while (scope) {
|
|
1894
2227
|
for (const ref of [...scope.through]) {
|
|
1895
2228
|
if (reference === ref) {
|
|
1896
2229
|
scope.through.splice(scope.through.indexOf(ref), 1);
|
|
1897
|
-
} else if (ref.identifier.name ===
|
|
2230
|
+
} else if (ref.identifier.name === name2) {
|
|
1898
2231
|
ref.resolved = variable;
|
|
1899
2232
|
if (!variable.references.includes(ref)) {
|
|
1900
2233
|
addReference(variable.references, ref);
|
|
@@ -1931,9 +2264,9 @@ function removeReference(reference, baseScope) {
|
|
|
1931
2264
|
if (varIndex >= 0) {
|
|
1932
2265
|
baseScope.variables.splice(varIndex, 1);
|
|
1933
2266
|
}
|
|
1934
|
-
const
|
|
1935
|
-
if (reference.resolved === baseScope.set.get(
|
|
1936
|
-
baseScope.set.delete(
|
|
2267
|
+
const name2 = reference.identifier.name;
|
|
2268
|
+
if (reference.resolved === baseScope.set.get(name2)) {
|
|
2269
|
+
baseScope.set.delete(name2);
|
|
1937
2270
|
}
|
|
1938
2271
|
} else {
|
|
1939
2272
|
const refIndex = reference.resolved.references.indexOf(reference);
|
|
@@ -1971,9 +2304,9 @@ function removeIdentifierVariable(node, scope) {
|
|
|
1971
2304
|
r.resolved = null;
|
|
1972
2305
|
});
|
|
1973
2306
|
scope.variables.splice(varIndex, 1);
|
|
1974
|
-
const
|
|
1975
|
-
if (variable === scope.set.get(
|
|
1976
|
-
scope.set.delete(
|
|
2307
|
+
const name2 = node.name;
|
|
2308
|
+
if (variable === scope.set.get(name2)) {
|
|
2309
|
+
scope.set.delete(name2);
|
|
1977
2310
|
}
|
|
1978
2311
|
} else {
|
|
1979
2312
|
const idIndex = variable.identifiers.indexOf(node);
|
|
@@ -2187,6 +2520,7 @@ function parseTemplate2(code) {
|
|
|
2187
2520
|
var ast_exports = {};
|
|
2188
2521
|
|
|
2189
2522
|
// src/index.ts
|
|
2523
|
+
var name = "astro-eslint-parser";
|
|
2190
2524
|
function parseForESLint2(code, options) {
|
|
2191
2525
|
return parseForESLint(code, options);
|
|
2192
2526
|
}
|
|
@@ -2196,6 +2530,7 @@ var VisitorKeys = KEYS;
|
|
|
2196
2530
|
AST,
|
|
2197
2531
|
ParseError,
|
|
2198
2532
|
VisitorKeys,
|
|
2533
|
+
name,
|
|
2199
2534
|
parseForESLint,
|
|
2200
2535
|
parseTemplate,
|
|
2201
2536
|
traverseNodes
|
package/lib/index.mjs
CHANGED
|
@@ -30,55 +30,327 @@ var debug = debugFactory("astro-eslint-parser");
|
|
|
30
30
|
|
|
31
31
|
// src/parser/ts-patch.ts
|
|
32
32
|
import { createRequire } from "module";
|
|
33
|
-
import
|
|
33
|
+
import path3 from "path";
|
|
34
|
+
import fs2 from "fs";
|
|
35
|
+
import { satisfies } from "semver";
|
|
36
|
+
|
|
37
|
+
// src/parser/ts-for-v5/get-project-config-files.ts
|
|
34
38
|
import fs from "fs";
|
|
35
|
-
|
|
39
|
+
import path from "path";
|
|
40
|
+
function getProjectConfigFiles(options) {
|
|
41
|
+
const tsconfigRootDir = typeof options.tsconfigRootDir === "string" ? options.tsconfigRootDir : process.cwd();
|
|
42
|
+
if (options.project !== true) {
|
|
43
|
+
return Array.isArray(options.project) ? options.project : [options.project];
|
|
44
|
+
}
|
|
45
|
+
let directory = path.dirname(options.filePath);
|
|
46
|
+
const checkedDirectories = [directory];
|
|
47
|
+
do {
|
|
48
|
+
const tsconfigPath = path.join(directory, "tsconfig.json");
|
|
49
|
+
if (fs.existsSync(tsconfigPath)) {
|
|
50
|
+
return [tsconfigPath];
|
|
51
|
+
}
|
|
52
|
+
directory = path.dirname(directory);
|
|
53
|
+
checkedDirectories.push(directory);
|
|
54
|
+
} while (directory.length > 1 && directory.length >= tsconfigRootDir.length);
|
|
55
|
+
throw new Error(
|
|
56
|
+
`project was set to \`true\` but couldn't find any tsconfig.json relative to '${options.filePath}' within '${tsconfigRootDir}'.`
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// src/parser/ts-for-v5/programs.ts
|
|
61
|
+
import path2 from "path";
|
|
62
|
+
var tsServices = /* @__PURE__ */ new Map();
|
|
63
|
+
function getTSProgram(code, options, ts) {
|
|
64
|
+
const tsconfigPath = options.project;
|
|
65
|
+
let service2 = tsServices.get(tsconfigPath);
|
|
66
|
+
if (!service2) {
|
|
67
|
+
service2 = new TSService(tsconfigPath, ts);
|
|
68
|
+
tsServices.set(tsconfigPath, service2);
|
|
69
|
+
}
|
|
70
|
+
return service2.getProgram(code, options.filePath);
|
|
71
|
+
}
|
|
72
|
+
var TSService = class {
|
|
73
|
+
constructor(tsconfigPath, ts) {
|
|
74
|
+
this.patchedHostSet = /* @__PURE__ */ new WeakSet();
|
|
75
|
+
this.currTarget = {
|
|
76
|
+
code: "",
|
|
77
|
+
filePath: ""
|
|
78
|
+
};
|
|
79
|
+
this.fileWatchCallbacks = /* @__PURE__ */ new Map();
|
|
80
|
+
this.ts = ts;
|
|
81
|
+
this.watch = this.createWatch(tsconfigPath);
|
|
82
|
+
}
|
|
83
|
+
getProgram(code, filePath) {
|
|
84
|
+
const normalized = normalizeFileName(this.ts, filePath);
|
|
85
|
+
const lastTarget = this.currTarget;
|
|
86
|
+
this.currTarget = {
|
|
87
|
+
code,
|
|
88
|
+
filePath: normalized
|
|
89
|
+
};
|
|
90
|
+
for (const { filePath: targetPath } of [this.currTarget, lastTarget]) {
|
|
91
|
+
if (!targetPath)
|
|
92
|
+
continue;
|
|
93
|
+
this.fileWatchCallbacks.get(targetPath)?.update();
|
|
94
|
+
}
|
|
95
|
+
const program = this.watch.getProgram().getProgram();
|
|
96
|
+
program.getTypeChecker();
|
|
97
|
+
return program;
|
|
98
|
+
}
|
|
99
|
+
createWatch(tsconfigPath) {
|
|
100
|
+
const { ts } = this;
|
|
101
|
+
const watchCompilerHost = ts.createWatchCompilerHost(
|
|
102
|
+
tsconfigPath,
|
|
103
|
+
{
|
|
104
|
+
noEmit: true,
|
|
105
|
+
jsx: ts.JsxEmit.Preserve,
|
|
106
|
+
// This option is required if `includes` only includes `*.astro` files.
|
|
107
|
+
// However, the option is not in the documentation.
|
|
108
|
+
// https://github.com/microsoft/TypeScript/issues/28447
|
|
109
|
+
allowNonTsExtensions: true
|
|
110
|
+
},
|
|
111
|
+
ts.sys,
|
|
112
|
+
(rootNames, options, argHost, oldProgram, configFileParsingDiagnostics, projectReferences) => {
|
|
113
|
+
const host = argHost;
|
|
114
|
+
if (!this.patchedHostSet.has(host)) {
|
|
115
|
+
this.patchedHostSet.add(host);
|
|
116
|
+
const getTargetSourceFile = (fileName, languageVersionOrOptions) => {
|
|
117
|
+
var _a;
|
|
118
|
+
if (this.currTarget.filePath === normalizeFileName(ts, fileName)) {
|
|
119
|
+
return (_a = this.currTarget).sourceFile ?? (_a.sourceFile = ts.createSourceFile(
|
|
120
|
+
this.currTarget.filePath,
|
|
121
|
+
this.currTarget.code,
|
|
122
|
+
languageVersionOrOptions,
|
|
123
|
+
true,
|
|
124
|
+
ts.ScriptKind.TSX
|
|
125
|
+
));
|
|
126
|
+
}
|
|
127
|
+
return null;
|
|
128
|
+
};
|
|
129
|
+
const original2 = {
|
|
130
|
+
getSourceFile: host.getSourceFile,
|
|
131
|
+
getSourceFileByPath: host.getSourceFileByPath
|
|
132
|
+
};
|
|
133
|
+
host.getSourceFile = (fileName, languageVersionOrOptions, ...args) => {
|
|
134
|
+
return getTargetSourceFile(fileName, languageVersionOrOptions) ?? original2.getSourceFile.call(
|
|
135
|
+
host,
|
|
136
|
+
fileName,
|
|
137
|
+
languageVersionOrOptions,
|
|
138
|
+
...args
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
host.getSourceFileByPath = (fileName, path6, languageVersionOrOptions, ...args) => {
|
|
142
|
+
return getTargetSourceFile(fileName, languageVersionOrOptions) ?? original2.getSourceFileByPath.call(
|
|
143
|
+
host,
|
|
144
|
+
fileName,
|
|
145
|
+
path6,
|
|
146
|
+
languageVersionOrOptions,
|
|
147
|
+
...args
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
return ts.createAbstractBuilder(
|
|
152
|
+
rootNames,
|
|
153
|
+
options,
|
|
154
|
+
host,
|
|
155
|
+
oldProgram,
|
|
156
|
+
configFileParsingDiagnostics,
|
|
157
|
+
projectReferences
|
|
158
|
+
);
|
|
159
|
+
},
|
|
160
|
+
(diagnostic) => {
|
|
161
|
+
throw new Error(formatDiagnostics(ts, [diagnostic]));
|
|
162
|
+
},
|
|
163
|
+
() => {
|
|
164
|
+
},
|
|
165
|
+
void 0,
|
|
166
|
+
[
|
|
167
|
+
{
|
|
168
|
+
extension: ".astro",
|
|
169
|
+
isMixedContent: true,
|
|
170
|
+
scriptKind: ts.ScriptKind.Deferred
|
|
171
|
+
}
|
|
172
|
+
]
|
|
173
|
+
);
|
|
174
|
+
const original = {
|
|
175
|
+
readFile: watchCompilerHost.readFile
|
|
176
|
+
};
|
|
177
|
+
watchCompilerHost.readFile = (fileName, ...args) => {
|
|
178
|
+
const normalized = normalizeFileName(ts, fileName);
|
|
179
|
+
if (this.currTarget.filePath === normalized) {
|
|
180
|
+
return this.currTarget.code;
|
|
181
|
+
}
|
|
182
|
+
return original.readFile.call(watchCompilerHost, fileName, ...args);
|
|
183
|
+
};
|
|
184
|
+
watchCompilerHost.watchFile = (fileName, callback) => {
|
|
185
|
+
const normalized = normalizeFileName(ts, fileName);
|
|
186
|
+
this.fileWatchCallbacks.set(normalized, {
|
|
187
|
+
update: () => callback(fileName, ts.FileWatcherEventKind.Changed)
|
|
188
|
+
});
|
|
189
|
+
return {
|
|
190
|
+
close: () => {
|
|
191
|
+
this.fileWatchCallbacks.delete(normalized);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
watchCompilerHost.watchDirectory = () => {
|
|
196
|
+
return {
|
|
197
|
+
close: () => {
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
watchCompilerHost.afterProgramCreate = (program) => {
|
|
202
|
+
const originalDiagnostics = program.getConfigFileParsingDiagnostics();
|
|
203
|
+
const configFileDiagnostics = originalDiagnostics.filter(
|
|
204
|
+
(diag) => diag.category === ts.DiagnosticCategory.Error && diag.code !== 18003
|
|
205
|
+
);
|
|
206
|
+
if (configFileDiagnostics.length > 0) {
|
|
207
|
+
throw new Error(formatDiagnostics(ts, configFileDiagnostics));
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
const watch = ts.createWatchProgram(watchCompilerHost);
|
|
211
|
+
return watch;
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
function formatDiagnostics(ts, diagnostics) {
|
|
215
|
+
return ts.formatDiagnostics(diagnostics, {
|
|
216
|
+
getCanonicalFileName: (f) => f,
|
|
217
|
+
getCurrentDirectory: () => process.cwd(),
|
|
218
|
+
getNewLine: () => "\n"
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
function normalizeFileName(ts, fileName) {
|
|
222
|
+
let normalized = path2.normalize(fileName);
|
|
223
|
+
if (normalized.endsWith(path2.sep)) {
|
|
224
|
+
normalized = normalized.slice(0, -1);
|
|
225
|
+
}
|
|
226
|
+
if (ts.sys.useCaseSensitiveFileNames) {
|
|
227
|
+
return toAbsolutePath(normalized, null);
|
|
228
|
+
}
|
|
229
|
+
return toAbsolutePath(normalized.toLowerCase(), null);
|
|
230
|
+
}
|
|
231
|
+
function toAbsolutePath(filePath, baseDir) {
|
|
232
|
+
return path2.isAbsolute(filePath) ? filePath : path2.join(baseDir || process.cwd(), filePath);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// src/parser/ts-for-v5/parse-tsx-for-typescript.ts
|
|
236
|
+
var DEFAULT_EXTRA_FILE_EXTENSIONS = [".vue", ".svelte", ".astro"];
|
|
237
|
+
function parseTsxForTypeScript(code, options, tsEslintParser, ts) {
|
|
238
|
+
const programs = [];
|
|
239
|
+
for (const option of iterateOptions(options)) {
|
|
240
|
+
programs.push(getTSProgram(code, option, ts));
|
|
241
|
+
}
|
|
242
|
+
const parserOptions = {
|
|
243
|
+
...options,
|
|
244
|
+
programs
|
|
245
|
+
};
|
|
246
|
+
return tsEslintParser.parseForESLint(code, parserOptions);
|
|
247
|
+
}
|
|
248
|
+
function* iterateOptions(options) {
|
|
249
|
+
if (!options) {
|
|
250
|
+
throw new Error("`parserOptions` is required.");
|
|
251
|
+
}
|
|
252
|
+
if (!options.filePath) {
|
|
253
|
+
throw new Error("`filePath` is required.");
|
|
254
|
+
}
|
|
255
|
+
if (!options.project) {
|
|
256
|
+
throw new Error(
|
|
257
|
+
"Specify `parserOptions.project`. Otherwise there is no point in using this parser."
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
for (const project of getProjectConfigFiles(options)) {
|
|
261
|
+
yield {
|
|
262
|
+
project,
|
|
263
|
+
filePath: options.filePath,
|
|
264
|
+
extraFileExtensions: options.extraFileExtensions || DEFAULT_EXTRA_FILE_EXTENSIONS
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// src/parser/ts-patch.ts
|
|
270
|
+
function tsPatch(scriptParserOptions, tsParserName) {
|
|
271
|
+
if (tsParserName === "typescript-eslint-parser-for-extra-files") {
|
|
272
|
+
return {
|
|
273
|
+
terminate() {
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
}
|
|
36
277
|
let targetExt = ".astro";
|
|
37
278
|
if (scriptParserOptions.filePath) {
|
|
38
|
-
const ext =
|
|
279
|
+
const ext = path3.extname(scriptParserOptions.filePath);
|
|
39
280
|
if (ext) {
|
|
40
281
|
targetExt = ext;
|
|
41
282
|
}
|
|
42
283
|
}
|
|
43
284
|
try {
|
|
44
285
|
const cwd = process.cwd();
|
|
45
|
-
const relativeTo =
|
|
286
|
+
const relativeTo = path3.join(cwd, "__placeholder__.js");
|
|
46
287
|
const ts = createRequire(relativeTo)("typescript");
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return ts.ScriptKind.TSX;
|
|
58
|
-
}
|
|
59
|
-
return getScriptKindFromFileName.call(this, fileName, ...args);
|
|
60
|
-
};
|
|
61
|
-
return {
|
|
62
|
-
terminate() {
|
|
63
|
-
ts.ensureScriptKind = ensureScriptKind;
|
|
64
|
-
ts.getScriptKindFromFileName = getScriptKindFromFileName;
|
|
65
|
-
}
|
|
66
|
-
};
|
|
288
|
+
if (satisfies(ts.version, ">=5")) {
|
|
289
|
+
const result = tsPatchForV5(ts, scriptParserOptions);
|
|
290
|
+
if (result) {
|
|
291
|
+
return result;
|
|
292
|
+
}
|
|
293
|
+
} else {
|
|
294
|
+
const result = tsPatchForV4(ts, targetExt);
|
|
295
|
+
if (result) {
|
|
296
|
+
return result;
|
|
297
|
+
}
|
|
67
298
|
}
|
|
68
299
|
} catch {
|
|
69
300
|
}
|
|
70
301
|
const tsxFilePath = `${scriptParserOptions.filePath}.tsx`;
|
|
71
302
|
scriptParserOptions.filePath = tsxFilePath;
|
|
72
|
-
if (!
|
|
73
|
-
|
|
303
|
+
if (!fs2.existsSync(tsxFilePath)) {
|
|
304
|
+
fs2.writeFileSync(tsxFilePath, "/* temp for astro-eslint-parser */");
|
|
74
305
|
return {
|
|
75
306
|
terminate() {
|
|
76
|
-
|
|
307
|
+
fs2.unlinkSync(tsxFilePath);
|
|
77
308
|
}
|
|
78
309
|
};
|
|
79
310
|
}
|
|
80
311
|
return null;
|
|
81
312
|
}
|
|
313
|
+
function tsPatchForV5(ts, scriptParserOptions) {
|
|
314
|
+
return {
|
|
315
|
+
terminate() {
|
|
316
|
+
},
|
|
317
|
+
parse(code, parser) {
|
|
318
|
+
return parseTsxForTypeScript(
|
|
319
|
+
code,
|
|
320
|
+
scriptParserOptions,
|
|
321
|
+
parser,
|
|
322
|
+
ts
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
function tsPatchForV4(ts, targetExt) {
|
|
328
|
+
const { ensureScriptKind, getScriptKindFromFileName } = ts;
|
|
329
|
+
if (typeof ensureScriptKind !== "function" || typeof getScriptKindFromFileName !== "function") {
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
ts.ensureScriptKind = function(fileName, ...args) {
|
|
333
|
+
if (fileName.endsWith(targetExt)) {
|
|
334
|
+
return ts.ScriptKind.TSX;
|
|
335
|
+
}
|
|
336
|
+
return ensureScriptKind.call(this, fileName, ...args);
|
|
337
|
+
};
|
|
338
|
+
ts.getScriptKindFromFileName = function(fileName, ...args) {
|
|
339
|
+
if (fileName.endsWith(targetExt)) {
|
|
340
|
+
return ts.ScriptKind.TSX;
|
|
341
|
+
}
|
|
342
|
+
return getScriptKindFromFileName.call(this, fileName, ...args);
|
|
343
|
+
};
|
|
344
|
+
if (ts.ensureScriptKind === ensureScriptKind || ts.getScriptKindFromFileName === getScriptKindFromFileName) {
|
|
345
|
+
return null;
|
|
346
|
+
}
|
|
347
|
+
return {
|
|
348
|
+
terminate() {
|
|
349
|
+
ts.ensureScriptKind = ensureScriptKind;
|
|
350
|
+
ts.getScriptKindFromFileName = getScriptKindFromFileName;
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
}
|
|
82
354
|
|
|
83
355
|
// src/context/resolve-parser/parser-object.ts
|
|
84
356
|
function isParserObject(value) {
|
|
@@ -93,9 +365,23 @@ function isBasicParserObject(value) {
|
|
|
93
365
|
function maybeTSESLintParserObject(value) {
|
|
94
366
|
return isEnhancedParserObject(value) && isBasicParserObject(value) && typeof value.createProgram === "function" && typeof value.clearCaches === "function" && typeof value.version === "string";
|
|
95
367
|
}
|
|
368
|
+
function getTSParserNameFromObject(value) {
|
|
369
|
+
if (!isEnhancedParserObject(value)) {
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
372
|
+
if (value.name === "typescript-eslint-parser-for-extra-files")
|
|
373
|
+
return "typescript-eslint-parser-for-extra-files";
|
|
374
|
+
if (value.meta?.name === "typescript-eslint/parser")
|
|
375
|
+
return "@typescript-eslint/parser";
|
|
376
|
+
return null;
|
|
377
|
+
}
|
|
96
378
|
function isTSESLintParserObject(value) {
|
|
97
379
|
if (!isEnhancedParserObject(value))
|
|
98
380
|
return false;
|
|
381
|
+
if (value.name === "typescript-eslint-parser-for-extra-files")
|
|
382
|
+
return true;
|
|
383
|
+
if (value.meta?.name === "typescript-eslint/parser")
|
|
384
|
+
return true;
|
|
99
385
|
try {
|
|
100
386
|
const result = value.parseForESLint("", {});
|
|
101
387
|
const services = result.services;
|
|
@@ -130,9 +416,9 @@ function parseScriptInternal(code, _ctx, parserOptionsCtx) {
|
|
|
130
416
|
try {
|
|
131
417
|
const parserOptions = parserOptionsCtx.parserOptions;
|
|
132
418
|
if (parserOptionsCtx.isTypeScript() && parserOptions.filePath && parserOptions.project) {
|
|
133
|
-
patchResult = tsPatch(parserOptions);
|
|
419
|
+
patchResult = tsPatch(parserOptions, parserOptionsCtx.getTSParserName());
|
|
134
420
|
}
|
|
135
|
-
const result = isEnhancedParserObject(parser) ? parser.parseForESLint(code, parserOptions) : parser.parse(code, parserOptions);
|
|
421
|
+
const result = isEnhancedParserObject(parser) ? patchResult?.parse ? patchResult.parse(code, parser) : parser.parseForESLint(code, parserOptions) : parser.parse(code, parserOptions);
|
|
136
422
|
if ("ast" in result && result.ast != null) {
|
|
137
423
|
return result;
|
|
138
424
|
}
|
|
@@ -166,6 +452,9 @@ import { AST_TOKEN_TYPES, AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
|
166
452
|
|
|
167
453
|
// src/errors.ts
|
|
168
454
|
var ParseError = class extends SyntaxError {
|
|
455
|
+
/**
|
|
456
|
+
* Initialize this ParseError instance.
|
|
457
|
+
*/
|
|
169
458
|
constructor(message, offset, ctx) {
|
|
170
459
|
super(message);
|
|
171
460
|
if (typeof offset === "number") {
|
|
@@ -588,6 +877,9 @@ var RestoreContext = class {
|
|
|
588
877
|
}
|
|
589
878
|
this.tokens.push(this.ctx.buildToken(type, range));
|
|
590
879
|
}
|
|
880
|
+
/**
|
|
881
|
+
* Restore AST nodes
|
|
882
|
+
*/
|
|
591
883
|
restore(result) {
|
|
592
884
|
const nodeMap = remapLocationsAndGetNodeMap(result, this.tokens, {
|
|
593
885
|
remapLocation: (n) => this.remapLocation(n),
|
|
@@ -779,6 +1071,7 @@ function processTemplate(ctx, resultTemplate) {
|
|
|
779
1071
|
walkElements(
|
|
780
1072
|
resultTemplate.ast,
|
|
781
1073
|
ctx.code,
|
|
1074
|
+
// eslint-disable-next-line complexity -- X(
|
|
782
1075
|
(node, [parent]) => {
|
|
783
1076
|
if (node.type === "frontmatter") {
|
|
784
1077
|
const start = node.position.start.offset;
|
|
@@ -1232,6 +1525,9 @@ var Context = class {
|
|
|
1232
1525
|
getIndexFromLoc(loc) {
|
|
1233
1526
|
return this.locs.getIndexFromLoc(loc);
|
|
1234
1527
|
}
|
|
1528
|
+
/**
|
|
1529
|
+
* Get the location information of the given indexes.
|
|
1530
|
+
*/
|
|
1235
1531
|
getLocations(start, end) {
|
|
1236
1532
|
return {
|
|
1237
1533
|
range: [start, end],
|
|
@@ -1241,6 +1537,9 @@ var Context = class {
|
|
|
1241
1537
|
}
|
|
1242
1538
|
};
|
|
1243
1539
|
}
|
|
1540
|
+
/**
|
|
1541
|
+
* Build token
|
|
1542
|
+
*/
|
|
1244
1543
|
buildToken(type, range) {
|
|
1245
1544
|
return {
|
|
1246
1545
|
type,
|
|
@@ -1248,6 +1547,9 @@ var Context = class {
|
|
|
1248
1547
|
...this.getLocations(...range)
|
|
1249
1548
|
};
|
|
1250
1549
|
}
|
|
1550
|
+
/**
|
|
1551
|
+
* get text
|
|
1552
|
+
*/
|
|
1251
1553
|
getText(range) {
|
|
1252
1554
|
return this.code.slice(range[0], range[1]);
|
|
1253
1555
|
}
|
|
@@ -1411,6 +1713,7 @@ function fixLocations(node, ctx) {
|
|
|
1411
1713
|
walk(
|
|
1412
1714
|
node,
|
|
1413
1715
|
ctx.code,
|
|
1716
|
+
// eslint-disable-next-line complexity -- X(
|
|
1414
1717
|
(node2, [parent]) => {
|
|
1415
1718
|
if (node2.type === "frontmatter") {
|
|
1416
1719
|
start = node2.position.start.offset = tokenIndex(ctx, "---", start);
|
|
@@ -1675,15 +1978,19 @@ function remap(result, normalized, originalCode, ctxForAstro) {
|
|
|
1675
1978
|
}
|
|
1676
1979
|
|
|
1677
1980
|
// src/context/parser-options.ts
|
|
1678
|
-
import
|
|
1679
|
-
import
|
|
1981
|
+
import path5 from "path";
|
|
1982
|
+
import fs3 from "fs";
|
|
1680
1983
|
|
|
1681
1984
|
// src/context/resolve-parser/espree.ts
|
|
1682
1985
|
import { createRequire as createRequire2 } from "module";
|
|
1683
|
-
import
|
|
1986
|
+
import path4 from "path";
|
|
1684
1987
|
var espreeCache = null;
|
|
1685
1988
|
function isLinterPath(p) {
|
|
1686
|
-
return
|
|
1989
|
+
return (
|
|
1990
|
+
// ESLint 6 and above
|
|
1991
|
+
p.includes(`eslint${path4.sep}lib${path4.sep}linter${path4.sep}linter.js`) || // ESLint 5
|
|
1992
|
+
p.includes(`eslint${path4.sep}lib${path4.sep}linter.js`)
|
|
1993
|
+
);
|
|
1687
1994
|
}
|
|
1688
1995
|
function getEspree() {
|
|
1689
1996
|
if (!espreeCache) {
|
|
@@ -1744,6 +2051,7 @@ var ParserOptionsContext = class {
|
|
|
1744
2051
|
tokens: true,
|
|
1745
2052
|
comment: true,
|
|
1746
2053
|
eslintVisitorKeys: true,
|
|
2054
|
+
// eslintScopeManager: true,
|
|
1747
2055
|
...options || {}
|
|
1748
2056
|
};
|
|
1749
2057
|
parserOptions.ecmaFeatures = {
|
|
@@ -1759,39 +2067,59 @@ var ParserOptionsContext = class {
|
|
|
1759
2067
|
getParser() {
|
|
1760
2068
|
return getParser({}, this.parserOptions.parser);
|
|
1761
2069
|
}
|
|
1762
|
-
|
|
1763
|
-
if (this.state.
|
|
1764
|
-
return this.state.
|
|
2070
|
+
getTSParserName() {
|
|
2071
|
+
if (this.state.ts != null) {
|
|
2072
|
+
return this.state.ts === false ? null : this.state.ts.parserName;
|
|
1765
2073
|
}
|
|
1766
2074
|
const parserValue = getParserForLang({}, this.parserOptions?.parser);
|
|
1767
2075
|
if (typeof parserValue !== "string") {
|
|
1768
|
-
|
|
2076
|
+
const name2 = getTSParserNameFromObject(parserValue);
|
|
2077
|
+
if (name2) {
|
|
2078
|
+
this.state.ts = { parserName: name2 };
|
|
2079
|
+
return this.state.ts.parserName;
|
|
2080
|
+
}
|
|
2081
|
+
if (maybeTSESLintParserObject(parserValue) || isTSESLintParserObject(parserValue)) {
|
|
2082
|
+
this.state.ts = { parserName: "$unknown$" };
|
|
2083
|
+
return this.state.ts.parserName;
|
|
2084
|
+
}
|
|
2085
|
+
this.state.ts = false;
|
|
2086
|
+
return null;
|
|
1769
2087
|
}
|
|
1770
2088
|
const parserName = parserValue;
|
|
1771
2089
|
if (TS_PARSER_NAMES.includes(parserName)) {
|
|
1772
|
-
|
|
2090
|
+
this.state.ts = { parserName };
|
|
2091
|
+
return this.state.ts.parserName;
|
|
1773
2092
|
}
|
|
1774
2093
|
if (TS_PARSER_NAMES.some((nm) => parserName.includes(nm))) {
|
|
1775
2094
|
let targetPath = parserName;
|
|
1776
2095
|
while (targetPath) {
|
|
1777
|
-
const pkgPath =
|
|
1778
|
-
if (
|
|
2096
|
+
const pkgPath = path5.join(targetPath, "package.json");
|
|
2097
|
+
if (fs3.existsSync(pkgPath)) {
|
|
1779
2098
|
try {
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
2099
|
+
const pkgName = JSON.parse(fs3.readFileSync(pkgPath, "utf-8"))?.name;
|
|
2100
|
+
if (TS_PARSER_NAMES.includes(pkgName)) {
|
|
2101
|
+
this.state.ts = { parserName: pkgName };
|
|
2102
|
+
return this.state.ts.parserName;
|
|
2103
|
+
}
|
|
2104
|
+
this.state.ts = false;
|
|
2105
|
+
return null;
|
|
1783
2106
|
} catch {
|
|
1784
|
-
|
|
2107
|
+
this.state.ts = false;
|
|
2108
|
+
return null;
|
|
1785
2109
|
}
|
|
1786
2110
|
}
|
|
1787
|
-
const parent =
|
|
2111
|
+
const parent = path5.dirname(targetPath);
|
|
1788
2112
|
if (targetPath === parent) {
|
|
1789
2113
|
break;
|
|
1790
2114
|
}
|
|
1791
2115
|
targetPath = parent;
|
|
1792
2116
|
}
|
|
1793
2117
|
}
|
|
1794
|
-
|
|
2118
|
+
this.state.ts = false;
|
|
2119
|
+
return null;
|
|
2120
|
+
}
|
|
2121
|
+
isTypeScript() {
|
|
2122
|
+
return Boolean(this.getTSParserName());
|
|
1795
2123
|
}
|
|
1796
2124
|
};
|
|
1797
2125
|
|
|
@@ -1849,12 +2177,12 @@ function addVirtualReference(node, variable, scope, readWrite) {
|
|
|
1849
2177
|
}
|
|
1850
2178
|
function addGlobalVariable(reference, scopeManager) {
|
|
1851
2179
|
const globalScope = scopeManager.globalScope;
|
|
1852
|
-
const
|
|
1853
|
-
let variable = globalScope.set.get(
|
|
2180
|
+
const name2 = reference.identifier.name;
|
|
2181
|
+
let variable = globalScope.set.get(name2);
|
|
1854
2182
|
if (!variable) {
|
|
1855
|
-
variable = new VariableClass(
|
|
2183
|
+
variable = new VariableClass(name2, globalScope);
|
|
1856
2184
|
globalScope.variables.push(variable);
|
|
1857
|
-
globalScope.set.set(
|
|
2185
|
+
globalScope.set.set(name2, variable);
|
|
1858
2186
|
}
|
|
1859
2187
|
reference.resolved = variable;
|
|
1860
2188
|
variable.references.push(reference);
|
|
@@ -1862,13 +2190,13 @@ function addGlobalVariable(reference, scopeManager) {
|
|
|
1862
2190
|
}
|
|
1863
2191
|
function removeReferenceFromThrough(reference, baseScope) {
|
|
1864
2192
|
const variable = reference.resolved;
|
|
1865
|
-
const
|
|
2193
|
+
const name2 = reference.identifier.name;
|
|
1866
2194
|
let scope = baseScope;
|
|
1867
2195
|
while (scope) {
|
|
1868
2196
|
for (const ref of [...scope.through]) {
|
|
1869
2197
|
if (reference === ref) {
|
|
1870
2198
|
scope.through.splice(scope.through.indexOf(ref), 1);
|
|
1871
|
-
} else if (ref.identifier.name ===
|
|
2199
|
+
} else if (ref.identifier.name === name2) {
|
|
1872
2200
|
ref.resolved = variable;
|
|
1873
2201
|
if (!variable.references.includes(ref)) {
|
|
1874
2202
|
addReference(variable.references, ref);
|
|
@@ -1905,9 +2233,9 @@ function removeReference(reference, baseScope) {
|
|
|
1905
2233
|
if (varIndex >= 0) {
|
|
1906
2234
|
baseScope.variables.splice(varIndex, 1);
|
|
1907
2235
|
}
|
|
1908
|
-
const
|
|
1909
|
-
if (reference.resolved === baseScope.set.get(
|
|
1910
|
-
baseScope.set.delete(
|
|
2236
|
+
const name2 = reference.identifier.name;
|
|
2237
|
+
if (reference.resolved === baseScope.set.get(name2)) {
|
|
2238
|
+
baseScope.set.delete(name2);
|
|
1911
2239
|
}
|
|
1912
2240
|
} else {
|
|
1913
2241
|
const refIndex = reference.resolved.references.indexOf(reference);
|
|
@@ -1945,9 +2273,9 @@ function removeIdentifierVariable(node, scope) {
|
|
|
1945
2273
|
r.resolved = null;
|
|
1946
2274
|
});
|
|
1947
2275
|
scope.variables.splice(varIndex, 1);
|
|
1948
|
-
const
|
|
1949
|
-
if (variable === scope.set.get(
|
|
1950
|
-
scope.set.delete(
|
|
2276
|
+
const name2 = node.name;
|
|
2277
|
+
if (variable === scope.set.get(name2)) {
|
|
2278
|
+
scope.set.delete(name2);
|
|
1951
2279
|
}
|
|
1952
2280
|
} else {
|
|
1953
2281
|
const idIndex = variable.identifiers.indexOf(node);
|
|
@@ -2161,6 +2489,7 @@ function parseTemplate2(code) {
|
|
|
2161
2489
|
var ast_exports = {};
|
|
2162
2490
|
|
|
2163
2491
|
// src/index.ts
|
|
2492
|
+
var name = "astro-eslint-parser";
|
|
2164
2493
|
function parseForESLint2(code, options) {
|
|
2165
2494
|
return parseForESLint(code, options);
|
|
2166
2495
|
}
|
|
@@ -2169,6 +2498,7 @@ export {
|
|
|
2169
2498
|
ast_exports as AST,
|
|
2170
2499
|
ParseError,
|
|
2171
2500
|
VisitorKeys,
|
|
2501
|
+
name,
|
|
2172
2502
|
parseForESLint2 as parseForESLint,
|
|
2173
2503
|
parseTemplate2 as parseTemplate,
|
|
2174
2504
|
traverseNodes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro-eslint-parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Astro component parser for ESLint",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.mjs",
|
|
@@ -53,7 +53,8 @@
|
|
|
53
53
|
"astrojs-compiler-sync": "^0.3.0",
|
|
54
54
|
"debug": "^4.3.4",
|
|
55
55
|
"eslint-visitor-keys": "^3.0.0",
|
|
56
|
-
"espree": "^9.0.0"
|
|
56
|
+
"espree": "^9.0.0",
|
|
57
|
+
"semver": "^7.3.8"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
60
|
"@changesets/changelog-github": "^0.4.6",
|
|
@@ -68,20 +69,19 @@
|
|
|
68
69
|
"@types/mocha": "^10.0.0",
|
|
69
70
|
"@types/node": "^18.0.0",
|
|
70
71
|
"@types/semver": "^7.3.9",
|
|
71
|
-
"@typescript-eslint/eslint-plugin": "~5.
|
|
72
|
-
"@typescript-eslint/parser": "~5.
|
|
73
|
-
"astro": "^
|
|
72
|
+
"@typescript-eslint/eslint-plugin": "~5.55.0",
|
|
73
|
+
"@typescript-eslint/parser": "~5.55.0",
|
|
74
|
+
"astro": "^2.0.0",
|
|
74
75
|
"astro-eslint-parser": ">=0.1.0",
|
|
75
76
|
"benchmark": "^2.1.4",
|
|
76
77
|
"chai": "^4.3.4",
|
|
77
|
-
"code-red": "^0.2.3",
|
|
78
78
|
"env-cmd": "^10.1.0",
|
|
79
|
-
"esbuild": "^0.
|
|
79
|
+
"esbuild": "^0.17.0",
|
|
80
80
|
"esbuild-register": "^3.3.3",
|
|
81
81
|
"eslint": "^8.15.0",
|
|
82
82
|
"eslint-config-prettier": "^8.3.0",
|
|
83
83
|
"eslint-formatter-codeframe": "^7.32.1",
|
|
84
|
-
"eslint-plugin-astro": "^0.
|
|
84
|
+
"eslint-plugin-astro": "^0.25.0",
|
|
85
85
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
86
86
|
"eslint-plugin-json-schema-validator": "^4.0.0",
|
|
87
87
|
"eslint-plugin-jsonc": "^2.0.0",
|
|
@@ -91,22 +91,22 @@
|
|
|
91
91
|
"eslint-plugin-prettier": "^4.0.0",
|
|
92
92
|
"eslint-plugin-react": "^7.29.4",
|
|
93
93
|
"eslint-plugin-regexp": "^1.5.0",
|
|
94
|
-
"eslint-plugin-simple-import-sort": "^
|
|
94
|
+
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
95
95
|
"eslint-plugin-svelte": "^2.0.0",
|
|
96
96
|
"estree-walker": "^3.0.0",
|
|
97
97
|
"locate-character": "^2.0.5",
|
|
98
|
-
"magic-string": "^0.
|
|
98
|
+
"magic-string": "^0.30.0",
|
|
99
99
|
"mocha": "^10.0.0",
|
|
100
100
|
"mocha-chai-jest-snapshot": "^1.1.3",
|
|
101
101
|
"nyc": "^15.1.0",
|
|
102
102
|
"prettier": "^2.0.5",
|
|
103
|
-
"prettier-plugin-astro": "^0.
|
|
103
|
+
"prettier-plugin-astro": "^0.8.0",
|
|
104
104
|
"prettier-plugin-svelte": "^2.7.0",
|
|
105
|
-
"semver": "^7.3.5",
|
|
106
105
|
"string-replace-loader": "^3.0.3",
|
|
107
106
|
"svelte": "^3.48.0",
|
|
108
107
|
"tsup": "^6.2.3",
|
|
109
|
-
"typescript": "~
|
|
108
|
+
"typescript": "~5.0.0",
|
|
109
|
+
"typescript-eslint-parser-for-extra-files": "^0.2.0"
|
|
110
110
|
},
|
|
111
111
|
"publishConfig": {
|
|
112
112
|
"access": "public"
|