knip 6.42.0 → 6.43.0

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.
Files changed (62) hide show
  1. package/dist/ConfigurationChief.d.ts +18 -0
  2. package/dist/IssueFixer.js +10 -5
  3. package/dist/WorkspaceWorker.js +15 -10
  4. package/dist/binaries/resolvers/bun.js +1 -0
  5. package/dist/binaries/resolvers/npm.js +12 -2
  6. package/dist/binaries/resolvers/pnpm.js +5 -3
  7. package/dist/compilers/compilers.js +2 -2
  8. package/dist/compilers/scss.js +2 -22
  9. package/dist/compilers/shared.d.ts +1 -1
  10. package/dist/compilers/shared.js +24 -1
  11. package/dist/constants.js +2 -0
  12. package/dist/plugins/_vue/auto-import.js +31 -1
  13. package/dist/plugins/buf/index.d.ts +3 -0
  14. package/dist/plugins/buf/index.js +33 -0
  15. package/dist/plugins/buf/types.d.ts +8 -0
  16. package/dist/plugins/buf/types.js +1 -0
  17. package/dist/plugins/bun/index.js +13 -0
  18. package/dist/plugins/electron-forge/index.d.ts +3 -0
  19. package/dist/plugins/electron-forge/index.js +94 -0
  20. package/dist/plugins/eslint/helpers.d.ts +1 -0
  21. package/dist/plugins/eslint/helpers.js +1 -1
  22. package/dist/plugins/eslint/resolveFromAST.js +35 -10
  23. package/dist/plugins/expo/helpers.d.ts +1 -1
  24. package/dist/plugins/expo/helpers.js +15 -8
  25. package/dist/plugins/expo/types.d.ts +2 -1
  26. package/dist/plugins/index.d.ts +3 -0
  27. package/dist/plugins/index.js +6 -0
  28. package/dist/plugins/jest/index.js +11 -7
  29. package/dist/plugins/mcp/index.d.ts +3 -0
  30. package/dist/plugins/mcp/index.js +33 -0
  31. package/dist/plugins/mcp/types.d.ts +11 -0
  32. package/dist/plugins/mcp/types.js +1 -0
  33. package/dist/plugins/next/index.d.ts +3 -0
  34. package/dist/plugins/next/index.js +57 -9
  35. package/dist/plugins/next/types.d.ts +11 -0
  36. package/dist/plugins/next/types.js +1 -0
  37. package/dist/plugins/semantic-release/index.js +32 -3
  38. package/dist/plugins/semantic-release/types.d.ts +1 -0
  39. package/dist/plugins/tailwind/compiler.js +14 -2
  40. package/dist/plugins/travis/index.js +2 -2
  41. package/dist/plugins/typescript/index.js +2 -4
  42. package/dist/plugins/vitest/helpers.d.ts +1 -1
  43. package/dist/plugins/vitest/helpers.js +13 -3
  44. package/dist/plugins/vitest/index.js +54 -46
  45. package/dist/plugins/vitest/types.d.ts +11 -7
  46. package/dist/run.js +1 -1
  47. package/dist/schema/configuration.d.ts +45 -0
  48. package/dist/schema/plugins.d.ts +15 -0
  49. package/dist/schema/plugins.js +3 -0
  50. package/dist/types/PluginNames.d.ts +2 -2
  51. package/dist/types/PluginNames.js +3 -0
  52. package/dist/types/config.d.ts +1 -0
  53. package/dist/typescript/ast-nodes.js +3 -3
  54. package/dist/typescript/visitors/exports.js +5 -4
  55. package/dist/typescript/visitors/walk.js +13 -1
  56. package/dist/util/create-options.d.ts +30 -0
  57. package/dist/util/modules.js +2 -1
  58. package/dist/util/remove-export.js +3 -1
  59. package/dist/version.d.ts +1 -1
  60. package/dist/version.js +1 -1
  61. package/package.json +4 -4
  62. package/schema.json +12 -0
@@ -2,7 +2,7 @@ import { readFileSync } from 'node:fs';
2
2
  import { DT_SCOPE, PROTOCOL_VIRTUAL } from '../constants.js';
3
3
  import { isAbsolute, isInNodeModules, join, toPosix } from './path.js';
