Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
Fix banned words check and update dts-critic (#236)
Browse files Browse the repository at this point in the history
* Fix banned words check and update dts-critic

1. Update to dts-critic 1.2, which no longer requires project urls to
include the homepage url specified on npm.
2. Check for banned words for all packages, not just those complex
enough to have a package.json. The location of the check was wrong.

* Remove handling for project url mismatch from npm-naming

* 0.7.7: Fix banned-words check and update dts-critic
  • Loading branch information
sandersn authored Jun 6, 2019
1 parent d9cef9d commit 6e3891a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dtslint",
"version": "0.7.7",
"version": "0.7.8",
"description": "Runs tests on TypeScript definition files",
"files": [
"bin",
Expand Down Expand Up @@ -28,7 +28,7 @@
},
"dependencies": {
"definitelytyped-header-parser": "1.2.0",
"dts-critic": "^1.0.9",
"dts-critic": "^1.2.0",
"fs-extra": "^6.0.1",
"request": "^2.88.0",
"strip-json-comments": "^2.0.1",
Expand Down
10 changes: 1 addition & 9 deletions src/checks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert = require("assert");
import { makeTypesVersionsForPackageJson, TypeScriptVersion } from "definitelytyped-header-parser";
import { pathExists } from "fs-extra";
import { basename, join as joinPaths } from "path";
import { join as joinPaths } from "path";

import { getCompilerOptions, readJson } from "./util";

Expand All @@ -17,14 +17,6 @@ export async function checkPackageJson(
}
return;
}
const basedir = basename(dirPath);
if (/download/.test(basedir) &&
basedir !== "download" &&
basedir !== "downloadjs" &&
basedir !== "s3-download-stream") {
// Since npm won't release their banned-words list, we'll have to manually add to this list.
throw new Error(`${dirPath}: Contains the word 'download', which is banned by npm.`);
}

const pkgJson = await readJson(pkgJsonPath) as {};

Expand Down
12 changes: 12 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ async function runTests(
// Someone may have copied text from DefinitelyTyped to their type definition and included a header,
// so assert that we're really on DefinitelyTyped.
assertPathIsInDefinitelyTyped(dirPath);
assertPathIsNotBanned(dirPath);
}

const typesVersions = await mapDefinedAsync(await readdir(dirPath), async name => {
Expand Down Expand Up @@ -218,6 +219,17 @@ function assertPathIsInDefinitelyTyped(dirPath: string): void {
}
}

function assertPathIsNotBanned(dirPath: string) {
const basedir = basename(dirPath);
if (/download/.test(basedir) &&
basedir !== "download" &&
basedir !== "downloadjs" &&
basedir !== "s3-download-stream") {
// Since npm won't release their banned-words list, we'll have to manually add to this list.
throw new Error(`${dirPath}: Contains the word 'download', which is banned by npm.`);
}
}

function getTypeScriptVersionFromComment(text: string): TypeScriptVersion | undefined {
const searchString = "// TypeScript Version: ";
const x = text.indexOf(searchString);
Expand Down
2 changes: 0 additions & 2 deletions src/rules/npmNamingRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ function walk(ctx: Lint.WalkContext<void>): void {
if (e.message.indexOf("d.ts file must have a matching npm package") > -1 ||
e.message.indexOf("The non-npm package") > -1) {
lookFor("// Type definitions for", e.message);
} else if (e.message.indexOf("At least one of the project urls listed") > -1) {
lookFor("// Project:", e.message);
} else if (e.message.indexOf("export default") > -1) {
lookFor("export default", e.message);
} else {
Expand Down

0 comments on commit 6e3891a

Please sign in to comment.