knip 3.3.2 → 3.3.4

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.
@@ -10,7 +10,7 @@ import { arrayify } from './util/array.js';
10
10
  import parsedArgValues from './util/cli-arguments.js';
11
11
  import { partitionCompilers } from './util/compilers.js';
12
12
  import { ConfigurationError, LoaderError } from './util/errors.js';
13
- import { findFile, loadJSON } from './util/fs.js';
13
+ import { findFile, isDirectory, isFile, loadJSON } from './util/fs.js';
14
14
  import { getIncludedIssueTypes } from './util/get-included-issue-types.js';
15
15
  import { _dirGlob } from './util/glob.js';
16
16
  import { _load } from './util/loader.js';
@@ -363,6 +363,11 @@ export class ConfigurationChief {
363
363
  getUnusedIgnoredWorkspaces() {
364
364
  const ignoredWorkspaceNames = this.config.ignoreWorkspaces;
365
365
  const workspaceNames = [...this.manifestWorkspaces.keys(), ...this.additionalWorkspaceNames];
366
- return ignoredWorkspaceNames.filter(ignoredWorkspaceName => !workspaceNames.some(name => micromatch.isMatch(name, ignoredWorkspaceName)));
366
+ return ignoredWorkspaceNames
367
+ .filter(ignoredWorkspaceName => !workspaceNames.some(name => micromatch.isMatch(name, ignoredWorkspaceName)))
368
+ .filter(ignoredWorkspaceName => {
369
+ const dir = join(this.cwd, ignoredWorkspaceName);
370
+ return !isDirectory(dir) || isFile(join(dir, 'package.json'));
371
+ });
367
372
  }
368
373
  }
@@ -20,7 +20,9 @@ const fileExists = (name, containingFile) => {
20
20
  export function createCustomModuleResolver(customSys, compilerOptions, virtualFileExtensions) {
21
21
  function resolveModuleNames(moduleNames, containingFile) {
22
22
  return moduleNames.map(moduleName => {
23
- const key = `${containingFile}:${moduleName}`;
23
+ const key = moduleName.startsWith('.')
24
+ ? join(dirname(containingFile), moduleName)
25
+ : `${containingFile}:${moduleName}`;
24
26
  if (resolutionCache.has(key))
25
27
  return resolutionCache.get(key);
26
28
  const resolvedModule = resolveModuleName(moduleName, containingFile);
package/dist/util/fs.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export declare const isDirectory: (filePath: string) => boolean;
1
2
  export declare const isFile: (filePath: string) => boolean;
2
3
  export declare const findFile: (workingDir: string, fileName: string) => string | undefined;
3
4
  export declare const loadFile: (filePath: string) => Promise<string>;
package/dist/util/fs.js CHANGED
@@ -4,6 +4,10 @@ import yaml from 'js-yaml';
4
4
  import stripJsonComments from 'strip-json-comments';
5
5
  import { LoaderError } from './errors.js';
6
6
  import { dirname, join } from './path.js';
7
+ export const isDirectory = (filePath) => {
8
+ const stat = statSync(filePath, { throwIfNoEntry: false });
9
+ return stat !== undefined && stat.isDirectory();
10
+ };
7
11
  export const isFile = (filePath) => {
8
12
  const stat = statSync(filePath, { throwIfNoEntry: false });
9
13
  return stat !== undefined && stat.isFile();
@@ -57,5 +57,7 @@ export const sanitizeSpecifier = (specifier) => {
57
57
  return specifier;
58
58
  if (isAbsolute(specifier))
59
59
  return specifier;
60
+ if (specifier.startsWith('virtual:'))
61
+ return specifier;
60
62
  return specifier.replace(/^([?!|-]+)?([^!?:]+).*/, '$2');
61
63
  };
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "3.3.2";
1
+ export declare const version = "3.3.4";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '3.3.2';
1
+ export const version = '3.3.4';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "3.3.2",
3
+ "version": "3.3.4",
4
4
  "description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
5
5
  "homepage": "https://knip.dev",
6
6
  "repository": {
@@ -102,6 +102,9 @@
102
102
  "npm run knip",
103
103
  "npm run knip:production",
104
104
  "npm test"
105
+ ],
106
+ "after:bump": [
107
+ "git add ../../package-lock.json"
105
108
  ]
106
109
  },
107
110
  "github": {