chore: upgrade and pin prettier dependencies (#7232)

We're seeing odd failures with Prettier on some CI branches; my hunch is that they are installing different versions of the package and therefore getting formatting conflicts. This PR updates them all and pins them to specific versions - something we should probably consider generally, or remove our `package-lock.json` from the gitignore.
This commit is contained in:
Jack Franklin 2021-05-12 15:48:30 +01:00 committed by GitHub
parent d9ace6c664
commit 523aa0aafa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 74 additions and 101 deletions

View File

@ -88,10 +88,10 @@
"commonmark": "^0.28.1", "commonmark": "^0.28.1",
"cross-env": "^7.0.2", "cross-env": "^7.0.2",
"eslint": "^7.10.0", "eslint": "^7.10.0",
"eslint-config-prettier": "^6.12.0", "eslint-config-prettier": "8.3.0",
"eslint-plugin-import": "^2.22.0", "eslint-plugin-import": "^2.22.0",
"eslint-plugin-mocha": "^8.0.0", "eslint-plugin-mocha": "^8.0.0",
"eslint-plugin-prettier": "^3.1.4", "eslint-plugin-prettier": "3.4.0",
"eslint-plugin-unicorn": "^22.0.0", "eslint-plugin-unicorn": "^22.0.0",
"esprima": "^4.0.0", "esprima": "^4.0.0",
"expect": "^25.2.7", "expect": "^25.2.7",
@ -103,7 +103,7 @@
"ncp": "^2.0.0", "ncp": "^2.0.0",
"pixelmatch": "^4.0.2", "pixelmatch": "^4.0.2",
"pngjs": "^5.0.0", "pngjs": "^5.0.0",
"prettier": "^2.1.2", "prettier": "2.3.0",
"sinon": "^9.0.2", "sinon": "^9.0.2",
"source-map-support": "^0.5.19", "source-map-support": "^0.5.19",
"standard-version": "^9.0.0", "standard-version": "^9.0.0",

View File

@ -52,7 +52,8 @@ function parseAriaSelector(selector: string): ariaQueryOption {
const normalize = (value: string): string => value.replace(/ +/g, ' ').trim(); const normalize = (value: string): string => value.replace(/ +/g, ' ').trim();
const knownAttributes = new Set(['name', 'role']); const knownAttributes = new Set(['name', 'role']);
const queryOptions: ariaQueryOption = {}; const queryOptions: ariaQueryOption = {};
const attributeRegexp = /\[\s*(?<attribute>\w+)\s*=\s*"(?<value>\\.|[^"\\]*)"\s*\]/g; const attributeRegexp =
/\[\s*(?<attribute>\w+)\s*=\s*"(?<value>\\.|[^"\\]*)"\s*\]/g;
const defaultName = selector.replace( const defaultName = selector.replace(
attributeRegexp, attributeRegexp,
(_, attribute: string, value: string) => { (_, attribute: string, value: string) => {

View File

@ -722,9 +722,8 @@ export class BrowserContext extends EventEmitter {
permissions: Permission[] permissions: Permission[]
): Promise<void> { ): Promise<void> {
const protocolPermissions = permissions.map((permission) => { const protocolPermissions = permissions.map((permission) => {
const protocolPermission = WEB_PERMISSION_TO_PROTOCOL_PERMISSION.get( const protocolPermission =
permission WEB_PERMISSION_TO_PROTOCOL_PERMISSION.get(permission);
);
if (!protocolPermission) if (!protocolPermission)
throw new Error('Unknown permission: ' + permission); throw new Error('Unknown permission: ' + permission);
return protocolPermission; return protocolPermission;

View File

@ -89,16 +89,14 @@ export const connectToBrowser = async (
connection = new Connection('', transport, slowMo); connection = new Connection('', transport, slowMo);
} else if (browserWSEndpoint) { } else if (browserWSEndpoint) {
const WebSocketClass = await getWebSocketTransportClass(); const WebSocketClass = await getWebSocketTransportClass();
const connectionTransport: ConnectionTransport = await WebSocketClass.create( const connectionTransport: ConnectionTransport =
browserWSEndpoint await WebSocketClass.create(browserWSEndpoint);
);
connection = new Connection(browserWSEndpoint, connectionTransport, slowMo); connection = new Connection(browserWSEndpoint, connectionTransport, slowMo);
} else if (browserURL) { } else if (browserURL) {
const connectionURL = await getWSEndpoint(browserURL); const connectionURL = await getWSEndpoint(browserURL);
const WebSocketClass = await getWebSocketTransportClass(); const WebSocketClass = await getWebSocketTransportClass();
const connectionTransport: ConnectionTransport = await WebSocketClass.create( const connectionTransport: ConnectionTransport =
connectionURL await WebSocketClass.create(connectionURL);
);
connection = new Connection(connectionURL, connectionTransport, slowMo); connection = new Connection(connectionURL, connectionTransport, slowMo);
} }

View File

@ -192,10 +192,8 @@ export class JSCoverage {
} = {} } = {}
): Promise<void> { ): Promise<void> {
assert(!this._enabled, 'JSCoverage is already enabled'); assert(!this._enabled, 'JSCoverage is already enabled');
const { const { resetOnNavigation = true, reportAnonymousScripts = false } =
resetOnNavigation = true, options;
reportAnonymousScripts = false,
} = options;
this._resetOnNavigation = resetOnNavigation; this._resetOnNavigation = resetOnNavigation;
this._reportAnonymousScripts = reportAnonymousScripts; this._reportAnonymousScripts = reportAnonymousScripts;
this._enabled = true; this._enabled = true;

View File

@ -484,9 +484,8 @@ export class DOMWorld {
selector: string, selector: string,
options: WaitForSelectorOptions options: WaitForSelectorOptions
): Promise<ElementHandle | null> { ): Promise<ElementHandle | null> {
const { updatedSelector, queryHandler } = getQueryHandlerAndSelector( const { updatedSelector, queryHandler } =
selector getQueryHandlerAndSelector(selector);
);
return queryHandler.waitFor(this, updatedSelector, options); return queryHandler.waitFor(this, updatedSelector, options);
} }
@ -687,10 +686,8 @@ export class DOMWorld {
options: { polling?: string | number; timeout?: number } = {}, options: { polling?: string | number; timeout?: number } = {},
...args: SerializableOrJSHandle[] ...args: SerializableOrJSHandle[]
): Promise<JSHandle> { ): Promise<JSHandle> {
const { const { polling = 'raf', timeout = this._timeoutSettings.timeout() } =
polling = 'raf', options;
timeout = this._timeoutSettings.timeout(),
} = options;
const waitTaskOptions: WaitTaskOptions = { const waitTaskOptions: WaitTaskOptions = {
domWorld: this, domWorld: this,
predicateBody: pageFunction, predicateBody: pageFunction,

View File

@ -31,9 +31,10 @@ export class EmulationManager {
const width = viewport.width; const width = viewport.width;
const height = viewport.height; const height = viewport.height;
const deviceScaleFactor = viewport.deviceScaleFactor || 1; const deviceScaleFactor = viewport.deviceScaleFactor || 1;
const screenOrientation: Protocol.Emulation.ScreenOrientation = viewport.isLandscape const screenOrientation: Protocol.Emulation.ScreenOrientation =
? { angle: 90, type: 'landscapePrimary' } viewport.isLandscape
: { angle: 0, type: 'portraitPrimary' }; ? { angle: 90, type: 'landscapePrimary' }
: { angle: 0, type: 'portraitPrimary' };
const hasTouch = viewport.hasTouch || false; const hasTouch = viewport.hasTouch || false;
await Promise.all([ await Promise.all([

View File

@ -267,10 +267,8 @@ export class ExecutionContext {
error.message += ' Are you passing a nested JSHandle?'; error.message += ' Are you passing a nested JSHandle?';
throw error; throw error;
} }
const { const { exceptionDetails, result: remoteObject } =
exceptionDetails, await callFunctionOnPromise.catch(rewriteError);
result: remoteObject,
} = await callFunctionOnPromise.catch(rewriteError);
if (exceptionDetails) if (exceptionDetails)
throw new Error( throw new Error(
'Evaluation failed: ' + helper.getExceptionMessage(exceptionDetails) 'Evaluation failed: ' + helper.getExceptionMessage(exceptionDetails)

View File

@ -776,9 +776,8 @@ export class ElementHandle<
async $<T extends Element = Element>( async $<T extends Element = Element>(
selector: string selector: string
): Promise<ElementHandle<T> | null> { ): Promise<ElementHandle<T> | null> {
const { updatedSelector, queryHandler } = getQueryHandlerAndSelector( const { updatedSelector, queryHandler } =
selector getQueryHandlerAndSelector(selector);
);
return queryHandler.queryOne(this, updatedSelector); return queryHandler.queryOne(this, updatedSelector);
} }
@ -789,9 +788,8 @@ export class ElementHandle<
async $$<T extends Element = Element>( async $$<T extends Element = Element>(
selector: string selector: string
): Promise<Array<ElementHandle<T>>> { ): Promise<Array<ElementHandle<T>>> {
const { updatedSelector, queryHandler } = getQueryHandlerAndSelector( const { updatedSelector, queryHandler } =
selector getQueryHandlerAndSelector(selector);
);
return queryHandler.queryAll(this, updatedSelector); return queryHandler.queryAll(this, updatedSelector);
} }
@ -873,9 +871,8 @@ export class ElementHandle<
) => ReturnType | Promise<ReturnType>, ) => ReturnType | Promise<ReturnType>,
...args: SerializableOrJSHandle[] ...args: SerializableOrJSHandle[]
): Promise<WrapElementHandle<ReturnType>> { ): Promise<WrapElementHandle<ReturnType>> {
const { updatedSelector, queryHandler } = getQueryHandlerAndSelector( const { updatedSelector, queryHandler } =
selector getQueryHandlerAndSelector(selector);
);
const arrayHandle = await queryHandler.queryAllArray(this, updatedSelector); const arrayHandle = await queryHandler.queryAllArray(this, updatedSelector);
const result = await arrayHandle.evaluate< const result = await arrayHandle.evaluate<
( (

View File

@ -278,9 +278,8 @@ export class NetworkManager extends EventEmitter {
!event.request.url.startsWith('data:') !event.request.url.startsWith('data:')
) { ) {
const requestId = event.requestId; const requestId = event.requestId;
const requestPausedEvent = this._requestIdToRequestPausedEvent.get( const requestPausedEvent =
requestId this._requestIdToRequestPausedEvent.get(requestId);
);
this._requestIdToRequestWillBeSentEvent.set(requestId, event); this._requestIdToRequestWillBeSentEvent.set(requestId, event);
@ -338,9 +337,8 @@ export class NetworkManager extends EventEmitter {
return; return;
} }
let requestWillBeSentEvent = this._requestIdToRequestWillBeSentEvent.get( let requestWillBeSentEvent =
requestId this._requestIdToRequestWillBeSentEvent.get(requestId);
);
// redirect requests have the same `requestId`, // redirect requests have the same `requestId`,
if ( if (

View File

@ -1827,11 +1827,15 @@ export class Page extends EventEmitter {
clip = { x: 0, y: 0, width, height, scale: 1 }; clip = { x: 0, y: 0, width, height, scale: 1 };
if (!captureBeyondViewport) { if (!captureBeyondViewport) {
const { isMobile = false, deviceScaleFactor = 1, isLandscape = false } = const {
this._viewport || {}; isMobile = false,
const screenOrientation: Protocol.Emulation.ScreenOrientation = isLandscape deviceScaleFactor = 1,
? { angle: 90, type: 'landscapePrimary' } isLandscape = false,
: { angle: 0, type: 'portraitPrimary' }; } = this._viewport || {};
const screenOrientation: Protocol.Emulation.ScreenOrientation =
isLandscape
? { angle: 90, type: 'landscapePrimary' }
: { angle: 0, type: 'portraitPrimary' };
await this._client.send('Emulation.setDeviceMetricsOverride', { await this._client.send('Emulation.setDeviceMetricsOverride', {
mobile: isMobile, mobile: isMobile,
width, width,

View File

@ -215,9 +215,10 @@ export function clearCustomQueryHandlers(): void {
/** /**
* @internal * @internal
*/ */
export function getQueryHandlerAndSelector( export function getQueryHandlerAndSelector(selector: string): {
selector: string updatedSelector: string;
): { updatedSelector: string; queryHandler: InternalQueryHandler } { queryHandler: InternalQueryHandler;
} {
const hasCustomQueryHandler = /^[a-zA-Z]+\//.test(selector); const hasCustomQueryHandler = /^[a-zA-Z]+\//.test(selector);
if (!hasCustomQueryHandler) if (!hasCustomQueryHandler)
return { updatedSelector: selector, queryHandler: _defaultHandler }; return { updatedSelector: selector, queryHandler: _defaultHandler };

View File

@ -58,8 +58,7 @@ const browserConfig = {
destination: '.local-chromium', destination: '.local-chromium',
}, },
firefox: { firefox: {
host: host: 'https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central',
'https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central',
destination: '.local-firefox', destination: '.local-firefox',
}, },
} as const; } as const;

View File

@ -62,14 +62,8 @@ export class BrowserRunner {
} }
start(options: LaunchOptions): void { start(options: LaunchOptions): void {
const { const { handleSIGINT, handleSIGTERM, handleSIGHUP, dumpio, env, pipe } =
handleSIGINT, options;
handleSIGTERM,
handleSIGHUP,
dumpio,
env,
pipe,
} = options;
let stdio: Array<'ignore' | 'pipe'> = ['pipe', 'pipe', 'pipe']; let stdio: Array<'ignore' | 'pipe'> = ['pipe', 'pipe', 'pipe'];
if (pipe) { if (pipe) {
if (dumpio) stdio = ['ignore', 'pipe', 'pipe', 'pipe', 'pipe']; if (dumpio) stdio = ['ignore', 'pipe', 'pipe', 'pipe', 'pipe'];

View File

@ -587,9 +587,10 @@ class FirefoxLauncher implements ProductLauncher {
} }
} }
function resolveExecutablePath( function resolveExecutablePath(launcher: ChromeLauncher | FirefoxLauncher): {
launcher: ChromeLauncher | FirefoxLauncher executablePath: string;
): { executablePath: string; missingText?: string } { missingText?: string;
} {
let downloadPath: string; let downloadPath: string;
// puppeteer-core doesn't take into account PUPPETEER_* env variables. // puppeteer-core doesn't take into account PUPPETEER_* env variables.
if (!launcher._isPuppeteerCore) { if (!launcher._isPuppeteerCore) {

View File

@ -84,12 +84,8 @@ export class PuppeteerNode extends Puppeteer {
productName?: Product; productName?: Product;
} & CommonPuppeteerSettings } & CommonPuppeteerSettings
) { ) {
const { const { projectRoot, preferredRevision, productName, ...commonSettings } =
projectRoot, settings;
preferredRevision,
productName,
...commonSettings
} = settings;
super(commonSettings); super(commonSettings);
this._projectRoot = projectRoot; this._projectRoot = projectRoot;
this.__productName = productName; this.__productName = productName;

View File

@ -74,10 +74,9 @@ describe('Page.click', function () {
const { page } = getTestState(); const { page } = getTestState();
const newPage = await page.browser().newPage(); const newPage = await page.browser().newPage();
await Promise.all([ await Promise.all([newPage.close(), newPage.mouse.click(1, 2)]).catch(
newPage.close(), () => {}
newPage.mouse.click(1, 2), );
]).catch(() => {});
}); });
it('should click the button after navigation ', async () => { it('should click the button after navigation ', async () => {
const { page, server } = getTestState(); const { page, server } = getTestState();

View File

@ -475,11 +475,8 @@ describe('Cookie specs', () => {
itFailsFirefox( itFailsFirefox(
'should set secure same-site cookies from a frame', 'should set secure same-site cookies from a frame',
async () => { async () => {
const { const { httpsServer, puppeteer, defaultBrowserOptions } =
httpsServer, getTestState();
puppeteer,
defaultBrowserOptions,
} = getTestState();
const browser = await puppeteer.launch({ const browser = await puppeteer.launch({
...defaultBrowserOptions, ...defaultBrowserOptions,

View File

@ -320,7 +320,8 @@ describe('ElementHandle specs', function () {
) )
); );
} }
const handlerNamesAfterUnregistering = puppeteer.customQueryHandlerNames(); const handlerNamesAfterUnregistering =
puppeteer.customQueryHandlerNames();
expect(handlerNamesAfterUnregistering.includes('getById')).toBeFalsy(); expect(handlerNamesAfterUnregistering.includes('getById')).toBeFalsy();
}); });
it('should throw with invalid query names', () => { it('should throw with invalid query names', () => {

View File

@ -531,11 +531,8 @@ describe('Launcher specs', function () {
]); ]);
}); });
it('should support ignoreHTTPSErrors option', async () => { it('should support ignoreHTTPSErrors option', async () => {
const { const { httpsServer, puppeteer, defaultBrowserOptions } =
httpsServer, getTestState();
puppeteer,
defaultBrowserOptions,
} = getTestState();
const originalBrowser = await puppeteer.launch(defaultBrowserOptions); const originalBrowser = await puppeteer.launch(defaultBrowserOptions);
const browserWSEndpoint = originalBrowser.wsEndpoint(); const browserWSEndpoint = originalBrowser.wsEndpoint();

View File

@ -18,8 +18,8 @@
const assert = require('assert'); const assert = require('assert');
const https = require('https'); const https = require('https');
// run `npm run dev-install` if lib dir is missing // run `npm run dev-install` if lib dir is missing
const BrowserFetcher = require('../lib/cjs/puppeteer/node/BrowserFetcher.js') const BrowserFetcher =
.BrowserFetcher; require('../lib/cjs/puppeteer/node/BrowserFetcher.js').BrowserFetcher;
const SUPPORTER_PLATFORMS = ['linux', 'mac', 'win32', 'win64']; const SUPPORTER_PLATFORMS = ['linux', 'mac', 'win32', 'win64'];
const fetchers = SUPPORTER_PLATFORMS.map( const fetchers = SUPPORTER_PLATFORMS.map(

View File

@ -20,7 +20,8 @@ const IS_RELEASE = Boolean(process.env.IS_RELEASE);
module.exports.ensureReleasedAPILinks = function (sources, version) { module.exports.ensureReleasedAPILinks = function (sources, version) {
// Release version is everything that doesn't include "-". // Release version is everything that doesn't include "-".
const apiLinkRegex = /https:\/\/github.com\/puppeteer\/puppeteer\/blob\/v[^/]*\/docs\/api.md/gi; const apiLinkRegex =
/https:\/\/github.com\/puppeteer\/puppeteer\/blob\/v[^/]*\/docs\/api.md/gi;
const lastReleasedAPI = `https://github.com/puppeteer/puppeteer/blob/v${ const lastReleasedAPI = `https://github.com/puppeteer/puppeteer/blob/v${
version.split('-')[0] version.split('-')[0]
}/docs/api.md`; }/docs/api.md`;

View File

@ -222,11 +222,9 @@ function loadFromJSONV1(json) {
const result = {}; const result = {};
result.type = /** @type {string} */ (parseValue(json, 'type', 'string')); result.type = /** @type {string} */ (parseValue(json, 'type', 'string'));
result.userAgent = /** @type {string} */ (parseValue( result.userAgent = /** @type {string} */ (
json, parseValue(json, 'user-agent', 'string')
'user-agent', );
'string'
));
const capabilities = parseValue(json, 'capabilities', 'object', []); const capabilities = parseValue(json, 'capabilities', 'object', []);
if (!Array.isArray(capabilities)) if (!Array.isArray(capabilities))
@ -238,11 +236,9 @@ function loadFromJSONV1(json) {
result.capabilities.push(capabilities[i]); result.capabilities.push(capabilities[i]);
} }
result.deviceScaleFactor = /** @type {number} */ (parseValue( result.deviceScaleFactor = /** @type {number} */ (
json['screen'], parseValue(json['screen'], 'device-pixel-ratio', 'number')
'device-pixel-ratio', );
'number'
));
if (result.deviceScaleFactor < 0 || result.deviceScaleFactor > 100) if (result.deviceScaleFactor < 0 || result.deviceScaleFactor > 100)
throw new Error( throw new Error(
'Emulated device has wrong deviceScaleFactor: ' + result.deviceScaleFactor 'Emulated device has wrong deviceScaleFactor: ' + result.deviceScaleFactor