From 66d3dd86260a4930e60f18792f36d802b1763ada Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Tue, 26 Nov 2019 08:19:02 -0800 Subject: [PATCH] lint: fixes (#85) --- .eslintrc.js | 7 +++++-- src/chromium/JSHandle.ts | 18 +++++++++--------- src/chromium/Target.ts | 2 +- src/firefox/JSHandle.ts | 18 +++++++++--------- src/helper.ts | 2 +- src/webkit/JSHandle.ts | 14 +++++++------- 6 files changed, 32 insertions(+), 29 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index ab34834e10..7f9cf61c72 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -34,7 +34,6 @@ module.exports = { "markers": ["*"] }], "eqeqeq": [2], - "arrow-body-style": [2, "as-needed"], "accessor-pairs": [2, { "getWithoutSet": false, "setWithoutGet": false @@ -76,7 +75,11 @@ module.exports = { // spacing details "space-infix-ops": 2, "space-in-parens": [2, "never"], - "space-before-function-paren": [2, "never"], + "space-before-function-paren": [2, { + "anonymous": "never", + "named": "never", + "asyncArrow": "always" + }], "no-whitespace-before-property": 2, "keyword-spacing": [2, { "overrides": { diff --git a/src/chromium/JSHandle.ts b/src/chromium/JSHandle.ts index da6d993259..84e22bd3be 100644 --- a/src/chromium/JSHandle.ts +++ b/src/chromium/JSHandle.ts @@ -153,7 +153,7 @@ export class ElementHandle extends JSHandle { } async _scrollIntoViewIfNeeded() { - const error = await this.evaluate(async(element, pageJavascriptEnabled) => { + const error = await this.evaluate(async (element, pageJavascriptEnabled) => { if (!element.isConnected) return 'Node is detached from document'; if (element.nodeType !== Node.ELEMENT_NODE) @@ -407,8 +407,8 @@ export class ElementHandle extends JSHandle { async $(selector: string): Promise { const handle = await this.evaluateHandle( - (root: SelectorRoot, selector: string, injected: Injected) => injected.querySelector('css=' + selector, root), - selector, await this._context._injected() + (root: SelectorRoot, selector: string, injected: Injected) => injected.querySelector('css=' + selector, root), + selector, await this._context._injected() ); const element = handle.asElement(); if (element) @@ -419,8 +419,8 @@ export class ElementHandle extends JSHandle { async $$(selector: string): Promise { const arrayHandle = await this.evaluateHandle( - (root: SelectorRoot, selector: string, injected: Injected) => injected.querySelectorAll('css=' + selector, root), - selector, await this._context._injected() + (root: SelectorRoot, selector: string, injected: Injected) => injected.querySelectorAll('css=' + selector, root), + selector, await this._context._injected() ); const properties = await arrayHandle.getProperties(); await arrayHandle.dispose(); @@ -444,8 +444,8 @@ export class ElementHandle extends JSHandle { $$eval: types.$$Eval = async (selector, pageFunction, ...args) => { const arrayHandle = await this.evaluateHandle( - (root: SelectorRoot, selector: string, injected: Injected) => injected.querySelectorAll('css=' + selector, root), - selector, await this._context._injected() + (root: SelectorRoot, selector: string, injected: Injected) => injected.querySelectorAll('css=' + selector, root), + selector, await this._context._injected() ); const result = await arrayHandle.evaluate(pageFunction, ...args as any); @@ -455,8 +455,8 @@ export class ElementHandle extends JSHandle { async $x(expression: string): Promise { const arrayHandle = await this.evaluateHandle( - (root: SelectorRoot, expression: string, injected: Injected) => injected.querySelectorAll('xpath=' + expression, root), - expression, await this._context._injected() + (root: SelectorRoot, expression: string, injected: Injected) => injected.querySelectorAll('xpath=' + expression, root), + expression, await this._context._injected() ); const properties = await arrayHandle.getProperties(); await arrayHandle.dispose(); diff --git a/src/chromium/Target.ts b/src/chromium/Target.ts index 72cc248235..3c39b35b55 100644 --- a/src/chromium/Target.ts +++ b/src/chromium/Target.ts @@ -87,7 +87,7 @@ export class Target { if (!this._workerPromise) { // TODO(einbinder): Make workers send their console logs. this._workerPromise = this._sessionFactory() - .then(client => new Worker(client, this._targetInfo.url, () => { } /* consoleAPICalled */, () => { } /* exceptionThrown */)); + .then(client => new Worker(client, this._targetInfo.url, () => { } /* consoleAPICalled */, () => { } /* exceptionThrown */)); } return this._workerPromise; } diff --git a/src/firefox/JSHandle.ts b/src/firefox/JSHandle.ts index 5fcd1d337b..eca0e58100 100644 --- a/src/firefox/JSHandle.ts +++ b/src/firefox/JSHandle.ts @@ -208,8 +208,8 @@ export class ElementHandle extends JSHandle { async $(selector: string): Promise { const handle = await this._frame.evaluateHandle( - (root: SelectorRoot, selector: string, injected: Injected) => injected.querySelector('css=' + selector, root), - this, selector, await this._context._injected() + (root: SelectorRoot, selector: string, injected: Injected) => injected.querySelector('css=' + selector, root), + this, selector, await this._context._injected() ); const element = handle.asElement(); if (element) @@ -220,8 +220,8 @@ export class ElementHandle extends JSHandle { async $$(selector: string): Promise { const arrayHandle = await this._frame.evaluateHandle( - (root: SelectorRoot, selector: string, injected: Injected) => injected.querySelectorAll('css=' + selector, root), - this, selector, await this._context._injected() + (root: SelectorRoot, selector: string, injected: Injected) => injected.querySelectorAll('css=' + selector, root), + this, selector, await this._context._injected() ); const properties = await arrayHandle.getProperties(); await arrayHandle.dispose(); @@ -245,8 +245,8 @@ export class ElementHandle extends JSHandle { $$eval: types.$$Eval = async (selector, pageFunction, ...args) => { const arrayHandle = await this._frame.evaluateHandle( - (root: SelectorRoot, selector: string, injected: Injected) => injected.querySelectorAll('css=' + selector, root), - this, selector, await this._context._injected() + (root: SelectorRoot, selector: string, injected: Injected) => injected.querySelectorAll('css=' + selector, root), + this, selector, await this._context._injected() ); const result = await this._frame.evaluate(pageFunction, arrayHandle, ...args); @@ -256,8 +256,8 @@ export class ElementHandle extends JSHandle { async $x(expression: string): Promise> { const arrayHandle = await this._frame.evaluateHandle( - (root: SelectorRoot, expression: string, injected: Injected) => injected.querySelectorAll('xpath=' + expression, root), - this, expression, await this._context._injected() + (root: SelectorRoot, expression: string, injected: Injected) => injected.querySelectorAll('xpath=' + expression, root), + this, expression, await this._context._injected() ); const properties = await arrayHandle.getProperties(); await arrayHandle.dispose(); @@ -326,7 +326,7 @@ export class ElementHandle extends JSHandle { } await this.evaluate(async (element: HTMLInputElement, payloads: FilePayload[]) => { const files = await Promise.all(payloads.map(async (file: FilePayload) => { - const result = await fetch(`data:${file.mimeType};base64,${file.data}`) + const result = await fetch(`data:${file.mimeType};base64,${file.data}`); return new File([await result.blob()], file.name); })); const dt = new DataTransfer(); diff --git a/src/helper.ts b/src/helper.ts index 301b623aad..ef56e325da 100644 --- a/src/helper.ts +++ b/src/helper.ts @@ -45,7 +45,7 @@ class Helper { const method = Reflect.get(classType.prototype, methodName); if (methodName === 'constructor' || typeof methodName !== 'string' || methodName.startsWith('_') || typeof method !== 'function' || method.constructor.name !== 'AsyncFunction') continue; - Reflect.set(classType.prototype, methodName, function(...args) { + Reflect.set(classType.prototype, methodName, function(...args: any[]) { const syncStack: any = {}; Error.captureStackTrace(syncStack); return method.call(this, ...args).catch(e => { diff --git a/src/webkit/JSHandle.ts b/src/webkit/JSHandle.ts index c88df4d6f0..46e035d84c 100644 --- a/src/webkit/JSHandle.ts +++ b/src/webkit/JSHandle.ts @@ -142,7 +142,7 @@ export class ElementHandle extends JSHandle { } async _scrollIntoViewIfNeeded() { - const error = await this.evaluate(async(element, pageJavascriptEnabled) => { + const error = await this.evaluate(async (element, pageJavascriptEnabled) => { if (!element.isConnected) return 'Node is detached from document'; if (element.nodeType !== Node.ELEMENT_NODE) @@ -287,8 +287,8 @@ export class ElementHandle extends JSHandle { async $(selector: string): Promise { const handle = await this.evaluateHandle( - (root: SelectorRoot, selector: string, injected: Injected) => injected.querySelector('css=' + selector, root), - selector, await this._context._injected() + (root: SelectorRoot, selector: string, injected: Injected) => injected.querySelector('css=' + selector, root), + selector, await this._context._injected() ); const element = handle.asElement(); if (element) @@ -324,8 +324,8 @@ export class ElementHandle extends JSHandle { $$eval: types.$$Eval = async (selector, pageFunction, ...args) => { const arrayHandle = await this.evaluateHandle( - (root: SelectorRoot, selector: string, injected: Injected) => injected.querySelectorAll('css=' + selector, root), - selector, await this._context._injected() + (root: SelectorRoot, selector: string, injected: Injected) => injected.querySelectorAll('css=' + selector, root), + selector, await this._context._injected() ); const result = await arrayHandle.evaluate(pageFunction, ...args as any); @@ -335,8 +335,8 @@ export class ElementHandle extends JSHandle { async $x(expression: string): Promise { const arrayHandle = await this.evaluateHandle( - (root: SelectorRoot, expression: string, injected: Injected) => injected.querySelectorAll('xpath=' + expression, root), - expression, await this._context._injected() + (root: SelectorRoot, expression: string, injected: Injected) => injected.querySelectorAll('xpath=' + expression, root), + expression, await this._context._injected() ); const properties = await arrayHandle.getProperties(); await arrayHandle.dispose();