chore(lint): add @typescript-eslint/type-annotation-spacing rule (#897)

This commit is contained in:
Joel Einbinder 2020-02-07 13:36:49 -08:00 committed by GitHub
parent 871235939e
commit 487d394f3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 30 additions and 29 deletions

View file

@ -41,7 +41,6 @@ module.exports = {
"brace-style": [2, "1tbs", {"allowSingleLine": true}], "brace-style": [2, "1tbs", {"allowSingleLine": true}],
"curly": [2, "multi-or-nest", "consistent"], "curly": [2, "multi-or-nest", "consistent"],
"new-parens": 2, "new-parens": 2,
"func-call-spacing": 2,
"arrow-parens": [2, "as-needed"], "arrow-parens": [2, "as-needed"],
"prefer-const": 2, "prefer-const": 2,
"quote-props": [2, "consistent"], "quote-props": [2, "consistent"],
@ -96,6 +95,8 @@ module.exports = {
"after": true, "after": true,
"before": true "before": true
}], }],
"@typescript-eslint/func-call-spacing": 2,
"@typescript-eslint/type-annotation-spacing": 2,
// file whitespace // file whitespace
"no-multiple-empty-lines": [2, {"max": 2}], "no-multiple-empty-lines": [2, {"max": 2}],

View file

@ -11,6 +11,6 @@ module.exports = {
*/ */
"rules": { "rules": {
"no-console": [2, { "allow": ["warn", "error", "assert", "timeStamp", "time", "timeEnd"] }], "no-console": [2, { "allow": ["warn", "error", "assert", "timeStamp", "time", "timeEnd"] }],
"no-debugger": 0, "no-debugger": 0
} }
}; };

View file

