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.1 to 0.1.2

bin/rules/strictExportDeclareModifiersRule.js

2

bin/checks.js

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

exports.checkPackageJson = checkPackageJson;
function checkTsconfig(dirPath, { dt }) {
function checkTsconfig(dirPath, dt) {
return __awaiter(this, void 0, void 0, function* () {

@@ -31,0 +31,0 @@ const tsconfigPath = path.join(dirPath, "tsconfig.json");

@@ -22,15 +22,11 @@ #!/usr/bin/env node

const args = process.argv.slice(2);
let clean = false;
let dt = false;
let noLint = false;
let tsNext = false;
let cwdSubDir;
let dirPath = process.cwd();
for (const arg of args) {
switch (arg) {
case "--clean":
clean = true;
break;
case "--dt":
dt = true;
break;
console.log("Cleaning installs...");
yield installer_1.cleanInstalls();
return;
case "--installAll":

@@ -56,35 +52,30 @@ console.log("Installing for all TypeScript versions...");

}
cwdSubDir = cwdSubDir === undefined ? arg : path_1.join(cwdSubDir, arg);
dirPath = dirPath === undefined ? arg : path_1.join(dirPath, arg);
}
}
if (clean) {
yield installer_1.cleanInstalls();
}
const cwd = process.cwd();
const dirPath = cwdSubDir ? path_1.join(cwd, cwdSubDir) : cwd;
yield runTests(dirPath, { dt, noLint, tsNext });
yield runTests(dirPath, noLint, tsNext);
});
}
function usage() {
console.log("Usage: dtslint [--dt] [--clean]");
console.log("Usage: dtslint [--version] [--clean] [--noLint] [--tsNext] [--installAll]");
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(" --noLint Just run 'tsc'. (Not recommended.)");
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) {
function runTests(dirPath, noLint, tsNext) {
return __awaiter(this, void 0, void 0, function* () {
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.");
const dt = text.includes("// Type definitions for");
const version = tsNext ? "next" : getTypeScriptVersion(text);
if (!noLint) {
yield lint_1.checkTslintJson(dirPath, dt);
}
const version = options.tsNext ? "next" : getTypeScriptVersion(text);
if (options.dt) {
if (dt) {
yield checks_1.checkPackageJson(dirPath);
}
yield checks_1.checkTsconfig(dirPath, options);
yield test(dirPath, options, version);
yield checks_1.checkTsconfig(dirPath, dt);
yield test(dirPath, noLint, version);
});

@@ -104,23 +95,24 @@ }

}
function test(dirPath, options, version) {
function test(dirPath, noLint, version) {
return __awaiter(this, void 0, void 0, function* () {
const a = yield testWithVersion(dirPath, options, version);
if (a) {
if (version !== definitelytyped_header_parser_1.TypeScriptVersion.Latest) {
const b = yield testWithVersion(dirPath, options, definitelytyped_header_parser_1.TypeScriptVersion.Latest);
if (!b) {
throw new Error(a.message +
`Package compiles in TypeScript ${definitelytyped_header_parser_1.TypeScriptVersion.Latest} but not in ${version}.\n` +
`You can add a line '// TypeScript Version: ${definitelytyped_header_parser_1.TypeScriptVersion.Latest}' to the end of the header ` +
"to specify a newer compiler version.");
}
const errorFromSpecifiedVersion = yield testWithVersion(dirPath, noLint, version);
if (!errorFromSpecifiedVersion) {
return;
}
if (version !== definitelytyped_header_parser_1.TypeScriptVersion.latest) {
const errorFromLatest = yield testWithVersion(dirPath, noLint, definitelytyped_header_parser_1.TypeScriptVersion.latest);
if (!errorFromLatest) {
throw new Error(errorFromSpecifiedVersion +
`Package compiles in TypeScript ${definitelytyped_header_parser_1.TypeScriptVersion.latest} but not in ${version}.\n` +
`You can add a line '// TypeScript Version: ${definitelytyped_header_parser_1.TypeScriptVersion.latest}' to the end of the header ` +
"to specify a newer compiler version.");
}
throw new Error(a.message);
}
throw new Error(errorFromSpecifiedVersion);
});
}
function testWithVersion(dirPath, options, version) {
function testWithVersion(dirPath, noLint, version) {
return __awaiter(this, void 0, void 0, function* () {
yield installer_1.install(version);
if (options.noLint) {
if (noLint) {
// Special for old DefinitelyTyped packages that aren't linted yet.

@@ -130,3 +122,3 @@ return execScript("node " + installer_1.tscPath(version), dirPath);

else {
return lint_1.lintWithVersion(dirPath, options, version);
return lint_1.lintWithVersion(dirPath, version);
}

@@ -137,4 +129,3 @@ });

return new Promise(resolve => {
// Resolves with 'err' if it's present.
child_process_1.exec(cmd, { encoding: "utf8", cwd }, resolve);
child_process_1.exec(cmd, { encoding: "utf8", cwd }, (err, stdout, stderr) => resolve(err ? stdout + stderr : undefined));
});

@@ -141,0 +132,0 @@ }

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

return __awaiter(this, void 0, void 0, function* () {
for (const v of definitelytyped_header_parser_1.TypeScriptVersion.All) {
for (const v of definitelytyped_header_parser_1.TypeScriptVersion.all) {
yield install(v);

@@ -21,0 +21,0 @@ }

@@ -12,9 +12,10 @@ "use strict";

const fs_promise_1 = require("fs-promise");
const path = require("path");
const path_1 = require("path");
const installer_1 = require("./installer");
const util_1 = require("./util");
function lintWithVersion(dirPath, options, version) {
function lintWithVersion(dirPath, version) {
return __awaiter(this, void 0, void 0, function* () {
const configPath = getConfigPath(dirPath);
const tslint = installer_1.getLinter(version);
const program = tslint.Linter.createProgram(path.join(dirPath, "tsconfig.json"));
const program = tslint.Linter.createProgram(path_1.join(dirPath, "tsconfig.json"));
const lintOptions = {

@@ -26,3 +27,3 @@ fix: false,

const linter = new tslint.Linter(lintOptions, program);
const config = yield getLintConfig(tslint.Configuration, path.join(dirPath, "tslint.json"), options);
const config = yield getLintConfig(tslint.Configuration, configPath);
for (const filename of program.getRootFileNames()) {

@@ -33,33 +34,38 @@ const contents = yield fs_promise_1.readFile(filename, "utf-8");

const result = linter.getResult();
return result.failures.length ? { message: result.output } : undefined;
return result.failures.length ? result.output : undefined;
});
}
exports.lintWithVersion = lintWithVersion;
function getLintConfig(configuration, configPath, options) {
function checkTslintJson(dirPath, dt) {
return __awaiter(this, void 0, void 0, function* () {
const configPath = getConfigPath(dirPath);
const shouldExtend = `dtslint/${dt ? "dt" : "dtslint"}.json`;
if (!(yield fs_promise_1.exists(configPath))) {
if (options.dt) {
throw new Error('On DefinitelyTyped, must include `tslint.json` containing `{ "extends": "../tslint.json" }`');
if (dt) {
throw new Error(`On DefinitelyTyped, must include \`tslint.json\` containing \`{ "extends": "${shouldExtend}" }\`.\n` +
"This was inferred as a DefinitelyTyped package because it contains a `// Type definitions for` header.");
}
return defaultConfig(configuration);
return;
}
const tslintJson = yield util_1.readJson(configPath);
if (!tslintJson.extends) {
const shouldExtend = options.dt ? "../tslint.json" : "dtslint/dtslint.json";
if (tslintJson.extends !== shouldExtend) {
throw new Error(`If 'tslint.json' is present, it should extend "${shouldExtend}"`);
}
return loadConfiguration(configuration, configPath);
});
}
function loadConfiguration(configuration, configPath) {
// Second param doesn't matter, since config path is provided.
const config = configuration.findConfiguration(configPath, "").results;
if (!config) {
throw new Error(`Could not load config at ${configPath}`);
}
return config;
exports.checkTslintJson = checkTslintJson;
function getConfigPath(dirPath) {
return path_1.join(dirPath, "tslint.json");
}
function defaultConfig(configuration) {
return loadConfiguration(configuration, path.join(__dirname, "..", "dtslint.json"));
function getLintConfig(configuration, expectedConfigPath) {
return __awaiter(this, void 0, void 0, function* () {
const configPath = (yield fs_promise_1.exists(expectedConfigPath)) ? expectedConfigPath : path_1.join(__dirname, "..", "dtslint.json");
// Second param to `findConfiguration` doesn't matter, since config path is provided.
const config = configuration.findConfiguration(configPath, "").results;
if (!config) {
throw new Error(`Could not load config at ${configPath}`);
}
return config;
});
}
//# sourceMappingURL=lint.js.map

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

(function (TypeScriptVersion) {
TypeScriptVersion.All = ["2.0", "2.1", "2.2"];
TypeScriptVersion.all = ["2.0", "2.1", "2.2"];
/** Latest version that may be specified in a `// TypeScript Version:` header. */
TypeScriptVersion.Latest = "2.2";
TypeScriptVersion.latest = "2.2";
})(TypeScriptVersion = exports.TypeScriptVersion || (exports.TypeScriptVersion = {}));

@@ -11,0 +11,0 @@ function validate(mainFileContent) {

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

}
return path_1.basename(path_1.dirname(parent)) === "DefinitelyTyped";
// Allow "types/foo/index.d.ts", not "types/foo/utils/index.d.ts"
return path_1.basename(path_1.dirname(parent)) === "types";
}
//# sourceMappingURL=dtHeaderRule.js.map

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

class Rule extends Lint.Rules.TypedRule {
/* tslint:enable:object-literal-sort-keys */
static FAILURE_STRING(expectedType, actualType) {
return `Expected type to be '${expectedType}'; got '${actualType}'.`;
return `Expected type to be:\n ${expectedType}\ngot:\n ${actualType}`;
}

@@ -27,2 +26,3 @@ applyWithProgram(sourceFile, program) {

};
/* tslint:enable:object-literal-sort-keys */
Rule.FAILURE_STRING_DUPLICATE_ASSERTION = "This line has 2 $ExpectType assertions.";

@@ -37,3 +37,3 @@ Rule.FAILURE_STRING_ASSERTION_MISSING_NODE = "Can not match a node to this assertion.";

const diagnostics = ts.getPreEmitDiagnostics(program, sourceFile);
if (sourceFile.isDeclarationFile || !sourceFile.text.includes("$ExpectType")) {
if (sourceFile.isDeclarationFile || !/\$Expect(Type|Error)/.test(sourceFile.text)) {
// Normal file.

@@ -43,9 +43,28 @@ for (const diagnostic of diagnostics) {

}
return;
}
else {
const { errors, types } = parseAssertions(sourceFile);
handleExpectError(errors);
addExpectTypeFailures(sourceFile, types);
const { errorLines, typeAssertions, duplicates } = parseAssertions(sourceFile);
for (const line of duplicates) {
addFailureAtLine(line, Rule.FAILURE_STRING_DUPLICATE_ASSERTION);
}
return;
const seenDiagnosticsOnLine = new Set();
for (const diagnostic of diagnostics) {
const line = lineOfPosition(diagnostic.start, sourceFile);
seenDiagnosticsOnLine.add(line);
if (!errorLines.has(line)) {
addDiagnosticFailure(diagnostic);
}
}
for (const line of errorLines) {
if (!seenDiagnosticsOnLine.has(line)) {
addFailureAtLine(line, Rule.FAILURE_STRING_EXPECTED_ERROR);
}
}
const { unmetExpectations, unusedAssertions } = getExpectTypeFailures(sourceFile, typeAssertions, checker);
for (const { node, expected, actual } of unmetExpectations) {
ctx.addFailureAtNode(node, Rule.FAILURE_STRING(expected, actual));
}
for (const line of unusedAssertions) {
addFailureAtLine(line, Rule.FAILURE_STRING_ASSERTION_MISSING_NODE);
}
function addDiagnosticFailure(diagnostic) {

@@ -59,98 +78,93 @@ if (diagnostic.file === sourceFile) {

}
function handleExpectError(errorLines) {
for (const diagnostic of diagnostics) {
const line = lineOfPosition(diagnostic.start);
if (!errorLines.delete(line)) {
addDiagnosticFailure(diagnostic);
}
function addFailureAtLine(line, failure) {
const start = sourceFile.getPositionOfLineAndCharacter(line, 0);
let end = sourceFile.getPositionOfLineAndCharacter(line + 1, 0) - 1;
if (sourceFile.text[end - 1] === "\r") {
end--;
}
for (const line of errorLines) {
addFailureAtLine(line, Rule.FAILURE_STRING_EXPECTED_ERROR);
ctx.addFailure(start, end, failure);
}
}
function parseAssertions(source) {
const scanner = ts.createScanner(ts.ScriptTarget.Latest, /*skipTrivia*/ false, ts.LanguageVariant.Standard, source.text);
const errorLines = new Set();
const typeAssertions = new Map();
const duplicates = [];
let prevTokenPos = -1;
const lineStarts = source.getLineStarts();
let curLine = 0;
const getLine = (pos) => {
// advance curLine to be the line preceding 'pos'
while (lineStarts[curLine + 1] <= pos) {
curLine++;
}
}
// Returns a map from a line number to the expected type at that line.
function parseAssertions(source) {
const scanner = ts.createScanner(ts.ScriptTarget.Latest, /*skipTrivia*/ false, ts.LanguageVariant.Standard, source.text);
const errors = new Set();
const types = new Map();
let prevTokenPos = -1;
const lineStarts = source.getLineStarts();
let curLine = 0;
const getLine = (pos) => {
// advance curLine to be the line preceding 'pos'
while (lineStarts[curLine + 1] <= pos) {
curLine++;
}
const isFirstTokenOnLine = lineStarts[curLine] > prevTokenPos;
// If this is the first token on the line, it applies to the next line.
// Otherwise, it applies to the text to the left of it.
return isFirstTokenOnLine ? curLine + 1 : curLine;
};
loop: while (true) {
const token = scanner.scan();
const pos = scanner.getTokenPos();
switch (token) {
case ts.SyntaxKind.EndOfFileToken:
break loop;
case ts.SyntaxKind.WhitespaceTrivia:
continue loop;
case ts.SyntaxKind.SingleLineCommentTrivia:
const commentText = scanner.getTokenText();
const match = commentText.match(/^\/\/ \$Expect((Type (.*))|Error)/);
if (match) {
const line = getLine(pos);
if (match[1] === "Error") {
if (errors.has(line)) {
addFailureAtLine(line, Rule.FAILURE_STRING_DUPLICATE_ASSERTION);
}
errors.add(line);
const isFirstTokenOnLine = lineStarts[curLine] > prevTokenPos;
// If this is the first token on the line, it applies to the next line.
// Otherwise, it applies to the text to the left of it.
return isFirstTokenOnLine ? curLine + 1 : curLine;
};
loop: while (true) {
const token = scanner.scan();
const pos = scanner.getTokenPos();
switch (token) {
case ts.SyntaxKind.EndOfFileToken:
break loop;
case ts.SyntaxKind.WhitespaceTrivia:
continue loop;
case ts.SyntaxKind.SingleLineCommentTrivia:
const commentText = scanner.getTokenText();
const match = commentText.match(/^\/\/ \$Expect((Type (.*))|Error)/);
if (match) {
const line = getLine(pos);
if (match[1] === "Error") {
if (errorLines.has(line)) {
duplicates.push(line);
}
errorLines.add(line);
}
else {
const expectedType = match[3];
// Don't bother with the assertion if there are 2 assertions on 1 line. Just fail for the duplicate.
if (typeAssertions.delete(line)) {
duplicates.push(line);
}
else {
const expectedType = match[3];
if (types.has(line)) {
addFailureAtLine(line, Rule.FAILURE_STRING_DUPLICATE_ASSERTION);
}
types.set(line, expectedType);
typeAssertions.set(line, expectedType);
}
}
break;
default:
prevTokenPos = pos;
break;
}
}
break;
default:
prevTokenPos = pos;
break;
}
return { errors, types };
}
function addExpectTypeFailures(source, assertions) {
// Match assertions to the first node that appears on the line they apply to.
const iterate = (node) => {
const line = lineOfPosition(node.getStart());
const expectedType = assertions.get(line);
if (expectedType !== undefined) {
// https://github.com/Microsoft/TypeScript/issues/14077
if (util.isExpressionStatement(node)) {
node = node.expression;
}
const actualType = checker.typeToString(checker.getTypeAtLocation(node));
if (actualType !== expectedType) {
ctx.addFailureAtNode(node, Rule.FAILURE_STRING(expectedType, actualType));
}
assertions.delete(line);
return { errorLines, typeAssertions, duplicates };
}
function getExpectTypeFailures(sourceFile, typeAssertions, checker) {
const unmetExpectations = [];
// Match assertions to the first node that appears on the line they apply to.
ts.forEachChild(sourceFile, iterate);
return { unmetExpectations, unusedAssertions: typeAssertions.keys() };
function iterate(node) {
const line = lineOfPosition(node.getStart(sourceFile), sourceFile);
const expected = typeAssertions.get(line);
if (expected !== undefined) {
// https://github.com/Microsoft/TypeScript/issues/14077
if (util.isExpressionStatement(node)) {
node = node.expression;
}
ts.forEachChild(node, iterate);
};
iterate(source);
for (const line of assertions.keys()) {
addFailureAtLine(line, Rule.FAILURE_STRING_ASSERTION_MISSING_NODE);
const type = checker.getTypeAtLocation(node);
const actual = checker.typeToString(type, /*enclosingDeclaration*/ undefined, ts.TypeFormatFlags.NoTruncation);
if (actual !== expected) {
unmetExpectations.push({ node, expected, actual });
}
typeAssertions.delete(line);
}
ts.forEachChild(node, iterate);
}
function lineOfPosition(pos) {
return sourceFile.getLineAndCharacterOfPosition(pos).line;
}
function addFailureAtLine(line, failure) {
const start = sourceFile.getPositionOfLineAndCharacter(line, 0);
const end = sourceFile.getPositionOfLineAndCharacter(line + 1, 0);
ctx.addFailure(start, end, failure);
}
}
function lineOfPosition(pos, sourceFile) {
return sourceFile.getLineAndCharacterOfPosition(pos).line;
}
//# sourceMappingURL=expectRule.js.map

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

apply(sourceFile) {
return this.applyWithWalker(new Walker(sourceFile, this.getOptions()));
return this.applyWithFunction(sourceFile, walk);
}

@@ -22,17 +22,16 @@ }

exports.Rule = Rule;
class Walker extends Lint.RuleWalker {
visitSourceFile(node) {
const exportEqualsNode = node.statements.find(isExportEquals);
if (!exportEqualsNode) {
return;
}
const expr = exportEqualsNode.expression;
if (!util.isIdentifier(expr)) {
return;
}
const exportEqualsName = expr.text;
if (exportEqualsName && isJustNamespace(node.statements, exportEqualsName)) {
this.addFailureAtNode(exportEqualsNode, Rule.FAILURE_STRING);
}
function walk(ctx) {
const { sourceFile: { statements } } = ctx;
const exportEqualsNode = statements.find(isExportEquals);
if (!exportEqualsNode) {
return;
}
const expr = exportEqualsNode.expression;
if (!util.isIdentifier(expr)) {
return;
}
const exportEqualsName = expr.text;
if (exportEqualsName && isJustNamespace(statements, exportEqualsName)) {
ctx.addFailureAtNode(exportEqualsNode, Rule.FAILURE_STRING);
}
}

@@ -39,0 +38,0 @@ function isExportEquals(node) {

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

Rule.FAILURE_STRING = "Don't use <reference path> to reference another package. Use an import or <reference types> instead.";
Rule.FAILURE_STRING_REFERENCE_IN_TEST = "Don't use <reference path> in test files. Use <reference types> or include the file in 'tsconfig.json'";
Rule.FAILURE_STRING_REFERENCE_IN_TEST = "Don't use <reference path> in test files. Use <reference types> or include the file in 'tsconfig.json'.";
exports.Rule = Rule;

@@ -26,7 +26,7 @@ function walk(ctx) {

if (ref.fileName.startsWith("..")) {
ctx.addFailureAt(ref.pos, ref.end, Rule.FAILURE_STRING);
ctx.addFailure(ref.pos, ref.end, Rule.FAILURE_STRING);
}
}
else {
ctx.addFailureAt(ref.pos, ref.end, Rule.FAILURE_STRING_REFERENCE_IN_TEST);
ctx.addFailure(ref.pos, ref.end, Rule.FAILURE_STRING_REFERENCE_IN_TEST);
}

@@ -33,0 +33,0 @@ }

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

function walk(ctx) {
const { sourceFile } = ctx;
if (!sourceFile.statements.length) {
const { sourceFile: { statements, text } } = ctx;
if (!statements.length) {
return;

@@ -28,10 +28,15 @@ }

// 'g' flag lets us set rgx.lastIndex
const rgx = /^\s*\/\/\/ <reference/mg;
const rgx = /^\s*(\/\/\/ <reference)/mg;
// Start search at the first statement. (`/// <reference>` before that is OK.)
rgx.lastIndex = sourceFile.statements[0].getStart();
const match = rgx.exec(sourceFile.text);
if (match !== null) {
ctx.addFailureAt(match.index, 0, Rule.FAILURE_STRING);
rgx.lastIndex = statements[0].getStart();
while (true) {
const match = rgx.exec(text);
if (match === null) {
break;
}
const length = match[1].length;
const start = match.index + match[0].length - length;
ctx.addFailureAt(start, length, Rule.FAILURE_STRING);
}
}
//# sourceMappingURL=noDeadReferenceRule.js.map

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

function walk(ctx) {
eachModuleStatement(ctx.sourceFile, (statement) => {
eachModuleStatement(ctx.sourceFile, statement => {
if (isVariableStatement(statement)) {

@@ -24,0 +24,0 @@ for (const varDecl of statement.declarationList.declarations) {

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

Rule.FAILURE_STRING_LEADING = "File should not begin with a blank line.";
Rule.FAILURE_STRING_TRAILING = "File should not end with a blank line. (Ending in '\\n' OK, ending in '\\n\\n' not OK.)";
Rule.FAILURE_STRING_TRAILING = "File should not end with a blank line. (Ending in one newline OK, ending in two newlines not OK.)";
exports.Rule = Rule;

@@ -24,8 +24,9 @@ function walk(ctx) {

if (text.startsWith("\r") || text.startsWith("\n")) {
ctx.addFailureAt(0, 1, Rule.FAILURE_STRING_LEADING);
ctx.addFailureAt(0, 0, Rule.FAILURE_STRING_LEADING);
}
if (text.endsWith("\n\n") || text.endsWith("\r\n\r\n")) {
ctx.addFailureAt(text.length - 1, 1, Rule.FAILURE_STRING_TRAILING);
const start = text.endsWith("\r\n") ? text.length - 2 : text.length - 1;
ctx.addFailureAt(start, 0, Rule.FAILURE_STRING_TRAILING);
}
}
//# sourceMappingURL=trimFileRule.js.map

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

function walk(ctx) {
ts.forEachChild(ctx.sourceFile, recur);
function recur(node) {
ts.forEachChild(ctx.sourceFile, function cb(node) {
if (node.kind === ts.SyntaxKind.VoidKeyword && !mayContainVoid(node.parent) && !isReturnType(node)) {

@@ -29,5 +28,5 @@ ctx.addFailureAtNode(node, Rule.FAILURE_STRING);

else {
ts.forEachChild(node, recur);
ts.forEachChild(node, cb);
}
}
});
}

@@ -40,2 +39,3 @@ function mayContainVoid({ kind }) {

case ts.SyntaxKind.CallExpression:
case ts.SyntaxKind.TypeParameter:
return true;

@@ -42,0 +42,0 @@ default:

@@ -5,2 +5,5 @@ {

"rules": {
// Wait on 5.2 release (https://github.com/palantir/tslint/pull/2391)
"prefer-const": false,
// Custom rules

@@ -13,3 +16,3 @@ "expect": true,

"no-relative-import-in-test": true,
"no-redundant-modifiers": true,
"strict-export-declare-modifiers": true,
"no-single-declare-module": true,

@@ -16,0 +19,0 @@ "no-useless-files": true,

{
"name": "dtslint",
"version": "0.1.1",
"version": "0.1.2",
"description": "Runs tests on TypeScript definition files",
"files": [
"bin",
"dtslint-definitelytyped.json",
"dt.json",
"dtslint.json"

@@ -23,3 +23,4 @@ ],

"build": "tsc",
"lint": "tslint --project tsconfig.json --type-check --format stylish"
"lint": "tslint --project tsconfig.json --type-check --format stylish",
"test": "node test/test.js"
},

@@ -38,6 +39,9 @@ "dependencies": {

"@types/strip-json-comments": "0.0.28",
"tslint": "^5.0.0",
"typescript": "^2.2.1"
"tslint": "^5.1.0",
"typescript": "^2.3.0"
},
"engines": {
"node": ">=7.0.0"
},
"license": "MIT"
}

@@ -130,3 +130,8 @@ `dtslint` tests a TypeScript declaration file for style and correctness.

## Test
Use `npm run test` to run all tests.
To run a single test: `node node_modules/tslint/bin/tslint --rulesDirectory bin/rules --test test/expect`.
## Publish

@@ -133,0 +138,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

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