Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Fix Page.emulateMedia doclint failure #5584

Merged
merged 2 commits into from Apr 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions utils/doclint/check_public_api/index.js
Expand Up @@ -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
Expand All @@ -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);
if (!missingMethodsForClass) continue;
if (missingMethodsForClass.has(methodName)) continue;
errors.push(`Non-existing method found: ${className}.${methodName}()`);
}
for (const methodName of methodDiff.missing)
errors.push(`Method not found: ${className}.${methodName}()`);

Expand Down Expand Up @@ -335,4 +346,3 @@ function diff(actual, expected) {
return i < 0 || j < 0 ? 0 : d[i][j];
}
}