4
4
  export const getPackageNameFromModuleSpecifier = (specifier) => {
5
- if (!isStartsLikePackageName(specifier))
5
+ if (!isStartsLikePackageName(specifier) && !isTildePackageName(specifier))
6
6
  return;
7
7
  let start = 0;
8
8
  if (specifier.charCodeAt(0) === 64) {
@@ -55,6 +55,7 @@ export const isStartsLikePackageName = (specifier) => {
55
55
  const ch = specifier.charCodeAt(0);
56
56
  return ch === 64 ? isPackageScopeStart(specifier.charCodeAt(1)) : isPackageNameStart(ch);
57
57
  };
58
+ const isTildePackageName = (specifier) => specifier.charCodeAt(0) === 126 && isPackageNameStart(specifier.charCodeAt(1));
58
59
  export const stripVersionFromSpecifier = (specifier) => specifier.replace(/(\S+)@.*/, '$1');
59
60
  export const isInNodeModulesBin = (value) => value.includes('node_modules/.bin/');
60
61
  export const isRelativeNodeModulesBin = (value) => /^(?:\.\.?\/)*node_modules\/\.bin\//.test(value);
@@ -1,4 +1,5 @@
1
1
  import { FIX_FLAGS } from '../constants.js';
2
+ const importAttributesMatcher = /^(?:\s*with|[^\S\r\n\u2028\u2029]*assert)\s*\{[^}]*\}/;
2
3
  const getOpeningBracketIndex = (text) => {
3
4
  let bracketOpenIndex = -1;
4
5
  let j = text.length - 1;
@@ -65,7 +66,8 @@ export const removeExport = ({ text, start, end, flags }) => {
65
66
  const specifierQuoteMatch = afterEnd.match(/['"][^'"]+['"]/);
66
67
  if (specifierQuoteMatch?.index) {
67
68
  const fromSpecifierLength = specifierQuoteMatch.index + specifierQuoteMatch[0].length;
68
- return beforeBracket.substring(0, exportKeywordOffset) + afterEnd.substring(fromSpecifierLength);
69
+ const afterSpecifier = afterEnd.substring(fromSpecifierLength).replace(importAttributesMatcher, '');
70
+ return beforeBracket.substring(0, exportKeywordOffset) + afterSpecifier;
69
71
  }
70
72
  }
71
73
  return beforeBracket.substring(0, exportKeywordOffset) + afterEnd.substring(closingBracketOffset);
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "6.42.0";
1
+ export declare const version = "6.43.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '6.42.0';
1
+ export const version = '6.43.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "6.42.0",
3
+ "version": "6.43.0",
4
4
  "description": "Find and fix unused dependencies, exports and files in your TypeScript and JavaScript projects",
5
5
  "keywords": [
6
6
  "analysis",
@@ -84,13 +84,13 @@
84
84
  "formatly": "^0.11.4",
85
85
  "get-tsconfig": "4.14.3",
86
86
  "jiti": "^2.7.0",
87
- "oxc-parser": "^0.154.0",
87
+ "oxc-parser": "^0.155.0",
88
88
  "oxc-resolver": "11.24.2",
89
89
  "picomatch": "^4.0.7",
90
90
  "smol-toml": "^1.9.0",
91
91
  "strip-json-comments": "5.0.3",
92
92
  "tinyglobby": "^0.2.17",
93
- "unbash": "^6.0.0",
93
+ "unbash": "^6.0.1",
94
94
  "yaml": "^2.9.1",
95
95
  "zod": "^4.6.5"
96
96
  },
@@ -102,7 +102,7 @@
102
102
  "prettier": "^3.9.10",
103
103
  "tsx": "^4.23.15",
104
104
  "typescript": "7.0.2",
105
- "webpack": "^5.111.1"
105
+ "webpack": "^5.112.0"
106
106
  },
107
107
  "engines": {
108
108
  "node": "^20.19.0 || >=22.12.0"
package/schema.json CHANGED
@@ -454,6 +454,10 @@
454
454
  "title": "borp plugin configuration (https://knip.dev/reference/plugins/borp)",
455
455
  "$ref": "#/definitions/plugin"
456
456
  },
457
+ "buf": {
458
+ "title": "buf plugin configuration (https://knip.dev/reference/plugins/buf)",
459
+ "$ref": "#/definitions/plugin"
460
+ },
457
461
  "bumpp": {
458
462
  "title": "bumpp plugin configuration (https://knip.dev/reference/plugins/bumpp)",
459
463
  "$ref": "#/definitions/plugin"
@@ -534,6 +538,10 @@
534
538
  "title": "Drizzle plugin configuration (https://knip.dev/reference/plugins/drizzle)",
535
539
  "$ref": "#/definitions/plugin"
536
540
  },
541
+ "electron-forge": {
542
+ "title": "Electron Forge plugin configuration (https://knip.dev/reference/plugins/electron-forge)",
543
+ "$ref": "#/definitions/plugin"
544
+ },
537
545
  "electron-vite": {
538
546
  "title": "electron-vite plugin configuration (https://knip.dev/reference/plugins/electron-vite)",
539
547
  "$ref": "#/definitions/plugin"
@@ -674,6 +682,10 @@
674
682
  "title": "marko plugin configuration (https://knip.dev/reference/plugins/marko)",
675
683
  "$ref": "#/definitions/plugin"
676
684
  },
685
+ "mcp": {
686
+ "title": "mcp plugin configuration (https://knip.dev/reference/plugins/mcp)",
687
+ "$ref": "#/definitions/plugin"
688
+ },
677
689
  "mdx": {
678
690
  "title": "mdx plugin configuration (https://knip.dev/reference/plugins/mdx)",
679
691
  "$ref": "#/definitions/plugin"