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

dtslint

Package Overview
Dependencies
Maintainers
1
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dtslint - npm Package Compare versions

Comparing version 0.4.9 to 0.5.0

63

bin/index.js

@@ -27,3 +27,13 @@ #!/usr/bin/env node

let shouldListen = false;
let lookingForTsLocal = false;
let tsLocal;
for (const arg of args) {
if (lookingForTsLocal) {
if (arg.startsWith("--")) {
throw new Error("Looking for local path for TS, but got " + arg);
}
tsLocal = arg;
lookingForTsLocal = false;
continue;
}
switch (arg) {

@@ -36,2 +46,5 @@ case "--installAll":

return;
case "--localTs":
lookingForTsLocal = true;
break;
case "--version":

@@ -65,15 +78,22 @@ console.log(require("../package.json").version);

}
if (lookingForTsLocal) {
throw new Error("Path for --localTs was not provided.");
}
if (shouldListen) {
listen(dirPath);
listen(dirPath, tsLocal);
// Do this *after* to ensure messages sent during installation aren't dropped.
yield installer_1.installAll();
if (!tsLocal) {
yield installer_1.installAll();
}
}
else {
if (onlyTestTsNext) {
yield installer_1.installNext();
if (!tsLocal) {
if (onlyTestTsNext) {
yield installer_1.installNext();
}
else {
yield installer_1.installAll();
}
}
else {
yield installer_1.installAll();
}
yield runTests(dirPath, onlyTestTsNext, expectOnly);
yield runTests(dirPath, onlyTestTsNext, expectOnly, tsLocal);
}

@@ -83,12 +103,16 @@ });

