astro-eslint-parser 0.16.1 → 0.16.3

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.1";
317
+ var version = "0.16.3";
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.1";
317
+ var version = "0.16.3";
318
318
 
319
319
  declare const meta_name: typeof name;
320
320
  declare const meta_version: typeof version;
package/lib/index.js CHANGED
@@ -1237,10 +1237,13 @@ function processTemplate(ctx, resultTemplate) {
1237
1237
  ]);
1238
1238
  } else if (isTag(node)) {
1239
1239
  if (parent.type === "expression") {
1240
- const index = parent.children.indexOf(node);
1241
- const before = parent.children[index - 1];
1240
+ const siblings = parent.children.filter(
1241
+ (n) => n.type !== "text" || n.value.trim()
1242
+ );
1243
+ const index = siblings.indexOf(node);
1244
+ const before = siblings[index - 1];
1242
1245
  if (!before || !isTag(before)) {
1243
- const after = parent.children[index + 1];
1246
+ const after = siblings[index + 1];
1244
1247
  if (after && (isTag(after) || after.type === "comment")) {
1245
1248
  const start2 = node.position.start.offset;
1246
1249
  script.appendOriginal(start2);
@@ -1472,10 +1475,13 @@ function processTemplate(ctx, resultTemplate) {
1472
1475
  }
1473
1476
  }
1474
1477
  if ((isTag(node) || node.type === "comment") && parent.type === "expression") {
1475
- const index = parent.children.indexOf(node);
1476
- const after = parent.children[index + 1];
1478
+ const siblings = parent.children.filter(
1479
+ (n) => n.type !== "text" || n.value.trim()
1480
+ );
1481
+ const index = siblings.indexOf(node);
1482
+ const after = siblings[index + 1];
1477
1483
  if (!after || !isTag(after) && after.type !== "comment") {
1478
- const before = parent.children[index - 1];
1484
+ const before = siblings[index - 1];
1479
1485
  if (before && (isTag(before) || before.type === "comment")) {
1480
1486
  const end = getEndOffset(node, ctx);
1481
1487
  script.appendOriginal(end);
@@ -1537,54 +1543,42 @@ function processTemplate(ctx, resultTemplate) {
1537
1543
  if (scriptNode.type === import_types.AST_NODE_TYPES.JSXAttribute && scriptNode.range[0] === targetIndex) {
1538
1544
  const baseNameNode = scriptNode.name;
1539
1545
  if (colonOffset != null) {
1540
- const nameNode = {
1541
- ...baseNameNode,
1542
- type: import_types.AST_NODE_TYPES.JSXNamespacedName,
1543
- namespace: {
1544
- type: import_types.AST_NODE_TYPES.JSXIdentifier,
1545
- name: attr.name.slice(0, colonOffset),
1546
- ...ctx.getLocations(
1547
- baseNameNode.range[0],
1548
- baseNameNode.range[0] + colonOffset
1549
- )
1550
- },
1551
- name: {
1552
- type: import_types.AST_NODE_TYPES.JSXIdentifier,
1553
- name: attr.name.slice(colonOffset + 1),
1554
- ...ctx.getLocations(
1555
- baseNameNode.range[0] + colonOffset + 1,
1556
- baseNameNode.range[1]
1557
- )
1558
- }
1546
+ const nameNode = baseNameNode;
1547
+ nameNode.type = import_types.AST_NODE_TYPES.JSXNamespacedName;
1548
+ nameNode.namespace = {
1549
+ type: import_types.AST_NODE_TYPES.JSXIdentifier,
1550
+ name: attr.name.slice(0, colonOffset),
1551
+ ...ctx.getLocations(
1552
+ baseNameNode.range[0],
1553
+ baseNameNode.range[0] + colonOffset
1554
+ )
1555
+ };
1556
+ nameNode.name = {
1557
+ type: import_types.AST_NODE_TYPES.JSXIdentifier,
1558
+ name: attr.name.slice(colonOffset + 1),
1559
+ ...ctx.getLocations(
1560
+ baseNameNode.range[0] + colonOffset + 1,
1561
+ baseNameNode.range[1]
1562
+ )
1559
1563
  };
1560
1564
  scriptNode.name = nameNode;
1561
1565
  nameNode.namespace.parent = nameNode;
1562
1566
  nameNode.name.parent = nameNode;
1563
1567
  } else {
1564
1568
  if (baseNameNode.type === import_types.AST_NODE_TYPES.JSXIdentifier) {
1565
- const nameNode = {
1566
- ...baseNameNode,
1567
- name: attr.name
1568
- };
1569
+ const nameNode = baseNameNode;
1570
+ nameNode.name = attr.name;
1569
1571
  scriptNode.name = nameNode;
1570
1572
  } else {
1571
- const nameNode = {
1572
- ...baseNameNode,
1573
- namespace: {
1574
- ...baseNameNode.namespace,
1575
- name: attr.name.slice(
1576
- baseNameNode.namespace.range[0] - start,
1577
- baseNameNode.namespace.range[1] - start
1578
- )
1579
- },
1580
- name: {
1581
- ...baseNameNode.name,
1582
- name: attr.name.slice(
1583
- baseNameNode.name.range[0] - start,
1584
- baseNameNode.name.range[1] - start
1585
- )
1586
- }
1587
- };
1573
+ const nameNode = baseNameNode;
1574
+ nameNode.namespace.name = attr.name.slice(
1575
+ baseNameNode.namespace.range[0] - start,
1576
+ baseNameNode.namespace.range[1] - start
1577
+ );
1578
+ nameNode.name.name = attr.name.slice(
1579
+ baseNameNode.name.range[0] - start,
1580
+ baseNameNode.name.range[1] - start
1581
+ );
1588
1582
  scriptNode.name = nameNode;
1589
1583
  nameNode.namespace.parent = nameNode;
1590
1584
  nameNode.name.parent = nameNode;
@@ -2661,7 +2655,7 @@ __export(meta_exports, {
2661
2655
 
2662
2656
  // package.json
2663
2657
  var name = "astro-eslint-parser";
2664
- var version = "0.16.1";
2658
+ var version = "0.16.3";
2665
2659
 
2666
2660
  // src/index.ts
2667
2661
  function parseForESLint2(code, options) {
package/lib/index.mjs CHANGED
@@ -1211,10 +1211,13 @@ function processTemplate(ctx, resultTemplate) {
1211
1211
  ]);
1212
1212
  } else if (isTag(node)) {
1213
1213
  if (parent.type === "expression") {
1214
- const index = parent.children.indexOf(node);
1215
- const before = parent.children[index - 1];
1214
+ const siblings = parent.children.filter(
1215
+ (n) => n.type !== "text" || n.value.trim()
1216
+ );
1217
+ const index = siblings.indexOf(node);
1218
+ const before = siblings[index - 1];
1216
1219
  if (!before || !isTag(before)) {
1217
- const after = parent.children[index + 1];
1220
+ const after = siblings[index + 1];
1218
1221
  if (after && (isTag(after) || after.type === "comment")) {
1219
1222
  const start2 = node.position.start.offset;
1220
1223
  script.appendOriginal(start2);
@@ -1446,10 +1449,13 @@ function processTemplate(ctx, resultTemplate) {
1446
1449
  }
1447
1450
  }
1448
1451
  if ((isTag(node) || node.type === "comment") && parent.type === "expression") {
1449
- const index = parent.children.indexOf(node);
1450
- const after = parent.children[index + 1];
1452
+ const siblings = parent.children.filter(
1453
+ (n) => n.type !== "text" || n.value.trim()
1454
+ );
1455
+ const index = siblings.indexOf(node);
1456
+ const after = siblings[index + 1];
1451
1457
  if (!after || !isTag(after) && after.type !== "comment") {
1452
- const before = parent.children[index - 1];
1458
+ const before = siblings[index - 1];
1453
1459
  if (before && (isTag(before) || before.type === "comment")) {
1454
1460
  const end = getEndOffset(node, ctx);
1455
1461
  script.appendOriginal(end);
@@ -1511,54 +1517,42 @@ function processTemplate(ctx, resultTemplate) {
1511
1517
  if (scriptNode.type === AST_NODE_TYPES.JSXAttribute && scriptNode.range[0] === targetIndex) {
1512
1518
  const baseNameNode = scriptNode.name;
1513
1519
  if (colonOffset != null) {
1514
- const nameNode = {
1515
- ...baseNameNode,
1516
- type: AST_NODE_TYPES.JSXNamespacedName,
1517
- namespace: {
1518
- type: AST_NODE_TYPES.JSXIdentifier,
1519
- name: attr.name.slice(0, colonOffset),
1520
- ...ctx.getLocations(
1521
- baseNameNode.range[0],
1522
- baseNameNode.range[0] + colonOffset
1523
- )
1524
- },
1525
- name: {
1526
- type: AST_NODE_TYPES.JSXIdentifier,
1527
- name: attr.name.slice(colonOffset + 1),
1528
- ...ctx.getLocations(
1529
- baseNameNode.range[0] + colonOffset + 1,
1530
- baseNameNode.range[1]
1531
- )
1532
- }
1520
+ const nameNode = baseNameNode;
1521
+ nameNode.type = AST_NODE_TYPES.JSXNamespacedName;
1522
+ nameNode.namespace = {
1523
+ type: AST_NODE_TYPES.JSXIdentifier,
1524
+ name: attr.name.slice(0, colonOffset),
1525
+ ...ctx.getLocations(
1526
+ baseNameNode.range[0],
1527
+ baseNameNode.range[0] + colonOffset
1528
+ )
1529
+ };
1530
+ nameNode.name = {
1531
+ type: AST_NODE_TYPES.JSXIdentifier,
1532
+ name: attr.name.slice(colonOffset + 1),
1533
+ ...ctx.getLocations(
1534
+ baseNameNode.range[0] + colonOffset + 1,
1535
+ baseNameNode.range[1]
1536
+ )
1533
1537
  };
1534
1538
  scriptNode.name = nameNode;
1535
1539
  nameNode.namespace.parent = nameNode;
1536
1540
  nameNode.name.parent = nameNode;
1537
1541
  } else {
1538
1542
  if (baseNameNode.type === AST_NODE_TYPES.JSXIdentifier) {
1539
- const nameNode = {
1540
- ...baseNameNode,
1541
- name: attr.name
1542
- };
1543
+ const nameNode = baseNameNode;
1544
+ nameNode.name = attr.name;
1543
1545
  scriptNode.name = nameNode;
1544
1546
  } else {
1545
- const nameNode = {
1546
- ...baseNameNode,
1547
- namespace: {
1548
- ...baseNameNode.namespace,
1549
- name: attr.name.slice(
1550
- baseNameNode.namespace.range[0] - start,
1551
- baseNameNode.namespace.range[1] - start
1552
- )
1553
- },
1554
- name: {
1555
- ...baseNameNode.name,
1556
- name: attr.name.slice(
1557
- baseNameNode.name.range[0] - start,
1558
- baseNameNode.name.range[1] - start
1559
- )
1560
- }
1561
- };
1547
+ const nameNode = baseNameNode;
1548
+ nameNode.namespace.name = attr.name.slice(
1549
+ baseNameNode.namespace.range[0] - start,
1550
+ baseNameNode.namespace.range[1] - start
1551
+ );
1552
+ nameNode.name.name = attr.name.slice(
1553
+ baseNameNode.name.range[0] - start,
1554
+ baseNameNode.name.range[1] - start
1555
+ );
1562
1556
  scriptNode.name = nameNode;
1563
1557
  nameNode.namespace.parent = nameNode;
1564
1558
  nameNode.name.parent = nameNode;
@@ -2638,7 +2632,7 @@ __export(meta_exports, {
2638
2632
 
2639
2633
  // package.json
2640
2634
  var name = "astro-eslint-parser";
2641
- var version = "0.16.1";
2635
+ var version = "0.16.3";
2642
2636
 
2643
2637
  // src/index.ts
2644
2638
  function parseForESLint2(code, options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-eslint-parser",
3
- "version": "0.16.1",
3
+ "version": "0.16.3",
4
4
  "description": "Astro component parser for ESLint",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.mjs",
@@ -71,14 +71,14 @@
71
71
  "@types/mocha": "^10.0.0",
72
72
  "@types/node": "^20.0.0",
73
73
  "@types/semver": "^7.3.9",
74
- "@typescript-eslint/eslint-plugin": "~6.18.0",
75
- "@typescript-eslint/parser": "~6.18.0",
74
+ "@typescript-eslint/eslint-plugin": "~6.20.0",
75
+ "@typescript-eslint/parser": "~6.20.0",
76
76
  "astro": "^4.0.0",
77
77
  "astro-eslint-parser": ">=0.1.0",
78
78
  "benchmark": "^2.1.4",
79
79
  "chai": "^5.0.0",
80
80
  "env-cmd": "^10.1.0",
81
- "esbuild": "^0.19.0",
81
+ "esbuild": "^0.20.0",
82
82
  "esbuild-register": "^3.3.3",
83
83
  "eslint": "^8.15.0",
84
84
  "eslint-config-prettier": "^9.0.0",
@@ -103,13 +103,13 @@
103
103
  "mocha-chai-jest-snapshot": "^1.1.3",
104
104
  "nyc": "^15.1.0",
105
105
  "prettier": "^3.0.0",
106
- "prettier-plugin-astro": "^0.12.0",
106
+ "prettier-plugin-astro": "^0.13.0",
107
107
  "prettier-plugin-svelte": "^3.0.0",
108
108
  "string-replace-loader": "^3.0.3",
109
109
  "svelte": "^4.0.0",
110
110
  "tsup": "^8.0.0",
111
111
  "typescript": "~5.3.0",
112
- "typescript-eslint-parser-for-extra-files": "^0.5.0"
112
+ "typescript-eslint-parser-for-extra-files": "^0.6.0"
113
113
  },
114
114
  "publishConfig": {
115
115
  "access": "public"