astro-eslint-parser 0.17.0 → 1.0.1

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.17.0";
317
+ var version = "1.0.1";
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.17.0";
317
+ var version = "1.0.1";
318
318
 
319
319
  declare const meta_name: typeof name;
320
320
  declare const meta_version: typeof version;
package/lib/index.js CHANGED
@@ -515,20 +515,80 @@ function isTSESLintParserObject(value) {
515
515
 
516
516
  // src/parser/script.ts
517
517
  var import_scope_manager = require("@typescript-eslint/scope-manager");
518
+ var import_eslint_scope = require("eslint-scope");
519
+
520
+ // src/traverse.ts
521
+ function fallbackKeysFilter(key) {
522
+ let value = null;
523
+ return key !== "comments" && key !== "leadingComments" && key !== "loc" && key !== "parent" && key !== "range" && key !== "tokens" && key !== "trailingComments" && (value = this[key]) !== null && typeof value === "object" && (typeof value.type === "string" || Array.isArray(value));
524
+ }
525
+ function getFallbackKeys(node) {
526
+ return Object.keys(node).filter(fallbackKeysFilter, node);
527
+ }
528
+ function getKeys(node, visitorKeys) {
529
+ const keys = (visitorKeys || KEYS)[node.type] || getFallbackKeys(node);
530
+ return keys.filter((key) => !getNodes(node, key).next().done);
531
+ }
532
+ function* getNodes(node, key) {
533
+ const child = node[key];
534
+ if (Array.isArray(child)) {
535
+ for (const c of child) {
536
+ if (isNode(c)) {
537
+ yield c;
538
+ }
539
+ }
540
+ } else if (isNode(child)) {
541
+ yield child;
542
+ }
543
+ }
544
+ function isNode(x) {
545
+ return x !== null && typeof x === "object" && typeof x.type === "string";
546
+ }
547
+ function traverse(node, parent, visitor) {
548
+ visitor.enterNode(node, parent);
549
+ const keys = getKeys(node, visitor.visitorKeys);
550
+ for (const key of keys) {
551
+ for (const child of getNodes(node, key)) {
552
+ traverse(child, node, visitor);
553
+ }
554
+ }
555
+ visitor.leaveNode(node, parent);
556
+ }
557
+ function traverseNodes(node, visitor) {
558
+ traverse(node, null, visitor);
559
+ }
560
+
561
+ // src/parser/script.ts
518
562
  function parseScript(code, ctx, parserOptionsCtx) {
519
563
  const result = parseScriptInternal(code, ctx, parserOptionsCtx);
520
564
  const parserOptions = parserOptionsCtx.parserOptions;
521
565
  if (!result.scopeManager && parserOptions.eslintScopeManager) {
522
- result.scopeManager = (0, import_scope_manager.analyze)(result.ast, {
523
- ecmaVersion: 1e8,
566
+ result.scopeManager = analyzeScope(result, parserOptions);
567
+ }
568
+ return result;
569
+ }
570
+ function analyzeScope(result, parserOptions) {
571
+ try {
572
+ return (0, import_scope_manager.analyze)(result.ast, {
524
573
  globalReturn: parserOptions.ecmaFeatures?.globalReturn,
525
574
  jsxPragma: parserOptions.jsxPragma,
526
575
  jsxFragmentName: parserOptions.jsxFragmentName,
527
576
  lib: parserOptions.lib,
528
577
  sourceType: parserOptions.sourceType
529
578
  });
579
+ } catch {
530
580
  }
531
- return result;
581
+ const ecmaFeatures = parserOptions.ecmaFeatures || {};
582
+ return (0, import_eslint_scope.analyze)(result.ast, {
583
+ ignoreEval: true,
584
+ nodejsScope: ecmaFeatures.globalReturn,
585
+ impliedStrict: ecmaFeatures.impliedStrict,
586
+ ecmaVersion: 1e8,
587
+ sourceType: parserOptions.sourceType === "commonjs" ? "script" : parserOptions.sourceType || "script",
588
+ // @ts-expect-error -- Type bug?
589
+ childVisitorKeys: result.visitorKeys || KEYS,
590
+ fallback: getKeys
591
+ });
532
592
  }
533
593
  function parseScriptInternal(code, _ctx, parserOptionsCtx) {
534
594
  const parser = parserOptionsCtx.getParser();
@@ -986,47 +1046,6 @@ function getSortedChildren(parent, code) {
986
1046
  return parent.children;
987
1047
  }
988
1048
 
989
- // src/traverse.ts
990
- function fallbackKeysFilter(key) {
991
- let value = null;
992
- return key !== "comments" && key !== "leadingComments" && key !== "loc" && key !== "parent" && key !== "range" && key !== "tokens" && key !== "trailingComments" && (value = this[key]) !== null && typeof value === "object" && (typeof value.type === "string" || Array.isArray(value));
993
- }
994
- function getFallbackKeys(node) {
995
- return Object.keys(node).filter(fallbackKeysFilter, node);
996
- }
997
- function getKeys(node, visitorKeys) {
998
- const keys = (visitorKeys || KEYS)[node.type] || getFallbackKeys(node);
999
- return keys.filter((key) => !getNodes(node, key).next().done);
1000
- }
1001
- function* getNodes(node, key) {
1002
- const child = node[key];
1003
- if (Array.isArray(child)) {
1004
- for (const c of child) {
1005
- if (isNode(c)) {
1006
- yield c;
1007
- }
1008
- }
1009
- } else if (isNode(child)) {
1010
- yield child;
1011
- }
1012
- }
1013
- function isNode(x) {
1014
- return x !== null && typeof x === "object" && typeof x.type === "string";
1015
- }
1016
- function traverse(node, parent, visitor) {
1017
- visitor.enterNode(node, parent);
1018
- const keys = getKeys(node, visitor.visitorKeys);
1019
- for (const key of keys) {
1020
- for (const child of getNodes(node, key)) {
1021
- traverse(child, node, visitor);
1022
- }
1023
- }
1024
- visitor.leaveNode(node, parent);
1025
- }
1026
- function traverseNodes(node, visitor) {
1027
- traverse(node, null, visitor);
1028
- }
1029
-
1030
1049
  // src/context/restore.ts
1031
1050
  var RestoreNodeProcessContext = class {
1032
1051
  constructor(result, nodeMap) {
@@ -2729,7 +2748,7 @@ __export(meta_exports, {
2729
2748
 
2730
2749
  // package.json
2731
2750
  var name = "astro-eslint-parser";
2732
- var version = "0.17.0";
2751
+ var version = "1.0.1";
2733
2752
 
2734
2753
  // src/index.ts
2735
2754
  function parseForESLint2(code, options) {
package/lib/index.mjs CHANGED
@@ -484,21 +484,81 @@ function isTSESLintParserObject(value) {
484
484
  }
485
485
 
486
486
  // src/parser/script.ts
487
- import { analyze } from "@typescript-eslint/scope-manager";
487
+ import { analyze as analyzeForTypeScript } from "@typescript-eslint/scope-manager";
488
+ import { analyze as analyzeForEcmaScript } from "eslint-scope";
489
+
490
+ // src/traverse.ts
491
+ function fallbackKeysFilter(key) {
492
+ let value = null;
493
+ return key !== "comments" && key !== "leadingComments" && key !== "loc" && key !== "parent" && key !== "range" && key !== "tokens" && key !== "trailingComments" && (value = this[key]) !== null && typeof value === "object" && (typeof value.type === "string" || Array.isArray(value));
494
+ }
495
+ function getFallbackKeys(node) {
496
+ return Object.keys(node).filter(fallbackKeysFilter, node);
497
+ }
498
+ function getKeys(node, visitorKeys) {
499
+ const keys = (visitorKeys || KEYS)[node.type] || getFallbackKeys(node);
500
+ return keys.filter((key) => !getNodes(node, key).next().done);
501
+ }
502
+ function* getNodes(node, key) {
503
+ const child = node[key];
504
+ if (Array.isArray(child)) {
505
+ for (const c of child) {
506
+ if (isNode(c)) {
507
+ yield c;
508
+ }
509
+ }
510
+ } else if (isNode(child)) {
511
+ yield child;
512
+ }
513
+ }
514
+ function isNode(x) {
515
+ return x !== null && typeof x === "object" && typeof x.type === "string";
516
+ }
517
+ function traverse(node, parent, visitor) {
518
+ visitor.enterNode(node, parent);
519
+ const keys = getKeys(node, visitor.visitorKeys);
520
+ for (const key of keys) {
521
+ for (const child of getNodes(node, key)) {
522
+ traverse(child, node, visitor);
523
+ }
524
+ }
525
+ visitor.leaveNode(node, parent);
526
+ }
527
+ function traverseNodes(node, visitor) {
528
+ traverse(node, null, visitor);
529
+ }
530
+
531
+ // src/parser/script.ts
488
532
  function parseScript(code, ctx, parserOptionsCtx) {
489
533
  const result = parseScriptInternal(code, ctx, parserOptionsCtx);
490
534
  const parserOptions = parserOptionsCtx.parserOptions;
491
535
  if (!result.scopeManager && parserOptions.eslintScopeManager) {
492
- result.scopeManager = analyze(result.ast, {
493
- ecmaVersion: 1e8,
536
+ result.scopeManager = analyzeScope(result, parserOptions);
537
+ }
538
+ return result;
539
+ }
540
+ function analyzeScope(result, parserOptions) {
541
+ try {
542
+ return analyzeForTypeScript(result.ast, {
494
543
  globalReturn: parserOptions.ecmaFeatures?.globalReturn,
495
544
  jsxPragma: parserOptions.jsxPragma,
496
545
  jsxFragmentName: parserOptions.jsxFragmentName,
497
546
  lib: parserOptions.lib,
498
547
  sourceType: parserOptions.sourceType
499
548
  });
549
+ } catch {
500
550
  }
501
- return result;
551
+ const ecmaFeatures = parserOptions.ecmaFeatures || {};
552
+ return analyzeForEcmaScript(result.ast, {
553
+ ignoreEval: true,
554
+ nodejsScope: ecmaFeatures.globalReturn,
555
+ impliedStrict: ecmaFeatures.impliedStrict,
556
+ ecmaVersion: 1e8,
557
+ sourceType: parserOptions.sourceType === "commonjs" ? "script" : parserOptions.sourceType || "script",
558
+ // @ts-expect-error -- Type bug?
559
+ childVisitorKeys: result.visitorKeys || KEYS,
560
+ fallback: getKeys
561
+ });
502
562
  }
503
563
  function parseScriptInternal(code, _ctx, parserOptionsCtx) {
504
564
  const parser = parserOptionsCtx.getParser();
@@ -960,47 +1020,6 @@ function getSortedChildren(parent, code) {
960
1020
  return parent.children;
961
1021
  }
962
1022
 
963
- // src/traverse.ts
964
- function fallbackKeysFilter(key) {
965
- let value = null;
966
- return key !== "comments" && key !== "leadingComments" && key !== "loc" && key !== "parent" && key !== "range" && key !== "tokens" && key !== "trailingComments" && (value = this[key]) !== null && typeof value === "object" && (typeof value.type === "string" || Array.isArray(value));
967
- }
968
- function getFallbackKeys(node) {
969
- return Object.keys(node).filter(fallbackKeysFilter, node);
970
- }
971
- function getKeys(node, visitorKeys) {
972
- const keys = (visitorKeys || KEYS)[node.type] || getFallbackKeys(node);
973
- return keys.filter((key) => !getNodes(node, key).next().done);
974
- }
975
- function* getNodes(node, key) {
976
- const child = node[key];
977
- if (Array.isArray(child)) {
978
- for (const c of child) {
979
- if (isNode(c)) {
980
- yield c;
981
- }
982
- }
983
- } else if (isNode(child)) {
984
- yield child;
985
- }
986
- }
987
- function isNode(x) {
988
- return x !== null && typeof x === "object" && typeof x.type === "string";
989
- }
990
- function traverse(node, parent, visitor) {
991
- visitor.enterNode(node, parent);
992
- const keys = getKeys(node, visitor.visitorKeys);
993
- for (const key of keys) {
994
- for (const child of getNodes(node, key)) {
995
- traverse(child, node, visitor);
996
- }
997
- }
998
- visitor.leaveNode(node, parent);
999
- }
1000
- function traverseNodes(node, visitor) {
1001
- traverse(node, null, visitor);
1002
- }
1003
-
1004
1023
  // src/context/restore.ts
1005
1024
  var RestoreNodeProcessContext = class {
1006
1025
  constructor(result, nodeMap) {
@@ -2706,7 +2725,7 @@ __export(meta_exports, {
2706
2725
 
2707
2726
  // package.json
2708
2727
  var name = "astro-eslint-parser";
2709
- var version = "0.17.0";
2728
+ var version = "1.0.1";
2710
2729
 
2711
2730
  // src/index.ts
2712
2731
  function parseForESLint2(code, options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-eslint-parser",
3
- "version": "0.17.0",
3
+ "version": "1.0.1",
4
4
  "description": "Astro component parser for ESLint",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.mjs",
@@ -8,7 +8,7 @@
8
8
  "lib"
9
9
  ],
10
10
  "engines": {
11
- "node": "^14.18.0 || >=16.0.0"
11
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
12
12
  },
13
13
  "scripts": {
14
14
  "prebuild": "npm run -s clean",
@@ -49,14 +49,15 @@
49
49
  "homepage": "https://github.com/ota-meshi/astro-eslint-parser#readme",
50
50
  "dependencies": {
51
51
  "@astrojs/compiler": "^2.0.0",
52
- "@typescript-eslint/scope-manager": "^5.0.0",
53
- "@typescript-eslint/types": "^5.0.0",
54
- "@typescript-eslint/typescript-estree": "^5.0.0",
55
- "astrojs-compiler-sync": "^0.3.0",
52
+ "@typescript-eslint/scope-manager": "^7.0.0",
53
+ "@typescript-eslint/types": "^7.0.0",
54
+ "@typescript-eslint/typescript-estree": "^7.0.0",
55
+ "astrojs-compiler-sync": "^1.0.0",
56
56
  "debug": "^4.3.4",
57
57
  "entities": "^4.5.0",
58
- "eslint-visitor-keys": "^3.0.0",
59
- "espree": "^9.0.0",
58
+ "eslint-scope": "^8.0.1",
59
+ "eslint-visitor-keys": "^4.0.0",
60
+ "espree": "^10.0.0",
60
61
  "globby": "^11.1.0",
61
62
  "is-glob": "^4.0.3",
62
63
  "semver": "^7.3.8"
@@ -75,8 +76,8 @@
75
76
  "@types/mocha": "^10.0.0",
76
77
  "@types/node": "^20.0.0",
77
78
  "@types/semver": "^7.3.9",
78
- "@typescript-eslint/eslint-plugin": "~6.21.0",
79
- "@typescript-eslint/parser": "~6.21.0",
79
+ "@typescript-eslint/eslint-plugin": "^7.7.1",
80
+ "@typescript-eslint/parser": "^7.7.1",
80
81
  "astro": "^4.0.0",
81
82
  "astro-eslint-parser": ">=0.1.0",
82
83
  "benchmark": "^2.1.4",
@@ -87,13 +88,13 @@
87
88
  "eslint": "^8.15.0",
88
89
  "eslint-config-prettier": "^9.0.0",
89
90
  "eslint-formatter-codeframe": "^7.32.1",
90
- "eslint-plugin-astro": "^0.33.0",
91
+ "eslint-plugin-astro": "^0.34.0",
91
92
  "eslint-plugin-eslint-comments": "^3.2.0",
92
93
  "eslint-plugin-json-schema-validator": "^5.0.0",
93
94
  "eslint-plugin-jsonc": "^2.0.0",
94
95
  "eslint-plugin-jsx-a11y": "^6.5.1",
95
- "eslint-plugin-n": "^16.0.0",
96
- "eslint-plugin-node-dependencies": "^0.11.0",
96
+ "eslint-plugin-n": "^17.0.0",
97
+ "eslint-plugin-node-dependencies": "^0.12.0",
97
98
  "eslint-plugin-prettier": "^5.0.0",
98
99
  "eslint-plugin-react": "^7.29.4",
99
100
  "eslint-plugin-regexp": "^2.0.0",