From b18b48560cf45ff6e5ea1453467743975fb1b657 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 16 Nov 2016 10:02:19 -0800 Subject: [PATCH] Copy `README.md` and `PULL_REQUEST_TEMPLATE.md` from `types-2.0` --- PULL_REQUEST_TEMPLATE.md | 1 + README.md | 61 ++++++++++++++++------------------------ 2 files changed, 25 insertions(+), 37 deletions(-) diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md index a2c9ec9e5b..a864dbcb13 100644 --- a/PULL_REQUEST_TEMPLATE.md +++ b/PULL_REQUEST_TEMPLATE.md @@ -4,6 +4,7 @@ Please fill in this template. - [ ] Test the change in your own code. - [ ] Follow the advice from the [readme](https://github.com/DefinitelyTyped/DefinitelyTyped#make-a-pull-request). - [ ] Avoid [common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped#common-mistakes). +- [ ] Run `npm run lint -- package-name` if a `tslint.json` is present. If adding a new definition: - [ ] The package does not provide its own types, and you can not add them. diff --git a/README.md b/README.md index 1794dea589..d3e6c0e27c 100644 --- a/README.md +++ b/README.md @@ -109,48 +109,15 @@ Your package should have this structure: | foo-tests.ts | This contains sample code which tests the typings. This code does *not* run, but it is type-checked. | | tsconfig.json | This allows you to run `tsc` within the package. | -`index.d.ts` should start with a header looking like: +Generate these by running `npm run new-package -- new-package-name`. -```ts -// Type definitions for foo 1.2 -// Project: https://github.com/baz/foo -// Definitions by: My Self -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -``` - -The `Project` link does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website. - -`tsconfig.json` should look like this: - -```json -{ - "compilerOptions": { - "module": "commonjs", - "target": "es6", - "noImplicitAny": true, - "strictNullChecks": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "foo-tests.ts" - ] -} -``` - -These should be identical accross projects except that `foo-tests` will be replaced with the name of your test file, -and you may also add the `"jsx"` compiler option if your library needs it. +You may edit the `tsconfig.json` to add new files or to add the `"jsx"` compiler option. DefinitelyTyped members routinely monitor for new PRs, though keep in mind that the number of other PRs may slow things down. For a good example package, see [base64-js](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/types-2.0/base64-js). + #### Common mistakes * First, follow advice from the [handbook](http://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html). @@ -186,7 +153,27 @@ Make a PR doing the following: * Any other packages in DefinitelyTyped that referenced the deleted package should be updated to reference the bundled types. To do this, add a `package.json` with `"dependencies": { "foo": "x.y.z" }`. -When a package is bundled, it no longer needs the header comment – this is only used by DefinitelyTyped, not by the TypeScript compiler. + +#### Lint + +To lint a package, just add a `tslint.json` to that package containing `{ "extends": "../tslint.json" }`. All new packages must be linted. +If a `tslint.json` turns rules off, this is because that hasn't been fixed yet. For example: + +```json +{ + "extends": "../tslint.json", + "rules": { + // This package uses the Function type, and it will take effort to fix. + "forbidden-types": false + } +} +``` + +(To indicate that a lint rule truly does not apply, use `// tslint:disable:rule-name` or better, `//tslint:disable-next-line:rule-name`.) + +Only `.d.ts` files are linted. +Test the linter by running `npm run lint -- package-name`. Do not use a globally installed tslint. + ## FAQ