Comparing version 0.1.0 to 0.1.1
@@ -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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
4
7
6
106651
45
1431
- Removedyargs@^6.6.0
- Removedansi-regex@2.1.1(transitive)
- Removedcamelcase@3.0.0(transitive)
- Removedcliui@3.2.0(transitive)
- Removedcode-point-at@1.1.0(transitive)
- Removeddecamelize@1.2.0(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedfind-up@1.1.2(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-caller-file@1.0.3(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhosted-git-info@2.8.9(transitive)
- Removedinvert-kv@1.0.0(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedis-core-module@2.16.1(transitive)
- Removedis-fullwidth-code-point@1.0.0(transitive)
- Removedis-utf8@0.2.1(transitive)
- Removedlcid@1.0.0(transitive)
- Removedload-json-file@1.1.0(transitive)
- Removednormalize-package-data@2.5.0(transitive)
- Removednumber-is-nan@1.0.1(transitive)
- Removedos-locale@1.4.0(transitive)
- Removedparse-json@2.2.0(transitive)
- Removedpath-exists@2.1.0(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpath-type@1.1.0(transitive)
- Removedpify@2.3.0(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
- Removedread-pkg@1.1.0(transitive)
- Removedread-pkg-up@1.0.1(transitive)
- Removedrequire-directory@2.1.1(transitive)
- Removedrequire-main-filename@1.0.1(transitive)
- Removedresolve@1.22.10(transitive)
- Removedsemver@5.7.2(transitive)
- Removedset-blocking@2.0.0(transitive)
- Removedspdx-correct@3.2.0(transitive)
- Removedspdx-exceptions@2.5.0(transitive)
- Removedspdx-expression-parse@3.0.1(transitive)
- Removedspdx-license-ids@3.0.21(transitive)
- Removedstring-width@1.0.2(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedstrip-bom@2.0.0(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedvalidate-npm-package-license@3.0.4(transitive)
- Removedwhich-module@1.0.0(transitive)
- Removedwrap-ansi@2.1.0(transitive)
- Removedy18n@3.2.2(transitive)
- Removedyargs@6.6.0(transitive)
- Removedyargs-parser@4.2.1(transitive)