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

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: microsoft/dtslint
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4e2deaa675fea5d8cacd6db209b6eb76871a70c1
Choose a base ref
...
head repository: microsoft/dtslint
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5f7605cea35054286c1dce02e5cb081ee350f16a
Choose a head ref
  • 2 commits
  • 7 files changed
  • 2 contributors

Commits on Dec 31, 2019

  1. Copy the full SHA
    05257e7 View commit details

Commits on Jan 6, 2020

  1. Copy the full SHA
    5f7605c View commit details
Showing with 22 additions and 21 deletions.
  1. +1 −1 README.md
  2. +11 −11 package-lock.json
  3. +3 −3 package.json
  4. +4 −5 src/index.ts
  5. +1 −0 src/rules/dtHeaderRule.ts
  6. +1 −1 src/rules/expectRule.ts
  7. +1 −0 test/dt-header/correct/types/foo/index.d.ts.lint
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -109,7 +109,7 @@ Normally packages will be tested using TypeScript 2.0.
To use a newer version, specify it by including a comment like so:

```ts
// TypeScript Version: 2.1
// Minimum TypeScript Version: 2.1
```

For DefinitelyTyped packages, this should go just under the header (on line 5).
22 changes: 11 additions & 11 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dtslint",
"version": "2.0.2",
"version": "2.0.3",
"description": "Runs tests on TypeScript definition files",
"files": [
"bin",
@@ -27,8 +27,8 @@
"prepublishOnly": "npm run build && npm run test && npm run lint"
},
"dependencies": {
"definitelytyped-header-parser": "3.8.1",
"dts-critic": "^2.2.3",
"definitelytyped-header-parser": "3.8.2",
"dts-critic": "^2.2.4",
"fs-extra": "^6.0.1",
"request": "^2.88.0",
"strip-json-comments": "^2.0.1",
9 changes: 4 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -195,7 +195,7 @@ async function testTypesVersion(
): Promise<void> {
const minVersionFromComment = getTypeScriptVersionFromComment(indexText);
if (minVersionFromComment !== undefined && inTypesVersionDirectory) {
throw new Error(`Already in the \`ts${lowVersion}\` directory, don't need \`// TypeScript Version\`.`);
throw new Error(`Already in the \`ts${lowVersion}\` directory, don't need \`// Minimum TypeScript Version\`.`);
}
const minVersion = lowVersion
|| minVersionFromComment && TypeScriptVersion.isSupported(minVersionFromComment) && minVersionFromComment
@@ -238,13 +238,12 @@ function assertPathIsNotBanned(dirPath: string) {
}

function getTypeScriptVersionFromComment(text: string): AllTypeScriptVersion | undefined {
const searchString = "// TypeScript Version: ";
const x = text.indexOf(searchString);
if (x === -1) {
const match = text.match(/\/\/ (?:Minimum)? TypeScript Version: /);
if (!match) {
return undefined;
}

let line = text.slice(x, text.indexOf("\n", x));
let line = text.slice(match.index, text.indexOf("\n", match.index));
if (line.endsWith("\r")) {
line = line.slice(0, line.length - 1);
}
1 change: 1 addition & 0 deletions src/rules/dtHeaderRule.ts
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@ function walk(ctx: Lint.WalkContext<void>): void {
if (!isMainFile(sourceFile.fileName, /*allowNested*/ true)) {
lookFor("// Type definitions for", "Header should only be in `index.d.ts` of the root.");
lookFor("// TypeScript Version", "TypeScript version should be specified under header in `index.d.ts`.");
lookFor("// Minimum TypeScript Version", "TypeScript version should be specified under header in `index.d.ts`.");
return;
}

2 changes: 1 addition & 1 deletion src/rules/expectRule.ts
Original file line number Diff line number Diff line change
@@ -211,7 +211,7 @@ function walk(
const msg = `Compile error in typescript@${versionName} but not in typescript@${nextHigherVersion}.\n`;
const explain = nextHigherVersion === "next"
? "TypeScript@next features not yet supported."
: `Fix with a comment '// TypeScript Version: ${nextHigherVersion}' just under the header.`;
: `Fix with a comment '// Minimum TypeScript Version: ${nextHigherVersion}' just under the header.`;
return msg + explain;
}
}
1 change: 1 addition & 0 deletions test/dt-header/correct/types/foo/index.d.ts.lint
Original file line number Diff line number Diff line change
@@ -2,3 +2,4 @@
// Project: https://github.com/bobby-headers/dt-header
// Definitions by: Jane Doe <https://github.com/janedoe>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Minimum TypeScript Version: 3.1