From 66d01fa01a409695bd400ad31570302397b01a15 Mon Sep 17 00:00:00 2001 From: Jack Franklin Date: Fri, 3 Apr 2020 15:22:03 +0100 Subject: [PATCH 1/2] chore: Fix Page.emulateMedia doclint failure This is expected as we now alias `emulateMedia` in `index.js` which isn't a file checked by DocLint. We alias there to avoid having the function overriden by the `asyncInstallHooks` code. This commit updates doclint to know about methods that we expect it will find are missing and in that case just skip over them. We should only do this for methods where we plan to deprecate them or we have to define them in an odd way to work around some problem (and if that's the case long term we should fix that problem so we can define them as normal). --- utils/doclint/check_public_api/index.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/utils/doclint/check_public_api/index.js b/utils/doclint/check_public_api/index.js index 94861aae8b313..43828c7dc417e 100644 --- a/utils/doclint/check_public_api/index.js +++ b/utils/doclint/check_public_api/index.js @@ -154,6 +154,13 @@ function checkDuplicates(doc) { return errors; } +const expectedNonExistingMethods = new Map([ + /* Expected to be missing as the method is deprecated + * and we alias it to Page.prototype.emulateMediaType in index.js + * which is not checked by DocLint + */ + ['Page', new Set(['emulateMedia'])], +]); /** * @param {!Documentation} actual * @param {!Documentation} expected @@ -176,8 +183,12 @@ function compareDocumentations(actual, expected) { const actualMethods = Array.from(actualClass.methods.keys()).sort(); const expectedMethods = Array.from(expectedClass.methods.keys()).sort(); const methodDiff = diff(actualMethods, expectedMethods); - for (const methodName of methodDiff.extra) + for (const methodName of methodDiff.extra) { + const missingMethodsForClass = expectedNonExistingMethods.get(className); + const methodNameIsExpectedMissing = missingMethodsForClass ? missingMethodsForClass.has(methodName) : false; + if (methodNameIsExpectedMissing) continue; errors.push(`Non-existing method found: ${className}.${methodName}()`); + } for (const methodName of methodDiff.missing) errors.push(`Method not found: ${className}.${methodName}()`); From a967ffe9ca477d4f86a42125f6f4c70a0f122eab Mon Sep 17 00:00:00 2001 From: Jack Franklin Date: Mon, 6 Apr 2020 09:11:09 +0100 Subject: [PATCH 2/2] Update utils/doclint/check_public_api/index.js Co-Authored-By: Mathias Bynens --- utils/doclint/check_public_api/index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/utils/doclint/check_public_api/index.js b/utils/doclint/check_public_api/index.js index 43828c7dc417e..838cdc834bc39 100644 --- a/utils/doclint/check_public_api/index.js +++ b/utils/doclint/check_public_api/index.js @@ -185,8 +185,8 @@ function compareDocumentations(actual, expected) { const methodDiff = diff(actualMethods, expectedMethods); for (const methodName of methodDiff.extra) { const missingMethodsForClass = expectedNonExistingMethods.get(className); - const methodNameIsExpectedMissing = missingMethodsForClass ? missingMethodsForClass.has(methodName) : false; - if (methodNameIsExpectedMissing) continue; + if (!missingMethodsForClass) continue; + if (missingMethodsForClass.has(methodName)) continue; errors.push(`Non-existing method found: ${className}.${methodName}()`); } for (const methodName of methodDiff.missing) @@ -346,4 +346,3 @@ function diff(actual, expected) { return i < 0 || j < 0 ? 0 : d[i][j]; } } -