Comparing version 0.5.5 to 0.5.6
@@ -1,2 +0,1 @@ | ||
#!/usr/bin/env node | ||
"use strict"; | ||
@@ -15,3 +14,2 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
const path_1 = require("path"); | ||
const critic = require("dts-critic"); | ||
const checks_1 = require("./checks"); | ||
@@ -150,5 +148,2 @@ const installer_1 = require("./installer"); | ||
if (dt) { | ||
if (!expectOnly && (yield hasDtHeaderLintRule(path_1.join(dirPath, "tslint.json"))) && isToplevelDtPath(dirPath)) { | ||
yield critic(path_1.join(dirPath, "index.d.ts")); | ||
} | ||
yield checks_1.checkPackageJson(dirPath, typesVersions); | ||
@@ -182,19 +177,2 @@ } | ||
} | ||
function isToplevelDtPath(dirPath) { | ||
return path_1.basename(path_1.dirname(dirPath)) === "types" && | ||
path_1.basename(path_1.dirname(path_1.dirname(dirPath))) === "DefinitelyTyped"; | ||
} | ||
function hasDtHeaderLintRule(tslintPath) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (yield fs_extra_1.pathExists(tslintPath)) { | ||
const tslint = yield util_1.readJson(tslintPath); | ||
if (tslint.rules && tslint.rules["dt-header"] !== undefined) { | ||
return !!tslint.rules["dt-header"]; | ||
} | ||
// if dt-header is not present, assume that tslint.json extends dtslint.json | ||
return true; | ||
} | ||
return false; | ||
}); | ||
} | ||
function testTypesVersion(dirPath, lowVersion, maxVersion, isOlderVersion, dt, indexText, expectOnly, tsLocal, inTypesVersionDirectory) { | ||
@@ -201,0 +179,0 @@ return __awaiter(this, void 0, void 0, function* () { |
"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"); | ||
@@ -30,3 +29,3 @@ const util_1 = require("../util"); | ||
}; | ||
if (!isMainFile(sourceFile.fileName)) { | ||
if (!util_1.isMainFile(sourceFile.fileName)) { | ||
lookFor("// Type definitions for", "Header should only be in `index.d.ts` of the root."); | ||
@@ -43,19 +42,2 @@ lookFor("// TypeScript Version", "TypeScript version should be specified under header in `index.d.ts`."); | ||
} | ||
function isMainFile(fileName) { | ||
// Linter may be run with cwd of the package. We want `index.d.ts` but not `submodule/index.d.ts` to match. | ||
if (fileName === "index.d.ts") { | ||
return true; | ||
} | ||
if (path_1.basename(fileName) !== "index.d.ts") { | ||
return false; | ||
} | ||
let parent = path_1.dirname(fileName); | ||
// May be a directory for an older version, e.g. `v0`. | ||
// Note a types redirect `foo/ts3.1` should not have its own header. | ||
if (/^v\d+$/.test(path_1.basename(parent))) { | ||
parent = path_1.dirname(parent); | ||
} | ||
// 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 |
@@ -106,2 +106,20 @@ "use strict"; | ||
exports.mapDefinedAsync = mapDefinedAsync; | ||
function isMainFile(fileName) { | ||
// Linter may be run with cwd of the package. We want `index.d.ts` but not `submodule/index.d.ts` to match. | ||
if (fileName === "index.d.ts") { | ||
return true; | ||
} | ||
if (path_1.basename(fileName) !== "index.d.ts") { | ||
return false; | ||
} | ||
let parent = path_1.dirname(fileName); | ||
// May be a directory for an older version, e.g. `v0`. | ||
// Note a types redirect `foo/ts3.1` should not have its own header. | ||
if (/^v\d+$/.test(path_1.basename(parent))) { | ||
parent = path_1.dirname(parent); | ||
} | ||
// Allow "types/foo/index.d.ts", not "types/foo/utils/index.d.ts" | ||
return path_1.basename(path_1.dirname(parent)) === "types"; | ||
} | ||
exports.isMainFile = isMainFile; | ||
//# sourceMappingURL=util.js.map |
@@ -24,2 +24,3 @@ { | ||
"void-return": true, | ||
"npm-naming": true, | ||
@@ -26,0 +27,0 @@ "comment-format": [true, "check-space"], // But not check-uppercase or check-lowercase |
{ | ||
"name": "dtslint", | ||
"version": "0.5.5", | ||
"version": "0.5.6", | ||
"description": "Runs tests on TypeScript definition files", | ||
@@ -31,3 +31,3 @@ "files": [ | ||
"definitelytyped-header-parser": "^1.0.1", | ||
"dts-critic": "^1.0.1", | ||
"dts-critic": "^1.0.4", | ||
"fs-extra": "^6.0.1", | ||
@@ -34,0 +34,0 @@ "request": "^2.88.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
181063
64
2472
Updateddts-critic@^1.0.4