function usage() {
console.error("Usage: dtslint [--version] [--installAll]");
console.error("Usage: dtslint [--version] [--installAll] [--onlyTestTsNext] [--expectOnly] [--localTs path]");
console.error("Args:");
console.error(" --version Print version and exit.");
console.error(" --installAll Cleans and installs all TypeScript versions.");
console.error(" --expectOnly Run only the ExpectType lint rule.");
console.error(" --onlyTestTsNext Only run with `typescript@next`, not with the minimum version.");
console.error(" --localTs path Run with *path* as the latest version of TS.");
console.error("");
console.error("onlyTestTsNext and localTs are (1) mutually exclusive and (2) test a single version of TS");
}
function listen(dirPath) {
function listen(dirPath, tsLocal) {
process.on("message", (message) => {
const { path, onlyTestTsNext, expectOnly } = message;
runTests(path_1.join(dirPath, path), onlyTestTsNext, !!expectOnly)
runTests(path_1.join(dirPath, path), onlyTestTsNext, !!expectOnly, tsLocal)
.catch(e => e.stack)

@@ -101,3 +125,3 @@ .then(maybeError => {

}
function runTests(dirPath, onlyTestTsNext, expectOnly) {
function runTests(dirPath, onlyTestTsNext, expectOnly, tsLocal) {
return __awaiter(this, void 0, void 0, function* () {

@@ -135,5 +159,6 @@ const isOlderVersion = /^v\d+$/.test(path_1.basename(dirPath));

}
if (onlyTestTsNext) {
if (onlyTestTsNext || tsLocal) {
const tsVersion = tsLocal ? "local" : "next";
if (typesVersions.length === 0) {
yield testTypesVersion(dirPath, "next", "next", isOlderVersion, dt, indexText, expectOnly);
yield testTypesVersion(dirPath, tsVersion, tsVersion, isOlderVersion, dt, indexText, expectOnly, tsLocal);
}

@@ -144,7 +169,7 @@ else {

const versionIndexText = yield fs_extra_1.readFile(path_1.join(versionPath, "index.d.ts"), "utf-8");
yield testTypesVersion(versionPath, "next", "next", isOlderVersion, dt, versionIndexText, expectOnly, /*inTypesVersionDirectory*/ true);
yield testTypesVersion(versionPath, tsVersion, tsVersion, isOlderVersion, dt, versionIndexText, expectOnly, tsLocal, /*inTypesVersionDirectory*/ true);
}
}
else {
yield testTypesVersion(dirPath, undefined, getTsVersion(0), isOlderVersion, dt, indexText, expectOnly);
yield testTypesVersion(dirPath, undefined, getTsVersion(0), isOlderVersion, dt, indexText, expectOnly, undefined);
for (let i = 0; i < typesVersions.length; i++) {

@@ -154,3 +179,3 @@ const version = typesVersions[i];

const versionIndexText = yield fs_extra_1.readFile(path_1.join(versionPath, "index.d.ts"), "utf-8");
yield testTypesVersion(versionPath, version, getTsVersion(i + 1), isOlderVersion, dt, versionIndexText, expectOnly, /*inTypesVersionDirectory*/ true);
yield testTypesVersion(versionPath, version, getTsVersion(i + 1), isOlderVersion, dt, versionIndexText, expectOnly, undefined, /*inTypesVersionDirectory*/ true);
}

@@ -180,3 +205,3 @@ function getTsVersion(i) {

}
function testTypesVersion(dirPath, lowVersion, maxVersion, isOlderVersion, dt, indexText, expectOnly, inTypesVersionDirectory) {
function testTypesVersion(dirPath, lowVersion, maxVersion, isOlderVersion, dt, indexText, expectOnly, tsLocal, inTypesVersionDirectory) {
return __awaiter(this, void 0, void 0, function* () {

@@ -192,3 +217,3 @@ const minVersionFromComment = getTypeScriptVersionFromComment(indexText);

: undefined);
const err = yield lint_1.lint(dirPath, minVersion, maxVersion, !!inTypesVersionDirectory, expectOnly);
const err = yield lint_1.lint(dirPath, minVersion, maxVersion, !!inTypesVersionDirectory, expectOnly, tsLocal);
if (err) {

@@ -195,0 +220,0 @@ throw new Error(err);

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

Object.defineProperty(exports, "__esModule", { value: true });
const assert = require("assert");
const child_process_1 = require("child_process");

@@ -40,2 +41,5 @@ const definitelytyped_header_parser_1 = require("definitelytyped-header-parser");

return __awaiter(this, void 0, void 0, function* () {
if (version === "local") {
return;
}
const dir = installDir(version);

@@ -55,3 +59,6 @@ if (!(yield fs.pathExists(dir))) {

exports.cleanInstalls = cleanInstalls;
function typeScriptPath(version) {
function typeScriptPath(version, tsLocal) {
if (version === "local") {
return tsLocal + "/typescript.js";
}
return path.join(installDir(version), "node_modules", "typescript");

@@ -61,2 +68,3 @@ }

function installDir(version) {
assert(version !== "local");
return path.join(installsDir, version);

@@ -63,0 +71,0 @@ }

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

const util_1 = require("./util");
function lint(dirPath, minVersion, maxVersion, inTypesVersionDirectory, expectOnly) {
function lint(dirPath, minVersion, maxVersion, inTypesVersionDirectory, expectOnly, tsLocal) {
return __awaiter(this, void 0, void 0, function* () {

@@ -25,3 +25,3 @@ const tsconfigPath = path_1.join(dirPath, "tsconfig.json");

for (const version of [maxVersion, minVersion]) {
const errors = testDependencies(version, dirPath, lintProgram);
const errors = testDependencies(version, dirPath, lintProgram, tsLocal);
if (errors) {

@@ -37,3 +37,3 @@ return errors;

const configPath = expectOnly ? path_1.join(__dirname, "..", "dtslint-expect-only.json") : getConfigPath(dirPath);
const config = yield getLintConfig(configPath, tsconfigPath, minVersion, maxVersion);
const config = yield getLintConfig(configPath, tsconfigPath, minVersion, maxVersion, tsLocal);
for (const file of lintProgram.getSourceFiles()) {

@@ -62,5 +62,6 @@ if (lintProgram.isSourceFileDefaultLibrary(file)) {

exports.lint = lint;
function testDependencies(version, dirPath, lintProgram) {
function testDependencies(version, dirPath, lintProgram, tsLocal) {
const tsconfigPath = path_1.join(dirPath, "tsconfig.json");
const ts = require(installer_1.typeScriptPath(version));
assert(version !== "local" || tsLocal);
const ts = require(installer_1.typeScriptPath(version, tsLocal));
const program = expectRule_1.getProgram(tsconfigPath, ts, version, lintProgram);

@@ -136,3 +137,3 @@ const diagnostics = ts.getPreEmitDiagnostics(program).filter(d => !d.file || isExternalDependency(d.file, dirPath, program));

}
function getLintConfig(expectedConfigPath, tsconfigPath, minVersion, maxVersion) {
function getLintConfig(expectedConfigPath, tsconfigPath, minVersion, maxVersion, tsLocal) {
return __awaiter(this, void 0, void 0, function* () {

@@ -151,3 +152,3 @@ const configExists = yield fs_extra_1.pathExists(expectedConfigPath);

if (expectRule) {
const versionsToTest = range(minVersion, maxVersion).map(versionName => ({ versionName, path: installer_1.typeScriptPath(versionName) }));
const versionsToTest = range(minVersion, maxVersion).map(versionName => ({ versionName, path: installer_1.typeScriptPath(versionName, tsLocal) }));
const expectOptions = { tsconfigPath, versionsToTest };

@@ -164,2 +165,6 @@ expectRule.ruleArguments = [expectOptions];

}
if (minVersion === "local") {
assert(maxVersion === "local");
return ["local"];
}
// The last item of TypeScriptVersion is the unreleased version of Typescript,

@@ -166,0 +171,0 @@ // which is called 'next' on npm, so replace it with 'next'.

{
"name": "dtslint",
"version": "0.4.9",
"version": "0.5.0",
"description": "Runs tests on TypeScript definition files",

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

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