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

typescript-parser

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typescript-parser - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

6

code-generators/typescript-generators/namedImport.js

@@ -38,3 +38,7 @@ "use strict";

const lib = imp.libraryName;
const importString = `import {${space}${specifiers}${space}} from ${stringQuoteStyle}${lib}${stringQuoteStyle}${eol}`;
let importSpecifiers = `${space}${specifiers}${space}`;
if (importSpecifiers.trim().length === 0) {
importSpecifiers = ' ';
}
const importString = `import {${importSpecifiers}} from ${stringQuoteStyle}${lib}${stringQuoteStyle}${eol}`;
if (importString.length > multiLineWrapThreshold) {

@@ -41,0 +45,0 @@ const spacings = Array(tabSize + 1).join(' ');

9

DeclarationIndex.js

@@ -26,4 +26,3 @@ "use strict";

const nodeIndex = dirs.indexOf('node_modules');
return dirs.slice(nodeIndex + 1).join('/')
.replace(/([.]d)?([.]tsx?)?/g, '')
return PathHelpers_1.normalizeFilename(dirs.slice(nodeIndex + 1).join('/'))
.replace(new RegExp(`/(index|${dirs[nodeIndex + 1]}|${dirs[dirs.length - 2]})$`), '');

@@ -169,3 +168,3 @@ }

