astro-eslint-parser 0.16.2 → 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 CHANGED
@@ -314,7 +314,7 @@ declare class ParseError extends SyntaxError {
314
314
  }
315
315
 
316
316
  var name = "astro-eslint-parser";
317
- var version = "0.16.2";
317
+ var version = "0.17.0";
318
318
 
319
319
  declare const meta_name: typeof name;
320
320
  declare const meta_version: typeof version;
package/lib/index.d.ts CHANGED
@@ -314,7 +314,7 @@ declare class ParseError extends SyntaxError {
314
314
  }
315
315
 
316
316
  var name = "astro-eslint-parser";
317
- var version = "0.16.2";
317
+ var version = "0.17.0";
318
318
 
319
319
  declare const meta_name: typeof name;
320
320
  declare const meta_version: typeof version;
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 import_module = require("module");
68
- var import_path3 = __toESM(require("path"));
69
- var import_fs2 = __toESM(require("fs"));
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 import_fs = __toESM(require("fs"));
74
- var import_path = __toESM(require("path"));
75
- function getProjectConfigFiles(options) {
76
- const tsconfigRootDir = typeof options.tsconfigRootDir === "string" ? options.tsconfigRootDir : process.cwd();
77
- if (options.project !== true) {
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 = import_path.default.dirname(options.filePath);
79
+ let directory = path.dirname(parseSettings.filePath);
81
80
  const checkedDirectories = [directory];
82
81
  do {
83
- const tsconfigPath = import_path.default.join(directory, "tsconfig.json");
84
- if (import_fs.default.existsSync(tsconfigPath)) {
85
- return [tsconfigPath];
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 = import_path.default.dirname(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 '${options.filePath}' within '${tsconfigRootDir}'.`
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 import_path2 = __toESM(require("path"));
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, path6, languageVersionOrOptions, ...args2) => {
174
+ host.getSourceFileByPath = (fileName, path7, languageVersionOrOptions, ...args2) => {
175
175
  const originalSourceFile = original2.getSourceFileByPath.call(
176
176
  host,
177
177
  fileName,
178
- path6,
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 = import_path2.default.normalize(fileName);
269
- if (normalized.endsWith(import_path2.default.sep)) {
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 import_path2.default.isAbsolute(filePath) ? filePath : import_path2.default.join(baseDir || process.cwd(), filePath);
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
- for (const project of getProjectConfigFiles(options)) {
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 = import_path3.default.extname(scriptParserOptions.filePath);
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 = import_path3.default.join(cwd, "__placeholder__.js");
333
- const ts = (0, import_module.createRequire)(relativeTo)("typescript");
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 (!import_fs2.default.existsSync(tsxFilePath)) {
350
- import_fs2.default.writeFileSync(tsxFilePath, "/* temp for astro-eslint-parser */");
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
- import_fs2.default.unlinkSync(tsxFilePath);
427
+ import_fs.default.unlinkSync(tsxFilePath);
354
428
  }
355
429
  };
356
430
  }
@@ -1237,10 +1311,13 @@ function processTemplate(ctx, resultTemplate) {
1237
1311
  ]);
1238
1312
  } else if (isTag(node)) {
1239
1313
  if (parent.type === "expression") {
1240
- const index = parent.children.indexOf(node);
1241
- const before = parent.children[index - 1];
1314
+ const siblings = parent.children.filter(
1315
+ (n) => n.type !== "text" || n.value.trim()
1316
+ );
1317
+ const index = siblings.indexOf(node);
1318
+ const before = siblings[index - 1];
1242
1319
  if (!before || !isTag(before)) {
1243
- const after = parent.children[index + 1];
1320
+ const after = siblings[index + 1];
1244
1321
  if (after && (isTag(after) || after.type === "comment")) {
1245
1322
  const start2 = node.position.start.offset;
1246
1323
  script.appendOriginal(start2);
@@ -1472,10 +1549,13 @@ function processTemplate(ctx, resultTemplate) {
1472
1549
  }
1473
1550
  }
1474
1551
  if ((isTag(node) || node.type === "comment") && parent.type === "expression") {
1475
- const index = parent.children.indexOf(node);
1476
- const after = parent.children[index + 1];
1552
+ const siblings = parent.children.filter(
1553
+ (n) => n.type !== "text" || n.value.trim()
1554
+ );
1555
+ const index = siblings.indexOf(node);
1556
+ const after = siblings[index + 1];
1477
1557
  if (!after || !isTag(after) && after.type !== "comment") {
1478
- const before = parent.children[index - 1];
1558
+ const before = siblings[index - 1];
1479
1559
  if (before && (isTag(before) || before.type === "comment")) {
1480
1560
  const end = getEndOffset(node, ctx);
1481
1561
  script.appendOriginal(end);
@@ -2119,18 +2199,18 @@ function remap(result, normalized, originalCode, ctxForAstro) {
2119
2199
  }
2120
2200
 
2121
2201
  // src/context/parser-options.ts
2122
- var import_path5 = __toESM(require("path"));
2123
- var import_fs3 = __toESM(require("fs"));
2202
+ var import_path4 = __toESM(require("path"));
2203
+ var import_fs2 = __toESM(require("fs"));
2124
2204
 
2125
2205
  // src/context/resolve-parser/espree.ts
2126
- var import_module2 = require("module");
2127
- var import_path4 = __toESM(require("path"));
2206
+ var import_module3 = require("module");
2207
+ var import_path3 = __toESM(require("path"));
2128
2208
  var espreeCache = null;
2129
2209
  function isLinterPath(p) {
2130
2210
  return (
2131
2211
  // ESLint 6 and above
2132
- p.includes(`eslint${import_path4.default.sep}lib${import_path4.default.sep}linter${import_path4.default.sep}linter.js`) || // ESLint 5
2133
- p.includes(`eslint${import_path4.default.sep}lib${import_path4.default.sep}linter.js`)
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`)
2134
2214
  );
2135
2215
  }
2136
2216
  function getEspree() {
@@ -2138,7 +2218,7 @@ function getEspree() {
2138
2218
  const linterPath = Object.keys(require.cache || {}).find(isLinterPath);
2139
2219
  if (linterPath) {
2140
2220
  try {
2141
- espreeCache = (0, import_module2.createRequire)(linterPath)("espree");
2221
+ espreeCache = (0, import_module3.createRequire)(linterPath)("espree");
2142
2222
  } catch {
2143
2223
  }
2144
2224
  }
@@ -2234,10 +2314,10 @@ var ParserOptionsContext = class {
2234
2314
  if (TS_PARSER_NAMES.some((nm) => parserName.includes(nm))) {
2235
2315
  let targetPath = parserName;
2236
2316
  while (targetPath) {
2237
- const pkgPath = import_path5.default.join(targetPath, "package.json");
2238
- if (import_fs3.default.existsSync(pkgPath)) {
2317
+ const pkgPath = import_path4.default.join(targetPath, "package.json");
2318
+ if (import_fs2.default.existsSync(pkgPath)) {
2239
2319
  try {
2240
- const pkgName = JSON.parse(import_fs3.default.readFileSync(pkgPath, "utf-8"))?.name;
2320
+ const pkgName = JSON.parse(import_fs2.default.readFileSync(pkgPath, "utf-8"))?.name;
2241
2321
  if (TS_PARSER_NAMES.includes(pkgName)) {
2242
2322
  this.state.ts = { parserName: pkgName };
2243
2323
  return this.state.ts.parserName;
@@ -2249,7 +2329,7 @@ var ParserOptionsContext = class {
2249
2329
  return null;
2250
2330
  }
2251
2331
  }
2252
- const parent = import_path5.default.dirname(targetPath);
2332
+ const parent = import_path4.default.dirname(targetPath);
2253
2333
  if (targetPath === parent) {
2254
2334
  break;
2255
2335
  }
@@ -2649,7 +2729,7 @@ __export(meta_exports, {
2649
2729
 
2650
2730
  // package.json
2651
2731
  var name = "astro-eslint-parser";
2652
- var version = "0.16.2";
2732
+ var version = "0.17.0";
2653
2733
 
2654
2734
  // src/index.ts
2655
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 path3 from "path";
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(options) {
46
- const tsconfigRootDir = typeof options.tsconfigRootDir === "string" ? options.tsconfigRootDir : process.cwd();
47
- if (options.project !== true) {
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(options.filePath);
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
- if (fs.existsSync(tsconfigPath)) {
55
- return [tsconfigPath];
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 '${options.filePath}' within '${tsconfigRootDir}'.`
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, path6, languageVersionOrOptions, ...args2) => {
144
+ host.getSourceFileByPath = (fileName, path7, languageVersionOrOptions, ...args2) => {
145
145
  const originalSourceFile = original2.getSourceFileByPath.call(
146
146
  host,
147
147
  fileName,
148
- path6,
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
- for (const project of getProjectConfigFiles(options)) {
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 = path3.extname(scriptParserOptions.filePath);
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 = path3.join(cwd, "__placeholder__.js");
303
- const ts = createRequire(relativeTo)("typescript");
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) {
@@ -1211,10 +1285,13 @@ function processTemplate(ctx, resultTemplate) {
1211
1285
  ]);
1212
1286
  } else if (isTag(node)) {
1213
1287
  if (parent.type === "expression") {
1214
- const index = parent.children.indexOf(node);
1215
- const before = parent.children[index - 1];
1288
+ const siblings = parent.children.filter(
1289
+ (n) => n.type !== "text" || n.value.trim()
1290
+ );
1291
+ const index = siblings.indexOf(node);
1292
+ const before = siblings[index - 1];
1216
1293
  if (!before || !isTag(before)) {
1217
- const after = parent.children[index + 1];
1294
+ const after = siblings[index + 1];
1218
1295
  if (after && (isTag(after) || after.type === "comment")) {
1219
1296
  const start2 = node.position.start.offset;
1220
1297
  script.appendOriginal(start2);
@@ -1446,10 +1523,13 @@ function processTemplate(ctx, resultTemplate) {
1446
1523
  }
1447
1524
  }
1448
1525
  if ((isTag(node) || node.type === "comment") && parent.type === "expression") {
1449
- const index = parent.children.indexOf(node);
1450
- const after = parent.children[index + 1];
1526
+ const siblings = parent.children.filter(
1527
+ (n) => n.type !== "text" || n.value.trim()
1528
+ );
1529
+ const index = siblings.indexOf(node);
1530
+ const after = siblings[index + 1];
1451
1531
  if (!after || !isTag(after) && after.type !== "comment") {
1452
- const before = parent.children[index - 1];
1532
+ const before = siblings[index - 1];
1453
1533
  if (before && (isTag(before) || before.type === "comment")) {
1454
1534
  const end = getEndOffset(node, ctx);
1455
1535
  script.appendOriginal(end);
@@ -2093,18 +2173,18 @@ function remap(result, normalized, originalCode, ctxForAstro) {
2093
2173
  }
2094
2174
 
2095
2175
  // src/context/parser-options.ts
2096
- import path5 from "path";
2176
+ import path6 from "path";
2097
2177
  import fs3 from "fs";
2098
2178
 
2099
2179
  // src/context/resolve-parser/espree.ts
2100
- import { createRequire as createRequire2 } from "module";
2101
- import path4 from "path";
2180
+ import { createRequire as createRequire3 } from "module";
2181
+ import path5 from "path";
2102
2182
  var espreeCache = null;
2103
2183
  function isLinterPath(p) {
2104
2184
  return (
2105
2185
  // ESLint 6 and above
2106
- p.includes(`eslint${path4.sep}lib${path4.sep}linter${path4.sep}linter.js`) || // ESLint 5
2107
- p.includes(`eslint${path4.sep}lib${path4.sep}linter.js`)
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`)
2108
2188
  );
2109
2189
  }
2110
2190
  function getEspree() {
@@ -2112,7 +2192,7 @@ function getEspree() {
2112
2192
  const linterPath = Object.keys(__require.cache || {}).find(isLinterPath);
2113
2193
  if (linterPath) {
2114
2194
  try {
2115
- espreeCache = createRequire2(linterPath)("espree");
2195
+ espreeCache = createRequire3(linterPath)("espree");
2116
2196
  } catch {
2117
2197
  }
2118
2198
  }
@@ -2208,7 +2288,7 @@ var ParserOptionsContext = class {
2208
2288
  if (TS_PARSER_NAMES.some((nm) => parserName.includes(nm))) {
2209
2289
  let targetPath = parserName;
2210
2290
  while (targetPath) {
2211
- const pkgPath = path5.join(targetPath, "package.json");
2291
+ const pkgPath = path6.join(targetPath, "package.json");
2212
2292
  if (fs3.existsSync(pkgPath)) {
2213
2293
  try {
2214
2294
  const pkgName = JSON.parse(fs3.readFileSync(pkgPath, "utf-8"))?.name;
@@ -2223,7 +2303,7 @@ var ParserOptionsContext = class {
2223
2303
  return null;
2224
2304
  }
2225
2305
  }
2226
- const parent = path5.dirname(targetPath);
2306
+ const parent = path6.dirname(targetPath);
2227
2307
  if (targetPath === parent) {
2228
2308
  break;
2229
2309
  }
@@ -2626,7 +2706,7 @@ __export(meta_exports, {
2626
2706
 
2627
2707
  // package.json
2628
2708
  var name = "astro-eslint-parser";
2629
- var version = "0.16.2";
2709
+ var version = "0.17.0";
2630
2710
 
2631
2711
  // src/index.ts
2632
2712
  function parseForESLint2(code, options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-eslint-parser",
3
- "version": "0.16.2",
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,25 +70,26 @@
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": "^1.0.0",
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.19.0",
75
- "@typescript-eslint/parser": "~6.19.0",
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",
79
83
  "chai": "^5.0.0",
80
84
  "env-cmd": "^10.1.0",
81
- "esbuild": "^0.19.0",
85
+ "esbuild": "^0.20.0",
82
86
  "esbuild-register": "^3.3.3",
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.31.0",
90
+ "eslint-plugin-astro": "^0.33.0",
87
91
  "eslint-plugin-eslint-comments": "^3.2.0",
88
- "eslint-plugin-json-schema-validator": "^4.0.0",
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,22 +97,22 @@
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": "^10.0.0",
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": "^13.22.0",
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",
103
107
  "mocha-chai-jest-snapshot": "^1.1.3",
104
108
  "nyc": "^15.1.0",
105
109
  "prettier": "^3.0.0",
106
- "prettier-plugin-astro": "^0.12.0",
110
+ "prettier-plugin-astro": "^0.13.0",
107
111
  "prettier-plugin-svelte": "^3.0.0",
108
112
  "string-replace-loader": "^3.0.3",
109
113
  "svelte": "^4.0.0",
110
114
  "tsup": "^8.0.0",
111
- "typescript": "~5.3.0",
115
+ "typescript": "~5.4.0",
112
116
  "typescript-eslint-parser-for-extra-files": "^0.6.0"
113
117
  },
114
118
  "publishConfig": {