@plugjs/eslint-plugin 0.2.15 → 0.2.16

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.1.1",
33
+ version: "4.2.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)",
@@ -78,7 +78,6 @@ var require_package = __commonJS({
78
78
  eslint: "^8.57.0 || ^9.0.0"
79
79
  },
80
80
  dependencies: {
81
- "@typescript-eslint/typescript-estree": "^8.1.0",
82
81
  "@typescript-eslint/utils": "^8.1.0",
83
82
  debug: "^4.3.4",
84
83
  doctrine: "^3.0.0",
@@ -314,9 +313,7 @@ var require_typescript = __commonJS({
314
313
  "@typescript-eslint/parser": [...typeScriptExtensions]
315
314
  },
316
315
  "import-x/resolver": {
317
- node: {
318
- extensions: allExtensions
319
- }
316
+ typescript: true
320
317
  }
321
318
  },
322
319
  rules: {
@@ -434,9 +431,7 @@ var require_typescript2 = __commonJS({
434
431
  "@typescript-eslint/parser": [...typeScriptExtensions]
435
432
  },
436
433
  "import-x/resolver": {
437
- node: {
438
- extensions: allExtensions
439
- }
434
+ typescript: true
440
435
  }
441
436
  },
442
437
  rules: {
@@ -680,9 +675,12 @@ var require_parse = __commonJS({
680
675
  exports2.parse = parse;
681
676
  var tslib_12 = require("tslib");
682
677
  var node_path_1 = tslib_12.__importDefault(require("node:path"));
683
- var typescript_estree_1 = require("@typescript-eslint/typescript-estree");
684
678
  var debug_1 = tslib_12.__importDefault(require("debug"));
685
679
  var module_require_1 = require_module_require();
680
+ function withoutProjectParserOptions(opts) {
681
+ const { EXPERIMENTAL_useProjectService, project, projectService, ...rest } = opts;
682
+ return rest;
683
+ }
686
684
  var log = (0, debug_1.default)("eslint-plugin-import-x:parse");
687
685
  function keysFromParser(parserPath, parserInstance, parsedResult) {
688
686
  if (parsedResult && parsedResult.visitorKeys) {
@@ -722,7 +720,7 @@ var require_parse = __commonJS({
722
720
  parserOptions.loc = true;
723
721
  parserOptions.range = true;
724
722
  parserOptions.filePath = path;
725
- parserOptions = (0, typescript_estree_1.withoutProjectParserOptions)(parserOptions);
723
+ parserOptions = withoutProjectParserOptions(parserOptions);
726
724
  const parser = typeof parserOrPath === "string" ? (0, module_require_1.moduleRequire)(parserOrPath) : parserOrPath;
727
725
  content = transformHashbang(stripUnicodeBOM(String(content)));
728
726
  if ("parseForESLint" in parser && typeof parser.parseForESLint === "function") {
@@ -3876,7 +3874,7 @@ var require_newline_after_import = __commonJS({
3876
3874
  });
3877
3875
  }
3878
3876
  }
3879
- function commentAfterImport(node, nextComment) {
3877
+ function commentAfterImport(node, nextComment, type) {
3880
3878
  const lineDifference = getLineDifference(node, nextComment);
3881
3879
  const EXPECTED_LINE_DIFFERENCE = options.count + 1;
3882
3880
  if (lineDifference < EXPECTED_LINE_DIFFERENCE) {
@@ -3893,7 +3891,7 @@ var require_newline_after_import = __commonJS({
3893
3891
  data: {
3894
3892
  count: options.count,
3895
3893
  lineSuffix: options.count > 1 ? "s" : "",
3896
- type: "import"
3894
+ type
3897
3895
  },
3898
3896
  fix: options.exactCount && EXPECTED_LINE_DIFFERENCE < lineDifference ? void 0 : (fixer) => fixer.insertTextAfter(node, "\n".repeat(EXPECTED_LINE_DIFFERENCE - lineDifference))
3899
3897
  });
@@ -3922,7 +3920,7 @@ var require_newline_after_import = __commonJS({
3922
3920
  return;
3923
3921
  }
3924
3922
  if (nextComment) {
3925
- commentAfterImport(node, nextComment);
3923
+ commentAfterImport(node, nextComment, "import");
3926
3924
  } else if (nextNode && nextNode.type !== "ImportDeclaration" && (nextNode.type !== "TSImportEqualsDeclaration" || nextNode.isExport)) {
3927
3925
  checkForNewLine(node, nextNode, "import");
3928
3926
  }
@@ -3949,7 +3947,16 @@ var require_newline_after_import = __commonJS({
3949
3947
  continue;
3950
3948
  }
3951
3949
  if (nextStatement && (!nextRequireCall || !containsNodeOrEqual(nextStatement, nextRequireCall))) {
3952
- checkForNewLine(statementWithRequireCall, nextStatement, "require");
3950
+ let nextComment;
3951
+ if ("comments" in statementWithRequireCall.parent && statementWithRequireCall.parent.comments !== void 0 && options.considerComments) {
3952
+ const endLine = node2.loc.end.line;
3953
+ nextComment = statementWithRequireCall.parent.comments.find((o) => o.loc.start.line >= endLine && o.loc.start.line <= endLine + options.count + 1);
3954
+ }
3955
+ if (nextComment && nextComment !== void 0) {
3956
+ commentAfterImport(statementWithRequireCall, nextComment, "require");
3957
+ } else {
3958
+ checkForNewLine(statementWithRequireCall, nextStatement, "require");
3959
+ }
3953
3960
  }
3954
3961
  }
3955
3962
  },
@@ -4783,6 +4790,18 @@ var require_no_duplicates = __commonJS({
4783
4790
  ];
4784
4791
  }, ["", !firstHasTrailingComma && !firstIsEmpty, firstExistingIdentifiers]);
4785
4792
  const fixes = [];
4793
+ if (shouldAddSpecifiers && preferInline && first.importKind === "type") {
4794
+ const typeIdentifierToken = tokens.find((token) => token.type === "Identifier" && token.value === "type");
4795
+ if (typeIdentifierToken) {
4796
+ fixes.push(fixer.removeRange([
4797
+ typeIdentifierToken.range[0],
4798
+ typeIdentifierToken.range[1] + 1
4799
+ ]));
4800
+ }
4801
+ for (const identifier of tokens.filter((token) => firstExistingIdentifiers.has(token.value))) {
4802
+ fixes.push(fixer.replaceTextRange([identifier.range[0], identifier.range[1]], `type ${identifier.value}`));
4803
+ }
4804
+ }
4786
4805
  if (openBrace == null && shouldAddSpecifiers && shouldAddDefault()) {
4787
4806
  fixes.push(fixer.insertTextAfter(firstToken, ` ${defaultImportName}, {${specifiersText}} from`));
4788
4807
  } else if (openBrace == null && !shouldAddSpecifiers && shouldAddDefault()) {
@@ -5251,7 +5270,7 @@ var require_no_extraneous_dependencies = __commonJS({
5251
5270
  isInBundledDeps: result.isInBundledDeps || deps.bundledDependencies.includes(ancestorName)
5252
5271
  }), newDeclarationStatus);
5253
5272
  }
5254
- function reportIfMissing(context, deps, depsOptions, node, name) {
5273
+ function reportIfMissing(context, deps, depsOptions, node, name, whitelist) {
5255
5274
  if (!depsOptions.verifyTypeImports && ("importKind" in node && (node.importKind === "type" || node.importKind === "typeof") || "exportKind" in node && node.exportKind === "type" || "specifiers" in node && Array.isArray(node.specifiers) && node.specifiers.length > 0 && node.specifiers.every((specifier) => "importKind" in specifier && (specifier.importKind === "type" || specifier.importKind === "typeof")))) {
5256
5275
  return;
5257
5276
  }
@@ -5276,6 +5295,9 @@ var require_no_extraneous_dependencies = __commonJS({
5276
5295
  }
5277
5296
  }
5278
5297
  const packageName = realPackageName || importPackageName;
5298
+ if (whitelist?.has(packageName)) {
5299
+ return;
5300
+ }
5279
5301
  if (declarationStatus.isInDevDeps && !depsOptions.allowDevDeps) {
5280
5302
  context.report({
5281
5303
  node,
@@ -5328,7 +5350,8 @@ var require_no_extraneous_dependencies = __commonJS({
5328
5350
  bundledDependencies: { type: ["boolean", "array"] },
5329
5351
  packageDir: { type: ["string", "array"] },
5330
5352
  includeInternal: { type: ["boolean"] },
5331
- includeTypes: { type: ["boolean"] }
5353
+ includeTypes: { type: ["boolean"] },
5354
+ whitelist: { type: ["array"] }
5332
5355
  },
5333
5356
  additionalProperties: false
5334
5357
  }
@@ -5356,7 +5379,7 @@ var require_no_extraneous_dependencies = __commonJS({
5356
5379
  };
5357
5380
  return {
5358
5381
  ...(0, utils_1.moduleVisitor)((source, node) => {
5359
- reportIfMissing(context, deps, depsOptions, node, source.value);
5382
+ reportIfMissing(context, deps, depsOptions, node, source.value, options.whitelist ? new Set(options.whitelist) : void 0);
5360
5383
  }, { commonjs: true }),
5361
5384
  "Program:exit"() {
5362
5385
  depFieldCache.clear();
@@ -6970,15 +6993,9 @@ var require_no_unused_modules = __commonJS({
6970
6993
  }
6971
6994
  }
6972
6995
  };
6973
- var getSrc = (src) => {
6974
- if (src) {
6975
- return src;
6976
- }
6977
- return [process.cwd()];
6978
- };
6979
6996
  var srcFiles;
6980
6997
  var lastPrepareKey;
6981
- var doPreparation = (src = [], ignoreExports, context) => {
6998
+ var doPreparation = (src, ignoreExports, context) => {
6982
6999
  const prepareKey = JSON.stringify({
6983
7000
  src: src.sort(),
6984
7001
  ignoreExports: (ignoreExports || []).sort(),
@@ -6991,7 +7008,7 @@ var require_no_unused_modules = __commonJS({
6991
7008
  exportList.clear();
6992
7009
  ignoredFiles.clear();
6993
7010
  filesOutsideSrc.clear();
6994
- srcFiles = resolveFiles(getSrc(src), ignoreExports, context);
7011
+ srcFiles = resolveFiles(src, ignoreExports, context);
6995
7012
  prepareImportsAndExports(srcFiles, context);
6996
7013
  determineUsage();
6997
7014
  lastPrepareKey = prepareKey;
@@ -7115,7 +7132,7 @@ var require_no_unused_modules = __commonJS({
7115
7132
  },
7116
7133
  defaultOptions: [],
7117
7134
  create(context) {
7118
- const { src, ignoreExports = [], missingExports, unusedExports, ignoreUnusedTypeExports } = context.options[0] || {};
7135
+ const { src = [process.cwd()], ignoreExports = [], missingExports, unusedExports, ignoreUnusedTypeExports } = context.options[0] || {};
7119
7136
  if (unusedExports) {
7120
7137
  doPreparation(src, ignoreExports, context);
7121
7138
  }
@@ -7161,7 +7178,7 @@ var require_no_unused_modules = __commonJS({
7161
7178
  return;
7162
7179
  }
7163
7180
  if (!srcFiles.has(filename)) {
7164
- srcFiles = resolveFiles(getSrc(src), ignoreExports, context);
7181
+ srcFiles = resolveFiles(src, ignoreExports, context);
7165
7182
  if (!srcFiles.has(filename)) {
7166
7183
  filesOutsideSrc.add(filename);
7167
7184
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plugjs/eslint-plugin",
3
- "version": "0.2.15",
3
+ "version": "0.2.16",
4
4
  "description": "Shared ESLint configurations and extras",
5
5
  "main": "./index.mjs",
6
6
  "type": "module",
@@ -37,13 +37,12 @@
37
37
  "dependencies": {
38
38
  "@eslint/js": "9.9.1",
39
39
  "@nolyfill/is-core-module": "1.0.39",
40
- "@typescript-eslint/typescript-estree": "8.3.0",
41
- "@typescript-eslint/utils": "8.3.0",
42
- "debug": "4.3.6",
40
+ "@typescript-eslint/utils": "8.4.0",
41
+ "debug": "4.3.7",
43
42
  "doctrine": "3.0.0",
44
43
  "enhanced-resolve": "5.17.1",
45
44
  "eslint": "9.9.1",
46
- "eslint-module-utils": "2.8.2",
45
+ "eslint-module-utils": "2.10.0",
47
46
  "eslint-plugin-unicorn": "55.0.0",
48
47
  "eslint-visitor-keys": "4.0.0",
49
48
  "espree": "10.1.0",
@@ -61,6 +60,6 @@
61
60
  "stable-hash": "0.0.4",
62
61
  "tslib": "2.7.0",
63
62
  "typescript": "5.5.4",
64
- "typescript-eslint": "8.3.0"
63
+ "typescript-eslint": "8.4.0"
65
64
  }
66
65
  }