astro-eslint-parser 0.16.3 → 0.17.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 +115 -41
- package/lib/index.mjs +102 -28
- package/package.json +13 -9
package/lib/index.d.mts
CHANGED
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -64,36 +64,36 @@ var import_debug = __toESM(require("debug"));
|
|
|
64
64
|
var debug = (0, import_debug.default)("astro-eslint-parser");
|
|
65
65
|
|
|
66
66
|
// src/parser/ts-patch.ts
|
|
67
|
-
var
|
|
68
|
-
var
|
|
69
|
-
var
|
|
67
|
+
var import_module2 = require("module");
|
|
68
|
+
var import_path2 = __toESM(require("path"));
|
|
69
|
+
var import_fs = __toESM(require("fs"));
|
|
70
70
|
var import_semver = require("semver");
|
|
71
71
|
|
|
72
72
|
// src/parser/ts-for-v5/get-project-config-files.ts
|
|
73
|
-
var
|
|
74
|
-
var
|
|
75
|
-
function getProjectConfigFiles(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return Array.isArray(options.project) ? options.project : [options.project];
|
|
73
|
+
var fs = __toESM(require("fs"));
|
|
74
|
+
var path = __toESM(require("path"));
|
|
75
|
+
function getProjectConfigFiles(parseSettings, project) {
|
|
76
|
+
if (project !== true) {
|
|
77
|
+
return project === void 0 || Array.isArray(project) ? project : [project];
|
|
79
78
|
}
|
|
80
|
-
let directory =
|
|
79
|
+
let directory = path.dirname(parseSettings.filePath);
|
|
81
80
|
const checkedDirectories = [directory];
|
|
82
81
|
do {
|
|
83
|
-
const tsconfigPath =
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
const tsconfigPath = path.join(directory, "tsconfig.json");
|
|
83
|
+
const cached = fs.existsSync(tsconfigPath) && tsconfigPath;
|
|
84
|
+
if (cached) {
|
|
85
|
+
return [cached];
|
|
86
86
|
}
|
|
87
|
-
directory =
|
|
87
|
+
directory = path.dirname(directory);
|
|
88
88
|
checkedDirectories.push(directory);
|
|
89
|
-
} while (directory.length > 1 && directory.length >= tsconfigRootDir.length);
|
|
89
|
+
} while (directory.length > 1 && directory.length >= parseSettings.tsconfigRootDir.length);
|
|
90
90
|
throw new Error(
|
|
91
|
-
`project was set to \`true\` but couldn't find any tsconfig.json relative to '${
|
|
91
|
+
`project was set to \`true\` but couldn't find any tsconfig.json relative to '${parseSettings.filePath}' within '${parseSettings.tsconfigRootDir}'.`
|
|
92
92
|
);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
// src/parser/ts-for-v5/programs.ts
|
|
96
|
-
var
|
|
96
|
+
var import_path = __toESM(require("path"));
|
|
97
97
|
var tsServices = /* @__PURE__ */ new Map();
|
|
98
98
|
function getTSProgram(code, options, ts) {
|
|
99
99
|
const tsconfigPath = options.project;
|
|
@@ -171,11 +171,11 @@ var TSService = class {
|
|
|
171
171
|
);
|
|
172
172
|
return getTargetSourceFile(fileName, languageVersionOrOptions) ?? originalSourceFile;
|
|
173
173
|
};
|
|
174
|
-
host.getSourceFileByPath = (fileName,
|
|
174
|
+
host.getSourceFileByPath = (fileName, path7, languageVersionOrOptions, ...args2) => {
|
|
175
175
|
const originalSourceFile = original2.getSourceFileByPath.call(
|
|
176
176
|
host,
|
|
177
177
|
fileName,
|
|
178
|
-
|
|
178
|
+
path7,
|
|
179
179
|
languageVersionOrOptions,
|
|
180
180
|
...args2
|
|
181
181
|
);
|
|
@@ -265,8 +265,8 @@ function formatDiagnostics(ts, diagnostics) {
|
|
|
265
265
|
});
|
|
266
266
|
}
|
|
267
267
|
function normalizeFileName(ts, fileName) {
|
|
268
|
-
let normalized =
|
|
269
|
-
if (normalized.endsWith(
|
|
268
|
+
let normalized = import_path.default.normalize(fileName);
|
|
269
|
+
if (normalized.endsWith(import_path.default.sep)) {
|
|
270
270
|
normalized = normalized.slice(0, -1);
|
|
271
271
|
}
|
|
272
272
|
if (ts.sys.useCaseSensitiveFileNames) {
|
|
@@ -275,7 +275,72 @@ function normalizeFileName(ts, fileName) {
|
|
|
275
275
|
return toAbsolutePath(normalized.toLowerCase(), null);
|
|
276
276
|
}
|
|
277
277
|
function toAbsolutePath(filePath, baseDir) {
|
|
278
|
-
return
|
|
278
|
+
return import_path.default.isAbsolute(filePath) ? filePath : import_path.default.join(baseDir || process.cwd(), filePath);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// src/parser/ts-for-v5/resolve-project-list.ts
|
|
282
|
+
var import_globby = require("globby");
|
|
283
|
+
var import_is_glob = __toESM(require("is-glob"));
|
|
284
|
+
var path3 = __toESM(require("path"));
|
|
285
|
+
var import_module = require("module");
|
|
286
|
+
function resolveProjectList(options) {
|
|
287
|
+
const sanitizedProjects = [];
|
|
288
|
+
if (typeof options.project === "string") {
|
|
289
|
+
sanitizedProjects.push(options.project);
|
|
290
|
+
} else if (Array.isArray(options.project)) {
|
|
291
|
+
for (const project of options.project) {
|
|
292
|
+
if (typeof project === "string") {
|
|
293
|
+
sanitizedProjects.push(project);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
if (sanitizedProjects.length === 0) {
|
|
298
|
+
return [];
|
|
299
|
+
}
|
|
300
|
+
const projectFolderIgnoreList = (options.projectFolderIgnoreList ?? ["**/node_modules/**"]).reduce((acc, folder) => {
|
|
301
|
+
if (typeof folder === "string") {
|
|
302
|
+
acc.push(folder);
|
|
303
|
+
}
|
|
304
|
+
return acc;
|
|
305
|
+
}, []).map((folder) => folder.startsWith("!") ? folder : `!${folder}`);
|
|
306
|
+
const nonGlobProjects = sanitizedProjects.filter(
|
|
307
|
+
(project) => !(0, import_is_glob.default)(project)
|
|
308
|
+
);
|
|
309
|
+
const globProjects = sanitizedProjects.filter((project) => (0, import_is_glob.default)(project));
|
|
310
|
+
const uniqueCanonicalProjectPaths = new Set(
|
|
311
|
+
nonGlobProjects.concat(
|
|
312
|
+
globProjects.length === 0 ? [] : (0, import_globby.sync)([...globProjects, ...projectFolderIgnoreList], {
|
|
313
|
+
cwd: options.tsconfigRootDir
|
|
314
|
+
})
|
|
315
|
+
).map(
|
|
316
|
+
(project) => getCanonicalFileName(
|
|
317
|
+
ensureAbsolutePath(project, options.tsconfigRootDir)
|
|
318
|
+
)
|
|
319
|
+
)
|
|
320
|
+
);
|
|
321
|
+
const returnValue = Array.from(uniqueCanonicalProjectPaths);
|
|
322
|
+
return returnValue;
|
|
323
|
+
}
|
|
324
|
+
var _correctPathCasing;
|
|
325
|
+
function correctPathCasing(filePath) {
|
|
326
|
+
if (_correctPathCasing === void 0) {
|
|
327
|
+
const ts = (0, import_module.createRequire)(
|
|
328
|
+
path3.join(process.cwd(), "__placeholder__.js")
|
|
329
|
+
)("typescript");
|
|
330
|
+
const useCaseSensitiveFileNames = ts.sys !== void 0 ? ts.sys.useCaseSensitiveFileNames : true;
|
|
331
|
+
_correctPathCasing = useCaseSensitiveFileNames ? (filePath2) => filePath2 : (filePath2) => filePath2.toLowerCase();
|
|
332
|
+
}
|
|
333
|
+
return _correctPathCasing(filePath);
|
|
334
|
+
}
|
|
335
|
+
function getCanonicalFileName(filePath) {
|
|
336
|
+
let normalized = path3.normalize(filePath);
|
|
337
|
+
if (normalized.endsWith(path3.sep)) {
|
|
338
|
+
normalized = normalized.slice(0, -1);
|
|
339
|
+
}
|
|
340
|
+
return correctPathCasing(normalized);
|
|
341
|
+
}
|
|
342
|
+
function ensureAbsolutePath(p, tsconfigRootDir) {
|
|
343
|
+
return path3.isAbsolute(p) ? p : path3.join(tsconfigRootDir || process.cwd(), p);
|
|
279
344
|
}
|
|
280
345
|
|
|
281
346
|
// src/parser/ts-for-v5/parse-tsx-for-typescript.ts
|
|
@@ -303,7 +368,16 @@ function* iterateOptions(options) {
|
|
|
303
368
|
"Specify `parserOptions.project`. Otherwise there is no point in using this parser."
|
|
304
369
|
);
|
|
305
370
|
}
|
|
306
|
-
|
|
371
|
+
const tsconfigRootDir = typeof options.tsconfigRootDir === "string" ? options.tsconfigRootDir : process.cwd();
|
|
372
|
+
const projects = resolveProjectList({
|
|
373
|
+
project: getProjectConfigFiles(
|
|
374
|
+
{ tsconfigRootDir, filePath: options.filePath },
|
|
375
|
+
options.project
|
|
376
|
+
),
|
|
377
|
+
projectFolderIgnoreList: options.projectFolderIgnoreList,
|
|
378
|
+
tsconfigRootDir
|
|
379
|
+
});
|
|
380
|
+
for (const project of projects) {
|
|
307
381
|
yield {
|
|
308
382
|
project,
|
|
309
383
|
filePath: options.filePath,
|
|
@@ -322,15 +396,15 @@ function tsPatch(scriptParserOptions, tsParserName) {
|
|
|
322
396
|
}
|
|
323
397
|
let targetExt = ".astro";
|
|
324
398
|
if (scriptParserOptions.filePath) {
|
|
325
|
-
const ext =
|
|
399
|
+
const ext = import_path2.default.extname(scriptParserOptions.filePath);
|
|
326
400
|
if (ext) {
|
|
327
401
|
targetExt = ext;
|
|
328
402
|
}
|
|
329
403
|
}
|
|
330
404
|
try {
|
|
331
405
|
const cwd = process.cwd();
|
|
332
|
-
const relativeTo =
|
|
333
|
-
const ts = (0,
|
|
406
|
+
const relativeTo = import_path2.default.join(cwd, "__placeholder__.js");
|
|
407
|
+
const ts = (0, import_module2.createRequire)(relativeTo)("typescript");
|
|
334
408
|
if ((0, import_semver.satisfies)(ts.version, ">=5")) {
|
|
335
409
|
const result = tsPatchForV5(ts, scriptParserOptions);
|
|
336
410
|
if (result) {
|
|
@@ -346,11 +420,11 @@ function tsPatch(scriptParserOptions, tsParserName) {
|
|
|
346
420
|
}
|
|
347
421
|
const tsxFilePath = `${scriptParserOptions.filePath}.tsx`;
|
|
348
422
|
scriptParserOptions.filePath = tsxFilePath;
|
|
349
|
-
if (!
|
|
350
|
-
|
|
423
|
+
if (!import_fs.default.existsSync(tsxFilePath)) {
|
|
424
|
+
import_fs.default.writeFileSync(tsxFilePath, "/* temp for astro-eslint-parser */");
|
|
351
425
|
return {
|
|
352
426
|
terminate() {
|
|
353
|
-
|
|
427
|
+
import_fs.default.unlinkSync(tsxFilePath);
|
|
354
428
|
}
|
|
355
429
|
};
|
|
356
430
|
}
|
|
@@ -2125,18 +2199,18 @@ function remap(result, normalized, originalCode, ctxForAstro) {
|
|
|
2125
2199
|
}
|
|
2126
2200
|
|
|
2127
2201
|
// src/context/parser-options.ts
|
|
2128
|
-
var
|
|
2129
|
-
var
|
|
2202
|
+
var import_path4 = __toESM(require("path"));
|
|
2203
|
+
var import_fs2 = __toESM(require("fs"));
|
|
2130
2204
|
|
|
2131
2205
|
// src/context/resolve-parser/espree.ts
|
|
2132
|
-
var
|
|
2133
|
-
var
|
|
2206
|
+
var import_module3 = require("module");
|
|
2207
|
+
var import_path3 = __toESM(require("path"));
|
|
2134
2208
|
var espreeCache = null;
|
|
2135
2209
|
function isLinterPath(p) {
|
|
2136
2210
|
return (
|
|
2137
2211
|
// ESLint 6 and above
|
|
2138
|
-
p.includes(`eslint${
|
|
2139
|
-
p.includes(`eslint${
|
|
2212
|
+
p.includes(`eslint${import_path3.default.sep}lib${import_path3.default.sep}linter${import_path3.default.sep}linter.js`) || // ESLint 5
|
|
2213
|
+
p.includes(`eslint${import_path3.default.sep}lib${import_path3.default.sep}linter.js`)
|
|
2140
2214
|
);
|
|
2141
2215
|
}
|
|
2142
2216
|
function getEspree() {
|
|
@@ -2144,7 +2218,7 @@ function getEspree() {
|
|
|
2144
2218
|
const linterPath = Object.keys(require.cache || {}).find(isLinterPath);
|
|
2145
2219
|
if (linterPath) {
|
|
2146
2220
|
try {
|
|
2147
|
-
espreeCache = (0,
|
|
2221
|
+
espreeCache = (0, import_module3.createRequire)(linterPath)("espree");
|
|
2148
2222
|
} catch {
|
|
2149
2223
|
}
|
|
2150
2224
|
}
|
|
@@ -2240,10 +2314,10 @@ var ParserOptionsContext = class {
|
|
|
2240
2314
|
if (TS_PARSER_NAMES.some((nm) => parserName.includes(nm))) {
|
|
2241
2315
|
let targetPath = parserName;
|
|
2242
2316
|
while (targetPath) {
|
|
2243
|
-
const pkgPath =
|
|
2244
|
-
if (
|
|
2317
|
+
const pkgPath = import_path4.default.join(targetPath, "package.json");
|
|
2318
|
+
if (import_fs2.default.existsSync(pkgPath)) {
|
|
2245
2319
|
try {
|
|
2246
|
-
const pkgName = JSON.parse(
|
|
2320
|
+
const pkgName = JSON.parse(import_fs2.default.readFileSync(pkgPath, "utf-8"))?.name;
|
|
2247
2321
|
if (TS_PARSER_NAMES.includes(pkgName)) {
|
|
2248
2322
|
this.state.ts = { parserName: pkgName };
|
|
2249
2323
|
return this.state.ts.parserName;
|
|
@@ -2255,7 +2329,7 @@ var ParserOptionsContext = class {
|
|
|
2255
2329
|
return null;
|
|
2256
2330
|
}
|
|
2257
2331
|
}
|
|
2258
|
-
const parent =
|
|
2332
|
+
const parent = import_path4.default.dirname(targetPath);
|
|
2259
2333
|
if (targetPath === parent) {
|
|
2260
2334
|
break;
|
|
2261
2335
|
}
|
|
@@ -2655,7 +2729,7 @@ __export(meta_exports, {
|
|
|
2655
2729
|
|
|
2656
2730
|
// package.json
|
|
2657
2731
|
var name = "astro-eslint-parser";
|
|
2658
|
-
var version = "0.
|
|
2732
|
+
var version = "0.17.0";
|
|
2659
2733
|
|
|
2660
2734
|
// src/index.ts
|
|
2661
2735
|
function parseForESLint2(code, options) {
|
package/lib/index.mjs
CHANGED
|
@@ -34,31 +34,31 @@ import debugFactory from "debug";
|
|
|
34
34
|
var debug = debugFactory("astro-eslint-parser");
|
|
35
35
|
|
|
36
36
|
// src/parser/ts-patch.ts
|
|
37
|
-
import { createRequire } from "module";
|
|
38
|
-
import
|
|
37
|
+
import { createRequire as createRequire2 } from "module";
|
|
38
|
+
import path4 from "path";
|
|
39
39
|
import fs2 from "fs";
|
|
40
40
|
import { satisfies } from "semver";
|
|
41
41
|
|
|
42
42
|
// src/parser/ts-for-v5/get-project-config-files.ts
|
|
43
|
-
import fs from "fs";
|
|
44
|
-
import path from "path";
|
|
45
|
-
function getProjectConfigFiles(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return Array.isArray(options.project) ? options.project : [options.project];
|
|
43
|
+
import * as fs from "fs";
|
|
44
|
+
import * as path from "path";
|
|
45
|
+
function getProjectConfigFiles(parseSettings, project) {
|
|
46
|
+
if (project !== true) {
|
|
47
|
+
return project === void 0 || Array.isArray(project) ? project : [project];
|
|
49
48
|
}
|
|
50
|
-
let directory = path.dirname(
|
|
49
|
+
let directory = path.dirname(parseSettings.filePath);
|
|
51
50
|
const checkedDirectories = [directory];
|
|
52
51
|
do {
|
|
53
52
|
const tsconfigPath = path.join(directory, "tsconfig.json");
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
const cached = fs.existsSync(tsconfigPath) && tsconfigPath;
|
|
54
|
+
if (cached) {
|
|
55
|
+
return [cached];
|
|
56
56
|
}
|
|
57
57
|
directory = path.dirname(directory);
|
|
58
58
|
checkedDirectories.push(directory);
|
|
59
|
-
} while (directory.length > 1 && directory.length >= tsconfigRootDir.length);
|
|
59
|
+
} while (directory.length > 1 && directory.length >= parseSettings.tsconfigRootDir.length);
|
|
60
60
|
throw new Error(
|
|
61
|
-
`project was set to \`true\` but couldn't find any tsconfig.json relative to '${
|
|
61
|
+
`project was set to \`true\` but couldn't find any tsconfig.json relative to '${parseSettings.filePath}' within '${parseSettings.tsconfigRootDir}'.`
|
|
62
62
|
);
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -141,11 +141,11 @@ var TSService = class {
|
|
|
141
141
|
);
|
|
142
142
|
return getTargetSourceFile(fileName, languageVersionOrOptions) ?? originalSourceFile;
|
|
143
143
|
};
|
|
144
|
-
host.getSourceFileByPath = (fileName,
|
|
144
|
+
host.getSourceFileByPath = (fileName, path7, languageVersionOrOptions, ...args2) => {
|
|
145
145
|
const originalSourceFile = original2.getSourceFileByPath.call(
|
|
146
146
|
host,
|
|
147
147
|
fileName,
|
|
148
|
-
|
|
148
|
+
path7,
|
|
149
149
|
languageVersionOrOptions,
|
|
150
150
|
...args2
|
|
151
151
|
);
|
|
@@ -248,6 +248,71 @@ function toAbsolutePath(filePath, baseDir) {
|
|
|
248
248
|
return path2.isAbsolute(filePath) ? filePath : path2.join(baseDir || process.cwd(), filePath);
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
+
// src/parser/ts-for-v5/resolve-project-list.ts
|
|
252
|
+
import { sync as globSync } from "globby";
|
|
253
|
+
import isGlob from "is-glob";
|
|
254
|
+
import * as path3 from "path";
|
|
255
|
+
import { createRequire } from "module";
|
|
256
|
+
function resolveProjectList(options) {
|
|
257
|
+
const sanitizedProjects = [];
|
|
258
|
+
if (typeof options.project === "string") {
|
|
259
|
+
sanitizedProjects.push(options.project);
|
|
260
|
+
} else if (Array.isArray(options.project)) {
|
|
261
|
+
for (const project of options.project) {
|
|
262
|
+
if (typeof project === "string") {
|
|
263
|
+
sanitizedProjects.push(project);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if (sanitizedProjects.length === 0) {
|
|
268
|
+
return [];
|
|
269
|
+
}
|
|
270
|
+
const projectFolderIgnoreList = (options.projectFolderIgnoreList ?? ["**/node_modules/**"]).reduce((acc, folder) => {
|
|
271
|
+
if (typeof folder === "string") {
|
|
272
|
+
acc.push(folder);
|
|
273
|
+
}
|
|
274
|
+
return acc;
|
|
275
|
+
}, []).map((folder) => folder.startsWith("!") ? folder : `!${folder}`);
|
|
276
|
+
const nonGlobProjects = sanitizedProjects.filter(
|
|
277
|
+
(project) => !isGlob(project)
|
|
278
|
+
);
|
|
279
|
+
const globProjects = sanitizedProjects.filter((project) => isGlob(project));
|
|
280
|
+
const uniqueCanonicalProjectPaths = new Set(
|
|
281
|
+
nonGlobProjects.concat(
|
|
282
|
+
globProjects.length === 0 ? [] : globSync([...globProjects, ...projectFolderIgnoreList], {
|
|
283
|
+
cwd: options.tsconfigRootDir
|
|
284
|
+
})
|
|
285
|
+
).map(
|
|
286
|
+
(project) => getCanonicalFileName(
|
|
287
|
+
ensureAbsolutePath(project, options.tsconfigRootDir)
|
|
288
|
+
)
|
|
289
|
+
)
|
|
290
|
+
);
|
|
291
|
+
const returnValue = Array.from(uniqueCanonicalProjectPaths);
|
|
292
|
+
return returnValue;
|
|
293
|
+
}
|
|
294
|
+
var _correctPathCasing;
|
|
295
|
+
function correctPathCasing(filePath) {
|
|
296
|
+
if (_correctPathCasing === void 0) {
|
|
297
|
+
const ts = createRequire(
|
|
298
|
+
path3.join(process.cwd(), "__placeholder__.js")
|
|
299
|
+
)("typescript");
|
|
300
|
+
const useCaseSensitiveFileNames = ts.sys !== void 0 ? ts.sys.useCaseSensitiveFileNames : true;
|
|
301
|
+
_correctPathCasing = useCaseSensitiveFileNames ? (filePath2) => filePath2 : (filePath2) => filePath2.toLowerCase();
|
|
302
|
+
}
|
|
303
|
+
return _correctPathCasing(filePath);
|
|
304
|
+
}
|
|
305
|
+
function getCanonicalFileName(filePath) {
|
|
306
|
+
let normalized = path3.normalize(filePath);
|
|
307
|
+
if (normalized.endsWith(path3.sep)) {
|
|
308
|
+
normalized = normalized.slice(0, -1);
|
|
309
|
+
}
|
|
310
|
+
return correctPathCasing(normalized);
|
|
311
|
+
}
|
|
312
|
+
function ensureAbsolutePath(p, tsconfigRootDir) {
|
|
313
|
+
return path3.isAbsolute(p) ? p : path3.join(tsconfigRootDir || process.cwd(), p);
|
|
314
|
+
}
|
|
315
|
+
|
|
251
316
|
// src/parser/ts-for-v5/parse-tsx-for-typescript.ts
|
|
252
317
|
var DEFAULT_EXTRA_FILE_EXTENSIONS = [".vue", ".svelte", ".astro"];
|
|
253
318
|
function parseTsxForTypeScript(code, options, tsEslintParser, ts) {
|
|
@@ -273,7 +338,16 @@ function* iterateOptions(options) {
|
|
|
273
338
|
"Specify `parserOptions.project`. Otherwise there is no point in using this parser."
|
|
274
339
|
);
|
|
275
340
|
}
|
|
276
|
-
|
|
341
|
+
const tsconfigRootDir = typeof options.tsconfigRootDir === "string" ? options.tsconfigRootDir : process.cwd();
|
|
342
|
+
const projects = resolveProjectList({
|
|
343
|
+
project: getProjectConfigFiles(
|
|
344
|
+
{ tsconfigRootDir, filePath: options.filePath },
|
|
345
|
+
options.project
|
|
346
|
+
),
|
|
347
|
+
projectFolderIgnoreList: options.projectFolderIgnoreList,
|
|
348
|
+
tsconfigRootDir
|
|
349
|
+
});
|
|
350
|
+
for (const project of projects) {
|
|
277
351
|
yield {
|
|
278
352
|
project,
|
|
279
353
|
filePath: options.filePath,
|
|
@@ -292,15 +366,15 @@ function tsPatch(scriptParserOptions, tsParserName) {
|
|
|
292
366
|
}
|
|
293
367
|
let targetExt = ".astro";
|
|
294
368
|
if (scriptParserOptions.filePath) {
|
|
295
|
-
const ext =
|
|
369
|
+
const ext = path4.extname(scriptParserOptions.filePath);
|
|
296
370
|
if (ext) {
|
|
297
371
|
targetExt = ext;
|
|
298
372
|
}
|
|
299
373
|
}
|
|
300
374
|
try {
|
|
301
375
|
const cwd = process.cwd();
|
|
302
|
-
const relativeTo =
|
|
303
|
-
const ts =
|
|
376
|
+
const relativeTo = path4.join(cwd, "__placeholder__.js");
|
|
377
|
+
const ts = createRequire2(relativeTo)("typescript");
|
|
304
378
|
if (satisfies(ts.version, ">=5")) {
|
|
305
379
|
const result = tsPatchForV5(ts, scriptParserOptions);
|
|
306
380
|
if (result) {
|
|
@@ -2099,18 +2173,18 @@ function remap(result, normalized, originalCode, ctxForAstro) {
|
|
|
2099
2173
|
}
|
|
2100
2174
|
|
|
2101
2175
|
// src/context/parser-options.ts
|
|
2102
|
-
import
|
|
2176
|
+
import path6 from "path";
|
|
2103
2177
|
import fs3 from "fs";
|
|
2104
2178
|
|
|
2105
2179
|
// src/context/resolve-parser/espree.ts
|
|
2106
|
-
import { createRequire as
|
|
2107
|
-
import
|
|
2180
|
+
import { createRequire as createRequire3 } from "module";
|
|
2181
|
+
import path5 from "path";
|
|
2108
2182
|
var espreeCache = null;
|
|
2109
2183
|
function isLinterPath(p) {
|
|
2110
2184
|
return (
|
|
2111
2185
|
// ESLint 6 and above
|
|
2112
|
-
p.includes(`eslint${
|
|
2113
|
-
p.includes(`eslint${
|
|
2186
|
+
p.includes(`eslint${path5.sep}lib${path5.sep}linter${path5.sep}linter.js`) || // ESLint 5
|
|
2187
|
+
p.includes(`eslint${path5.sep}lib${path5.sep}linter.js`)
|
|
2114
2188
|
);
|
|
2115
2189
|
}
|
|
2116
2190
|
function getEspree() {
|
|
@@ -2118,7 +2192,7 @@ function getEspree() {
|
|
|
2118
2192
|
const linterPath = Object.keys(__require.cache || {}).find(isLinterPath);
|
|
2119
2193
|
if (linterPath) {
|
|
2120
2194
|
try {
|
|
2121
|
-
espreeCache =
|
|
2195
|
+
espreeCache = createRequire3(linterPath)("espree");
|
|
2122
2196
|
} catch {
|
|
2123
2197
|
}
|
|
2124
2198
|
}
|
|
@@ -2214,7 +2288,7 @@ var ParserOptionsContext = class {
|
|
|
2214
2288
|
if (TS_PARSER_NAMES.some((nm) => parserName.includes(nm))) {
|
|
2215
2289
|
let targetPath = parserName;
|
|
2216
2290
|
while (targetPath) {
|
|
2217
|
-
const pkgPath =
|
|
2291
|
+
const pkgPath = path6.join(targetPath, "package.json");
|
|
2218
2292
|
if (fs3.existsSync(pkgPath)) {
|
|
2219
2293
|
try {
|
|
2220
2294
|
const pkgName = JSON.parse(fs3.readFileSync(pkgPath, "utf-8"))?.name;
|
|
@@ -2229,7 +2303,7 @@ var ParserOptionsContext = class {
|
|
|
2229
2303
|
return null;
|
|
2230
2304
|
}
|
|
2231
2305
|
}
|
|
2232
|
-
const parent =
|
|
2306
|
+
const parent = path6.dirname(targetPath);
|
|
2233
2307
|
if (targetPath === parent) {
|
|
2234
2308
|
break;
|
|
2235
2309
|
}
|
|
@@ -2632,7 +2706,7 @@ __export(meta_exports, {
|
|
|
2632
2706
|
|
|
2633
2707
|
// package.json
|
|
2634
2708
|
var name = "astro-eslint-parser";
|
|
2635
|
-
var version = "0.
|
|
2709
|
+
var version = "0.17.0";
|
|
2636
2710
|
|
|
2637
2711
|
// src/index.ts
|
|
2638
2712
|
function parseForESLint2(code, options) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro-eslint-parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Astro component parser for ESLint",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.mjs",
|
|
@@ -51,11 +51,14 @@
|
|
|
51
51
|
"@astrojs/compiler": "^2.0.0",
|
|
52
52
|
"@typescript-eslint/scope-manager": "^5.0.0",
|
|
53
53
|
"@typescript-eslint/types": "^5.0.0",
|
|
54
|
+
"@typescript-eslint/typescript-estree": "^5.0.0",
|
|
54
55
|
"astrojs-compiler-sync": "^0.3.0",
|
|
55
56
|
"debug": "^4.3.4",
|
|
56
57
|
"entities": "^4.5.0",
|
|
57
58
|
"eslint-visitor-keys": "^3.0.0",
|
|
58
59
|
"espree": "^9.0.0",
|
|
60
|
+
"globby": "^11.1.0",
|
|
61
|
+
"is-glob": "^4.0.3",
|
|
59
62
|
"semver": "^7.3.8"
|
|
60
63
|
},
|
|
61
64
|
"devDependencies": {
|
|
@@ -67,12 +70,13 @@
|
|
|
67
70
|
"@types/debug": "^4.1.7",
|
|
68
71
|
"@types/eslint": "^8.0.0",
|
|
69
72
|
"@types/eslint-scope": "^3.7.0",
|
|
70
|
-
"@types/eslint-visitor-keys": "^
|
|
73
|
+
"@types/eslint-visitor-keys": "^3.0.0",
|
|
74
|
+
"@types/is-glob": "^4.0.4",
|
|
71
75
|
"@types/mocha": "^10.0.0",
|
|
72
76
|
"@types/node": "^20.0.0",
|
|
73
77
|
"@types/semver": "^7.3.9",
|
|
74
|
-
"@typescript-eslint/eslint-plugin": "~6.
|
|
75
|
-
"@typescript-eslint/parser": "~6.
|
|
78
|
+
"@typescript-eslint/eslint-plugin": "~6.21.0",
|
|
79
|
+
"@typescript-eslint/parser": "~6.21.0",
|
|
76
80
|
"astro": "^4.0.0",
|
|
77
81
|
"astro-eslint-parser": ">=0.1.0",
|
|
78
82
|
"benchmark": "^2.1.4",
|
|
@@ -83,9 +87,9 @@
|
|
|
83
87
|
"eslint": "^8.15.0",
|
|
84
88
|
"eslint-config-prettier": "^9.0.0",
|
|
85
89
|
"eslint-formatter-codeframe": "^7.32.1",
|
|
86
|
-
"eslint-plugin-astro": "^0.
|
|
90
|
+
"eslint-plugin-astro": "^0.33.0",
|
|
87
91
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
88
|
-
"eslint-plugin-json-schema-validator": "^
|
|
92
|
+
"eslint-plugin-json-schema-validator": "^5.0.0",
|
|
89
93
|
"eslint-plugin-jsonc": "^2.0.0",
|
|
90
94
|
"eslint-plugin-jsx-a11y": "^6.5.1",
|
|
91
95
|
"eslint-plugin-n": "^16.0.0",
|
|
@@ -93,10 +97,10 @@
|
|
|
93
97
|
"eslint-plugin-prettier": "^5.0.0",
|
|
94
98
|
"eslint-plugin-react": "^7.29.4",
|
|
95
99
|
"eslint-plugin-regexp": "^2.0.0",
|
|
96
|
-
"eslint-plugin-simple-import-sort": "^
|
|
100
|
+
"eslint-plugin-simple-import-sort": "^12.0.0",
|
|
97
101
|
"eslint-plugin-svelte": "^2.0.0",
|
|
98
102
|
"estree-walker": "^3.0.0",
|
|
99
|
-
"globals": "^
|
|
103
|
+
"globals": "^15.0.0",
|
|
100
104
|
"locate-character": "^3.0.0",
|
|
101
105
|
"magic-string": "^0.30.0",
|
|
102
106
|
"mocha": "^10.0.0",
|
|
@@ -108,7 +112,7 @@
|
|
|
108
112
|
"string-replace-loader": "^3.0.3",
|
|
109
113
|
"svelte": "^4.0.0",
|
|
110
114
|
"tsup": "^8.0.0",
|
|
111
|
-
"typescript": "~5.
|
|
115
|
+
"typescript": "~5.4.0",
|
|
112
116
|
"typescript-eslint-parser-for-extra-files": "^0.6.0"
|
|
113
117
|
},
|
|
114
118
|
"publishConfig": {
|