ts-unused-exports
Advanced tools
Comparing version 5.4.0 to 5.5.0
@@ -0,1 +1,7 @@ | ||
## [5.5.0] - 20 Jan 2020 | ||
### Added | ||
- Add option --allowUnusedTypes to skip unused types or interfaces. | ||
## [5.4.0] - 19 Jan 2020 | ||
@@ -2,0 +8,0 @@ |
@@ -74,3 +74,3 @@ "use strict"; | ||
imports[key].forEach(function (imp) { | ||
return imp == '*' | ||
return imp === '*' | ||
? Object.keys(ex) | ||
@@ -77,0 +77,0 @@ .filter(function (e) { return e != 'default'; }) |
@@ -18,2 +18,5 @@ "use strict"; | ||
switch (optionName) { | ||
case '--allowUnusedTypes': | ||
newOptions.allowUnusedTypes = true; | ||
break; | ||
case '--exitWithCount': | ||
@@ -20,0 +23,0 @@ newOptions.exitWithCount = true; |
import * as ts from 'typescript'; | ||
import { LocationInFile } from '../types'; | ||
import { LocationInFile, ExtraCommandLineOptions } from '../types'; | ||
import { FromWhat } from './common'; | ||
@@ -10,2 +10,2 @@ export declare const extractExportStatement: (decl: ts.ExportDeclaration) => string[]; | ||
export declare const extractExport: (path: string, node: ts.Node) => string; | ||
export declare const addExportCore: (exportName: string, file: ts.SourceFile, node: ts.Node, exportLocations: LocationInFile[], exports: string[]) => void; | ||
export declare const addExportCore: (exportName: string, file: ts.SourceFile, node: ts.Node, exportLocations: LocationInFile[], exports: string[], extraOptions?: ExtraCommandLineOptions | undefined) => void; |
@@ -46,4 +46,16 @@ "use strict"; | ||
}; | ||
exports.addExportCore = function (exportName, file, node, exportLocations, exports) { | ||
if (exports.includes(exportName)) { | ||
var TYPE_NODE_KINDS = [ | ||
ts.SyntaxKind.InterfaceDeclaration, | ||
ts.SyntaxKind.TypeAliasDeclaration, | ||
]; | ||
var shouldNodeTypeBeIgnored = function (node, extraOptions) { | ||
var _a; | ||
var allowUnusedTypes = !!((_a = extraOptions) === null || _a === void 0 ? void 0 : _a.allowUnusedTypes); | ||
if (!allowUnusedTypes) | ||
return false; | ||
return TYPE_NODE_KINDS.includes(node.kind); | ||
}; | ||
exports.addExportCore = function (exportName, file, node, exportLocations, exports, extraOptions) { | ||
if (exports.includes(exportName) || | ||
shouldNodeTypeBeIgnored(node, extraOptions)) { | ||
return; | ||
@@ -50,0 +62,0 @@ } |
@@ -32,3 +32,3 @@ "use strict"; | ||
var addExport = function (exportName, node) { | ||
export_1.addExportCore(exportName, file, node, exportLocations, exportNames); | ||
export_1.addExportCore(exportName, file, node, exportLocations, exportNames, extraOptions); | ||
}; | ||
@@ -35,0 +35,0 @@ ts.forEachChild(file, function (node) { |
@@ -32,2 +32,3 @@ export interface Imports { | ||
export interface ExtraCommandLineOptions { | ||
allowUnusedTypes?: boolean; | ||
exitWithCount?: boolean; | ||
@@ -34,0 +35,0 @@ excludeDeclarationFiles?: boolean; |
@@ -1,1 +0,1 @@ | ||
export declare const USAGE = "\n usage: ts-unused-exports path/to/tsconfig.json [file1.ts file2.ts] [--excludeDeclarationFiles][--exitWithCount][--ignorePaths=path1;path2][--searchNamespaces][--showLineNumber]\n \n Note: if no file is specified after tsconfig, the files will be read from the\n tsconfig's \"files\" key which must be present.\n\n If the files are specified, their path must be relative to the tsconfig file.\n For example, given:\n /\n |-- config\n | -- tsconfig.json\n -- src\n -- file.ts\n\n Then the usage would be:\n ts-unused-exports config/tsconfig.json ../src/file.ts\n "; | ||
export declare const USAGE = "\n usage: ts-unused-exports path/to/tsconfig.json [file1.ts file2.ts] [--allowUnusedTypes][--excludeDeclarationFiles][--exitWithCount][--ignorePaths=path1;path2][--searchNamespaces][--showLineNumber]\n \n Note: if no file is specified after tsconfig, the files will be read from the\n tsconfig's \"files\" key which must be present.\n\n If the files are specified, their path must be relative to the tsconfig file.\n For example, given:\n /\n |-- config\n | -- tsconfig.json\n -- src\n -- file.ts\n\n Then the usage would be:\n ts-unused-exports config/tsconfig.json ../src/file.ts\n "; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.USAGE = "\n usage: ts-unused-exports path/to/tsconfig.json [file1.ts file2.ts] [--excludeDeclarationFiles][--exitWithCount][--ignorePaths=path1;path2][--searchNamespaces][--showLineNumber]\n \n Note: if no file is specified after tsconfig, the files will be read from the\n tsconfig's \"files\" key which must be present.\n\n If the files are specified, their path must be relative to the tsconfig file.\n For example, given:\n /\n |-- config\n | -- tsconfig.json\n -- src\n -- file.ts\n\n Then the usage would be:\n ts-unused-exports config/tsconfig.json ../src/file.ts\n "; | ||
exports.USAGE = "\n usage: ts-unused-exports path/to/tsconfig.json [file1.ts file2.ts] [--allowUnusedTypes][--excludeDeclarationFiles][--exitWithCount][--ignorePaths=path1;path2][--searchNamespaces][--showLineNumber]\n \n Note: if no file is specified after tsconfig, the files will be read from the\n tsconfig's \"files\" key which must be present.\n\n If the files are specified, their path must be relative to the tsconfig file.\n For example, given:\n /\n |-- config\n | -- tsconfig.json\n -- src\n -- file.ts\n\n Then the usage would be:\n ts-unused-exports config/tsconfig.json ../src/file.ts\n "; | ||
//# sourceMappingURL=usage.js.map |
{ | ||
"name": "ts-unused-exports", | ||
"version": "5.4.0", | ||
"version": "5.5.0", | ||
"description": "ts-unused-exports finds unused exported symbols in your Typescript project", | ||
@@ -5,0 +5,0 @@ "main": "lib/app.js", |
@@ -56,9 +56,10 @@ # ts-unused-exports | ||
| Option name | Description | Example | | ||
| ------------------------- | ---------------------------------------------------------------------------- | --------------------------- | | ||
| ` --searchNamespaces` | Enable searching for unused exports within namespaces. Note: this can affect performance on large codebases. | `--searchNamespaces` | | ||
| `excludeDeclarationFiles` | Exclude `.d.ts` files when looking for unused exports. | `--excludeDeclarationFiles` | | ||
| `exitWithCount` | Set the process exit code to be the count of files that have unused exports. | `--exitWithCount` | | ||
| `ignorePaths` | Exclude files that match the given path segments. | `--ignorePaths=math;utils` | | ||
| `showLineNumber` | Show the line number and column of the unused export. | `--showLineNumber` | | ||
| Option name | Description | Example | | ||
| ------------------------- | ------------------------------------------------------------------------------------------------------------ | --------------------------- | | ||
| `allowUnusedTypes` | Allow unused `type` or `interface`. | `--allowUnusedTypes` | | ||
| `excludeDeclarationFiles` | Exclude `.d.ts` files when looking for unused exports. | `--excludeDeclarationFiles` | | ||
| `exitWithCount` | Set the process exit code to be the count of files that have unused exports. | `--exitWithCount` | | ||
| `ignorePaths` | Exclude files that match the given path segments. | `--ignorePaths=math;utils` | | ||
| `--searchNamespaces` | Enable searching for unused exports within namespaces. Note: this can affect performance on large codebases. | `--searchNamespaces` | | ||
| `showLineNumber` | Show the line number and column of the unused export. | `--showLineNumber` | | ||
@@ -154,3 +155,3 @@ Note that if `ts-unused-exports` is called without files, the files will be read from the tsconfig's `files` or `include` key which must be present. If called with files, then those file paths should be relative to the `tsconfig.json`, just like you would specify them in your tsconfig's `files` key. | ||
# Changelog (Release History) | ||
# Changelog (Release History) | ||
@@ -157,0 +158,0 @@ To see what has changed in each version, please see our [CHANGELOG.md](https://github.com/pzavolinsky/ts-unused-exports/blob/master/CHANGELOG.md). |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
90679
1244
168