@ -20,7 +20,7 @@ import { Protocol } from './protocol';
import * as dom from '../dom'; import * as dom from '../dom';
import * as accessibility from '../accessibility'; 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 {nodes} = await client.send('Accessibility.getFullAXTree');
const tree = CRAXNode.createTree(client, nodes); const tree = CRAXNode.createTree(client, nodes);
return { return {

View file

@ -118,7 +118,7 @@ export const CRSessionEvents = {
export class CRSession extends platform.EventEmitter { export class CRSession extends platform.EventEmitter {
_connection: CRConnection | null; _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 _targetType: string;
private _sessionId: 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; 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;

View file

@ -26,7 +26,7 @@ import * as types from '../types';
type CoverageEntry = { type CoverageEntry = {
url: string, url: string,
text: string, text: string,
ranges : {start: number, end: number}[] ranges: {start: number, end: number}[]
}; };
export class CRCoverage implements Coverage { export class CRCoverage implements Coverage {

View file

@ -280,7 +280,7 @@ export class CRPage implements PageDelegate {
this._page._onBindingCalled(event.payload, context); 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( this._page.emit(Events.Page.Dialog, new dialog.Dialog(
event.type as dialog.DialogType, event.type as dialog.DialogType,
event.message, event.message,
@ -367,7 +367,7 @@ export class CRPage implements PageDelegate {
await this._client.send('Page.setInterceptFileChooserDialog', { enabled }).catch(e => {}); // target can be closed. 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(); const openerTarget = CRTarget.fromPage(this._page).opener();
if (!openerTarget) if (!openerTarget)
return null; return null;

View file

@ -20,7 +20,7 @@ import { FFSession } from './ffConnection';
import { Protocol } from './protocol'; import { Protocol } from './protocol';
import * as dom from '../dom'; 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 objectId = needle ? needle._remoteObject.objectId : undefined;
const { tree } = await session.send('Accessibility.getFullAXTree', { objectId }); const { tree } = await session.send('Accessibility.getFullAXTree', { objectId });
const axNode = new FFAXNode(tree); const axNode = new FFAXNode(tree);

View file

@ -315,7 +315,7 @@ export class FFPage implements PageDelegate {
await this._session.send('Page.setInterceptFileChooserDialog', { enabled }).catch(e => {}); // target can be closed. 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(); return await this._openerResolver();
} }

View file

@ -332,7 +332,7 @@ export class WebSocketTransport implements ConnectionTransport {
// In Web, all IO callbacks (e.g. WebSocket callbacks) // In Web, all IO callbacks (e.g. WebSocket callbacks)
// are dispatched into separate tasks, so there's no need // are dispatched into separate tasks, so there's no need
// to do anything extra. // 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 => { this._ws.addEventListener('message', event => {
messageWrap(() => { messageWrap(() => {

View file

@ -118,7 +118,7 @@ export type PDFOptions = {
export type CoverageEntry = { export type CoverageEntry = {
url: string, url: string,
text: string, text: string,
ranges : {start: number, end: number}[] ranges: {start: number, end: number}[]
}; };
export type CSSCoverageOptions = { export type CSSCoverageOptions = {

View file

@ -56,7 +56,7 @@ class WKAXNode implements accessibility.AXNode {
private _payload: Protocol.Page.AXNode; private _payload: Protocol.Page.AXNode;
private _children: WKAXNode[]; private _children: WKAXNode[];
constructor(payload : Protocol.Page.AXNode) { constructor(payload: Protocol.Page.AXNode) {
this._payload = payload; this._payload = payload;
this._children = []; this._children = [];
@ -68,7 +68,7 @@ class WKAXNode implements accessibility.AXNode {
return this._children; return this._children;
} }
_findNeedle() : WKAXNode | null { _findNeedle(): WKAXNode | null {
if (this._payload.found) if (this._payload.found)
return this; return this;
for (const child of this._children) { for (const child of this._children) {
@ -79,7 +79,7 @@ class WKAXNode implements accessibility.AXNode {
return null; return null;
} }
isControl() : boolean { isControl(): boolean {
switch (this._payload.role) { switch (this._payload.role) {
case 'button': case 'button':
case 'checkbox': case 'checkbox':
@ -108,7 +108,7 @@ class WKAXNode implements accessibility.AXNode {
} }
} }
_isTextControl() : boolean { _isTextControl(): boolean {
switch (this._payload.role) { switch (this._payload.role) {
case 'combobox': case 'combobox':
case 'searchfield': case 'searchfield':
@ -119,13 +119,13 @@ class WKAXNode implements accessibility.AXNode {
return false; return false;
} }
_name() : string { _name(): string {
if (this._payload.role === 'text') if (this._payload.role === 'text')
return this._payload.value || ''; return this._payload.value || '';
return this._payload.name || ''; return this._payload.name || '';
} }
isInteresting(insideControl: boolean) : boolean { isInteresting(insideControl: boolean): boolean {
const {role, focusable} = this._payload; const {role, focusable} = this._payload;
const name = this._name(); const name = this._name();
if (role === 'ScrollArea') if (role === 'ScrollArea')
@ -154,7 +154,7 @@ class WKAXNode implements accessibility.AXNode {
return child._payload.role === 'text' && this._payload.name === child._payload.value; return child._payload.role === 'text' && this._payload.name === child._payload.value;
} }
isLeafNode() : boolean { isLeafNode(): boolean {
if (!this._children.length) if (!this._children.length)
return true; return true;
// WebKit on Linux ignores everything inside text controls, normalize this behavior // WebKit on Linux ignores everything inside text controls, normalize this behavior
@ -167,7 +167,7 @@ class WKAXNode implements accessibility.AXNode {
} }
serialize(): accessibility.SerializedAXNode { serialize(): accessibility.SerializedAXNode {
const node : accessibility.SerializedAXNode = { const node: accessibility.SerializedAXNode = {
role: WKRoleToARIARole.get(this._payload.role) || this._payload.role, role: WKRoleToARIARole.get(this._payload.role) || this._payload.role,
name: this._name(), name: this._name(),
}; };

View file

@ -97,7 +97,7 @@ export class WKSession extends platform.EventEmitter {
private _disposed = false; private _disposed = false;
private readonly _rawSend: (message: any) => void; 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; 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; 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;

View file

@ -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) { if (!this._globalObjectIdPromise) {
this._globalObjectIdPromise = this._session.send('Runtime.evaluate', { this._globalObjectIdPromise = this._session.send('Runtime.evaluate', {
expression: 'this', expression: 'this',
@ -189,7 +189,7 @@ export class WKExecutionContext implements js.ExecutionContextDelegate {
return this._globalObjectIdPromise; return this._globalObjectIdPromise;
} }
private async _returnObjectByValue(objectId: Protocol.Runtime.RemoteObjectId) : Promise<any> { private async _returnObjectByValue(objectId: Protocol.Runtime.RemoteObjectId): Promise<any> {
try { try {
const serializeResponse = await this._session.send('Runtime.callFunctionOn', { const serializeResponse = await this._session.send('Runtime.callFunctionOn', {
// Serialize object using standard JSON implementation to correctly pass 'undefined'. // 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); 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; const objectHandle = arg && (arg instanceof js.JSHandle) ? arg : null;
if (objectHandle) { if (objectHandle) {
if (objectHandle._context._delegate !== this) if (objectHandle._context._delegate !== this)

View file

@ -66,7 +66,7 @@ export class WKPage implements PageDelegate {
} }
private async _initializePageProxySession() { private async _initializePageProxySession() {
const promises : Promise<any>[] = [ const promises: Promise<any>[] = [
this._pageProxySession.send('Dialog.enable'), this._pageProxySession.send('Dialog.enable'),
this.authenticate(this._page._state.credentials) this.authenticate(this._page._state.credentials)
]; ];
@ -114,7 +114,7 @@ export class WKPage implements PageDelegate {
session.send('Page.getResourceTree'), session.send('Page.getResourceTree'),
] as const); ] as const);
resourceTreeHandler(frameTree); resourceTreeHandler(frameTree);
const promises : Promise<any>[] = [ const promises: Promise<any>[] = [
// Resource tree should be received before first execution context. // Resource tree should be received before first execution context.
session.send('Runtime.enable'), session.send('Runtime.enable'),
session.send('Page.createUserWorld', { name: UTILITY_WORLD_NAME }).catch(_ => {}), // Worlds are per-process 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); await Promise.all(promises);
} }
initializeProvisionalPage(provisionalSession: WKSession) : Promise<void> { initializeProvisionalPage(provisionalSession: WKSession): Promise<void> {
assert(!this._provisionalPage); assert(!this._provisionalPage);
this._provisionalPage = new WKProvisionalPage(provisionalSession, this); this._provisionalPage = new WKProvisionalPage(provisionalSession, this);
return this._provisionalPage.initializationPromise; 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)) if (this._contextIdToContext.has(contextPayload.id))
return; return;
const frame = this._page._frameManager.frame(contextPayload.frameId); 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>; 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); return getAccessibilityTree(this._session, needle);
} }

View file

@ -69,7 +69,7 @@ export class WKPageProxy {
this._pageProxySession.dispatchMessage(message); this._pageProxySession.dispatchMessage(message);
} }
private _isProvisionalCrossProcessLoadInProgress() : boolean { private _isProvisionalCrossProcessLoadInProgress(): boolean {
for (const anySession of this._sessions.values()) { for (const anySession of this._sessions.values()) {
if ((anySession as any)[isPovisionalSymbol]) if ((anySession as any)[isPovisionalSymbol])
return true; return true;