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
1
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 6.2.0 to 6.2.1

9

CHANGELOG.md

@@ -0,1 +1,10 @@

## [6.2.1] - 1 Jun 2020
### Changed
- Fix: Dynamically import with destructuring and less whitespace
- Fix: Dynamically import to a promise (Issue #139)
- Fix: Dynamically import with lambda inside div (Issue #140)
- (Internal) Add dynamic import tests involving ternary operator
## [6.2.0] - 11 May 2020

@@ -2,0 +11,0 @@

3

CONTRIBUTING.md

@@ -62,1 +62,4 @@ # Contributing

If you don't know where to put the breakpoint, you can always put it in the first line of the default export of `app.ts`.
Hint: to simplify debugging, you can comment out all the other tests in the file.
In **Visual Code**, a quick way to do this, is to select the tests you want to skip, and press `CTRL + /`.

57

lib/parser/dynamic.js

@@ -28,4 +28,4 @@ "use strict";

var parseDestructuredLambdaParamsToTypes = function (paramList) {
if (paramList.startsWith('{')) {
var names = paramList.substring(1, paramList.length - 2);
if (paramList.startsWith('{') && paramList.endsWith('}')) {
var names = paramList.substring(1, paramList.length - 1);
return names

@@ -76,17 +76,29 @@ .split(',')

};
var tryParseImportExpression = function (expr, addImport) {
var callExpression = util_1.findFirstChildOfKind(expr, ts.SyntaxKind.CallExpression);
if (!(callExpression === null || callExpression === void 0 ? void 0 : callExpression.getText().startsWith('import'))) {
return false;
}
var syntaxListWithFrom = util_1.findFirstChildOfKind(callExpression, ts.SyntaxKind.SyntaxList);
if (!syntaxListWithFrom) {
return false;
}
var from = syntaxListWithFrom.getText();
return addImportViaLambda(expr, from, addImport);
};
var tryParseExpression = function (expr, addImport) {
if (expr.getText().startsWith('import')) {
var callExpression = util_1.findFirstChildOfKind(expr, ts.SyntaxKind.CallExpression);
if (!(callExpression === null || callExpression === void 0 ? void 0 : callExpression.getText().startsWith('import'))) {
return false;
return tryParseImportExpression(expr, addImport);
}
// Handle complex expressions, where the 'import' is buried in a tree.
// Example: see test with Promise.all[]
util_1.recurseIntoChildren(expr, function (node) {
if (isWithExpression(node) && node.getText().startsWith('import')) {
tryParseImportExpression(node, addImport);
}
var syntaxListWithFrom = util_1.findFirstChildOfKind(callExpression, ts.SyntaxKind.SyntaxList);
if (!syntaxListWithFrom) {
return false;
}
var from = syntaxListWithFrom.getText();
return addImportViaLambda(expr, from, addImport);
}
return true;
});
return false;
};
// note: JSX Attributes do not show up as children.
var handleImportWithJsxAttributes = function (attributes, addImport) {

@@ -104,8 +116,11 @@ attributes.properties.forEach(function (prop) {

var handleImportWithinExpression = function (node, addImport) {
var expr = node;
while (isWithExpression(expr)) {
var newExpr = expr.expression;
if (!tryParseExpression(newExpr, addImport)) {
if (ts.isJsxElement(newExpr) || ts.isJsxFragment(newExpr)) {
var jsxExpressions = util_1.findAllChildrenOfKind(newExpr, ts.SyntaxKind.JsxExpression);
var expression1 = null;
if (node.kind === ts.SyntaxKind.CallExpression)
expression1 = node;
else if (isWithExpression(node))
expression1 = node.expression;
while (!!expression1) {
if (!tryParseExpression(expression1, addImport)) {
if (ts.isJsxElement(expression1) || ts.isJsxFragment(expression1)) {
var jsxExpressions = util_1.findAllChildrenOfKind(expression1, ts.SyntaxKind.JsxExpression);
jsxExpressions.forEach(function (j) {

@@ -118,3 +133,3 @@ var jsxExpr = j;

}
var selfClosingElements = util_1.findAllChildrenOfKind(newExpr, ts.SyntaxKind.JsxSelfClosingElement);
var selfClosingElements = util_1.findAllChildrenOfKind(expression1, ts.SyntaxKind.JsxSelfClosingElement);
selfClosingElements.forEach(function (elem) {

@@ -126,4 +141,4 @@ if (ts.isJsxSelfClosingElement(elem)) {

}
if (isWithExpression(newExpr)) {
expr = newExpr;
if (isWithExpression(expression1)) {
expression1 = expression1.expression;
}

@@ -130,0 +145,0 @@ else {

{
"name": "ts-unused-exports",
"version": "6.2.0",
"version": "6.2.1",
"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