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.1.0 to 0.1.1

0

bin/checks.js

@@ -0,0 +0,0 @@ "use strict";

103

bin/index.js

@@ -13,6 +13,5 @@ #!/usr/bin/env node

const child_process_1 = require("child_process");
const fs_promise_1 = require("fs-promise");
const path_1 = require("path");
const definitelytyped_header_parser_1 = require("./rules/definitelytyped-header-parser");
const fs_promise_1 = require("fs-promise");
const path = require("path");
const yargs = require("yargs");
const checks_1 = require("./checks");

@@ -23,29 +22,45 @@ const installer_1 = require("./installer");

return __awaiter(this, void 0, void 0, function* () {
const argv = yargs.argv;
for (const key in argv) {
if (!(["_", "clean", "dt", "installAll", "version", "noLint", "tsNext"].includes(key) || /^\$\d$/.test(key))) {
console.error(`Unexpected argument '${key}'\n`);
usage();
return;
const args = process.argv.slice(2);
let clean = false;
let dt = false;
let noLint = false;
let tsNext = false;
let cwdSubDir;
for (const arg of args) {
switch (arg) {
case "--clean":
clean = true;
break;
case "--dt":
dt = true;
break;
case "--installAll":
console.log("Installing for all TypeScript versions...");
yield installer_1.cleanInstalls();
yield installer_1.installAll();
return;
case "--version":
console.log(require("../package.json").version);
return;
case "--noLint":
noLint = true;
break;
case "--tsNext":
tsNext = true;
break;
default:
if (arg.startsWith("--")) {
console.error(`Unknown option '${arg}'`);
usage();
process.exit(1);
}
cwdSubDir = cwdSubDir === undefined ? arg : path_1.join(cwdSubDir, arg);
}
}
if (argv.version) {
console.log(require("../package.json").version);
return;
}
if (argv.installAll) {
console.log("Installing for all TypeScript versions...");
if (clean) {
yield installer_1.cleanInstalls();
yield installer_1.installAll();
return;
}
if (argv.clean) {
console.log("Cleaning typescript installs...");
yield installer_1.cleanInstalls();
console.log("Cleaned.");
}
const cwd = process.cwd();
const name = argv._[0];
const dirPath = name ? path.join(cwd, name) : cwd;
yield runTests(dirPath, { dt: !!argv.dt, noLint: !!argv.noLint, tsNext: !!argv.tsNext });
const dirPath = cwdSubDir ? path_1.join(cwd, cwdSubDir) : cwd;
yield runTests(dirPath, { dt, noLint, tsNext });
});

@@ -56,26 +71,21 @@ }

console.log("Args:");
console.log(" --version Print version and exit.");
console.log(" --dt Run extra checks for DefinitelyTyped packages.");
console.log(" --clean Clean typescript installs and install again.");
console.log(" --noLint Just run 'tsc'.");
console.log(" --tsNext Run with 'typescript@next' instead of the specified version.");
console.log(" --version Print version and exit.");
console.log(" --dt Run extra checks for DefinitelyTyped packages.");
console.log(" --clean Clean TypeScript installs and install again.");
console.log(" --noLint Just run 'tsc'.");
console.log(" --tsNext Run with 'typescript@next' instead of the specified version.");
console.log(" --installAll Cleans and installs all TypeScript versions.");
}
function runTests(dirPath, options) {
return __awaiter(this, void 0, void 0, function* () {
try {
const text = yield fs_promise_1.readFile(path.join(dirPath, "index.d.ts"), "utf-8");
if (text.includes("// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped") && !options.dt) {
console.warn("Warning: Text includes DefinitelyTyped link, but '--dt' is not set.");
}
const version = options.tsNext ? "next" : getTypeScriptVersion(text);
if (options.dt) {
yield checks_1.checkPackageJson(dirPath);
}
yield checks_1.checkTsconfig(dirPath, options);
yield test(dirPath, options, version);
const text = yield fs_promise_1.readFile(path_1.join(dirPath, "index.d.ts"), "utf-8");
if (text.includes("// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped") && !options.dt) {
console.warn("Warning: Text includes DefinitelyTyped link, but '--dt' is not set.");
}
catch (e) {
console.error(e.message);
process.exit(1);
const version = options.tsNext ? "next" : getTypeScriptVersion(text);
if (options.dt) {
yield checks_1.checkPackageJson(dirPath);
}
yield checks_1.checkTsconfig(dirPath, options);
yield test(dirPath, options, version);
});

@@ -131,4 +141,7 @@ }

if (!module.parent) {
main().catch(console.error);
main().catch(err => {
console.error(err.message);
process.exit(1);
});
}
//# sourceMappingURL=index.js.map

@@ -12,5 +12,5 @@ "use strict";

const child_process_1 = require("child_process");
const definitelytyped_header_parser_1 = require("./rules/definitelytyped-header-parser");
const fsp = require("fs-promise");
const path = require("path");
const definitelytyped_header_parser_1 = require("./rules/definitelytyped-header-parser");
const installsDir = path.join(__dirname, "..", "typescript-installs");

@@ -17,0 +17,0 @@ function installAll() {

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

const program = tslint.Linter.createProgram(path.join(dirPath, "tsconfig.json"));
global.program = program;
const lintOptions = {

@@ -33,3 +32,3 @@ fix: false,

const result = linter.getResult();
return result.failureCount ? { message: result.output } : undefined;
return result.failures.length ? { message: result.output } : undefined;
});

@@ -36,0 +35,0 @@ }

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

libraryMinorVersion: label.minor,
projects, contributors, typeScriptVersion
projects, contributors, typeScriptVersion,
}));

