@plugjs/eslint-plugin 0.2.18 → 0.2.20

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.
@@ -30,7 +30,7 @@ var require_package = __commonJS({
30
30
  "node_modules/eslint-plugin-import-x/package.json"(exports2, module2) {
31
31
  module2.exports = {
32
32
  name: "eslint-plugin-import-x",
33
- version: "4.2.1",
33
+ version: "4.3.1",
34
34
  description: "Import with sanity.",
35
35
  repository: "git+https://github.com/un-ts/eslint-plugin-import-x",
36
36
  author: "JounQin <admin@1stg.me> (https://www.1stG.me)",
@@ -947,9 +947,6 @@ var require_resolve = __commonJS({
947
947
  if (cachedPath !== void 0) {
948
948
  return { found: true, path: cachedPath };
949
949
  }
950
- function cache(resolvedPath) {
951
- fileExistsCache.set(cacheKey, resolvedPath);
952
- }
953
950
  function withResolver(resolver, config) {
954
951
  if (resolver.interfaceVersion === 2) {
955
952
  return resolver.resolve(modulePath, sourceFile, config);
@@ -974,14 +971,16 @@ var require_resolve = __commonJS({
974
971
  const configResolvers = settings["import-x/resolver"] || {
975
972
  node: settings["import-x/resolve"]
976
973
  };
977
- const resolvers = resolverReducer(configResolvers, /* @__PURE__ */ new Map());
978
- for (const [name, config] of resolvers) {
979
- const resolver = requireResolver(name, sourceFile);
980
- const resolved = withResolver(resolver, config);
974
+ const resolvers = normalizeConfigResolvers(configResolvers, sourceFile);
975
+ for (const { enable, options, resolver } of resolvers) {
976
+ if (!enable) {
977
+ continue;
978
+ }
979
+ const resolved = withResolver(resolver, options);
981
980
  if (!resolved.found) {
982
981
  continue;
983
982
  }
984
- cache(resolved.path);
983
+ fileExistsCache.set(cacheKey, resolved.path);
985
984
  return resolved;
986
985
  }
987
986
  return { found: false };
@@ -989,25 +988,50 @@ var require_resolve = __commonJS({
989
988
  function relative(modulePath, sourceFile, settings) {
990
989
  return fullResolve(modulePath, sourceFile, settings).path;
991
990
  }
992
- function resolverReducer(resolvers, map) {
993
- if (Array.isArray(resolvers)) {
994
- for (const r of resolvers)
995
- resolverReducer(r, map);
996
- return map;
997
- }
998
- if (typeof resolvers === "string") {
999
- map.set(resolvers, null);
1000
- return map;
1001
- }
1002
- if (typeof resolvers === "object") {
1003
- for (const [key, value] of Object.entries(resolvers)) {
1004
- map.set(key, value);
991
+ function normalizeConfigResolvers(resolvers, sourceFile) {
992
+ const resolverArray = Array.isArray(resolvers) ? resolvers : [resolvers];
993
+ const map = /* @__PURE__ */ new Map();
994
+ for (const nameOrRecordOrObject of resolverArray) {
995
+ if (typeof nameOrRecordOrObject === "string") {
996
+ const name = nameOrRecordOrObject;
997
+ map.set(name, {
998
+ name,
999
+ enable: true,
1000
+ options: void 0,
1001
+ resolver: requireResolver(name, sourceFile)
1002
+ });
1003
+ } else if (typeof nameOrRecordOrObject === "object") {
1004
+ if (nameOrRecordOrObject.name && nameOrRecordOrObject.resolver) {
1005
+ const object = nameOrRecordOrObject;
1006
+ const { name, enable = true, options, resolver } = object;
1007
+ map.set(name, { name, enable, options, resolver });
1008
+ } else {
1009
+ const record = nameOrRecordOrObject;
1010
+ for (const [name, enableOrOptions] of Object.entries(record)) {
1011
+ if (typeof enableOrOptions === "boolean") {
1012
+ map.set(name, {
1013
+ name,
1014
+ enable: enableOrOptions,
1015
+ options: void 0,
1016
+ resolver: requireResolver(name, sourceFile)
1017
+ });
1018
+ } else {
1019
+ map.set(name, {
1020
+ name,
1021
+ enable: true,
1022
+ options: enableOrOptions,
1023
+ resolver: requireResolver(name, sourceFile)
1024
+ });
1025
+ }
1026
+ }
1027
+ }
1028
+ } else {
1029
+ const err = new Error("invalid resolver config");
1030
+ err.name = ERROR_NAME;
1031
+ throw err;
1005
1032
  }
1006
- return map;
1007
1033
  }
1008
- const err = new Error("invalid resolver config");
1009
- err.name = ERROR_NAME;
1010
- throw err;
1034
+ return [...map.values()];
1011
1035
  }
1012
1036
  function getBaseDir(sourceFile) {
1013
1037
  return (0, pkg_dir_1.pkgDir)(sourceFile) || process.cwd();
@@ -1882,7 +1906,11 @@ var require_import_declaration = __commonJS({
1882
1906
  "use strict";
1883
1907
  Object.defineProperty(exports2, "__esModule", { value: true });
1884
1908
  exports2.importDeclaration = void 0;
1909
+ var utils_1 = require("@typescript-eslint/utils");
1885
1910
  var importDeclaration = (context, node) => {
1911
+ if (node.parent && node.parent.type === utils_1.AST_NODE_TYPES.ImportDeclaration) {
1912
+ return node.parent;
1913
+ }
1886
1914
  const ancestors = context.sourceCode.getAncestors(node);
1887
1915
  return ancestors[ancestors.length - 1];
1888
1916
  };
@@ -4929,8 +4957,13 @@ var require_no_duplicates = __commonJS({
4929
4957
  };
4930
4958
  moduleMaps.set(parent, map);
4931
4959
  }
4932
- if (!preferInline && n.importKind === "type") {
4933
- return n.specifiers.length > 0 && n.specifiers[0].type === "ImportDefaultSpecifier" ? map.defaultTypesImported : map.namedTypesImported;
4960
+ if (n.importKind === "type") {
4961
+ if (n.specifiers.length > 0 && n.specifiers[0].type === "ImportDefaultSpecifier") {
4962
+ return map.defaultTypesImported;
4963
+ }
4964
+ if (!preferInline) {
4965
+ return map.namedTypesImported;
4966
+ }
4934
4967
  }
4935
4968
  if (!preferInline && n.specifiers.some((spec) => "importKind" in spec && spec.importKind === "type")) {
4936
4969
  return map.namedTypesImported;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plugjs/eslint-plugin",
3
- "version": "0.2.18",
3
+ "version": "0.2.20",
4
4
  "description": "Shared ESLint configurations and extras",
5
5
  "main": "./index.mjs",
6
6
  "type": "module",
@@ -10,7 +10,7 @@
10
10
  "build": "eslint"
11
11
  },
12
12
  "peerDependencies": {
13
- "eslint": "^9.10.0"
13
+ "eslint": "^9.11.1"
14
14
  },
15
15
  "files": [
16
16
  "*.md",
@@ -35,21 +35,21 @@
35
35
  },
36
36
  "homepage": "https://github.com/plugjs/eslint-plugin#readme",
37
37
  "dependencies": {
38
- "@eslint/js": "9.10.0",
38
+ "@eslint/js": "9.11.1",
39
39
  "@nolyfill/is-core-module": "1.0.39",
40
- "@typescript-eslint/utils": "8.6.0",
40
+ "@typescript-eslint/utils": "8.8.0",
41
41
  "debug": "4.3.7",
42
42
  "doctrine": "3.0.0",
43
43
  "enhanced-resolve": "5.17.1",
44
- "eslint": "9.10.0",
45
- "eslint-module-utils": "2.11.0",
46
- "eslint-plugin-unicorn": "55.0.0",
47
- "eslint-visitor-keys": "4.0.0",
48
- "espree": "10.1.0",
44
+ "eslint": "9.11.1",
45
+ "eslint-module-utils": "2.12.0",
46
+ "eslint-plugin-unicorn": "56.0.0",
47
+ "eslint-visitor-keys": "4.1.0",
48
+ "espree": "10.2.0",
49
49
  "estraverse": "5.3.0",
50
50
  "fast-glob": "3.3.2",
51
51
  "get-tsconfig": "4.8.1",
52
- "globals": "15.9.0",
52
+ "globals": "15.10.0",
53
53
  "is-bun-module": "1.2.1",
54
54
  "is-core-module": "2.15.1",
55
55
  "is-glob": "4.0.3",
@@ -60,6 +60,6 @@
60
60
  "stable-hash": "0.0.4",
61
61
  "tslib": "2.7.0",
62
62
  "typescript": "5.6.2",
63
- "typescript-eslint": "8.6.0"
63
+ "typescript-eslint": "8.8.0"
64
64
  }
65
65
  }