@plugjs/eslint-plugin 0.2.3 → 0.2.5

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.
@@ -180,7 +180,7 @@ var require_package = __commonJS({
180
180
  "node_modules/eslint-plugin-import-x/package.json"(exports2, module2) {
181
181
  module2.exports = {
182
182
  name: "eslint-plugin-import-x",
183
- version: "3.0.0",
183
+ version: "3.0.1",
184
184
  description: "Import with sanity.",
185
185
  repository: "git+https://github.com/un-ts/eslint-plugin-import-x",
186
186
  author: "JounQin <admin@1stg.me> (https://www.1stG.me)",
@@ -228,6 +228,7 @@ var require_package = __commonJS({
228
228
  eslint: "^8.56.0 || ^9.0.0-0"
229
229
  },
230
230
  dependencies: {
231
+ "@rtsao/scc": "^1.1.0",
231
232
  "@typescript-eslint/utils": "^7.4.0",
232
233
  debug: "^4.3.4",
233
234
  doctrine: "^3.0.0",
@@ -368,52 +369,6 @@ var require_get_value = __commonJS({
368
369
  }
369
370
  });
370
371
 
371
- // node_modules/eslint-plugin-import-x/lib/utils/hash.js
372
- var require_hash = __commonJS({
373
- "node_modules/eslint-plugin-import-x/lib/utils/hash.js"(exports2) {
374
- "use strict";
375
- Object.defineProperty(exports2, "__esModule", { value: true });
376
- exports2.hashObject = exports2.hashArray = exports2.hashify = void 0;
377
- var node_crypto_1 = require("node:crypto");
378
- function hashify(value, hash) {
379
- hash !== null && hash !== void 0 ? hash : hash = (0, node_crypto_1.createHash)("sha256");
380
- if (Array.isArray(value)) {
381
- hashArray(value, hash);
382
- } else if (value instanceof Object) {
383
- hashObject(value, hash);
384
- } else {
385
- hash.update(JSON.stringify(value) || "undefined");
386
- }
387
- return hash;
388
- }
389
- exports2.hashify = hashify;
390
- function hashArray(array, hash) {
391
- hash !== null && hash !== void 0 ? hash : hash = (0, node_crypto_1.createHash)("sha256");
392
- hash.update("[");
393
- for (const element of array) {
394
- hashify(element, hash);
395
- hash.update(",");
396
- }
397
- hash.update("]");
398
- return hash;
399
- }
400
- exports2.hashArray = hashArray;
401
- function hashObject(object, hash) {
402
- hash !== null && hash !== void 0 ? hash : hash = (0, node_crypto_1.createHash)("sha256");
403
- hash.update("{");
404
- for (const key of Object.keys(object).sort()) {
405
- hash.update(JSON.stringify(key));
406
- hash.update(":");
407
- hashify(object[key], hash);
408
- hash.update(",");
409
- }
410
- hash.update("}");
411
- return hash;
412
- }
413
- exports2.hashObject = hashObject;
414
- }
415
- });
416
-
417
372
  // node_modules/eslint-plugin-import-x/lib/utils/ignore.js
418
373
  var require_ignore = __commonJS({
419
374
  "node_modules/eslint-plugin-import-x/lib/utils/ignore.js"(exports2) {
@@ -449,15 +404,16 @@ var require_ignore = __commonJS({
449
404
  return exts;
450
405
  }
451
406
  exports2.getFileExtensions = getFileExtensions;
452
- function ignore(filepath, context) {
453
- if (!hasValidExtension(filepath, context)) {
407
+ function ignore(filepath, context, skipExtensionCheck = false) {
408
+ if (!skipExtensionCheck && !hasValidExtension(filepath, context)) {
454
409
  return true;
455
410
  }
456
411
  const ignoreStrings = context.settings["import-x/ignore"];
457
412
  if (!(ignoreStrings === null || ignoreStrings === void 0 ? void 0 : ignoreStrings.length)) {
458
413
  return false;
459
414
  }
460
- for (const ignoreString of ignoreStrings) {
415
+ for (let i = 0, len = ignoreStrings.length; i < len; i++) {
416
+ const ignoreString = ignoreStrings[i];
461
417
  const regex = new RegExp(ignoreString);
462
418
  if (regex.test(filepath)) {
463
419
  log(`ignoring ${filepath}, matched pattern /${ignoreString}/`);
@@ -474,6 +430,48 @@ var require_ignore = __commonJS({
474
430
  }
475
431
  });
476
432
 
433
+ // node_modules/eslint-plugin-import-x/lib/utils/lazy-value.js
434
+ var require_lazy_value = __commonJS({
435
+ "node_modules/eslint-plugin-import-x/lib/utils/lazy-value.js"(exports2) {
436
+ "use strict";
437
+ Object.defineProperty(exports2, "__esModule", { value: true });
438
+ exports2.defineLazyProperty = exports2.lazy = void 0;
439
+ var lazy = (cb) => {
440
+ let isCalled = false;
441
+ let result;
442
+ return () => {
443
+ if (!isCalled) {
444
+ isCalled = true;
445
+ result = cb();
446
+ }
447
+ return result;
448
+ };
449
+ };
450
+ exports2.lazy = lazy;
451
+ function defineLazyProperty(object, propertyName, valueGetter) {
452
+ const define = (value) => Object.defineProperty(object, propertyName, {
453
+ value,
454
+ enumerable: true,
455
+ writable: true
456
+ });
457
+ Object.defineProperty(object, propertyName, {
458
+ configurable: true,
459
+ enumerable: true,
460
+ get() {
461
+ const result = valueGetter();
462
+ define(result);
463
+ return result;
464
+ },
465
+ set(value) {
466
+ define(value);
467
+ }
468
+ });
469
+ return object;
470
+ }
471
+ exports2.defineLazyProperty = defineLazyProperty;
472
+ }
473
+ });
474
+
477
475
  // node_modules/eslint-plugin-import-x/lib/utils/module-require.js
478
476
  var require_module_require = __commonJS({
479
477
  "node_modules/eslint-plugin-import-x/lib/utils/module-require.js"(exports2) {
@@ -647,7 +645,7 @@ var require_module_cache = __commonJS({
647
645
  }
648
646
  static getSettings(settings) {
649
647
  const cacheSettings = Object.assign({ lifetime: 30 }, settings["import-x/cache"]);
650
- if (["\u221E", "Infinity"].includes(cacheSettings.lifetime)) {
648
+ if (typeof cacheSettings.lifetime === "string" && ["\u221E", "Infinity"].includes(cacheSettings.lifetime)) {
651
649
  cacheSettings.lifetime = Number.POSITIVE_INFINITY;
652
650
  }
653
651
  return cacheSettings;
@@ -715,7 +713,7 @@ var require_resolve = __commonJS({
715
713
  var node_fs_1 = tslib_12.__importDefault(require("node:fs"));
716
714
  var node_module_1 = require("node:module");
717
715
  var node_path_1 = tslib_12.__importDefault(require("node:path"));
718
- var hash_1 = require_hash();
716
+ var stable_hash_1 = tslib_12.__importDefault(require("stable-hash"));
719
717
  var module_cache_1 = require_module_cache();
720
718
  var pkg_dir_1 = require_pkg_dir();
721
719
  exports2.CASE_SENSITIVE_FS = !node_fs_1.default.existsSync(node_path_1.default.resolve(__dirname, node_path_1.default.basename(__filename).replace(/^resolve\./, "reSOLVE.")));
@@ -776,7 +774,7 @@ var require_resolve = __commonJS({
776
774
  }
777
775
  const sourceDir = node_path_1.default.dirname(sourceFile);
778
776
  if (prevSettings !== settings) {
779
- memoizedHash = (0, hash_1.hashObject)(settings).digest("hex");
777
+ memoizedHash = (0, stable_hash_1.default)(settings);
780
778
  prevSettings = settings;
781
779
  }
782
780
  const cacheKey = sourceDir + memoizedHash + modulePath;
@@ -957,7 +955,7 @@ var require_export_map = __commonJS({
957
955
  "node_modules/eslint-plugin-import-x/lib/utils/export-map.js"(exports2) {
958
956
  "use strict";
959
957
  Object.defineProperty(exports2, "__esModule", { value: true });
960
- exports2.recursivePatternCapture = exports2.ExportMap = void 0;
958
+ exports2.childContext = exports2.recursivePatternCapture = exports2.ExportMap = void 0;
961
959
  var tslib_12 = require("tslib");
962
960
  var node_fs_1 = tslib_12.__importDefault(require("node:fs"));
963
961
  var node_path_1 = tslib_12.__importDefault(require("node:path"));
@@ -967,8 +965,8 @@ var require_export_map = __commonJS({
967
965
  var get_tsconfig_1 = require("get-tsconfig");
968
966
  var stable_hash_1 = tslib_12.__importDefault(require("stable-hash"));
969
967
  var get_value_1 = require_get_value();
970
- var hash_1 = require_hash();
971
968
  var ignore_1 = require_ignore();
969
+ var lazy_value_1 = require_lazy_value();
972
970
  var parse_1 = require_parse();
973
971
  var resolve_1 = require_resolve();
974
972
  var unambiguous_12 = require_unambiguous();
@@ -976,23 +974,36 @@ var require_export_map = __commonJS({
976
974
  var log = (0, debug_1.default)("eslint-plugin-import-x:ExportMap");
977
975
  var exportCache = /* @__PURE__ */ new Map();
978
976
  var tsconfigCache = /* @__PURE__ */ new Map();
977
+ var declTypes = /* @__PURE__ */ new Set([
978
+ "VariableDeclaration",
979
+ "ClassDeclaration",
980
+ "TSDeclareFunction",
981
+ "TSEnumDeclaration",
982
+ "TSTypeAliasDeclaration",
983
+ "TSInterfaceDeclaration",
984
+ "TSAbstractClassDeclaration",
985
+ "TSModuleDeclaration"
986
+ ]);
979
987
  var ExportMap = class _ExportMap {
980
988
  static for(context) {
981
- const { path: filepath } = context;
982
- const cacheKey = context.cacheKey || (0, hash_1.hashObject)(context).digest("hex");
989
+ const filepath = context.path;
990
+ const cacheKey = context.cacheKey;
983
991
  let exportMap = exportCache.get(cacheKey);
984
- if (exportMap === null) {
985
- return null;
986
- }
987
- const stats = node_fs_1.default.statSync(context.path);
988
- if (exportMap != null && exportMap.mtime.valueOf() - stats.mtime.valueOf() === 0) {
989
- return exportMap;
992
+ const stats = (0, lazy_value_1.lazy)(() => node_fs_1.default.statSync(filepath));
993
+ if (exportCache.has(cacheKey)) {
994
+ const exportMap2 = exportCache.get(cacheKey);
995
+ if (exportMap2 === null) {
996
+ return null;
997
+ }
998
+ if (exportMap2 != null && exportMap2.mtime - stats().mtime.valueOf() === 0) {
999
+ return exportMap2;
1000
+ }
990
1001
  }
991
1002
  if (!(0, ignore_1.hasValidExtension)(filepath, context)) {
992
1003
  exportCache.set(cacheKey, null);
993
1004
  return null;
994
1005
  }
995
- if ((0, ignore_1.ignore)(filepath, context)) {
1006
+ if ((0, ignore_1.ignore)(filepath, context, true)) {
996
1007
  log("ignored path due to ignore settings:", filepath);
997
1008
  exportCache.set(cacheKey, null);
998
1009
  return null;
@@ -1005,12 +1016,12 @@ var require_export_map = __commonJS({
1005
1016
  }
1006
1017
  log("cache miss", cacheKey, "for path", filepath);
1007
1018
  exportMap = _ExportMap.parse(filepath, content, context);
1008
- if (exportMap == null) {
1019
+ if (exportMap === null) {
1009
1020
  log("ignored path due to ambiguous parse:", filepath);
1010
1021
  exportCache.set(cacheKey, null);
1011
1022
  return null;
1012
1023
  }
1013
- exportMap.mtime = stats.mtime;
1024
+ exportMap.mtime = stats().mtime.valueOf();
1014
1025
  exportCache.set(cacheKey, exportMap);
1015
1026
  return exportMap;
1016
1027
  }
@@ -1024,7 +1035,7 @@ var require_export_map = __commonJS({
1024
1035
  static parse(filepath, content, context) {
1025
1036
  var _a, _b;
1026
1037
  const m = new _ExportMap(filepath);
1027
- const isEsModuleInteropTrue = isEsModuleInterop();
1038
+ const isEsModuleInteropTrue = (0, lazy_value_1.lazy)(isEsModuleInterop);
1028
1039
  let ast;
1029
1040
  let visitorKeys;
1030
1041
  try {
@@ -1071,8 +1082,8 @@ var require_export_map = __commonJS({
1071
1082
  }
1072
1083
  }
1073
1084
  });
1074
- const unambiguouslyESM = (0, unambiguous_12.isUnambiguousModule)(ast);
1075
- if (!unambiguouslyESM && !hasDynamicImports) {
1085
+ const unambiguouslyESM = (0, lazy_value_1.lazy)(() => (0, unambiguous_12.isUnambiguousModule)(ast));
1086
+ if (!hasDynamicImports && !unambiguouslyESM()) {
1076
1087
  return null;
1077
1088
  }
1078
1089
  const docStyles = context.settings && context.settings["import-x/docstyle"] || ["jsdoc"];
@@ -1080,22 +1091,6 @@ var require_export_map = __commonJS({
1080
1091
  for (const style of docStyles) {
1081
1092
  docStyleParsers[style] = availableDocStyleParsers[style];
1082
1093
  }
1083
- if (ast.comments) {
1084
- ast.comments.some((c) => {
1085
- if (c.type !== "Block") {
1086
- return false;
1087
- }
1088
- try {
1089
- const doc = doctrine_1.default.parse(c.value, { unwrap: true });
1090
- if (doc.tags.some((t) => t.title === "module")) {
1091
- m.doc = doc;
1092
- return true;
1093
- }
1094
- } catch (_a2) {
1095
- }
1096
- return false;
1097
- });
1098
- }
1099
1094
  const namespaces = /* @__PURE__ */ new Map();
1100
1095
  function remotePath(value) {
1101
1096
  return (0, resolve_1.relative)(value, filepath, context.settings);
@@ -1207,17 +1202,17 @@ var require_export_map = __commonJS({
1207
1202
  m.imports.set(p, { getter, declarations: /* @__PURE__ */ new Set([declarationMetadata]) });
1208
1203
  return getter;
1209
1204
  }
1210
- const source = makeSourceCode(content, ast);
1205
+ const source = new eslint_1.SourceCode({ text: content, ast });
1211
1206
  function isEsModuleInterop() {
1207
+ var _a2, _b2;
1212
1208
  const parserOptions = context.parserOptions || {};
1213
1209
  let tsconfigRootDir = parserOptions.tsconfigRootDir;
1214
1210
  const project = parserOptions.project;
1215
- const cacheKey = (0, hash_1.hashObject)({
1216
- tsconfigRootDir,
1217
- project
1218
- }).digest("hex");
1219
- let tsConfig = tsconfigCache.get(cacheKey);
1220
- if (tsConfig === void 0) {
1211
+ const cacheKey = (0, stable_hash_1.default)({ tsconfigRootDir, project });
1212
+ let tsConfig;
1213
+ if (tsconfigCache.has(cacheKey)) {
1214
+ tsConfig = tsconfigCache.get(cacheKey);
1215
+ } else {
1221
1216
  tsconfigRootDir = tsconfigRootDir || process.cwd();
1222
1217
  let tsconfigResult;
1223
1218
  if (project) {
@@ -1234,7 +1229,7 @@ var require_export_map = __commonJS({
1234
1229
  tsConfig = tsconfigResult && tsconfigResult.config || null;
1235
1230
  tsconfigCache.set(cacheKey, tsConfig);
1236
1231
  }
1237
- return tsConfig && tsConfig.compilerOptions ? tsConfig.compilerOptions.esModuleInterop : false;
1232
+ return (_b2 = (_a2 = tsConfig === null || tsConfig === void 0 ? void 0 : tsConfig.compilerOptions) === null || _a2 === void 0 ? void 0 : _a2.esModuleInterop) !== null && _b2 !== void 0 ? _b2 : false;
1238
1233
  }
1239
1234
  for (const n of ast.body) {
1240
1235
  if (n.type === "ExportDefaultDeclaration") {
@@ -1297,21 +1292,11 @@ var require_export_map = __commonJS({
1297
1292
  }
1298
1293
  }
1299
1294
  const exports3 = ["TSExportAssignment"];
1300
- if (isEsModuleInteropTrue) {
1295
+ if (isEsModuleInteropTrue()) {
1301
1296
  exports3.push("TSNamespaceExportDeclaration");
1302
1297
  }
1303
1298
  if (exports3.includes(n.type)) {
1304
1299
  const exportedName = n.type === "TSNamespaceExportDeclaration" ? (n.id || n.name).name : "expression" in n && n.expression && ("name" in n.expression && n.expression.name || "id" in n.expression && n.expression.id && n.expression.id.name) || null;
1305
- const declTypes = /* @__PURE__ */ new Set([
1306
- "VariableDeclaration",
1307
- "ClassDeclaration",
1308
- "TSDeclareFunction",
1309
- "TSEnumDeclaration",
1310
- "TSTypeAliasDeclaration",
1311
- "TSInterfaceDeclaration",
1312
- "TSAbstractClassDeclaration",
1313
- "TSModuleDeclaration"
1314
- ]);
1315
1300
  const getRoot = (node) => {
1316
1301
  if (node.left.type === "TSQualifiedName") {
1317
1302
  return getRoot(node.left);
@@ -1325,7 +1310,7 @@ var require_export_map = __commonJS({
1325
1310
  m.namespace.set("default", captureDoc(source, docStyleParsers, n));
1326
1311
  continue;
1327
1312
  }
1328
- if (isEsModuleInteropTrue && !m.namespace.has("default")) {
1313
+ if (isEsModuleInteropTrue() && !m.namespace.has("default")) {
1329
1314
  m.namespace.set("default", {});
1330
1315
  }
1331
1316
  for (const decl of exportedDecls) {
@@ -1360,12 +1345,33 @@ var require_export_map = __commonJS({
1360
1345
  }
1361
1346
  }
1362
1347
  }
1363
- if (isEsModuleInteropTrue && m.namespace.size > 0 && !m.namespace.has("default")) {
1348
+ (0, lazy_value_1.defineLazyProperty)(m, "doc", () => {
1349
+ if (ast.comments) {
1350
+ for (let i = 0, len = ast.comments.length; i < len; i++) {
1351
+ const c = ast.comments[i];
1352
+ if (c.type !== "Block") {
1353
+ continue;
1354
+ }
1355
+ try {
1356
+ const doc = doctrine_1.default.parse(c.value, { unwrap: true });
1357
+ if (doc.tags.some((t) => t.title === "module")) {
1358
+ return doc;
1359
+ }
1360
+ } catch (_a2) {
1361
+ }
1362
+ }
1363
+ }
1364
+ });
1365
+ if (isEsModuleInteropTrue() && m.namespace.size > 0 && !m.namespace.has("default")) {
1364
1366
  m.namespace.set("default", {});
1365
1367
  }
1366
- if (unambiguouslyESM) {
1367
- m.parseGoal = "Module";
1368
- }
1368
+ const prevParseGoal = m.parseGoal;
1369
+ (0, lazy_value_1.defineLazyProperty)(m, "parseGoal", () => {
1370
+ if (prevParseGoal !== "Module" && unambiguouslyESM()) {
1371
+ return "Module";
1372
+ }
1373
+ return prevParseGoal;
1374
+ });
1369
1375
  return m;
1370
1376
  }
1371
1377
  constructor(path) {
@@ -1514,29 +1520,32 @@ var require_export_map = __commonJS({
1514
1520
  exports2.ExportMap = ExportMap;
1515
1521
  function captureDoc(source, docStyleParsers, ...nodes) {
1516
1522
  const metadata = {};
1517
- nodes.some((n) => {
1518
- if (!n) {
1519
- return false;
1520
- }
1521
- try {
1522
- let leadingComments;
1523
- if ("leadingComments" in n && Array.isArray(n.leadingComments)) {
1524
- leadingComments = n.leadingComments;
1525
- } else if (n.range) {
1526
- leadingComments = source.getCommentsBefore(n);
1527
- }
1528
- if (!leadingComments || leadingComments.length === 0) {
1529
- return false;
1523
+ (0, lazy_value_1.defineLazyProperty)(metadata, "doc", () => {
1524
+ for (let i = 0, len = nodes.length; i < len; i++) {
1525
+ const n = nodes[i];
1526
+ if (!n) {
1527
+ continue;
1530
1528
  }
1531
- for (const parser of Object.values(docStyleParsers)) {
1532
- const doc = parser(leadingComments);
1533
- if (doc) {
1534
- metadata.doc = doc;
1529
+ try {
1530
+ let leadingComments;
1531
+ if ("leadingComments" in n && Array.isArray(n.leadingComments)) {
1532
+ leadingComments = n.leadingComments;
1533
+ } else if (n.range) {
1534
+ leadingComments = source.getCommentsBefore(n);
1535
+ }
1536
+ if (!leadingComments || leadingComments.length === 0) {
1537
+ continue;
1538
+ }
1539
+ for (const parser of Object.values(docStyleParsers)) {
1540
+ const doc = parser(leadingComments);
1541
+ if (doc) {
1542
+ return doc;
1543
+ }
1535
1544
  }
1545
+ return;
1546
+ } catch (_a) {
1547
+ continue;
1536
1548
  }
1537
- return true;
1538
- } catch (_a) {
1539
- return false;
1540
1549
  }
1541
1550
  });
1542
1551
  return metadata;
@@ -1546,17 +1555,16 @@ var require_export_map = __commonJS({
1546
1555
  tomdoc: captureTomDoc
1547
1556
  };
1548
1557
  function captureJsDoc(comments) {
1549
- let doc;
1550
- for (const comment of comments) {
1558
+ for (let i = comments.length - 1; i >= 0; i--) {
1559
+ const comment = comments[i];
1551
1560
  if (comment.type !== "Block") {
1552
1561
  continue;
1553
1562
  }
1554
1563
  try {
1555
- doc = doctrine_1.default.parse(comment.value, { unwrap: true });
1564
+ return doctrine_1.default.parse(comment.value, { unwrap: true });
1556
1565
  } catch (_a) {
1557
1566
  }
1558
1567
  }
1559
- return doc;
1560
1568
  }
1561
1569
  function captureTomDoc(comments) {
1562
1570
  const lines = [];
@@ -1626,7 +1634,7 @@ var require_export_map = __commonJS({
1626
1634
  function childContext(path, context) {
1627
1635
  const { settings, parserOptions, parserPath, languageOptions } = context;
1628
1636
  return {
1629
- cacheKey: makeContextCacheKey(context) + String(path),
1637
+ cacheKey: makeContextCacheKey(context) + path,
1630
1638
  settings,
1631
1639
  parserOptions,
1632
1640
  parserPath,
@@ -1635,6 +1643,7 @@ var require_export_map = __commonJS({
1635
1643
  filename: "physicalFilename" in context ? context.physicalFilename : context.filename
1636
1644
  };
1637
1645
  }
1646
+ exports2.childContext = childContext;
1638
1647
  function makeContextCacheKey(context) {
1639
1648
  var _a, _b, _c;
1640
1649
  const { settings, parserPath, parserOptions, languageOptions } = context;
@@ -1645,12 +1654,52 @@ var require_export_map = __commonJS({
1645
1654
  hash += (0, stable_hash_1.default)((_c = parserPath !== null && parserPath !== void 0 ? parserPath : (_b = languageOptions === null || languageOptions === void 0 ? void 0 : languageOptions.parser) === null || _b === void 0 ? void 0 : _b.meta) !== null && _c !== void 0 ? _c : languageOptions === null || languageOptions === void 0 ? void 0 : languageOptions.parser);
1646
1655
  return hash;
1647
1656
  }
1648
- function makeSourceCode(text, ast) {
1649
- if (eslint_1.SourceCode.length > 1) {
1650
- return new eslint_1.SourceCode(text, ast);
1657
+ }
1658
+ });
1659
+
1660
+ // node_modules/eslint-plugin-import-x/lib/utils/hash.js
1661
+ var require_hash = __commonJS({
1662
+ "node_modules/eslint-plugin-import-x/lib/utils/hash.js"(exports2) {
1663
+ "use strict";
1664
+ Object.defineProperty(exports2, "__esModule", { value: true });
1665
+ exports2.hashObject = exports2.hashArray = exports2.hashify = void 0;
1666
+ var node_crypto_1 = require("node:crypto");
1667
+ function hashify(value, hash) {
1668
+ hash !== null && hash !== void 0 ? hash : hash = (0, node_crypto_1.createHash)("sha256");
1669
+ if (Array.isArray(value)) {
1670
+ hashArray(value, hash);
1671
+ } else if (value instanceof Object) {
1672
+ hashObject(value, hash);
1673
+ } else {
1674
+ hash.update(JSON.stringify(value) || "undefined");
1651
1675
  }
1652
- return new eslint_1.SourceCode({ text, ast });
1676
+ return hash;
1677
+ }
1678
+ exports2.hashify = hashify;
1679
+ function hashArray(array, hash) {
1680
+ hash !== null && hash !== void 0 ? hash : hash = (0, node_crypto_1.createHash)("sha256");
1681
+ hash.update("[");
1682
+ for (const element of array) {
1683
+ hashify(element, hash);
1684
+ hash.update(",");
1685
+ }
1686
+ hash.update("]");
1687
+ return hash;
1653
1688
  }
1689
+ exports2.hashArray = hashArray;
1690
+ function hashObject(object, hash) {
1691
+ hash !== null && hash !== void 0 ? hash : hash = (0, node_crypto_1.createHash)("sha256");
1692
+ hash.update("{");
1693
+ for (const key of Object.keys(object).sort()) {
1694
+ hash.update(JSON.stringify(key));
1695
+ hash.update(":");
1696
+ hashify(object[key], hash);
1697
+ hash.update(",");
1698
+ }
1699
+ hash.update("}");
1700
+ return hash;
1701
+ }
1702
+ exports2.hashObject = hashObject;
1654
1703
  }
1655
1704
  });
1656
1705
 
@@ -1764,9 +1813,6 @@ var require_import_type = __commonJS({
1764
1813
  }
1765
1814
  exports2.isBuiltIn = isBuiltIn;
1766
1815
  function isExternalModule(name, modulePath, context) {
1767
- if (arguments.length < 3) {
1768
- throw new TypeError("isExternalModule: name, path, and context are all required");
1769
- }
1770
1816
  return (isModule(name) || isScoped(name)) && typeTest(name, context, modulePath) === "external";
1771
1817
  }
1772
1818
  exports2.isExternalModule = isExternalModule;
@@ -2022,6 +2068,86 @@ var require_module_visitor = __commonJS({
2022
2068
  }
2023
2069
  });
2024
2070
 
2071
+ // node_modules/eslint-plugin-import-x/lib/utils/scc.js
2072
+ var require_scc = __commonJS({
2073
+ "node_modules/eslint-plugin-import-x/lib/utils/scc.js"(exports2) {
2074
+ "use strict";
2075
+ Object.defineProperty(exports2, "__esModule", { value: true });
2076
+ exports2.StronglyConnectedComponents = void 0;
2077
+ var tslib_12 = require("tslib");
2078
+ var scc_1 = tslib_12.__importDefault(require("@rtsao/scc"));
2079
+ var export_map_1 = require_export_map();
2080
+ var resolve_1 = require_resolve();
2081
+ var cache = /* @__PURE__ */ new Map();
2082
+ exports2.StronglyConnectedComponents = {
2083
+ clearCache() {
2084
+ cache.clear();
2085
+ },
2086
+ get(source, context) {
2087
+ const path = (0, resolve_1.resolve)(source, context);
2088
+ if (path == null) {
2089
+ return null;
2090
+ }
2091
+ return exports2.StronglyConnectedComponents.for((0, export_map_1.childContext)(path, context));
2092
+ },
2093
+ for(context) {
2094
+ const cacheKey = context.cacheKey;
2095
+ if (cache.has(cacheKey)) {
2096
+ return cache.get(cacheKey);
2097
+ }
2098
+ const scc = exports2.StronglyConnectedComponents.calculate(context);
2099
+ cache.set(cacheKey, scc);
2100
+ return scc;
2101
+ },
2102
+ calculate(context) {
2103
+ const exportMap = export_map_1.ExportMap.for(context);
2104
+ const adjacencyList = exports2.StronglyConnectedComponents.exportMapToAdjacencyList(exportMap);
2105
+ const calculatedScc = (0, scc_1.default)(adjacencyList);
2106
+ return exports2.StronglyConnectedComponents.calculatedSccToPlainObject(calculatedScc);
2107
+ },
2108
+ exportMapToAdjacencyList(initialExportMap) {
2109
+ const adjacencyList = /* @__PURE__ */ new Map();
2110
+ function visitNode(exportMap) {
2111
+ if (!exportMap) {
2112
+ return;
2113
+ }
2114
+ for (const [importedPath, v] of exportMap.imports.entries()) {
2115
+ const from = exportMap.path;
2116
+ const to = importedPath;
2117
+ if (!adjacencyList.has(from)) {
2118
+ adjacencyList.set(from, /* @__PURE__ */ new Set());
2119
+ }
2120
+ const set = adjacencyList.get(from);
2121
+ if (set.has(to)) {
2122
+ continue;
2123
+ }
2124
+ set.add(to);
2125
+ visitNode(v.getter());
2126
+ }
2127
+ }
2128
+ visitNode(initialExportMap);
2129
+ adjacencyList.forEach((values) => {
2130
+ values.forEach((value) => {
2131
+ if (!adjacencyList.has(value)) {
2132
+ adjacencyList.set(value, /* @__PURE__ */ new Set());
2133
+ }
2134
+ });
2135
+ });
2136
+ return adjacencyList;
2137
+ },
2138
+ calculatedSccToPlainObject(sccs) {
2139
+ const obj = {};
2140
+ for (const [index, scc] of sccs.entries()) {
2141
+ for (const node of scc) {
2142
+ obj[node] = index;
2143
+ }
2144
+ }
2145
+ return obj;
2146
+ }
2147
+ };
2148
+ }
2149
+ });
2150
+
2025
2151
  // node_modules/eslint-plugin-import-x/lib/utils/static-require.js
2026
2152
  var require_static_require = __commonJS({
2027
2153
  "node_modules/eslint-plugin-import-x/lib/utils/static-require.js"(exports2) {
@@ -2060,6 +2186,7 @@ var require_utils = __commonJS({
2060
2186
  tslib_12.__exportStar(require_pkg_up(), exports2);
2061
2187
  tslib_12.__exportStar(require_read_pkg_up(), exports2);
2062
2188
  tslib_12.__exportStar(require_resolve(), exports2);
2189
+ tslib_12.__exportStar(require_scc(), exports2);
2063
2190
  tslib_12.__exportStar(require_static_require(), exports2);
2064
2191
  tslib_12.__exportStar(require_unambiguous(), exports2);
2065
2192
  tslib_12.__exportStar(require_visit(), exports2);
@@ -4166,7 +4293,8 @@ var require_no_cycle = __commonJS({
4166
4293
  }
4167
4294
  const options = context.options[0] || {};
4168
4295
  const maxDepth = typeof options.maxDepth === "number" ? options.maxDepth : Number.POSITIVE_INFINITY;
4169
- const ignoreModule = (name) => options.ignoreExternal && (0, utils_1.isExternalModule)(name, (0, utils_1.resolve)(name, context), context);
4296
+ const ignoreModule = options.ignoreExternal ? (name) => (0, utils_1.isExternalModule)(name, (0, utils_1.resolve)(name, context), context) : () => false;
4297
+ const scc = utils_1.StronglyConnectedComponents.get(filename, context);
4170
4298
  return Object.assign(Object.assign({}, (0, utils_1.moduleVisitor)(function checkSourceValue(sourceNode, importer) {
4171
4299
  if (ignoreModule(sourceNode.value)) {
4172
4300
  return;
@@ -4184,6 +4312,12 @@ var require_no_cycle = __commonJS({
4184
4312
  if (imported.path === filename) {
4185
4313
  return;
4186
4314
  }
4315
+ if (scc) {
4316
+ const hasDependencyCycle = scc[filename] === scc[imported.path];
4317
+ if (!hasDependencyCycle) {
4318
+ return;
4319
+ }
4320
+ }
4187
4321
  const untraversed = [{ mget: () => imported, route: [] }];
4188
4322
  function detectCycle({ mget, route }) {
4189
4323
  const m = mget();
@@ -4444,27 +4578,6 @@ var require_no_deprecated = __commonJS({
4444
4578
  }
4445
4579
  });
4446
4580
 
4447
- // node_modules/eslint-plugin-import-x/lib/utils/lazy-value.js
4448
- var require_lazy_value = __commonJS({
4449
- "node_modules/eslint-plugin-import-x/lib/utils/lazy-value.js"(exports2) {
4450
- "use strict";
4451
- Object.defineProperty(exports2, "__esModule", { value: true });
4452
- exports2.lazy = void 0;
4453
- var lazy = (cb) => {
4454
- let isCalled = false;
4455
- let result;
4456
- return () => {
4457
- if (!isCalled) {
4458
- isCalled = true;
4459
- result = cb();
4460
- }
4461
- return result;
4462
- };
4463
- };
4464
- exports2.lazy = lazy;
4465
- }
4466
- });
4467
-
4468
4581
  // node_modules/eslint-plugin-import-x/lib/rules/no-duplicates.js
4469
4582
  var require_no_duplicates = __commonJS({
4470
4583
  "node_modules/eslint-plugin-import-x/lib/rules/no-duplicates.js"(exports2, module2) {
package/eslint.config.mjs CHANGED
@@ -33,7 +33,10 @@ export * from './configs/javascript.mjs'
33
33
  * * `plugjs-typescript`: our rules overriding `typescript-eslint/recommended`.
34
34
  */
35
35
  export default [
36
- js.configs.recommended,
36
+ { // give a name to this config before we go completely nuts!
37
+ name: 'eslint/js/recommended',
38
+ ...js.configs.recommended,
39
+ },
37
40
  ...basic,
38
41
  ...javascript,
39
42
  ...typescript,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plugjs/eslint-plugin",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Shared ESLint configurations and extras",
5
5
  "main": "./eslint.config.mjs",
6
6
  "type": "module",
@@ -10,7 +10,7 @@
10
10
  "build": "eslint build.mjs eslint.config.mjs configs"
11
11
  },
12
12
  "peerDependencies": {
13
- "eslint": "^9.6.0"
13
+ "eslint": "^9.7.0"
14
14
  },
15
15
  "files": [
16
16
  "*.md",
@@ -19,29 +19,30 @@
19
19
  "configs/"
20
20
  ],
21
21
  "dependencies": {
22
- "@eslint/js": "9.6.0",
23
- "@typescript-eslint/utils": "8.0.0-alpha.41",
22
+ "@eslint/js": "9.7.0",
23
+ "@rtsao/scc": "1.1.0",
24
+ "@typescript-eslint/utils": "8.0.0-alpha.45",
24
25
  "debug": "4.3.5",
25
26
  "doctrine": "2.1.0",
26
27
  "enhanced-resolve": "5.17.0",
27
- "eslint": "9.6.0",
28
+ "eslint": "9.7.0",
28
29
  "eslint-module-utils": "2.8.1",
29
30
  "eslint-plugin-unicorn": "54.0.0",
30
31
  "eslint-visitor-keys": "4.0.0",
31
32
  "espree": "10.1.0",
32
33
  "estraverse": "5.3.0",
33
34
  "fast-glob": "3.3.2",
34
- "get-tsconfig": "4.7.5",
35
+ "get-tsconfig": "4.7.6",
35
36
  "globals": "15.8.0",
36
- "is-core-module": "2.14.0",
37
+ "is-core-module": "2.15.0",
37
38
  "is-glob": "4.0.3",
38
39
  "minimatch": "9.0.5",
39
40
  "picomatch": "4.0.2",
40
41
  "resolve": "1.22.8",
41
- "semver": "7.6.2",
42
+ "semver": "7.6.3",
42
43
  "stable-hash": "0.0.4",
43
44
  "tslib": "2.6.3",
44
45
  "typescript": "5.5.3",
45
- "typescript-eslint": "8.0.0-alpha.41"
46
+ "typescript-eslint": "8.0.0-alpha.45"
46
47
  }
47
48
  }