mirror of
https://github.com/microsoft/playwright.git
synced 2024-08-16 23:50:33 +03:00
chore(lint): add @typescript-eslint/type-annotation-spacing rule (#897)
This commit is contained in:
parent
871235939e
commit
487d394f3b
@ -41,7 +41,6 @@ module.exports = {
|
||||
"brace-style": [2, "1tbs", {"allowSingleLine": true}],
|
||||
"curly": [2, "multi-or-nest", "consistent"],
|
||||
"new-parens": 2,
|
||||
"func-call-spacing": 2,
|
||||
"arrow-parens": [2, "as-needed"],
|
||||
"prefer-const": 2,
|
||||
"quote-props": [2, "consistent"],
|
||||
@ -96,6 +95,8 @@ module.exports = {
|
||||
"after": true,
|
||||
"before": true
|
||||
}],
|
||||
"@typescript-eslint/func-call-spacing": 2,
|
||||
"@typescript-eslint/type-annotation-spacing": 2,
|
||||
|
||||
// file whitespace
|
||||
"no-multiple-empty-lines": [2, {"max": 2}],
|
||||
|
@ -11,6 +11,6 @@ module.exports = {
|
||||
*/
|
||||
"rules": {
|
||||
"no-console": [2, { "allow": ["warn", "error", "assert", "timeStamp", "time", "timeEnd"] }],
|
||||
"no-debugger": 0,
|
||||
"no-debugger": 0
|
||||
}
|
||||
};
|
||||
|
@ -20,7 +20,7 @@ import { Protocol } from './protocol';
|
||||
import * as dom from '../dom';
|
||||
import * as accessibility from '../accessibility';
|
||||
|
||||
export async function getAccessibilityTree(client: CRSession, needle?: dom.ElementHandle) : Promise<{tree: accessibility.AXNode, needle: accessibility.AXNode | null}> {
|
||||
export async function getAccessibilityTree(client: CRSession, needle?: dom.ElementHandle): Promise<{tree: accessibility.AXNode, needle: accessibility.AXNode | null}> {
|
||||
const {nodes} = await client.send('Accessibility.getFullAXTree');
|
||||
const tree = CRAXNode.createTree(client, nodes);
|
||||
return {
|
||||
|
@ -118,7 +118,7 @@ export const CRSessionEvents = {
|
||||
|
||||
export class CRSession extends platform.EventEmitter {
|
||||
_connection: CRConnection | null;
|
||||
private _callbacks = new Map<number, {resolve:(o: any) => void, reject: (e: Error) => void, error: Error, method: string}>();
|
||||
private _callbacks = new Map<number, {resolve: (o: any) => void, reject: (e: Error) => void, error: Error, method: string}>();
|
||||
private _targetType: string;
|
||||
private _sessionId: string;
|
||||
on: <T extends keyof Protocol.Events | symbol>(event: T, listener: (payload: T extends symbol ? any : Protocol.Events[T extends keyof Protocol.Events ? T : never]) => void) => this;
|
||||
|
@ -26,7 +26,7 @@ import * as types from '../types';
|
||||
type CoverageEntry = {
|
||||
url: string,
|
||||
text: string,
|
||||
ranges : {start: number, end: number}[]
|
||||
ranges: {start: number, end: number}[]
|
||||
};
|
||||
|
||||
export class CRCoverage implements Coverage {
|
||||
|
@ -280,7 +280,7 @@ export class CRPage implements PageDelegate {
|
||||
this._page._onBindingCalled(event.payload, context);
|
||||
}
|
||||
|
||||
_onDialog(event : Protocol.Page.javascriptDialogOpeningPayload) {
|
||||
_onDialog(event: Protocol.Page.javascriptDialogOpeningPayload) {
|
||||
this._page.emit(Events.Page.Dialog, new dialog.Dialog(
|
||||
event.type as dialog.DialogType,
|
||||
event.message,
|
||||
@ -367,7 +367,7 @@ export class CRPage implements PageDelegate {
|
||||
await this._client.send('Page.setInterceptFileChooserDialog', { enabled }).catch(e => {}); // target can be closed.
|
||||
}
|
||||
|
||||
async opener() : Promise<Page | null> {
|
||||
async opener(): Promise<Page | null> {
|
||||
const openerTarget = CRTarget.fromPage(this._page).opener();
|
||||
if (!openerTarget)
|
||||
return null;
|
||||
|
@ -20,7 +20,7 @@ import { FFSession } from './ffConnection';
|
||||
import { Protocol } from './protocol';
|
||||
import * as dom from '../dom';
|
||||
|
||||
export async function getAccessibilityTree(session: FFSession, needle?: dom.ElementHandle) : Promise<{tree: accessibility.AXNode, needle: accessibility.AXNode | null}> {
|
||||
export async function getAccessibilityTree(session: FFSession, needle?: dom.ElementHandle): Promise<{tree: accessibility.AXNode, needle: accessibility.AXNode | null}> {
|
||||
const objectId = needle ? needle._remoteObject.objectId : undefined;
|
||||
const { tree } = await session.send('Accessibility.getFullAXTree', { objectId });
|
||||
const axNode = new FFAXNode(tree);
|
||||
|
@ -315,7 +315,7 @@ export class FFPage implements PageDelegate {
|
||||
await this._session.send('Page.setInterceptFileChooserDialog', { enabled }).catch(e => {}); // target can be closed.
|
||||
}
|
||||
|
||||
async opener() : Promise<Page | null> {
|
||||
async opener(): Promise<Page | null> {
|
||||
return await this._openerResolver();
|
||||
}
|
||||
|
||||
|
@ -332,7 +332,7 @@ export class WebSocketTransport implements ConnectionTransport {
|
||||
// In Web, all IO callbacks (e.g. WebSocket callbacks)
|
||||
// are dispatched into separate tasks, so there's no need
|
||||
// to do anything extra.
|
||||
const messageWrap: (cb :() => void) => void = isNode ? makeWaitForNextTask() : cb => cb();
|
||||
const messageWrap: (cb: () => void) => void = isNode ? makeWaitForNextTask() : cb => cb();
|
||||
|
||||
this._ws.addEventListener('message', event => {
|
||||
messageWrap(() => {
|
||||
|
@ -118,7 +118,7 @@ export type PDFOptions = {
|
||||
export type CoverageEntry = {
|
||||
url: string,
|
||||
text: string,
|
||||
ranges : {start: number, end: number}[]
|
||||
ranges: {start: number, end: number}[]
|
||||
};
|
||||
|
||||
export type CSSCoverageOptions = {
|
||||
|
@ -56,7 +56,7 @@ class WKAXNode implements accessibility.AXNode {
|
||||
private _payload: Protocol.Page.AXNode;
|
||||
private _children: WKAXNode[];
|
||||
|
||||
constructor(payload : Protocol.Page.AXNode) {
|
||||
constructor(payload: Protocol.Page.AXNode) {
|
||||
this._payload = payload;
|
||||
|
||||
this._children = [];
|
||||
@ -68,7 +68,7 @@ class WKAXNode implements accessibility.AXNode {
|
||||
return this._children;
|
||||
}
|
||||
|
||||
_findNeedle() : WKAXNode | null {
|
||||
_findNeedle(): WKAXNode | null {
|
||||
if (this._payload.found)
|
||||
return this;
|
||||
for (const child of this._children) {
|
||||
@ -79,7 +79,7 @@ class WKAXNode implements accessibility.AXNode {
|
||||
return null;
|
||||
}
|
||||
|
||||
isControl() : boolean {
|
||||
isControl(): boolean {
|
||||
switch (this._payload.role) {
|
||||
case 'button':
|
||||
case 'checkbox':
|
||||
@ -108,7 +108,7 @@ class WKAXNode implements accessibility.AXNode {
|
||||
}
|
||||
}
|
||||
|
||||
_isTextControl() : boolean {
|
||||
_isTextControl(): boolean {
|
||||
switch (this._payload.role) {
|
||||
case 'combobox':
|
||||
case 'searchfield':
|
||||
@ -119,13 +119,13 @@ class WKAXNode implements accessibility.AXNode {
|
||||
return false;
|
||||
}
|
||||
|
||||
_name() : string {
|
||||
_name(): string {
|
||||
if (this._payload.role === 'text')
|
||||
return this._payload.value || '';
|
||||
return this._payload.name || '';
|
||||
}
|
||||
|
||||
isInteresting(insideControl: boolean) : boolean {
|
||||
isInteresting(insideControl: boolean): boolean {
|
||||
const {role, focusable} = this._payload;
|
||||
const name = this._name();
|
||||
if (role === 'ScrollArea')
|
||||
@ -154,7 +154,7 @@ class WKAXNode implements accessibility.AXNode {
|
||||
return child._payload.role === 'text' && this._payload.name === child._payload.value;
|
||||
}
|
||||
|
||||
isLeafNode() : boolean {
|
||||
isLeafNode(): boolean {
|
||||
if (!this._children.length)
|
||||
return true;
|
||||
// WebKit on Linux ignores everything inside text controls, normalize this behavior
|
||||
@ -167,7 +167,7 @@ class WKAXNode implements accessibility.AXNode {
|
||||
}
|
||||
|
||||
serialize(): accessibility.SerializedAXNode {
|
||||
const node : accessibility.SerializedAXNode = {
|
||||
const node: accessibility.SerializedAXNode = {
|
||||
role: WKRoleToARIARole.get(this._payload.role) || this._payload.role,
|
||||
name: this._name(),
|
||||
};
|
||||
|
@ -97,7 +97,7 @@ export class WKSession extends platform.EventEmitter {
|
||||
|
||||
private _disposed = false;
|
||||
private readonly _rawSend: (message: any) => void;
|
||||
private readonly _callbacks = new Map<number, {resolve:(o: any) => void, reject: (e: Error) => void, error: Error, method: string}>();
|
||||
private readonly _callbacks = new Map<number, {resolve: (o: any) => void, reject: (e: Error) => void, error: Error, method: string}>();
|
||||
|
||||
on: <T extends keyof Protocol.Events | symbol>(event: T, listener: (payload: T extends symbol ? any : Protocol.Events[T extends keyof Protocol.Events ? T : never]) => void) => this;
|
||||
addListener: <T extends keyof Protocol.Events | symbol>(event: T, listener: (payload: T extends symbol ? any : Protocol.Events[T extends keyof Protocol.Events ? T : never]) => void) => this;
|
||||
|
@ -177,7 +177,7 @@ export class WKExecutionContext implements js.ExecutionContextDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
private _contextGlobalObjectId() : Promise<Protocol.Runtime.RemoteObjectId> {
|
||||
private _contextGlobalObjectId(): Promise<Protocol.Runtime.RemoteObjectId> {
|
||||
if (!this._globalObjectIdPromise) {
|
||||
this._globalObjectIdPromise = this._session.send('Runtime.evaluate', {
|
||||
expression: 'this',
|
||||
@ -189,7 +189,7 @@ export class WKExecutionContext implements js.ExecutionContextDelegate {
|
||||
return this._globalObjectIdPromise;
|
||||
}
|
||||
|
||||
private async _returnObjectByValue(objectId: Protocol.Runtime.RemoteObjectId) : Promise<any> {
|
||||
private async _returnObjectByValue(objectId: Protocol.Runtime.RemoteObjectId): Promise<any> {
|
||||
try {
|
||||
const serializeResponse = await this._session.send('Runtime.callFunctionOn', {
|
||||
// Serialize object using standard JSON implementation to correctly pass 'undefined'.
|
||||
@ -253,7 +253,7 @@ export class WKExecutionContext implements js.ExecutionContextDelegate {
|
||||
return (includeType ? 'JSHandle:' : '') + valueFromRemoteObject(object);
|
||||
}
|
||||
|
||||
private _convertArgument(arg: js.JSHandle | any) : Protocol.Runtime.CallArgument {
|
||||
private _convertArgument(arg: js.JSHandle | any): Protocol.Runtime.CallArgument {
|
||||
const objectHandle = arg && (arg instanceof js.JSHandle) ? arg : null;
|
||||
if (objectHandle) {
|
||||
if (objectHandle._context._delegate !== this)
|
||||
|
@ -66,7 +66,7 @@ export class WKPage implements PageDelegate {
|
||||
}
|
||||
|
||||
private async _initializePageProxySession() {
|
||||
const promises : Promise<any>[] = [
|
||||
const promises: Promise<any>[] = [
|
||||
this._pageProxySession.send('Dialog.enable'),
|
||||
this.authenticate(this._page._state.credentials)
|
||||
];
|
||||
@ -114,7 +114,7 @@ export class WKPage implements PageDelegate {
|
||||
session.send('Page.getResourceTree'),
|
||||
] as const);
|
||||
resourceTreeHandler(frameTree);
|
||||
const promises : Promise<any>[] = [
|
||||
const promises: Promise<any>[] = [
|
||||
// Resource tree should be received before first execution context.
|
||||
session.send('Runtime.enable'),
|
||||
session.send('Page.createUserWorld', { name: UTILITY_WORLD_NAME }).catch(_ => {}), // Worlds are per-process
|
||||
@ -148,7 +148,7 @@ export class WKPage implements PageDelegate {
|
||||
await Promise.all(promises);
|
||||
}
|
||||
|
||||
initializeProvisionalPage(provisionalSession: WKSession) : Promise<void> {
|
||||
initializeProvisionalPage(provisionalSession: WKSession): Promise<void> {
|
||||
assert(!this._provisionalPage);
|
||||
this._provisionalPage = new WKProvisionalPage(provisionalSession, this);
|
||||
return this._provisionalPage.initializationPromise;
|
||||
@ -285,7 +285,7 @@ export class WKPage implements PageDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
private _onExecutionContextCreated(contextPayload : Protocol.Runtime.ExecutionContextDescription) {
|
||||
private _onExecutionContextCreated(contextPayload: Protocol.Runtime.ExecutionContextDescription) {
|
||||
if (this._contextIdToContext.has(contextPayload.id))
|
||||
return;
|
||||
const frame = this._page._frameManager.frame(contextPayload.frameId);
|
||||
@ -578,7 +578,7 @@ export class WKPage implements PageDelegate {
|
||||
return to._createHandle(result.object) as dom.ElementHandle<T>;
|
||||
}
|
||||
|
||||
async getAccessibilityTree(needle?: dom.ElementHandle) : Promise<{tree: accessibility.AXNode, needle: accessibility.AXNode | null}> {
|
||||
async getAccessibilityTree(needle?: dom.ElementHandle): Promise<{tree: accessibility.AXNode, needle: accessibility.AXNode | null}> {
|
||||
return getAccessibilityTree(this._session, needle);
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ export class WKPageProxy {
|
||||
this._pageProxySession.dispatchMessage(message);
|
||||
}
|
||||
|
||||
private _isProvisionalCrossProcessLoadInProgress() : boolean {
|
||||
private _isProvisionalCrossProcessLoadInProgress(): boolean {
|
||||
for (const anySession of this._sessions.values()) {
|
||||
if ((anySession as any)[isPovisionalSymbol])
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user