From 3322677250134f225b11535185820c9604361cb2 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 31 Oct 2019 12:39:08 -0700 Subject: [PATCH] Add npm-naming documentation --- docs/npm-naming.md | 67 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 docs/npm-naming.md diff --git a/docs/npm-naming.md b/docs/npm-naming.md new file mode 100644 index 00000000..d8ea39c2 --- /dev/null +++ b/docs/npm-naming.md @@ -0,0 +1,67 @@ +# npm-naming + +(This rule is specific to DefinitelyTyped.) + +Checks that the name of the type package matches a source package on npm. + +--- + +**Bad**: + +```ts +// Type definitions for browser-only-package 1.2 +``` + +* If the package is really browser-only, you have mark it with "non-npm package" +* If the package actually has a matching npm package, you must use that name. + +**Good**: + +```ts +// Type definitions for non-npm package browser-only-package 1.2 +``` + +--- + +**Bad**: + +```ts +// Type definitions for some-package 101.1 +``` + +* The version number in the header must actually exist on npm for the source package. + +**Good**: + +```ts +// Type definitions for some-package 10.1 +``` + +--- + +**Bad**: + +`foo/index.d.ts`: + +```ts +declare function f(): void; +export default f; +``` + +`foo/index.js`: + +```js +module.exports = function () { +}; +``` + +* A commonjs module.exports assignment is not really an export default, and the d.ts should use the `export =` syntax. + +**Good**: + +`foo/index.d.ts`: + +```ts +function f(): void; +export = f; +```