const filePath = PathHelpers_1.normalizePathUri(change);
const resource = '/' + path_1.relative(this.rootPath, filePath).replace(/[.]tsx?/g, '');
const resource = '/' + PathHelpers_1.normalizeFilename(path_1.relative(this.rootPath, filePath));
if (removeResources.indexOf(resource) < 0) {

@@ -182,3 +181,3 @@ removeResources.push(resource);

const filePath = PathHelpers_1.normalizePathUri(change);
const resource = '/' + path_1.relative(this.rootPath, filePath).replace(/[.]tsx?/g, '');
const resource = '/' + PathHelpers_1.normalizeFilename(path_1.relative(this.rootPath, filePath));
if (rebuildResources.indexOf(resource) < 0) {

@@ -351,3 +350,3 @@ rebuildResources.push(resource);

else {
sourceLib = '/' + path_1.relative(this.rootPath, sourceLib).replace(/([.]d)?[.]tsx?/g, '');
sourceLib = '/' + PathHelpers_1.normalizeFilename(path_1.relative(this.rootPath, sourceLib));
}

@@ -354,0 +353,0 @@ if (!parsedResources[sourceLib]) {

{
"name": "typescript-parser",
"version": "1.2.1",
"version": "1.3.0",
"description": "Parser for typescript (and javascript) files, that compiles those files and generates a human understandable AST.",

@@ -45,3 +45,3 @@ "main": "index.js",

"tsutils": "^2.7.1",
"typedoc": "^0.7.1"
"typedoc": "^0.8.0"
},

@@ -48,0 +48,0 @@ "dependencies": {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = require("path");
const PathHelpers_1 = require("../utilities/PathHelpers");
const Module_1 = require("./Module");

@@ -27,3 +28,3 @@ const Namespace_1 = require("./Namespace");

get identifier() {
return '/' + path_1.relative(this.rootPath, this.filePath).replace(/([.]d)?[.]tsx?/g, '');
return '/' + PathHelpers_1.normalizeFilename(path_1.relative(this.rootPath, this.filePath));
}

@@ -30,0 +31,0 @@ get nonLocalUsages() {

@@ -52,4 +52,9 @@ import { NamedImport } from '../../imports/NamedImport';

const lib = imp.libraryName;
let importSpecifiers = `${space}${specifiers}${space}`;
if (importSpecifiers.trim().length === 0) {
importSpecifiers = ' ';
}
const importString = `import {${space}${specifiers}${space}} from ${stringQuoteStyle}${lib}${stringQuoteStyle}${eol}`;
const importString = `import {${importSpecifiers}} from ${stringQuoteStyle}${lib}${stringQuoteStyle}${eol}`;
if (importString.length > multiLineWrapThreshold) {

@@ -56,0 +61,0 @@ const spacings = Array(tabSize + 1).join(' ');

@@ -15,3 +15,3 @@ import { difference, differenceWith, intersection, isEqual } from 'lodash';

import { TypescriptParser } from './TypescriptParser';
import { normalizePathUri } from './utilities/PathHelpers';
import { normalizeFilename, normalizePathUri } from './utilities/PathHelpers';

@@ -29,4 +29,3 @@ /**

return dirs.slice(nodeIndex + 1).join('/')
.replace(/([.]d)?([.]tsx?)?/g, '')
return normalizeFilename(dirs.slice(nodeIndex + 1).join('/'))
.replace(new RegExp(`/(index|${dirs[nodeIndex + 1]}|${dirs[dirs.length - 2]})$`), '');

@@ -227,3 +226,3 @@ }

const filePath = normalizePathUri(change);
const resource = '/' + relative(this.rootPath, filePath).replace(/[.]tsx?/g, '');
const resource = '/' + normalizeFilename(relative(this.rootPath, filePath));

@@ -243,3 +242,3 @@ if (removeResources.indexOf(resource) < 0) {

const filePath = normalizePathUri(change);
const resource = '/' + relative(this.rootPath, filePath).replace(/[.]tsx?/g, '');
const resource = '/' + normalizeFilename(relative(this.rootPath, filePath));

@@ -434,3 +433,3 @@ if (rebuildResources.indexOf(resource) < 0) {

} else {
sourceLib = '/' + relative(this.rootPath, sourceLib).replace(/([.]d)?[.]tsx?/g, '');
sourceLib = '/' + normalizeFilename(relative(this.rootPath, sourceLib));
}

@@ -437,0 +436,0 @@

@@ -7,2 +7,3 @@ import { parse, ParsedPath, relative } from 'path';

import { Node } from '../Node';
import { normalizeFilename } from '../utilities/PathHelpers';
import { Module } from './Module';

@@ -28,3 +29,3 @@ import { Namespace } from './Namespace';

public get identifier(): string {
return '/' + relative(this.rootPath, this.filePath).replace(/([.]d)?[.]tsx?/g, '');
return '/' + normalizeFilename(relative(this.rootPath, this.filePath));
}

@@ -38,4 +39,4 @@

.concat(
this.resources.reduce((all, cur) => all.concat(cur.nonLocalUsages), [] as string[]),
);
this.resources.reduce((all, cur) => all.concat(cur.nonLocalUsages), [] as string[]),
);
}

@@ -65,3 +66,3 @@

constructor(public filePath: string, private rootPath: string, public start: number, public end: number) {}
constructor(public filePath: string, private rootPath: string, public start: number, public end: number) { }
}

@@ -55,3 +55,3 @@ import { readFileSync } from 'fs';

public async parseSource(source: string): Promise<File> {
return await this.parseTypescript(createSourceFile('inline.ts', source, ScriptTarget.ES2015, true), '/');
return await this.parseTypescript(createSourceFile('inline.tsx', source, ScriptTarget.ES2015, true), '/');
}

@@ -58,0 +58,0 @@

@@ -18,1 +18,13 @@ import { platform } from 'os';

}
/**
* Returns an adjusted and normalized filepath to use within the index.
* Essentially does remove `.tsx` `.ts` `.js` `.jsx` endings and other adjustments.
*
* @export
* @param {string} filepath
* @returns {string}
*/
export function normalizeFilename(filepath: string): string {
return filepath.replace(/([.]d)?[.](t|j)sx?$/g, '');
}

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

return tslib_1.__awaiter(this, void 0, void 0, function* () {
return yield this.parseTypescript(typescript_1.createSourceFile('inline.ts', source, typescript_1.ScriptTarget.ES2015, true), '/');
return yield this.parseTypescript(typescript_1.createSourceFile('inline.tsx', source, typescript_1.ScriptTarget.ES2015, true), '/');
});

@@ -41,0 +41,0 @@ }

@@ -9,1 +9,10 @@ /**

export declare function normalizePathUri(uri: string): string;
/**
* Returns an adjusted and normalized filepath to use within the index.
* Essentially does remove `.tsx` `.ts` `.js` `.jsx` endings and other adjustments.
*
* @export
* @param {string} filepath
* @returns {string}
*/
export declare function normalizeFilename(filepath: string): string;

@@ -19,1 +19,13 @@ "use strict";

exports.normalizePathUri = normalizePathUri;
/**
* Returns an adjusted and normalized filepath to use within the index.
* Essentially does remove `.tsx` `.ts` `.js` `.jsx` endings and other adjustments.
*
* @export
* @param {string} filepath
* @returns {string}
*/
function normalizeFilename(filepath) {
return filepath.replace(/([.]d)?[.](t|j)sx?$/g, '');
}
exports.normalizeFilename = normalizeFilename;
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