mirror of
https://github.com/chenasraf/DefinitelyTyped.git
synced 2026-05-18 01:49:01 +00:00
Use dtslint (#15482)
This commit is contained in:
6
.github/PULL_REQUEST_TEMPLATE.md
vendored
6
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,19 +1,17 @@
|
||||
Please fill in this template.
|
||||
|
||||
- [ ] Make your PR against the `master` branch.
|
||||
- [ ] Use a meaningful title for the pull request. Include the name of the package modified.
|
||||
- [ ] Test the change in your own code. (Compile and run.)
|
||||
- [ ] Follow the advice from the [readme](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#make-a-pull-request).
|
||||
- [ ] Avoid [common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#common-mistakes).
|
||||
- [ ] Run `tsc` without errors.
|
||||
- [ ] Run `npm run lint package-name` if a `tslint.json` is present.
|
||||
- [ ] Run `npm run lint package-name` (or `tsc` if no `tslint.json` is present).
|
||||
|
||||
Select one of these and delete the others:
|
||||
|
||||
If adding a new definition:
|
||||
- [ ] The package does not provide its own types, and you can not add them.
|
||||
- [ ] If this is for an NPM package, match the name. If not, do not conflict with the name of an NPM package.
|
||||
- [ ] Create it with `npm run new-package package-name`, not by basing it on an existing project.
|
||||
- [ ] Create it with `dts-gen --dt`, not by basing it on an existing project.
|
||||
- [ ] `tslint.json` should be present, and `tsconfig.json` should have `noImplicitAny`, `noImplicitThis`, and `strictNullChecks` set to `true`.
|
||||
|
||||
If changing an existing definition:
|
||||
|
||||
11
README.md
11
README.md
@@ -110,9 +110,8 @@ Your package should have this structure:
|
||||
| tsconfig.json | This allows you to run `tsc` within the package. |
|
||||
| tslint.json | Enables linting. |
|
||||
|
||||
Generate these by running `npm run new-package -- --name my-package-name --template module`.
|
||||
(Other templates are `module-class`, `module-function`, `module-plugin`, `global`, `global-plugin`, and `global-modifying-module`.
|
||||
This just wraps [dts-gen](https://github.com/Microsoft/dts-gen), so it supports all options from that.)
|
||||
Generate these by running `npm install -g dts-gen` and `dts-gen --dt --name my-package-name --template module`.
|
||||
See all options at [dts-gen](https://github.com/Microsoft/dts-gen).
|
||||
|
||||
You may edit the `tsconfig.json` to add new files, to add `"target": "es6"` (needed for async functions), to add to `"lib"`, or to add the `"jsx"` compiler option.
|
||||
|
||||
@@ -167,9 +166,11 @@ If a `tslint.json` turns rules off, this is because that hasn't been fixed yet.
|
||||
}
|
||||
```
|
||||
|
||||
(To indicate that a lint rule truly does not apply, use `// tslint:disable:rule-name` or better, `//tslint:disable-next-line:rule-name`.)
|
||||
(To indicate that a lint rule truly does not apply, use `// tslint:disable rule-name` or better, `//tslint:disable-next-line rule-name`.)
|
||||
|
||||
Test by running `npm run lint package-name` where `package-name` is the name of your package.
|
||||
This script uses [dtslint](https://github.com/Microsoft/dtslint).
|
||||
|
||||
Test the linter by running `npm run lint -- package-name`. Do not use a globally installed tslint.
|
||||
|
||||
## FAQ
|
||||
|
||||
|
||||
@@ -16,13 +16,12 @@
|
||||
},
|
||||
"scripts": {
|
||||
"compile-scripts": "tsc -p scripts",
|
||||
"new-package": "dts-gen --dt",
|
||||
"not-needed": "node scripts/not-needed.js",
|
||||
"lint": "node scripts/lint.js",
|
||||
"test": "node node_modules/types-publisher/bin/tester/test.js --run-from-definitely-typed --nProcesses 1"
|
||||
"test": "node node_modules/types-publisher/bin/tester/test.js --run-from-definitely-typed --nProcesses 1",
|
||||
"lint": "dtslint --dt types"
|
||||
},
|
||||
"devDependencies": {
|
||||
"types-publisher": "Microsoft/types-publisher#production",
|
||||
"dts-gen": "latest"
|
||||
"dtslint": "Microsoft/dtslint#production",
|
||||
"types-publisher": "Microsoft/types-publisher#production"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
// Usage: npm run lint -- my-package-name
|
||||
const pkg = process.argv[2];
|
||||
const execSync = require("child_process").execSync;
|
||||
const existsSync = require("fs").existsSync;
|
||||
const path = require("path");
|
||||
|
||||
const pkgPath = path.join("types", pkg);
|
||||
|
||||
// Path of tslint when `types-publisher` is symlinked
|
||||
const symlinkedTslintPath = "../../node_modules/types-publisher/node_modules/tslint"
|
||||
let tslintPath = existsSync(path.join(pkgPath, symlinkedTslintPath)) ? symlinkedTslintPath : "../node_modules/tslint";
|
||||
// An older version (e.g. abs/v0) is in a nested directory, so needs to look one more level up for tslint.
|
||||
if (pkg.includes("/") && pkg[pkg.length - 1] !== "/") {
|
||||
tslintPath = path.join("..", tslintPath);
|
||||
}
|
||||
|
||||
const cmd = `node ${tslintPath}/lib/tslint-cli --format stylish "**/*.ts"`;
|
||||
console.log(cmd);
|
||||
|
||||
try {
|
||||
// Child process writes directly to our own stdout
|
||||
execSync(cmd, { cwd: pkgPath, stdio: "inherit" });
|
||||
} catch (_) {
|
||||
// Process should have printed out error info
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false
|
||||
"ban-types": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false,
|
||||
"ban-types": false,
|
||||
"unified-signatures": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
],
|
||||
"align": true,
|
||||
"callable-types": false,
|
||||
"forbidden-types": false,
|
||||
"ban-types": false,
|
||||
"indent": [
|
||||
true,
|
||||
"spaces"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as base64js from "base64-js";
|
||||
|
||||
const length: number = base64js.byteLength("");
|
||||
const bytes: Uint8Array = base64js.toByteArray("");
|
||||
const decoded: string = base64js.fromByteArray(new Uint8Array(0));
|
||||
base64js.byteLength(""); // $ExpectType number
|
||||
base64js.toByteArray(""); // $ExpectType Uint8Array
|
||||
base64js.fromByteArray(new Uint8Array(0)); // $ExpectTpe string
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
"no-empty-interface": false,
|
||||
"array-type": false,
|
||||
"unified-signatures": false,
|
||||
"forbidden-types": false
|
||||
"ban-types": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false
|
||||
"ban-types": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false
|
||||
"ban-types": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"callable-types": false,
|
||||
"forbidden-types": false
|
||||
"ban-types": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false
|
||||
"ban-types": false
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
// Heavy use of Function type in this older package.
|
||||
"forbidden-types": false,
|
||||
"ban-types": false,
|
||||
"no-misused-new": false,
|
||||
// not sure what this means
|
||||
"no-single-declare-module": false
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"forbidden-types": false,
|
||||
"ban-types": false,
|
||||
"interface-name": false,
|
||||
"no-empty-interface": false,
|
||||
"unified-signatures": false
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false,
|
||||
"ban-types": false,
|
||||
"unified-signatures": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false,
|
||||
"ban-types": false,
|
||||
"unified-signatures": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"dt-header": false,
|
||||
"forbidden-types": false,
|
||||
"ban-types": false,
|
||||
"unified-signatures": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false,
|
||||
"ban-types": false,
|
||||
"no-single-declare-module": false
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false,
|
||||
"ban-types": false,
|
||||
"unified-signatures": false,
|
||||
"array-type": false,
|
||||
"no-empty-interface": false,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"dt-header": false,
|
||||
"forbidden-types": false,
|
||||
"ban-types": false,
|
||||
"unified-signatures": false,
|
||||
"max-line-length": false,
|
||||
"whitespace": false
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false,
|
||||
"ban-types": false,
|
||||
"unified-signatures": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false
|
||||
"ban-types": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false
|
||||
"ban-types": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false,
|
||||
"ban-types": false,
|
||||
"no-misused-new": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false
|
||||
"ban-types": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false
|
||||
"ban-types": false
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false
|
||||
"ban-types": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"array-type": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"forbidden-types": false,
|
||||
"ban-types": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"max-line-length": false,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false
|
||||
"ban-types": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false
|
||||
"ban-types": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false
|
||||
"ban-types": false
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false,
|
||||
"ban-types": false,
|
||||
"interface-name": false,
|
||||
"no-single-declare-module": false,
|
||||
"unified-signatures": false,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false,
|
||||
"ban-types": false,
|
||||
"no-empty-interface": false,
|
||||
"interface-name": false
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
// Lowercase `object` is available in TypeScript 2.2 only.
|
||||
"forbidden-types": false
|
||||
"ban-types": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false,
|
||||
"ban-types": false,
|
||||
"no-empty-interface": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false,
|
||||
"ban-types": false,
|
||||
"no-empty-interface": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false,
|
||||
"ban-types": false,
|
||||
"no-empty-interface": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false
|
||||
"ban-types": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
// this package augments Rx with namespace level functions
|
||||
// it would be particualrly strange to type these functions differently
|
||||
"forbidden-types": false
|
||||
// it would be particualrly strange to type these functions differently
|
||||
"ban-types": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"rules": {
|
||||
"unified-signatures": false,
|
||||
"no-empty-interface": false,
|
||||
"forbidden-types": false,
|
||||
"ban-types": false,
|
||||
"interface-name": false,
|
||||
"array-type": false,
|
||||
"max-line-length": false,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"forbidden-types": false,
|
||||
"interface-name": [false],
|
||||
"no-empty-interface": false,
|
||||
"unified-signatures": false
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false
|
||||
"ban-types": false
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"callable-types": false,
|
||||
"forbidden-types": false,
|
||||
"ban-types": false,
|
||||
"no-empty-interface": false,
|
||||
"no-single-declare-module": false,
|
||||
"unified-signatures": false
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false
|
||||
"ban-types": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{ "extends": "../node_modules/types-publisher/tslint-definitions.json" }
|
||||
{ "extends": "dtslint/dtslint.json" }
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false
|
||||
"ban-types": false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user