knip 2.38.1 → 2.38.2

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.
@@ -129,14 +129,16 @@ export class ProjectPrincipal {
129
129
  }
130
130
  else {
131
131
  const sanitizedSpecifier = sanitizeSpecifier(specifier);
132
- if (isMaybePackageName(sanitizedSpecifier)) {
132
+ const ext = extname(sanitizedSpecifier);
133
+ const hasIgnoredExtension = IGNORED_FILE_EXTENSIONS.includes(ext);
134
+ if (!hasIgnoredExtension && isMaybePackageName(sanitizedSpecifier)) {
133
135
  external.add(sanitizedSpecifier);
134
136
  }
135
137
  else {
136
138
  const isIgnored = this.isGitIgnored(join(dirname(filePath), sanitizedSpecifier));
137
139
  if (!isIgnored) {
138
140
  const ext = extname(sanitizedSpecifier);
139
- if (!ext || (ext !== '.json' && !IGNORED_FILE_EXTENSIONS.includes(ext))) {
141
+ if (!ext || (ext !== '.json' && !hasIgnoredExtension)) {
140
142
  unresolvedImports.add(specifier);
141
143
  }
142
144
  }
@@ -11,6 +11,8 @@ const getDependenciesFromScripts = (npmScripts, options = {}) => {
11
11
  const scripts = typeof npmScripts === 'string' ? [npmScripts] : [...npmScripts];
12
12
  const results = scripts.flatMap(script => getBinariesFromScript(script, { cwd, manifest, knownGlobalsOnly }));
13
13
  return compact(results.map(identifier => {
14
+ if (identifier.startsWith('http'))
15
+ return;
14
16
  if (isBinary(identifier))
15
17
  return identifier;
16
18
  if (isInternal(identifier)) {
@@ -3,7 +3,6 @@ export declare const NAME = "Storybook";
3
3
  export declare const ENABLERS: (string | RegExp)[];
4
4
  export declare const isEnabled: IsPluginEnabledCallback;
5
5
  export declare const CONFIG_FILE_PATTERNS: string[];
6
- export declare const STORIES_FILE_PATTERNS: string[];
7
6
  export declare const ENTRY_FILE_PATTERNS: string[];
8
7
  export declare const PROJECT_FILE_PATTERNS: string[];
9
8
  export declare const findDependencies: GenericPluginCallback;
@@ -6,8 +6,9 @@ export const NAME = 'Storybook';
6
6
  export const ENABLERS = [/^@storybook\//, '@nrwl/storybook'];
7
7
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
8
8
  export const CONFIG_FILE_PATTERNS = ['.storybook/{main,test-runner}.{js,ts}'];
9
- export const STORIES_FILE_PATTERNS = ['**/*.@(mdx|stories.@(mdx|js|jsx|mjs|ts|tsx))'];
10
- export const ENTRY_FILE_PATTERNS = ['.storybook/{manager,preview}.{js,jsx,ts,tsx}', ...STORIES_FILE_PATTERNS];
9
+ const STORIES_FILE_PATTERNS = ['**/*.@(mdx|stories.@(mdx|js|jsx|mjs|ts|tsx))'];
10
+ const REST_ENTRY_FILE_PATTERNS = ['.storybook/{manager,preview}.{js,jsx,ts,tsx}'];
11
+ export const ENTRY_FILE_PATTERNS = [...REST_ENTRY_FILE_PATTERNS, ...STORIES_FILE_PATTERNS];
11
12
  export const PROJECT_FILE_PATTERNS = ['.storybook/**/*.{js,jsx,ts,tsx}'];
12
13
  const findStorybookDependencies = async (configFilePath, options) => {
13
14
  const { isProduction, cwd, config } = options;
@@ -20,8 +21,11 @@ const findStorybookDependencies = async (configFilePath, options) => {
20
21
  return relative(cwd, join(dirname(configFilePath), pattern));
21
22
  return relative(cwd, join(dirname(configFilePath), pattern.directory, pattern.files ?? STORIES_FILE_PATTERNS[0]));
22
23
  });
23
- const patterns = [...(config?.entry ?? []), ...(relativePatterns ?? [])];
24
- const entryPatterns = (patterns.length > 0 ? patterns : ENTRY_FILE_PATTERNS).map(toEntryPattern);
24
+ const patterns = [
25
+ ...(config?.entry ?? REST_ENTRY_FILE_PATTERNS),
26
+ ...(relativePatterns && relativePatterns.length > 0 ? relativePatterns : STORIES_FILE_PATTERNS),
27
+ ];
28
+ const entryPatterns = patterns.map(toEntryPattern);
25
29
  if (!localConfig || isProduction)
26
30
  return entryPatterns;
27
31
  const addons = localConfig.addons?.map(addon => (typeof addon === 'string' ? addon : addon.name)) ?? [];
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "2.38.1";
1
+ export declare const version = "2.38.2";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '2.38.1';
1
+ export const version = '2.38.2';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "2.38.1",
3
+ "version": "2.38.2",
4
4
  "description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
5
5
  "homepage": "https://github.com/webpro/knip",
6
6
  "repository": "github:webpro/knip",
@@ -73,7 +73,7 @@
73
73
  "@types/js-yaml": "4.0.8",
74
74
  "@types/micromatch": "4.0.4",
75
75
  "@types/minimist": "1.2.4",
76
- "@types/node": "20.8.8",
76
+ "@types/node": "20.8.9",
77
77
  "@types/npmcli__map-workspaces": "3.0.3",
78
78
  "@types/pkgjs__parseargs": "0.10.2",
79
79
  "@types/webpack": "5.28.4",
@@ -90,7 +90,7 @@
90
90
  "remark-cli": "12.0.0",
91
91
  "remark-preset-webpro": "1.0.0",
92
92
  "tsx": "3.14.0",
93
- "type-fest": "4.5.0"
93
+ "type-fest": "4.6.0"
94
94
  },
95
95
  "engines": {
96
96
  "node": ">=16.17.0 <17 || >=18.6.0"