New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ts-unused-exports

Package Overview
Dependencies
Maintainers
2
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-unused-exports - npm Package Compare versions

Comparing version 10.1.0 to 11.0.0

29

CHANGELOG.md

@@ -0,1 +1,30 @@

## [11.0.0] - 25 Nov 2024
### Changed
- BREAKING CHANGE: The default export (API entry point) has been changed to be compatible with esm module (should also work with cjs)
- BREAKING CHANGE: The results (API) structure has been changed:
- OLD:
```ts
const result = {
"filePath1": { /* ... */ },
"filePath2": { /* ... */ },
/* ... */
unusedFiles: { /* ... */ },
};
```
- NEW:
```ts
const result = {
unusedExports: {
"filePath1": { /* ... */ },
"filePath2": { /* ... */ },
/* ... */
},
unusedFiles: [ "filePath1", "filePath2", /*"..."*/ ]
};
```
- fix: The scope of --ignoreTestFiles has been reduced, to make it less likely to exclude non-test files
- (internal) built using Node v20.13.1
## [10.1.0] - 24 May 2024

@@ -2,0 +31,0 @@

2

CONTRIBUTING.md

@@ -66,1 +66,3 @@ # Contributing

In **Visual Code**, a quick way to do this, is to select the tests you want to skip, and press `CTRL + /`.
Hint: to run only certain tests from the command line, place the `@only` decorator just before the test. Then execute them via `test:unit:only`.

6

lib/analyzer.js

@@ -195,3 +195,3 @@ "use strict";

filteredFiles.forEach(function (file) { return processImports(file, exportMap); });
var analysis = {};
var analysis = { unusedExports: {} };
var unusedFiles = [];

@@ -215,5 +215,5 @@ Object.keys(exportMap).forEach(function (file) {

var realExportNames = Object.keys(exports);
analysis[path] = [];
analysis.unusedExports[path] = [];
unusedExports.forEach(function (e) {
analysis[path].push({
analysis.unusedExports[path].push({
exportName: makeExportStarRelativeForPresentation(extraOptions === null || extraOptions === void 0 ? void 0 : extraOptions.baseUrl, e),

@@ -220,0 +220,0 @@ location: exports[e].location,

import { Analysis } from './analyzer';
declare const _default: (tsconfigPath: string, files?: string[] | undefined) => Analysis;
export default _default;
export declare const analyzeTsConfig: (tsconfigPath: string, files?: string[] | undefined) => Analysis;

@@ -14,2 +14,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.analyzeTsConfig = void 0;
var ts = require("typescript");

@@ -48,3 +49,3 @@ var analyzer_1 = require("./analyzer");

};
exports.default = (function (tsconfigPath, files) {
exports.analyzeTsConfig = function (tsconfigPath, files) {
var args = argsParser_1.extractOptionsFromFiles(files);

@@ -54,3 +55,3 @@ var tsConfig = loadTsConfig(tsconfigPath, args.tsFiles);

return analyzer_1.default(parser_1.default(tsConfig, args.options), options);
});
};
//# sourceMappingURL=app.js.map

@@ -71,3 +71,3 @@ "use strict";

{
ignoreFilesRegex.push("(spec|test|Test)");
ignoreFilesRegex.push("(.spec|.test|Test.*)");
}

@@ -74,0 +74,0 @@ break;

@@ -37,3 +37,3 @@ "use strict";

files.forEach(function (path) {
analysis[path].forEach(function (unusedExport) {
analysis.unusedExports[path].forEach(function (unusedExport) {
showMessage("" + path + getLocationInFile(unusedExport.location) + ": " + chalk.bold.yellow(unusedExport.exportName));

@@ -45,3 +45,3 @@ });

files.forEach(function (path) {
return showMessage(path + ": " + chalk.bold.yellow(analysis[path].map(function (r) { return r.exportName; }).join(', ')));
return showMessage(path + ": " + chalk.bold.yellow(analysis.unusedExports[path].map(function (r) { return r.exportName; }).join(', ')));
});

@@ -63,4 +63,4 @@ }

try {
var _b = app_1.default(tsconfig, tsFiles.length ? tsFiles : undefined), unusedFiles = _b.unusedFiles, analysis_1 = __rest(_b, ["unusedFiles"]);
var files = Object.keys(analysis_1);
var _b = app_1.analyzeTsConfig(tsconfig, tsFiles.length ? tsFiles : undefined), unusedFiles = _b.unusedFiles, analysis_1 = __rest(_b, ["unusedFiles"]);
var files = Object.keys(analysis_1.unusedExports);
var options = argsParser_1.extractOptionsFromFiles(tsFiles).options;

@@ -78,3 +78,3 @@ var hideMessages = (options === null || options === void 0 ? void 0 : options.silent) && files.length === 0;

var totalIssues = files
.map(function (f) { return analysis_1[f].length; })
.map(function (f) { return analysis_1.unusedExports[f].length; })
.reduce(function (previous, current) { return previous + current; }, 0);

@@ -81,0 +81,0 @@ return exitWith(Math.min(MAX_ALLOWED_EXIT_CODE, totalIssues));

@@ -63,3 +63,5 @@ "use strict";

case ts.SyntaxKind.VariableStatement:
return parseExportNames(node.declarationList.declarations[0].name.getText());
return parseExportNames(
// prettier-ignore
node.declarationList.declarations[0].name.getText());
case ts.SyntaxKind.FunctionDeclaration:

@@ -66,0 +68,0 @@ var name_1 = node.name;

@@ -26,3 +26,5 @@ export interface Imports {

}
export declare type Analysis = AnalysisExports & AnalysisUnusedFiles;
export declare type Analysis = {
unusedExports: AnalysisExports;
} & AnalysisUnusedFiles;
export interface TsConfigPaths {

@@ -29,0 +31,0 @@ [glob: string]: string[];

{
"name": "ts-unused-exports",
"version": "10.1.0",
"version": "11.0.0",
"description": "ts-unused-exports finds unused exported symbols in your Typescript project",

@@ -5,0 +5,0 @@ "main": "lib/app.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc