From 2176b0282daa4bb3d24201986ea240ec04b7aeea Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Tue, 22 Oct 2024 11:37:52 +0200 Subject: [PATCH] chore: update eslintignore to lint files in utils/ folders --- .eslintignore | 9 +++------ packages/playwright-core/src/utils/crypto.ts | 11 +++++----- .../src/utils/happy-eyeballs.ts | 20 +++++++++---------- .../src/utils/isomorphic/locatorGenerators.ts | 2 +- packages/playwright-core/src/utils/network.ts | 2 +- .../playwright-core/src/utils/stackTrace.ts | 1 - packages/playwright-core/src/utils/zones.ts | 3 ++- 7 files changed, 23 insertions(+), 25 deletions(-) diff --git a/.eslintignore b/.eslintignore index 60b8fd360fcb95..9d22f618d81c1c 100644 --- a/.eslintignore +++ b/.eslintignore @@ -8,14 +8,11 @@ test/assets/modernizr.js /packages/playwright-ct-core/src/generated/* /index.d.ts node_modules/ -browser_patches/*/checkout/ -browser_patches/chromium/output/ **/*.d.ts output/ test-results/ -tests/components/ -tests/installation/fixture-scripts/ -examples/ +/tests/components/ +/tests/installation/fixture-scripts/ DEPS .cache/ -utils/ +/utils/ diff --git a/packages/playwright-core/src/utils/crypto.ts b/packages/playwright-core/src/utils/crypto.ts index 5da56d4e9b695c..f538912d24bd95 100644 --- a/packages/playwright-core/src/utils/crypto.ts +++ b/packages/playwright-core/src/utils/crypto.ts @@ -33,11 +33,12 @@ function encodeBase128(value: number): Buffer { do { let byte = value & 0x7f; value >>>= 7; - if (bytes.length > 0) byte |= 0x80; + if (bytes.length > 0) + byte |= 0x80; bytes.push(byte); } while (value > 0); return Buffer.from(bytes.reverse()); -}; +} // ASN1/DER Speficiation: https://www.itu.int/rec/T-REC-X.680-X.693-202102-I/en class DER { @@ -49,13 +50,13 @@ class DER { return this._encode(0x02, Buffer.from([data])); } static encodeObjectIdentifier(oid: string): Buffer { - const parts = oid.split('.').map((v) => Number(v)); + const parts = oid.split('.').map(v => Number(v)); // Encode the second part, which could be large, using base-128 encoding if necessary const output = [encodeBase128(40 * parts[0] + parts[1])]; - for (let i = 2; i < parts.length; i++) { + for (let i = 2; i < parts.length; i++) output.push(encodeBase128(parts[i])); - } + return this._encode(0x06, Buffer.concat(output)); } diff --git a/packages/playwright-core/src/utils/happy-eyeballs.ts b/packages/playwright-core/src/utils/happy-eyeballs.ts index 18de1a938cad2a..02b78de4f045e1 100644 --- a/packages/playwright-core/src/utils/happy-eyeballs.ts +++ b/packages/playwright-core/src/utils/happy-eyeballs.ts @@ -29,8 +29,8 @@ import { monotonicTime } from './time'; // Same as in Chromium (https://source.chromium.org/chromium/chromium/src/+/5666ff4f5077a7e2f72902f3a95f5d553ea0d88d:net/socket/transport_connect_job.cc;l=102) const connectionAttemptDelayMs = 300; -const kDNSLookupAt = Symbol('kDNSLookupAt') -const kTCPConnectionAt = Symbol('kTCPConnectionAt') +const kDNSLookupAt = Symbol('kDNSLookupAt'); +const kTCPConnectionAt = Symbol('kTCPConnectionAt'); class HttpHappyEyeballsAgent extends http.Agent { createConnection(options: http.ClientRequestArgs, oncreate?: (err: Error | null, socket?: net.Socket) => void): net.Socket | undefined { @@ -75,7 +75,7 @@ export async function createTLSSocket(options: tls.ConnectionOptions): Promise { assert(options.host, 'host is required'); if (net.isIP(options.host)) { - const socket = tls.connect(options) + const socket = tls.connect(options); socket.on('secureConnect', () => resolve(socket)); socket.on('error', error => reject(error)); } else { @@ -92,20 +92,20 @@ export async function createTLSSocket(options: tls.ConnectionOptions): Promise void) | undefined, + options: http.ClientRequestArgs, + oncreate: ((err: Error | null, socket?: tls.TLSSocket) => void) | undefined, useTLS: true ): Promise; export async function createConnectionAsync( - options: http.ClientRequestArgs, - oncreate: ((err: Error | null, socket?: net.Socket) => void) | undefined, + options: http.ClientRequestArgs, + oncreate: ((err: Error | null, socket?: net.Socket) => void) | undefined, useTLS: false ): Promise; export async function createConnectionAsync( - options: http.ClientRequestArgs, - oncreate: ((err: Error | null, socket?: any) => void) | undefined, + options: http.ClientRequestArgs, + oncreate: ((err: Error | null, socket?: any) => void) | undefined, useTLS: boolean ): Promise { const lookup = (options as any).__testHookLookup || lookupAddresses; @@ -202,5 +202,5 @@ export function timingForSocket(socket: net.Socket | tls.TLSSocket) { return { dnsLookupAt: (socket as any)[kDNSLookupAt] as number | undefined, tcpConnectionAt: (socket as any)[kTCPConnectionAt] as number | undefined, - } + }; } diff --git a/packages/playwright-core/src/utils/isomorphic/locatorGenerators.ts b/packages/playwright-core/src/utils/isomorphic/locatorGenerators.ts index 56252d02d3dd1d..930abaaba6e00e 100644 --- a/packages/playwright-core/src/utils/isomorphic/locatorGenerators.ts +++ b/packages/playwright-core/src/utils/isomorphic/locatorGenerators.ts @@ -163,7 +163,7 @@ function innerAsLocators(factory: LocatorFactory, parsed: ParsedSelector, isFram continue; } - let locatorType: LocatorType = 'default'; + const locatorType: LocatorType = 'default'; const nextPart = parts[index + 1]; diff --git a/packages/playwright-core/src/utils/network.ts b/packages/playwright-core/src/utils/network.ts index 632c74fe3a19da..25d3a111563af5 100644 --- a/packages/playwright-core/src/utils/network.ts +++ b/packages/playwright-core/src/utils/network.ts @@ -124,7 +124,7 @@ export function createHttpsServer(...args: any[]): https.Server { return server; } -export function createHttp2Server( onRequestHandler?: (request: http2.Http2ServerRequest, response: http2.Http2ServerResponse) => void,): http2.Http2SecureServer; +export function createHttp2Server(onRequestHandler?: (request: http2.Http2ServerRequest, response: http2.Http2ServerResponse) => void,): http2.Http2SecureServer; export function createHttp2Server(options: http2.SecureServerOptions, onRequestHandler?: (request: http2.Http2ServerRequest, response: http2.Http2ServerResponse) => void,): http2.Http2SecureServer; export function createHttp2Server(...args: any[]): http2.Http2SecureServer { const server = http2.createSecureServer(...args); diff --git a/packages/playwright-core/src/utils/stackTrace.ts b/packages/playwright-core/src/utils/stackTrace.ts index 77e1365b3f8766..9693b34030b415 100644 --- a/packages/playwright-core/src/utils/stackTrace.ts +++ b/packages/playwright-core/src/utils/stackTrace.ts @@ -50,7 +50,6 @@ export function captureRawStack(): RawStack { export function captureLibraryStackTrace(): { frames: StackFrame[], apiName: string } { const stack = captureRawStack(); - const isTesting = isUnderTest(); type ParsedFrame = { frame: StackFrame; frameText: string; diff --git a/packages/playwright-core/src/utils/zones.ts b/packages/playwright-core/src/utils/zones.ts index 68cb6fa7fa74c0..e6fabac0f15559 100644 --- a/packages/playwright-core/src/utils/zones.ts +++ b/packages/playwright-core/src/utils/zones.ts @@ -46,8 +46,9 @@ class ZoneManager { if (zone.type === 'apiZone') str += `(${(zone.data as any).apiName})`; zones.push(str); - + } + // eslint-disable-next-line no-console console.log('zones: ', zones.join(' -> ')); } }