mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
a614bc45aa
* chore: migrate `src/Connection` to TypeScript This commit migrates `src/Connection` to TypeScript. It also changes its exports to be ESM because TypeScript's support for exporting values to use as types via CommonJS is poor (by design) and so rather than battle that it made more sense to migrate the file to ESM. The good news is that TypeScript is still outputting to `lib/` as CommonJS, so the fact that we author in ESM is actually not a breaking change at all. So going forwards we will: * migrate TS files to use ESM for importing and exporting * continue to output to `lib/` as CommonJS * continue to use CommonJS requires when in a `src/*.js` file I'd also like to split `Connection.ts` into two; I think the `CDPSession` class belongs in its own file, but I will do that in another PR to avoid this one becoming bigger than it already is. I also turned off `@typescript-eslint/no-use-before-define` as I don't think it was adding value and Puppeteer's codebase seems to have a style of declaring helper functions at the bottom which is fine by me. Finally, I updated the DocLint tool so it knows of expected method mismatches. It was either that or come up with a smart way to support TypeScript generics in DocLint and given we don't want to use DocLint that much longer that didn't feel worth it. * Fix params being required |
||
---|---|---|
.. | ||
check_public_api | ||
generate_types | ||
preprocessor | ||
.gitignore | ||
cli.js | ||
Message.js | ||
README.md | ||
Source.js |
DocLint
Doclint is a small program that lints Puppeteer's documentation against Puppeteer's source code.
Doclint works in a few steps:
- Read sources in
lib/
folder, parse AST trees and extract public API- note that we run DocLint on the outputted JavaScript in
lib/
rather than the source code insrc/
. We will do this until we have migratedsrc/
to be exclusively TypeScript and then we can update DocLint to support TypeScript.
- note that we run DocLint on the outputted JavaScript in
- Read sources in
docs/
folder, render markdown to HTML, use puppeteer to traverse the HTML and extract described API - Compare one API to another
Doclint is also responsible for general markdown checks, most notably for the table of contents relevancy.
Running
npm run doc
Tests
Doclint has its own set of jasmine tests, located at utils/doclint/test
folder.
To execute tests, run:
npm run test-doclint