knip 3.6.0 → 3.6.1

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.
@@ -3,7 +3,7 @@ import { DEFAULT_EXTENSIONS } from './constants.js';
3
3
  import { IGNORED_FILE_EXTENSIONS } from './constants.js';
4
4
  import { getJSDocTags, getLineAndCharacterOfPosition, isInModuleBlock } from './typescript/ast-helpers.js';
5
5
  import { createHosts } from './typescript/createHosts.js';
6
- import { getImportsAndExports } from './typescript/getImportsAndExports.js';
6
+ import { _getImportsAndExports } from './typescript/getImportsAndExports.js';
7
7
  import { createCustomModuleResolver } from './typescript/resolveModuleNames.js';
8
8
  import { SourceFileManager } from './typescript/SourceFileManager.js';
9
9
  import { compact } from './util/array.js';
@@ -121,7 +121,7 @@ export class ProjectPrincipal {
121
121
  const getResolvedModule = specifier => this.backend.program?.getResolvedModule
122
122
  ? this.backend.program.getResolvedModule(sourceFile, specifier, undefined)
123
123
  : sourceFile.resolvedModules?.get(specifier, undefined);
124
- const { imports, exports, scripts } = getImportsAndExports(sourceFile, getResolvedModule, {
124
+ const { imports, exports, scripts } = _getImportsAndExports(sourceFile, getResolvedModule, {
125
125
  skipTypeOnly,
126
126
  skipExports,
127
127
  });
package/dist/index.js CHANGED
@@ -308,8 +308,11 @@ export const main = async (unresolvedConfiguration) => {
308
308
  if (isProduction && exportedItem.jsDocTags.has('@internal'))
309
309
  continue;
310
310
  if (importsForExport && isSymbolImported(symbol, importsForExport)) {
311
- if (importsForExport.isReExport && isExportedInEntryFile(principal, importsForExport))
311
+ if (!isIncludeEntryExports &&
312
+ importsForExport.isReExport &&
313
+ isExportedInEntryFile(principal, importsForExport)) {
312
314
  continue;
315
+ }
313
316
  if (report.enumMembers && exportedItem.type === 'enum' && exportedItem.members) {
314
317
  principal.findUnusedMembers(filePath, exportedItem.members).forEach(member => {
315
318
  collector.addIssue({
@@ -17,7 +17,7 @@ export type AddImportOptions = {
17
17
  export type AddExportOptions = ExportItem & {
18
18
  identifier: string;
19
19
  };
20
- export declare const getImportsAndExports: (sourceFile: BoundSourceFile, getResolvedModule: GetResolvedModule, options: GetImportsAndExportsOptions) => {
20
+ export declare const _getImportsAndExports: (sourceFile: BoundSourceFile, getResolvedModule: GetResolvedModule, options: GetImportsAndExportsOptions) => {
21
21
  imports: {
22
22
  internal: Imports;
23
23
  external: Set<string>;
@@ -3,6 +3,7 @@ import ts from 'typescript';
3
3
  import { getOrSet } from '../util/map.js';
4
4
  import { isStartsLikePackageName, sanitizeSpecifier } from '../util/modules.js';
5
5
  import { isInNodeModules } from '../util/path.js';
6
+ import { timerify } from '../util/Performance.js';
6
7
  import { isDeclarationFileExtension, isAccessExpression, getAccessExpressionName, getJSDocTags, getLineAndCharacterOfPosition, } from './ast-helpers.js';
7
8
  import getExportVisitors from './visitors/exports/index.js';
8
9
  import { getJSXImplicitImportBase } from './visitors/helpers.js';
@@ -13,7 +14,7 @@ const getVisitors = (sourceFile) => ({
13
14
  import: getImportVisitors(sourceFile),
14
15
  script: getScriptVisitors(sourceFile),
15
16
  });
16
- export const getImportsAndExports = (sourceFile, getResolvedModule, options) => {
17
+ const getImportsAndExports = (sourceFile, getResolvedModule, options) => {
17
18
  const internalImports = new Map();
18
19
  const externalImports = new Set();
19
20
  const unresolvedImports = new Set();
@@ -176,3 +177,4 @@ export const getImportsAndExports = (sourceFile, getResolvedModule, options) =>
176
177
  scripts,
177
178
  };
178
179
  };
180
+ export const _getImportsAndExports = timerify(getImportsAndExports);
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "3.6.0";
1
+ export declare const version = "3.6.1";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '3.6.0';
1
+ export const version = '3.6.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "3.6.0",
3
+ "version": "3.6.1",
4
4
  "description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
5
5
  "homepage": "https://knip.dev",
6
6
  "repository": {
@@ -14,6 +14,16 @@
14
14
  "name": "Lars Kappert",
15
15
  "email": "lars@webpro.nl"
16
16
  },
17
+ "funding": [
18
+ {
19
+ "type": "github",
20
+ "url": "https://github.com/sponsors/webpro"
21
+ },
22
+ {
23
+ "type": "opencollective",
24
+ "url": "https://opencollective.com/webpro"
25
+ }
26
+ ],
17
27
  "main": "./dist/index.js",
18
28
  "bin": {
19
29
  "knip": "./bin/knip.js"
package/schema.json CHANGED
@@ -96,17 +96,17 @@
96
96
  "rules": {
97
97
  "type": "object",
98
98
  "properties": {
99
- "files": { "$ref": "#/definitions/ruleValue" },
99
+ "classMembers": { "$ref": "#/definitions/ruleValue" },
100
100
  "dependencies": { "$ref": "#/definitions/ruleValue" },
101
- "unlisted": { "$ref": "#/definitions/ruleValue" },
102
- "unresolved": { "$ref": "#/definitions/ruleValue" },
101
+ "duplicates": { "$ref": "#/definitions/ruleValue" },
102
+ "enumMembers": { "$ref": "#/definitions/ruleValue" },
103
103
  "exports": { "$ref": "#/definitions/ruleValue" },
104
+ "files": { "$ref": "#/definitions/ruleValue" },
104
105
  "nsExports": { "$ref": "#/definitions/ruleValue" },
105
- "classMembers": { "$ref": "#/definitions/ruleValue" },
106
- "types": { "$ref": "#/definitions/ruleValue" },
107
106
  "nsTypes": { "$ref": "#/definitions/ruleValue" },
108
- "enumMembers": { "$ref": "#/definitions/ruleValue" },
109
- "duplicates": { "$ref": "#/definitions/ruleValue" }
107
+ "types": { "$ref": "#/definitions/ruleValue" },
108
+ "unlisted": { "$ref": "#/definitions/ruleValue" },
109
+ "unresolved": { "$ref": "#/definitions/ruleValue" }
110
110
  }
111
111
  }
112
112
  },
@@ -123,16 +123,18 @@
123
123
  "items": {
124
124
  "type": "string",
125
125
  "enum": [
126
- "files",
126
+ "binaries",
127
+ "classMembers",
127
128
  "dependencies",
128
- "unlisted",
129
+ "duplicates",
130
+ "enumMembers",
129
131
  "exports",
132
+ "files",
130
133
  "nsExports",
131
- "classMembers",
132
- "types",
133
134
  "nsTypes",
134
- "enumMembers",
135
- "duplicates"
135
+ "types",
136
+ "unlisted",
137
+ "unresolved"
136
138
  ]
137
139
  }
138
140
  },