@@ -64,3 +64,2 @@ }

}
;
// TODO: Should we do something with the URL?

@@ -67,0 +66,0 @@ const definitionsParser = pm.regexp(/\r?\n\/\/ Definitions: [^\r\n]+/);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const definitelytyped_header_parser_1 = require("./definitelytyped-header-parser");
const path_1 = require("path");
const Lint = require("tslint");
const definitelytyped_header_parser_1 = require("./definitelytyped-header-parser");
class Rule extends Lint.Rules.AbstractRule {

@@ -7,0 +7,0 @@ apply(sourceFile) {

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

// Based on https://github.com/danvk/typings-checker
// TODO: Want TypedRule, but currently it gives me a bad `program`.
class Rule extends Lint.Rules.AbstractRule {
class Rule extends Lint.Rules.TypedRule {
/* tslint:enable:object-literal-sort-keys */

@@ -14,4 +13,4 @@ static FAILURE_STRING(expectedType, actualType) {

}
apply(sourceFile) {
return this.applyWithFunction(sourceFile, ctx => walk(ctx, global.program));
applyWithProgram(sourceFile, program) {
return this.applyWithFunction(sourceFile, ctx => walk(ctx, program));
}

@@ -34,4 +33,3 @@ }

function walk(ctx, program) {
// See https://github.com/palantir/tslint/issues/1969
const sourceFile = program.getSourceFile(ctx.sourceFile.fileName);
const { sourceFile } = ctx;
const checker = program.getTypeChecker();

@@ -38,0 +36,0 @@ // Don't care about emit errors.

@@ -0,0 +0,0 @@ "use strict";

@@ -10,5 +10,4 @@ "use strict";

Rule.metadata = {
ruleName: "no-parent-references",
description: 'Forbid <reference path="../etc"/>',
rationale: "Parent references are not inferred as dependencies by types-publisher.",
ruleName: "no-bad-reference",
description: 'Forbid <reference path="../etc"/> in any file, and forbid <reference path> in test files.',
optionsDescription: "Not configurable.",

@@ -15,0 +14,0 @@ options: null,

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

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

if (ts.isExternalModule(sourceFile)) {
if (!isExportAssign && !isExternalModuleDeclaration(node)) {
if (!isExportAssign && !isDeclareGlobalOrExternalModuleDeclaration(node)) {
ctx.addFailureAtNode(node, "Prefer 'export' to 'declare' in an external module.");

@@ -76,4 +76,5 @@ }

}
function isExternalModuleDeclaration(node) {
return isModuleDeclaration(node) && node.name.kind === ts.SyntaxKind.StringLiteral;
function isDeclareGlobalOrExternalModuleDeclaration(node) {
return isModuleDeclaration(node) && (node.name.kind === ts.SyntaxKind.StringLiteral ||
node.name.kind === ts.SyntaxKind.Identifier && node.name.text === "global");
}

@@ -80,0 +81,0 @@ function isModuleDeclaration(node) {

@@ -5,8 +5,8 @@ "use strict";

const ts = require("typescript");
class Rule extends Lint.Rules.AbstractRule {
apply(sourceFile) {
class Rule extends Lint.Rules.TypedRule {
applyWithProgram(sourceFile, program) {
if (sourceFile.isDeclarationFile) {
return [];
}
return this.applyWithFunction(sourceFile, ctx => walk(ctx, global.program));
return this.applyWithFunction(sourceFile, ctx => walk(ctx, program.getTypeChecker()));
}

@@ -25,6 +25,4 @@ }

"Use a global import as if this were a user of the package.";
function walk(ctx, program) {
// See https://github.com/palantir/tslint/issues/1969
const sourceFile = program.getSourceFile(ctx.sourceFile.fileName);
const checker = program.getTypeChecker();
function walk(ctx, checker) {
const { sourceFile } = ctx;
for (const i of sourceFile.imports) {

@@ -31,0 +29,0 @@ if (i.text.startsWith(".")) {

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

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

&& !Lint.isBlockScopedVariable(node)
&& !(sourceFile.isDeclarationFile && !ts.isExternalModule(ctx.sourceFile) && node.parent === sourceFile)) {
&& !(node.parent.kind === ts.SyntaxKind.ModuleBlock && isDeclareGlobal(node.parent.parent))
&& !(node.parent === sourceFile && !ts.isExternalModule(sourceFile) && sourceFile.isDeclarationFile)) {
ctx.addFailureAtNode(node, Rule.FAILURE_STRING);

@@ -48,2 +49,8 @@ }

}
function isDeclareGlobal(node) {
return isModuleDeclaration(node) && node.name.kind === ts.SyntaxKind.Identifier && node.name.text === "global";
}
function isModuleDeclaration(node) {
return node.kind === ts.SyntaxKind.ModuleDeclaration;
}
//# sourceMappingURL=noVarRule.js.map

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

{
"extends": "tslint:latest",
// This will get overridden with the rules directory in `typescript-installs`. But having this here lets tslint editor plugins work.
// TODO: this won't work until the `global.program` hack is gotten rid of. See `expectRule.ts`.
//"rulesDirectory": "./bin/rules",
"rulesDirectory": "./bin/rules",
"rules": {

@@ -10,6 +8,5 @@ // Custom rules

"export-just-namespace": true,
"no-bad-reference": true,
"no-dead-reference": true,
"no-padding": true,
"no-public": true,
"no-reference-import": true,
"no-relative-import-in-test": true,

@@ -24,5 +21,2 @@ "no-redundant-modifiers": true,

// TODO: once https://github.com/palantir/tslint/pull/2229 is in, enable this
"only-arrow-functions": false,
"no-var-keyword": false,

@@ -33,3 +27,5 @@ "no-var": true,

"max-line-length": [true, 200],
"member-access": [true, "no-public"],
"no-consecutive-blank-lines": true,
"no-unnecessary-callback-wrapper": true,
"object-literal-key-quotes": [true, "as-needed"],

@@ -61,5 +57,3 @@ "one-line": [

"indent": false,
"jsdoc-format": false,
"max-classes-per-file": false,
"member-access": false,
"member-ordering": false,

@@ -71,9 +65,7 @@ "no-angle-bracket-type-assertion": false,

"no-namespace": false,
"no-reference": false, // But see src/tslint/noParentReferencesRule.ts
"no-reference": false, // But see no-bad-reference
"no-shadowed-variable": false,
"no-string-literal": false,
"no-unused-expression": false,
"no-unused-new": false,
"object-literal-sort-keys": false,
"one-variable-per-declaration": false,
"ordered-imports": false,

@@ -80,0 +72,0 @@ "quotemark": false,

{
"name": "dtslint",
"version": "0.1.0",
"version": "0.1.1",
"description": "Runs tests on TypeScript definition files",

@@ -16,2 +16,6 @@ "files": [

],
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/dtslint.git"
},
"scripts": {

@@ -26,4 +30,3 @@ "watch": "tsc --watch",

"strip-json-comments": "^2.0.1",
"tsutils": "^1.1.0",
"yargs": "^6.6.0"
"tsutils": "^1.1.0"
},

@@ -36,4 +39,3 @@ "devDependencies": {

"@types/strip-json-comments": "0.0.28",
"@types/yargs": "^6.6.0",
"tslint": "^4.5.1",
"tslint": "^5.0.0",
"typescript": "^2.2.1"

@@ -40,0 +42,0 @@ },

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

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

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

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