Skip to content

Commit

Permalink
Add dtslint/dts-critic to the monorepo (#353)
Browse files Browse the repository at this point in the history
* 0.6.2 - update dependencies

* 0.7.0 - log performance data to disk

* Fix lint x(

* 0.7.1 - Update dependencies

* 0.7.2 - Update dts-critic dependency

* 0.7.3 - update dts-critic dependency

* Resolve localTs path (#229)

* 0.7.4 - call path.resolve on tsLocal path

* 0.7.5 - support TS 3.6

* 0.7.6 roll back to definitelytyped-header-parser 1.1

* 0.7.7 - support TS 3.6 again

* Actually change to 0.7.7

* Fix banned words check and update dts-critic (#236)

* 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

* forbid only whole-word 'download'

previously it was any substring.

* 0.7.9 - fix forbidden-word regex for 'download'

* Show TS version in ExpectType error (#237)

I didn't add a test because tslint doesn't support baselines with
newlines in them. It works locally, though.

* 0.8.0: Add TS version to ExpectType errors

* Add CODEOWNERS so PRs ping me

* 0.9 - npm-naming:require d.ts to match npm version

* Update checks.ts (#240)

Not all type definitions use `React.createElement` as the jsx pragma. I bumped into this issue when updating `storybook__preact` types as per DefinitelyTyped/DefinitelyTyped#37275

By adding the compiler option `jsxFactory` other pragmas can be used in type definitions

* 0.9.1 - Update @types/node dependency; allow jsxFactory

* Add documentation about localTs and expectOnly option (#244)

* Add documentation about localTs and expectOnly option

* Update `--expectOnly` description

According to microsoft/dtslint#244 (comment)

Co-Authored-By: Nathan Shively-Sanders <[email protected]>

* Remove long series of empty lines in tool output (#247)

* 0.9.2 - remove bogus newlines+better documentation

Thanks to @IvonGoncharov and @lukyth, respectively.

* Use prepublishOnly instead of made-up do-publish

* ExpectRule creates cache dir (#248)

This is important for users that always use --localTs, which means that
they never run the code that creates the cache directory as part of
installing old versions of typescript.

* 0.9.4 - stop crashing after an initial --localTs run

* 0.9.4 - Add TS3.7 support

* dt-header-parser 3.7.1

* 0.9.5 - definitelytyped-header-parser 3.7.1

* 0.9.6 - dt-header-parser 3.7.2

The 3.7 parser that actually contains 3.7!

* Point ExpectRule users to tsd in README

* Merge pull request #250 from microsoft/multipleExpectTypes

Support $ExpectType with || separating multiple choices

* 0.9.7 - ExpectType supports multiples, sep by ||

* 0.9.8 - update dts-critic dependency

* Fix typo in readme (#251) (#252)

* 0.9.9 - Update dts-critic dependency

* Add support for 3.8 via definitelytyped-header-parser

* Revert to 3.7 definitelytyped-header-parser

* really revert to 3.7

* Add npm-naming documentation

* even more documentation

* unused-dependencies (#261)

* Support TS 3.8

* Drop support for 2.0 2.7 (#264)

* Switch to supported versions of Typescript

I still need to update package-lock.json when I install the shipping
version of definitelytyped-header-parser.

* Upgrade definitelytyped-header-parser

Also fix some lint

* 2.0: stop testing on Typescript 2.0 - 2.7

* Update dts-critic to 2.2.2

* Update dts-critic to 2.2.3

* 2.0.3 - update dtslint and definitelytyped-header-parser

* Support “Minimum” in TS version line (#265)

* 2.0.4 - support "Minimum" in TS version line

* Fix regex typo (#266)

* 2.0.5 - fix Typescript version parsing regex

* Remove unused 'request' dependency (#268)

Maybe I'm missing something but I don't see why it was added in
microsoft/dtslint@3c57139

* 2.0.6 - remove request dependency

* Update npm naming (#269)

* Update npm-naming for new dts-critic

* Remove logs

* Fix tslint errors

* Update node version

* Update docs

* fixes

* Update npm-naming for new dts-critic

* Remove logs

* Fix tslint errors

* Update node version

* Update docs

* fixes

* 3.0 - new version of dts-critic

* Support Node 10 (#272)

* Tslint updater (#274)

* Create tslint updater

* Small fixes

* Adjustments

* Fixes

* Fix jsons

* Explicitly install dependencies

* Add script explanation

* Refactor

* 3.1.0 - turn on dts-critic rules

* 3.2.0 - update definitelytyped-header-parser to TS3.9

* Add support for lint suggestions (#276)

* Support suggestions

* Refactor

* Fix lint errors

* Remove export and add comment

* Refactor

* feat: Disallow `"strict": false` (#277)

* Use TypeScriptVersion.latest instead of "next" (#279)

* Convert latest TS version to "next" on DT

dtslint installs the latest version of typescript as "next" because
that's the npm name.

Probably a better fix is to install typescript@next into a directory
with the same name as the rest, stripping off the .0-dev.20200323 part.

* Just install typescript@next into 3.9 folder

This removes the need to change the name when testing dependencies. I'm
not sure yet about when testing the main package.

* Remove "next" from TsVersion type

Instead, just use TYpeScriptVersion.latest everywhere except when
installing from npm.

* Update TS and fix new compile error

* 3.4 - only use "next" to install from npm

* fix lint

* Merge pull request #280 from microsoft/fixDosPathComparison

Fix issue with path comparison for typesVersions on Windows file systems

* Support parallel minor versions (#282)

* [package] Use latest typescript@next

* Support parallel minor versions.

* 3.4.1 - allow v0.xx packages in one more place

* 3.4.2 - update dts-critic dependency

* Update to 4.0, deprecate 2.8 (#287)

* Update to 4.0, deprecate 2.8

Also switch from definitelytyped-header-parser to
@definitelytyped/header-parser,
@definitelytyped/typescript-versions,
@definitelytyped/utils.

This brings a couple of updates, principally a new way of tracking which
TS versions have shipped under the "latest" tag vs shipped under the
"next" tag. dtslint tests *only* versions that have shipped under
"latest", plus whatever is *currently* shipping under "next". It doesn't
test any betas or RCs.

Note that the new dependencies are currently closed source. We're
waiting on the MS open source legal office to OK the new repos.

* make range handle latest correctly

* reindent tsconfig

* fix lint

* Merge pull request #289 from microsoft/bug/wait-for-installation

Ensure TypeScript is installed before starting

* Lint

* 3.5.1

* 3.5.2

* 3.6 - update dependencies to support shipped TS3.9

* 3.6.1 - update to fixed header-parser

* 3.6.2 - update dts-critic (with fixed header-parser)

* 3.6.3 - update dts-critic

Bugfixes for dts-critic.

* 3.6.4 - update dts-critic dependency

should make dtslint-runner not run out of space

* Use latest @DefinitelyTyped packages to ensure same version as DefinitelyTyped

* 3.6.5

* Update tuple rule for new AST

* 3.6.6

* Merge pull request #292 from microsoft/disable-failing-custom-lint-rules

Disable failing custom lint rules

* 3.6.7

* Disable no-redundant-jsdoc-2 (#294)

It is also broken on typescript@next

* 3.6.8 - disable another failing lint rule

* Update and re-enable tslint rules (#296)

1. Update to dts-critic and @definitelytyped/definitions-parser that use
peerDeps for typescript.
2. Specify dts-critic@latest instead of a specific version.
3. Re-enable the disabled lint rules.

* 3.6.9 - update dependencies, re-enable lint rules

* chore(deps): Move `typescript` to `peerDependencies` (#295)

* 3.6.10 - move TS to peer dep

* 3.6.11 - update dts-critic dependency

* 3.6.12 - update dts-critic dependency

* Merge pull request #301 from microsoft/jsdoc-deprecated-support

Adds a rough approximation of deprecated support

* Merge pull request #302 from microsoft/auto_deploy

Add auto-deploy deploy step

* Check should deploy

* Use main

* Use the right name

* Fix lint, add CI

* Rename CI

* Merge pull request #303 from microsoft/deprecated_allow

Allow JSDoc deprecated anywhere

* 3.7.0 - update for TS 4.1 support

* update package-lock

* Flip typesVersions (#306)

* Flip typesVersions

1. Update @DefinitelyTyped dependencies
2. Simplify+invert runTests

* account for Minimum TS version in ts* directories

* ❤️ lint

* maxVersion: narrow type to removed undefined from first param

* go back to latest of @DefinitelyTyped packages

* 4.0.0 - flip order of typesVersions

Order typesVersions old-to-new, not new-to-old. Also put newest version
in the root, with older versions in ts* subdirectories.

* 4.0.1 - deprecate Typescript 3.1

* 4.0.2 - fixes from @definitelytyped/*

* Add @see tag (#310)

* Add support for @see tag

Also fix no-redundant-jsdoc2 test. It was not testing anything before.

* Move test to correctly named folder

* 4.0.3 - update @DefinitelyTyped dependencies

* 4.0.4 - track import dependencies as well

* 4.0.5 - update @definitelytyped/* and dts-critic

Adds support for 4.2 now that 4.1 is in RC.

* 4.0.6 - Update @definitelytyped/* and dtslint

1. Ship TS 4.1
2. Deprecate TS 3.2

* Fix package when installed using pnpm (#222)

Co-authored-by: Nathan Shively-Sanders <[email protected]>

* Merge pull request #319 from microsoft/tell_npm_instructions

Adds a message telling you to npm install when there's missing deps

* Merge pull request #320 from microsoft/vbump

Version bump and remove travis

* Update jsdoc tags + housekeeping + ts-ignore fix (#324)

1. Update package-lock, including dts-critic' npm@7 fixes
2. Don't forbid ts-ignore or tslint:disable inside node_modules
3. Allow or disallow a bunch of new JSDoc tags.

* 4.0.8 - upgrade no-redundant-jsdoc-2 + fix ts-ignore

* use eslint on this repo (#318)

Co-authored-by: Nathan Shively-Sanders <[email protected]>

* Merge pull request #321 from OliverJAsh/patch-1

Allow `noUncheckedIndexedAccess`

* Merge pull request #317 from jablko/patch-7

Copy advice from the DT common mistakes

* Merge pull request #327 from microsoft/update_node_Types

Update node types

* update to latest @DefinitelyTyped+dts-critic

* Update @DefinitelyTyped+dts-critic

* Version bump to 4.1.0 to workaround npm-should-deploy-action bug

* Disable no-redundant-undefined rule (#336)

It is going to turn into redundant-undefined soon, but in the meantime I
need to turn off the rule so that I can switch DT from complying with
no-redundant-undefined to complying with redundant-undefined.

* 4.1.1 - disable no-redundant-undefined

* no-redundant-undefined: enforce `undefined` for optional parameters (#335)

* make optional properties require undefined

* rename to redundant-undefined

* add missed no-redundant-undefined references

* add fix for missing undefined

* improve fix to handle function types

* Remove checks on properties

Including undefined, or not, is now semantically meaningful when
exactOptionalPropertyTypes is true.

* 4.1.2 - turn on redundant-undefined

Now only optional parameters are required to omit undefined. Optional
properties may include or not include it.

* Allow pre-1.0 /v* subdirectories. (#338)

Does not allow arbitrary minor versions, only 0.*
Matches #723

Fixes #333

* 4.1.3 - allow pre-1.0 /v* subdirectories

* fix(no-single-declare-module): allow single wildcard module declaration (#339)

* Remove 'external module' wording from rules (#340)

The term now is just 'module'. I improved the wording while I was here.

* 4.1.3 - Improve no-single-module rule

- Allow single *.ext modules
- Remove 'external module' wording

* 4.1.5 - update @DefinitelyTyped + dts-critic depenendencies

Add support for TS 4.5
Remove support for TS 3.6

* 4.1.6 - update @DefinitelyTyped + dts-critic depenendencies

* Sync README tsconfig.json with dts-gen template (#345)

* Add concurrency explanation -> FAQ (#343)

* Add concurrency explanation -> FAQ

* Update typescript-installs FAQ

* Merge pull request #346 from microsoft/weswigham-patch-1

Allow package.json files to specify imports/exports/type

* 4.2.0

* Fix typo in tsconfig.json example (#347)

* 4.2.1 - update @DefinitelyTyped and dts-critic dependencies

* Initial commit

* Create README.md

* Initial version

* Add jest (and yargs)

* Working on npm retrieval now

* Basic checking is done

* Improve error handling on the command-line

* Update README and add DT runner

* Add check to dtsCritic. Oops!

* Some minor improvements to index.js

* Changes to DT tester

Plus more normalisation in the core critic

* Add fixer to one Definitely Typed error

It's not a very good fixer.

* Unmangle scoped package names for npm lookup

* Work with non-npm packages

* Correct error code and allow current squatters

They get an explicit check.
Also update readme to explain the new check.

* Bring tests back up to date

* Add author field to package.json

* Correct JSON format in package.json

* Add index.d.ts

* Improve error wording

* Bump package.json to 1.0.2

* Update definitelytyped-header-parser dependency

* Update/publish new npm version

* Update definitelytyped-header-parser

* Update missed tests

* Read source text

Also switch to download-file-sync, and just download files
synchronously. This simplifies the code considerably.

* Error on unmatched 'export default'

* Cleanup

* Fixes to checkNames feature

1. Update dt.js to fix errors from checkNames
2. Handle scoped names in checkNames.
3. Better predicate in checkNames.

* Create ignore list for export default

* Add geojson to list of squatters

See DefinitelyTyped/DefinitelyTyped#33850 for
discussion on how the owners decided to allow this change.

* Print source when `export default` rule fails.

I'm pretty sure unpkg fails some of the time and I don't know what is in
stdout when it does.

* Update package.json for 1.0.5 (and lock)

* Merge pull request #4 from sandersn/do-not-fail-on-500

Do not error for 500 or 524 errors

* 1.0.6 - no error for 5xx errors

* Merge pull request #5 from wooorm/fix-trailing-comma

Remove unneeded trailing comma

* 1.0.7 - remove trailing comma

* Use header version for querying unpkg.

If there is a dt header, use the version from the header to query unpkg
instead of just using the latest version on unpkg.

* 1.0.8 - fix:query unpkg with package version from header

* Couple of fixes

1. No error if types have `export default` AND `export =`. One package
had an incorrect export default in the comments, but correct code.
2. No error if the version specified in the header doesn't correspond to
a version on NPM. This is pretty common! I thought we checked for it.

* 1.0.9 - minor fixes

* 1.1 - add support for TS 3.6

* Update package.json to 1.1.0

* Merge pull request #6 from sandersn/stop-checking-project-url

Stop checking project URL.

* 1.2 : stop requiring project url and npm homepage url to be the same

* Merge pull request #8 from sandersn/require-matching-npm-version

Require matching npm version

* 2.0 - require d.ts to match npm version

* Merge pull request #9 from orta/curl_check

Adds a curl check on launch

* 2.1 - nice error if curl doesn't exist

* Skip Rate exceeded from unpkg too

* 2.2 - skip Rate exceeded from unpkg

* 2.2.1: Update deps + add to error message

* Increase curl buffer size

Some package.jsons were larger than 1 MB. Also remove dependency on
download-file-sync, replacing with a call to execFileSync that specifies
a 50MB buffer.

* Further increase curl buffer size

Turns out 50 MB is not enough. Use 100 MB instead.

* 2.2.3 - increase curl buffer size

* 2.2.4 - update definitelytyped-header-parser

* JS to TS (#14)

* Convert JS to TS

* Configure build and test gulp tasks

* Add eslint

* Fix eslint issues

* Minor fixes

* Update docs instructions

* Add typescript as dependency

* Fix tsconfig noEmit

* Fix gulp build

* Create nodejs.yml

* Merge pull request #16 from DefinitelyTyped/add-build-task

add build task

* Add new checks (#15)

* Create exports checking script

* Minor refactor

* Add new checks to index.ts.

* Rename file

* Minor fixes

* Fix test

* Add option to format result as json

* Update readme

* Nits

* Turn off js exports property check by default

* Fixes

* More nits

* Use enum

* Fixes

* Improve error messages

* More fixes

* More fixes

* Change dtsCritic options

* Change function and error names

* Add mode option to CLI and move some things

* Update readme

* Fixes (#17)

* Fixes

* Rename toExportErrorKind

* Make ErrorKind a string enum

* Path-related fixes

* Update index.ts and remove gulp

* 3.0 - use compiler to check d.ts + better source downloads

* Silence tar warnings

* 3.0.1 - silence tar warning output

* Add engines to package.json (#18)

* Add engines to package.json

* Use node 10.17

* Delete npm sources after usage

This prevents dtslint-runner's overnight run from running out of space
on Azure pipelines

* 3.0.2 - delete npm sources after running

* switch to @definitelytyped/header-parser

* 3.1.0 - update to new header-parser from @DefinitelyTyped

* 3.2.0 - update to 3.9 version of header-parser

* 3.2.1 - update to fixed header-parser

* update typescript to 3.9

* Merge pull request #28 from DefinitelyTyped/use-tmp-for-npm-downloads

Use tmp for npm downloads

* Merge pull request #29 from DefinitelyTyped/ignore-webpack-single-letter-properties

ignore webpack's single-letter properties

* 3.2.2 - use tmp, skip webpack properties

1. Use tmp instead of rimraf to make sure npm package downloads are deleted.
2. Do not report missing-property errors on webpack-emitted single-letter
capital variables.

* resume deleting source after a single run

* 3.2.3 - delete package source each time

It went back to running out of space -- I guess tmp dirs aren't deleted
soon enough.

* 3.2.4 - make typescript a peer dependency

* Merge pull request #31 from DefinitelyTyped/update-yargs-dep

Update yargs dependency

* 3.2.5 - update yargs dependency

* Merge pull request #32 from DefinitelyTyped/dont-squelch-tar-warnings-on-macos

Do not squelch tar warnings on macOS

* 3.2.6 - no tar warnings on macOS

* Merge pull request #34 from DefinitelyTyped/add-prepublish-script

Add prepublishOnly script

* 3.2.7 - actually update .js + add prepublish script

* 3.3.0 update to header-parser with 4.1 support

* 3.3.1: update to header-parser with 3.1 deprecated

* 3.3.2 - update @definitelytyped/header-parser dependency

* 3.3.3 - update @definitelytyped/header-parser for 4.2

* 3.3.4 - update @definitelytyped/header-parser for shipping 4.1

* Merge pull request #42 from DefinitelyTyped/check-stderr-too

Check stderr when stdout is empty

* 3.3.5 - work correctly with npm@7

* 3.3.6 - fix for npm pack on npm@7

* Update to latest header-parser

* 3.3.8 - update to latest header-parser

* 3.3.9 - update @definitelytyped/header-parser dependency

* true 3.3.9 - update @definitelytyped/header-parser

To the version that supports TS 4.5.

* 3.3.10 - update @definitelytyped/header-parser

* 3.3.11 -- update @definitelytyped/header-parser dependency

* Add dtslint and dts-critic to README

* Alter package.jsons and run 'yarn install'

* Post-package-import updates

1. Update some TS usage.
2. Depend on TS internals instead of tsutils for JSDoc.
3. Update name of dtsutil/dts-critic imports.

* Fix lint

Also improve regex for "No interfaces starting with I" so that it no
longer forbids I followed by a lowercase letter.

* Address PR comments

* remove trailing comma from dtslint/package.json

* update versions in new package.json

* fix internal dependency versions

Co-authored-by: Nicholas Jamieson <[email protected]>
Co-authored-by: Juan J. Jimenez-Anca <[email protected]>
Co-authored-by: Kanitkorn Sujautra <[email protected]>
Co-authored-by: Ivan Goncharov <[email protected]>
Co-authored-by: Anders Hejlsberg <[email protected]>
Co-authored-by: Travis Valenti <[email protected]>
Co-authored-by: PopGoesTheWza <[email protected]>
Co-authored-by: Andrew Branch <[email protected]>
Co-authored-by: Gabriela Araujo Britto <[email protected]>
Co-authored-by: Dominik Moritz <[email protected]>
Co-authored-by: ExE Boss <[email protected]>
Co-authored-by: Ron Buckton <[email protected]>
Co-authored-by: Eloy Durán <[email protected]>
Co-authored-by: Andrew Branch <[email protected]>
Co-authored-by: Orta Therox <[email protected]>
Co-authored-by: Orta <[email protected]>
Co-authored-by: James Garbutt <[email protected]>
Co-authored-by: Gautier Ben Aïm <[email protected]>
Co-authored-by: Jack Bates <[email protected]>
Co-authored-by: Wesley Wigham <[email protected]>
Co-authored-by: Andrew Luca <[email protected]>
Co-authored-by: Gabriela Araujo Britto <[email protected]>
  • Loading branch information
23 people authored Dec 1, 2021
1 parent 8ed0b5b commit dae5c76
Show file tree
Hide file tree
Showing 185 changed files with 8,872 additions and 120 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{
"selector": "interface",
"format": ["PascalCase"],
"custom": { "regex": "^I", "match": false } },
"custom": { "regex": "^I[A-Z0-9]", "match": false } },
{
"selector": "class",
"format": ["PascalCase"]
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
A monorepo for formerly disparate DefinitelyTyped-related tools:

- [definitions-parser](packages/definitions-parser): the part of [microsoft/types-publisher](https://github.com/microsoft/types-publisher) that reads DefinitelyTyped repository data
- [dtslint](packages/dtslint): [microsoft/dtslint](https://github.com/microsoft/dtslint)
- [dtslint-runner](packages/dtslint-runner): [DefinitelyTyped/dtslint-runner](https://github.com/DefinitelyTyped/dtslint-runner)
- [dts-critic](packages/dts-critic): [DefinitelyTyped/dts-critic](https://github.com/DefinitelyTyped/dts-critic)
- [header-parser](packages/header-parser): [microsoft/definitelytyped-header-parser](https://github.com/microsoft/definitelytyped-header-parser)
- [perf](packages/perf): [andrewbranch/definitely-not-slow](https://github.com/andrewbranch/definitely-not-slow)
- [publisher](packages/publisher): the rest of [microsoft/types-publisher](https://github.com/microsoft/types-publisher)
Expand Down
69 changes: 69 additions & 0 deletions packages/dts-critic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next

.vscode

# TypeScript compiler output
dist/

# Files downloaded during development
sources/
21 changes: 21 additions & 0 deletions packages/dts-critic/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Nathan Shively-Sanders

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
88 changes: 88 additions & 0 deletions packages/dts-critic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# dts-critic

Checks a new dts against the Javascript sources and tells you what
problems it has.

# Usage

Build the program:
```sh
$ npm run build
```

Run the program using node:
```sh
$ node dist/index.js --dts=path-to-d.ts [--js=path-to-source] [--mode=mode] [--debug]
```

If the d.ts path is to a file named `index.d.ts`, the name of the directory
will be used as the package name instead. For example
`~/dt/types/jquery/index.d.ts` will use `jquery` as the name.

`path-to-source` is optional; if you leave it off, the code will
check npm for a package with the same name as the d.ts.

## Mode

You can run dts-critic in different modes that affect which checks will be performed:
1. `name-only`: dts-critic will check your package name and [DefinitelyTyped header]
(https://github.com/Microsoft/definitelytyped-header-parser) (if present) against npm packages.
For example, if your declaration is for an npm package called 'cool-js-package', it will check if a
package named 'cool-js-package' actually exists in npm.

2. `code`: in addition to the checks performed in `name-only` mode, dts-critic will check if your
declaration exports match the source JavaScript module exports.
For example, if your declaration has a default export, it will check if the JavaScript module also
has a default export.

# Current checks

## Npm declaration
If your declaration is for an npm package:

1. An npm package with the same name of your declaration's package must exist.
2. If your declaration has a [Definitely Typed header](https://github.com/Microsoft/definitelytyped-header-parser)
and the header specifies a target version, the npm package must have
a matching version.
3. If you are running under `code` mode, your declaration must also match the source JavaScript module.

## Non-npm declaration
<!-- 2. If no local path to source is provided, an npm package with the
same name as the d.ts must exist. -->
If your declaration is for a non-npm package (in other words, if your declaration has a
[Definitely Typed header](https://github.com/Microsoft/definitelytyped-header-parser) *and*
the header specifies that the declaration file is for a non-npm package):

1. An npm package with the same name of your declaration's package **cannot** exist.
3. If you are running under `code` mode *and* a path to the JavaScript source file was provided, your
declaration must also match the source JavaScript module.

# Planned work

1. Make sure your module structure fits the source.
2. Make sure your exported symbols match the source.
3. Make sure your types match the source types???
6. Download source based on npm homepage (if it is github).

Note that for real use on Definitely Typed, a lot of these checks need to be pretty loose.

# Also

```sh
$ node dist/dt.js
```

Will run dts-critic on every directory inside `../DefinitelyTyped` and
print errors.

# Contributing

## Testing

The tests use the [Jest](https://jestjs.io/) framework. To build and execute the tests, run:

```sh
$ npm run test
```

This will build the program and run jest.
Loading

0 comments on commit dae5c76

Please sign in to comment.