diff --git a/package.json b/package.json index 055e825c60e54..e50c84356ad96 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "wunit": "npm run wtest", "debug-test": "node --inspect-brk test/test.js", "test-doclint": "node utils/doclint/check_public_api/test/test.js && node utils/doclint/preprocessor/test.js", - "test": "npm run lint --silent && npm run coverage && npm run test-doclint && node utils/testrunner/test/test.js", + "test": "npm run lint --silent && npm run ccoverage && npm run fcoverage && npm run wcoverage && npm run test-doclint && node utils/testrunner/test/test.js", "prepare": "node prepare.js", "lint": "([ \"$CI\" = true ] && eslint --quiet -f codeframe --ext js,ts ./src || eslint --ext js,ts ./src) && npm run tsc && npm run doc", "doc": "node utils/doclint/cli.js", diff --git a/utils/doclint/check_public_api/Documentation.js b/utils/doclint/check_public_api/Documentation.js index ab640ce59b334..f9a6c66dae188 100644 --- a/utils/doclint/check_public_api/Documentation.js +++ b/utils/doclint/check_public_api/Documentation.js @@ -73,7 +73,7 @@ Documentation.Class = class { } } - validateOrder(errors) { + validateOrder(errors, cls) { const members = this.membersArray; // Events should go first. let eventIndex = 0; diff --git a/utils/doclint/check_public_api/JSBuilder.js b/utils/doclint/check_public_api/JSBuilder.js index ee81b9eb8c101..6fc09746982e2 100644 --- a/utils/doclint/check_public_api/JSBuilder.js +++ b/utils/doclint/check_public_api/JSBuilder.js @@ -28,7 +28,7 @@ module.exports = { checkSources, expandPrefix }; function checkSources(sources, externalDependencies) { // special treatment for Events.js const classEvents = new Map(); - const eventsSources = sources.filter(source => source.name().startsWith('events.ts')); + const eventsSources = sources.filter(source => source.name().startsWith('events.')); for (const eventsSource of eventsSources) { const {Events} = require(eventsSource.filePath().endsWith('.js') ? eventsSource.filePath() : eventsSource.filePath().replace(/\bsrc\b/, 'lib').replace('.ts', '.js')); for (const [className, events] of Object.entries(Events)) diff --git a/utils/doclint/check_public_api/MDBuilder.js b/utils/doclint/check_public_api/MDBuilder.js index 898c1afc8fc52..0a726d28d1211 100644 --- a/utils/doclint/check_public_api/MDBuilder.js +++ b/utils/doclint/check_public_api/MDBuilder.js @@ -306,7 +306,7 @@ module.exports = async function(page, sources) { // Push base class documentation to derived classes. for (const [name, clazz] of documentation.classes.entries()) { - clazz.validateOrder(errors); + clazz.validateOrder(errors, clazz); if (!clazz.extends || clazz.extends === 'EventEmitter' || clazz.extends === 'Error') continue; diff --git a/utils/doclint/check_public_api/test/check-duplicates/api.ts b/utils/doclint/check_public_api/test/check-duplicates/api.ts new file mode 100644 index 0000000000000..66b2b7d80f70e --- /dev/null +++ b/utils/doclint/check_public_api/test/check-duplicates/api.ts @@ -0,0 +1,13 @@ +class Foo { + test() { + } + + title(arg: number) { + } +} + +class Bar { +} + +export {Bar}; +export {Foo}; \ No newline at end of file diff --git a/utils/doclint/check_public_api/test/check-duplicates/foo.js b/utils/doclint/check_public_api/test/check-duplicates/foo.js deleted file mode 100644 index 640271ae4928a..0000000000000 --- a/utils/doclint/check_public_api/test/check-duplicates/foo.js +++ /dev/null @@ -1,13 +0,0 @@ -class Foo { - test() { - } - - /** - * @param {number} arg - */ - title(arg) { - } -} - -class Bar { -} diff --git a/utils/doclint/check_public_api/test/check-returns/foo.js b/utils/doclint/check_public_api/test/check-returns/api.ts similarity index 93% rename from utils/doclint/check_public_api/test/check-returns/foo.js rename to utils/doclint/check_public_api/test/check-returns/api.ts index 5833c14699640..b97049ce7e0b8 100644 --- a/utils/doclint/check_public_api/test/check-returns/foo.js +++ b/utils/doclint/check_public_api/test/check-returns/api.ts @@ -18,3 +18,5 @@ class Foo { async asyncFunction() { } } + +export {Foo}; \ No newline at end of file diff --git a/utils/doclint/check_public_api/test/check-sorting/foo.js b/utils/doclint/check_public_api/test/check-sorting/api.ts similarity index 55% rename from utils/doclint/check_public_api/test/check-sorting/foo.js rename to utils/doclint/check_public_api/test/check-sorting/api.ts index 9a61bf11a4d98..8bd0913171e21 100644 --- a/utils/doclint/check_public_api/test/check-sorting/foo.js +++ b/utils/doclint/check_public_api/test/check-sorting/api.ts @@ -1,7 +1,5 @@ class Foo { - constructor() { - this.ddd = 10; - } + ddd = 10; aaa() {} @@ -10,3 +8,4 @@ class Foo { ccc() {} } +export {Foo}; \ No newline at end of file diff --git a/utils/doclint/check_public_api/test/check-sorting/Events.js b/utils/doclint/check_public_api/test/check-sorting/events.js similarity index 100% rename from utils/doclint/check_public_api/test/check-sorting/Events.js rename to utils/doclint/check_public_api/test/check-sorting/events.js diff --git a/utils/doclint/check_public_api/test/diff-arguments/api.ts b/utils/doclint/check_public_api/test/diff-arguments/api.ts new file mode 100644 index 0000000000000..35c054db0f32e --- /dev/null +++ b/utils/doclint/check_public_api/test/diff-arguments/api.ts @@ -0,0 +1,11 @@ +class Foo { + foo(arg1: string, arg3 = {}) { + } + + test(...filePaths : string[]) { + } + + bar(options: {visibility?: boolean}) { + } +} +export {Foo}; \ No newline at end of file diff --git a/utils/doclint/check_public_api/test/diff-arguments/foo.js b/utils/doclint/check_public_api/test/diff-arguments/foo.js deleted file mode 100644 index d102f6f7ae185..0000000000000 --- a/utils/doclint/check_public_api/test/diff-arguments/foo.js +++ /dev/null @@ -1,19 +0,0 @@ -class Foo { - /** - * @param {string} arg1 - */ - foo(arg1, arg3 = {}) { - } - - /** - * @param {...string} filePaths - */ - test(...filePaths) { - } - - /** - * @param {{visibility?: boolean}} options - */ - bar(options) { - } -} diff --git a/utils/doclint/check_public_api/test/diff-classes/api.ts b/utils/doclint/check_public_api/test/diff-classes/api.ts new file mode 100644 index 0000000000000..89af0e79615b7 --- /dev/null +++ b/utils/doclint/check_public_api/test/diff-classes/api.ts @@ -0,0 +1,2 @@ +export {Foo} from './foo'; +export {Other} from './other'; diff --git a/utils/doclint/check_public_api/test/diff-classes/foo.js b/utils/doclint/check_public_api/test/diff-classes/foo.js deleted file mode 100644 index f230fa0f41dde..0000000000000 --- a/utils/doclint/check_public_api/test/diff-classes/foo.js +++ /dev/null @@ -1,2 +0,0 @@ -class Foo { -} diff --git a/utils/doclint/check_public_api/test/diff-classes/foo.ts b/utils/doclint/check_public_api/test/diff-classes/foo.ts new file mode 100644 index 0000000000000..08c51dd90dbed --- /dev/null +++ b/utils/doclint/check_public_api/test/diff-classes/foo.ts @@ -0,0 +1,2 @@ +export class Foo { +} diff --git a/utils/doclint/check_public_api/test/diff-classes/other.js b/utils/doclint/check_public_api/test/diff-classes/other.js deleted file mode 100644 index 1b94418eb0af4..0000000000000 --- a/utils/doclint/check_public_api/test/diff-classes/other.js +++ /dev/null @@ -1,2 +0,0 @@ -class Other { -} diff --git a/utils/doclint/check_public_api/test/diff-classes/other.ts b/utils/doclint/check_public_api/test/diff-classes/other.ts new file mode 100644 index 0000000000000..57e436cf889b8 --- /dev/null +++ b/utils/doclint/check_public_api/test/diff-classes/other.ts @@ -0,0 +1,2 @@ +export class Other { +} diff --git a/utils/doclint/check_public_api/test/diff-events/foo.js b/utils/doclint/check_public_api/test/diff-events/api.ts similarity index 53% rename from utils/doclint/check_public_api/test/diff-events/foo.js rename to utils/doclint/check_public_api/test/diff-events/api.ts index fbb14b31366de..8a15f23400107 100644 --- a/utils/doclint/check_public_api/test/diff-events/foo.js +++ b/utils/doclint/check_public_api/test/diff-events/api.ts @@ -1,3 +1,4 @@ class Foo { } +export {Foo}; \ No newline at end of file diff --git a/utils/doclint/check_public_api/test/diff-events/Events.js b/utils/doclint/check_public_api/test/diff-events/events.js similarity index 100% rename from utils/doclint/check_public_api/test/diff-events/Events.js rename to utils/doclint/check_public_api/test/diff-events/events.js diff --git a/utils/doclint/check_public_api/test/diff-methods/foo.js b/utils/doclint/check_public_api/test/diff-methods/api.ts similarity index 87% rename from utils/doclint/check_public_api/test/diff-methods/foo.js rename to utils/doclint/check_public_api/test/diff-methods/api.ts index 76f44edab7730..3142fc70d2aab 100644 --- a/utils/doclint/check_public_api/test/diff-methods/foo.js +++ b/utils/doclint/check_public_api/test/diff-methods/api.ts @@ -14,3 +14,5 @@ class Foo { money$$money() { } } + +export {Foo}; \ No newline at end of file diff --git a/utils/doclint/check_public_api/test/diff-properties/api.ts b/utils/doclint/check_public_api/test/diff-properties/api.ts new file mode 100644 index 0000000000000..40b7cecf89b39 --- /dev/null +++ b/utils/doclint/check_public_api/test/diff-properties/api.ts @@ -0,0 +1,5 @@ +class Foo { + a = 42; + b = 'hello'; +} +export {Foo}; \ No newline at end of file diff --git a/utils/doclint/check_public_api/test/diff-properties/foo.js b/utils/doclint/check_public_api/test/diff-properties/foo.js deleted file mode 100644 index a978379f2cefe..0000000000000 --- a/utils/doclint/check_public_api/test/diff-properties/foo.js +++ /dev/null @@ -1,7 +0,0 @@ -class Foo { - constructor() { - this.a = 42; - this.b = 'hello'; - this.emit('done'); - } -} diff --git a/utils/doclint/check_public_api/test/js-builder-common/foo.js b/utils/doclint/check_public_api/test/js-builder-common/api.ts similarity index 69% rename from utils/doclint/check_public_api/test/js-builder-common/foo.js rename to utils/doclint/check_public_api/test/js-builder-common/api.ts index cf82646e3c3e9..5251e4fe17c8b 100644 --- a/utils/doclint/check_public_api/test/js-builder-common/foo.js +++ b/utils/doclint/check_public_api/test/js-builder-common/api.ts @@ -1,7 +1,7 @@ class A { + property1 = 1; + _property2 = 2; constructor(delegate) { - this.property1 = 1; - this._property2 = 2; } get getter() { @@ -11,3 +11,5 @@ class A { async method(foo, bar) { } } + +export {A}; \ No newline at end of file diff --git a/utils/doclint/check_public_api/test/js-builder-common/Events.js b/utils/doclint/check_public_api/test/js-builder-common/events.js similarity index 100% rename from utils/doclint/check_public_api/test/js-builder-common/Events.js rename to utils/doclint/check_public_api/test/js-builder-common/events.js diff --git a/utils/doclint/check_public_api/test/js-builder-inheritance/foo.js b/utils/doclint/check_public_api/test/js-builder-inheritance/api.ts similarity index 82% rename from utils/doclint/check_public_api/test/js-builder-inheritance/foo.js rename to utils/doclint/check_public_api/test/js-builder-inheritance/api.ts index 1d5cb154d48e3..914588a0f71fd 100644 --- a/utils/doclint/check_public_api/test/js-builder-inheritance/foo.js +++ b/utils/doclint/check_public_api/test/js-builder-inheritance/api.ts @@ -13,3 +13,6 @@ class B extends A { bar(override) { } } + +export {A}; +export {B}; \ No newline at end of file diff --git a/utils/doclint/check_public_api/test/js-builder-inheritance/Events.js b/utils/doclint/check_public_api/test/js-builder-inheritance/events.js similarity index 100% rename from utils/doclint/check_public_api/test/js-builder-inheritance/Events.js rename to utils/doclint/check_public_api/test/js-builder-inheritance/events.js diff --git a/utils/doclint/check_public_api/test/test.js b/utils/doclint/check_public_api/test/test.js index 269da71f5dadc..cdf7663d7e6fb 100644 --- a/utils/doclint/check_public_api/test/test.js +++ b/utils/doclint/check_public_api/test/test.js @@ -34,7 +34,7 @@ let browserContext; let page; beforeAll(async function() { - browser = await playwright.launch(); + browser = await playwright.chromium.launch(); page = await browser.newPage(); }); @@ -65,8 +65,9 @@ async function testLint(state, test) { }); const mdSources = await Source.readdir(dirPath, '.md'); + const tsSources = await Source.readdir(dirPath, '.ts'); const jsSources = await Source.readdir(dirPath, '.js'); - const messages = await checkPublicAPI(page, mdSources, jsSources); + const messages = await checkPublicAPI(page, mdSources, jsSources.concat(tsSources)); const errors = messages.map(message => message.text); expect(errors.join('\n')).toBeGolden('result.txt'); } @@ -86,8 +87,9 @@ async function testJSBuilder(state, test) { const {expect} = new Matchers({ toBeGolden: GoldenUtils.compare.bind(null, dirPath, dirPath) }); - const sources = await Source.readdir(dirPath, '.js'); - const {documentation} = await jsBuilder(sources); + const jsSources = await Source.readdir(dirPath, '.js'); + const tsSources = await Source.readdir(dirPath, '.ts'); + const {documentation} = await jsBuilder.checkSources(jsSources.concat(tsSources)); expect(serialize(documentation)).toBeGolden('result.txt'); }