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

@rehearsal/ts-utils

Package Overview
Dependencies
Maintainers
3
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rehearsal/ts-utils - npm Package Compare versions

Comparing version 1.0.15-beta to 1.0.16-beta

dist/test/test/tsconfig.tsbuildinfo

5

dist/src/helpers/typescript-ast.d.ts

@@ -6,7 +6,2 @@ /**

/**
* Find the diagnosed node and passes it to `transformer` function.
* The `transform` function have to return modified node or `undefined` to remove node from AST.
*/
export declare function transformDiagnosedNode(diagnostic: DiagnosticWithLocation, transformer: (node: Node) => Node | undefined): string;
/**
* Checks if node starts with `start` position and its length equals to `length`.

@@ -13,0 +8,0 @@ */

32

dist/src/helpers/typescript-ast.js

@@ -5,24 +5,4 @@ /**

import ts from 'typescript';
const { createPrinter, findAncestor, forEachChild, getLineAndCharacterOfPosition, isCatchClause, isIdentifier, isJsxElement, isJsxFragment, isSourceFile, NewLineKind, transform, visitEachChild, visitNode, } = ts;
const { findAncestor, getLineAndCharacterOfPosition, isCatchClause, isIdentifier, isJsxElement, isJsxFragment, isSourceFile, } = ts;
/**
* Find the diagnosed node and passes it to `transformer` function.
* The `transform` function have to return modified node or `undefined` to remove node from AST.
*/
export function transformDiagnosedNode(diagnostic, transformer) {
const result = transform(diagnostic.file, [
(context) => {
const visit = (node) => {
return isNodeDiagnosed(node, diagnostic)
? transformer(node)
: visitEachChild(node, visit, context);
};
return (node) => visitNode(node, visit);
},
]);
return createPrinter({
newLine: NewLineKind.LineFeed,
removeComments: false,
}).printFile(result.transformed[0]);
}
/**
* Checks if node starts with `start` position and its length equals to `length`.

@@ -57,3 +37,11 @@ */

export function findNodeAtPosition(sourceFile, start, length) {
const visitor = (node) => isNodeAtPosition(node, start, length) ? node : forEachChild(node, visitor);
const visitor = (node) => {
if (isNodeAtPosition(node, start, length)) {
return node;
}
if (node.getStart() <= start && node.getEnd() >= start + length) {
return ts.forEachChild(node, visitor);
}
return undefined;
};
return visitor(sourceFile);

@@ -60,0 +48,0 @@ }

{
"name": "@rehearsal/ts-utils",
"version": "1.0.15-beta",
"version": "1.0.16-beta",
"description": "Rehearsal TypeScript Utils",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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