Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions guides/eslint-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
- [ ] npm/svelte

### Batch 3: Build-related
- [ ] npm/webpack-batteries-included-preprocessor
- [x] npm/webpack-batteries-included-preprocessor
- [ ] npm/webpack-preprocessor
- [ ] npm/webpack-dev-server
- [ ] npm/vite-plugin-cypress-esm
Expand All @@ -30,7 +30,7 @@
- [ ] packages/driver
- [ ] packages/rewriter
- [ ] packages/reporter
- [ ] packages/server
- [x] packages/server

### Batch 4b: Core packages (part 2)
- [ ] packages/runner
Expand Down
1 change: 0 additions & 1 deletion npm/webpack-batteries-included-preprocessor/.eslintignore

This file was deleted.

17 changes: 17 additions & 0 deletions npm/webpack-batteries-included-preprocessor/eslint.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { baseConfig } from '@packages/eslint-config'
import globals from 'globals'

export default [
...baseConfig,
{
ignores: ['test/fixtures/**/*', 'test/_test-output/**'],
},
{
files: ['**/*.js', '**/*.ts'],
languageOptions: {
globals: {
...globals.node,
},
},
},
]
9 changes: 8 additions & 1 deletion npm/webpack-batteries-included-preprocessor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Cypress preprocessor for bundling JavaScript via webpack with dependencies included and support for various ES features, TypeScript, and CoffeeScript",
"private": false,
"scripts": {
"lint": "eslint --ext .js,.json, .",
"lint": "eslint",
"test": "mocha test/**/*.spec.* --timeout 4000"
},
"dependencies": {
Expand Down Expand Up @@ -33,10 +33,14 @@
},
"devDependencies": {
"@cypress/webpack-preprocessor": "0.0.0-development",
"@packages/eslint-config": "0.0.0-development",
"@types/mocha": "^8.0.2",
"@types/webpack": "^5.28.1",
"chai": "^4.2.0",
"decache": "^4.6.2",
"eslint": "^9.31.0",
"globals": "^15.12.0",
"jiti": "^2.4.2",
"mocha": "^8.1.1",
"mock-require": "3.0.3",
"react": "^16.13.1",
Expand All @@ -63,6 +67,9 @@
"cypress-preprocessor",
"webpack"
],
"lint-staged": {
"**/*.{js,jsx,ts,tsx,json}": "eslint --fix"
},
"publishConfig": {
"access": "public"
},
Expand Down
23 changes: 0 additions & 23 deletions npm/webpack-batteries-included-preprocessor/test/.eslintrc.json

This file was deleted.

7 changes: 0 additions & 7 deletions packages/server/.eslintignore

This file was deleted.

31 changes: 31 additions & 0 deletions packages/server/eslint.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { baseConfig } from '@packages/eslint-config'
import globals from 'globals'

export default [
...baseConfig,
{
languageOptions: {
globals: {
...globals.node,
globalThis: 'readonly',
window: 'readonly',
},
},
},
{
files: ['test/**/*.{js,ts}'],
languageOptions: {
globals: {
// Test-specific globals
mockery: 'readonly',
proxyquire: 'readonly',
supertest: 'readonly',
sinon: 'readonly',
nock: 'readonly',
},
},
},
{
ignores: ['test/support/fixtures/server/**/*'],
},
]
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export class AutomationNotImplemented extends Error {
constructor (message: string, automationType: string, ...args) {
super(`Automation command '${message}' not implemented by ${automationType}`)
}

static isAutomationNotImplementedErr (e: any): e is AutomationNotImplemented {
return e?.kind === AutomationNotImplementedKind
}
Expand Down
1 change: 1 addition & 0 deletions packages/server/lib/browsers/bidi_automation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export class BidiAutomation {
'browsingContext.contextCreated',
'browsingContext.contextDestroyed',
]

private webDriverClient: WebDriverClient
private automation: Automation
private autContextId: string | undefined = undefined
Expand Down
5 changes: 4 additions & 1 deletion packages/server/lib/browsers/cdp-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,24 @@ export class CDPConnection {

get ws () {
// this is reached into by browser-cri-client to detect close events - needs rethinking
return (this._connection as { _ws?: WebSocket})._ws
return (this._connection as { _ws?: WebSocket })._ws
}

on<T extends CdpEvent> (event: T, callback: CDPListener<T>) {
this.debug('attaching event listener to cdp connection', event)

this._emitter.on(event, callback)
}

addConnectionEventListener<T extends CDPConnectionEvent> (event: T, callback: CDPConnectionEventListener<T>) {
this.debug('adding connection event listener for ', event)
this._emitter.on(event, callback)
}

off<T extends CdpEvent> (event: T, callback: CDPListener<T>) {
this._emitter.off(event, callback)
}

removeConnectionEventListener<T extends CDPConnectionEvent> (event: T, callback: CDPConnectionEventListener<T>) {
this._emitter.off(event, callback)
}
Expand Down
1 change: 0 additions & 1 deletion packages/server/lib/browsers/cdp_automation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ export class CdpAutomation implements CDPClient, AutomationMiddleware {
})
}

// eslint-disable-next-line @cypress/dev/arrow-body-multiline-braces
private _updateFrameTree = (client: CriClient, eventName) => async () => {
debugVerbose(`update frame tree for ${eventName}`)

Expand Down
3 changes: 1 addition & 2 deletions packages/server/lib/browsers/chrome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ const _normalizeArgExtensions = function (extPath, args, pluginExtensions, brows
if (loadExtension || pluginExtensions.length > 0) {
// @see https://github.com/cypress-io/cypress/issues/31702
if (Number(browser.majorVersion) >= 137 && browser.name === 'chrome') {
// eslint-disable-next-line no-console
errors.warning('CHROME_137_LOAD_EXTENSION_NOT_SUPPORTED')
}
}
Expand Down Expand Up @@ -575,7 +574,7 @@ export = {
// first allows us to connect the remote interface,
// start video recording and then
// we will load the actual page
const launchedBrowser = await launch(browser, 'about:blank', port, args, launchOptions.env) as unknown as BrowserInstance & { browserCriClient: BrowserCriClient}
const launchedBrowser = await launch(browser, 'about:blank', port, args, launchOptions.env) as unknown as BrowserInstance & { browserCriClient: BrowserCriClient }

la(launchedBrowser, 'did not get launched browser instance')

Expand Down
2 changes: 1 addition & 1 deletion packages/server/lib/browsers/firefox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ const defaultPreferences = {
'dom.timeout.enable_budget_timer_throttling': false,

// allow getUserMedia APIs on insecure domains
'media.devices.insecure.enabled': true,
'media.devices.insecure.enabled': true,
'media.getusermedia.insecure.enabled': true,

'marionette.log.level': launcherDebug.enabled ? 'Debug' : undefined,
Expand Down
2 changes: 1 addition & 1 deletion packages/server/lib/browsers/memory/cgroup-v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const getTotalMemoryLimit = async () => {
* @returns object of memory stats
*/
const convertRawStats = (rawStats: string): { total_inactive_file: string } => {
const stats = rawStats.split('\n').filter(Boolean).reduce((acc, arr): { total_inactive_file: string} => {
const stats = rawStats.split('\n').filter(Boolean).reduce((acc, arr): { total_inactive_file: string } => {
const stat = arr.split(' ')

acc[stat[0]] = stat[1]
Expand Down
2 changes: 1 addition & 1 deletion packages/server/lib/browsers/memory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export const calculateMemoryStats: () => Promise<void> = measure(async () => {
* @param automation - the automation client used to collect garbage
* @param test - the current test
*/
const checkMemoryPressureAndLog = async ({ automation, test }: { automation: Automation, test: { title: string, order: number, currentRetry: number }}) => {
const checkMemoryPressureAndLog = async ({ automation, test }: { automation: Automation, test: { title: string, order: number, currentRetry: number } }) => {
await checkMemoryPressure(automation)

gcLog.testTitle = test.title
Expand Down
9 changes: 4 additions & 5 deletions packages/server/lib/browsers/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-redeclare */
import Bluebird from 'bluebird'
import _ from 'lodash'
import type { FoundBrowser } from '@packages/types'
Expand Down Expand Up @@ -55,10 +54,10 @@ const getMajorVersion = (version) => {
}

const defaultLaunchOptions: {
preferences: {[key: string]: any}
preferences: { [key: string]: any }
extensions: string[]
args: string[]
env: {[key: string]: any}
env: { [key: string]: any }
} = {
preferences: {},
extensions: [],
Expand Down Expand Up @@ -318,8 +317,8 @@ const parseBrowserOption = (opt) => {
}
}

function ensureAndGetByNameOrPath(nameOrPath: string, returnAll: false, browsers?: FoundBrowser[]): Bluebird<FoundBrowser>
function ensureAndGetByNameOrPath(nameOrPath: string, returnAll: true, browsers?: FoundBrowser[]): Bluebird<FoundBrowser[]>
function ensureAndGetByNameOrPath (nameOrPath: string, returnAll: false, browsers?: FoundBrowser[]): Bluebird<FoundBrowser>
function ensureAndGetByNameOrPath (nameOrPath: string, returnAll: true, browsers?: FoundBrowser[]): Bluebird<FoundBrowser[]>

async function ensureAndGetByNameOrPath (nameOrPath: string, returnAll = false, prevKnownBrowsers: FoundBrowser[] = []) {
const browsers = prevKnownBrowsers.length ? prevKnownBrowsers : (await getBrowsers())
Expand Down
2 changes: 0 additions & 2 deletions packages/server/lib/capture.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ const stdout = function () {
process.log = function (str) {
logs.push(str)

// eslint-disable-next-line prefer-rest-params
return log.apply(this, arguments)
}
}

process.stdout.write = function (str) {
logs.push(str)

// eslint-disable-next-line prefer-rest-params
return write.apply(this, arguments)
}

Expand Down
4 changes: 2 additions & 2 deletions packages/server/lib/cloud/artifacts/screenshot_artifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const createScreenshotArtifact = async (filePath: string, uploadUrl: string): Pr
}

export const createScreenshotArtifactBatch = (
screenshotUploadUrls: {screenshotId: string, uploadUrl: string}[],
screenshotFiles: {screenshotId: string, path: string}[],
screenshotUploadUrls: { screenshotId: string, uploadUrl: string }[],
screenshotFiles: { screenshotId: string, path: string }[],
): Promise<IArtifact[]> => {
const correlatedPaths = screenshotUploadUrls.map(({ screenshotId, uploadUrl }) => {
const correlatedFilePath = screenshotFiles.find((pathPair) => {
Expand Down
1 change: 1 addition & 0 deletions packages/server/lib/cloud/network/parse_error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export class ParseError extends Error {
constructor (public readonly originalError: Error, message?: string) {
super(message)
}

static isParseError (err: Error & { kind: string }): err is ParseError {
return err.kind === ParseErrorKind
}
Expand Down
4 changes: 2 additions & 2 deletions packages/server/lib/cloud/network/put_fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ type PutOptions = PutInit & {
parse?: ParseKind
}

export async function putFetch <
TReturn extends any
export async function putFetch<
TReturn,
> (input: RequestInfo | URL, options: PutOptions = { parse: 'json' }): Promise<TReturn> {
const {
parse,
Expand Down
1 change: 1 addition & 0 deletions packages/server/lib/cloud/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export class ProtocolManager implements ProtocolManagerShape {
private _afterSpecDurations: AfterSpecDurations & {
afterSpecTotal: number
} | undefined

private AppCaptureProtocol: AppCaptureProtocolConstructor | undefined
private options: ProtocolManagerOptions | undefined

Expand Down
2 changes: 1 addition & 1 deletion packages/server/lib/cloud/upload/stream_stalled_error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class StreamStalledError extends Error {
super(`Stream stalled: failed to transfer ${chunkSizeBytes} bytes over the previous ${maxActivityDwellTime}ms`)
}

public static isStreamStalledError (error: Error & {kind?: any}): error is StreamStalledError {
public static isStreamStalledError (error: Error & { kind?: any }): error is StreamStalledError {
return error.kind === StreamStalledErrorKind
}
}
1 change: 0 additions & 1 deletion packages/server/lib/controllers/iframes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export const iframesController = {

nodeProxy.web(req, res, {}, (e) => {
if (e) {
// eslint-disable-next-line
debug('Proxy request error. This is likely the socket hangup issue, we can basically ignore this because the stream will automatically continue once the asset will be available', e)
}
})
Expand Down
8 changes: 4 additions & 4 deletions packages/server/lib/gui/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ export function trackState (projectRoot, isTextTerminal, win, keys: TrackStateMa
.then((state) => {
return state.set(newState)
})
}
, 500))
},
500))

win.on('moved', _.debounce(() => {
if (isDestroyed()) {
Expand All @@ -307,8 +307,8 @@ export function trackState (projectRoot, isTextTerminal, win, keys: TrackStateMa
.then((state) => {
return state.set(newState)
})
}
, 500))
},
500))

win.webContents.on('devtools-opened', () => {
const newState = {}
Expand Down
3 changes: 1 addition & 2 deletions packages/server/lib/modes/interactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { makeGraphQLServer } from '@packages/graphql/src/makeGraphQLServer'
import { globalPubSub, getCtx, clearCtx } from '@packages/data-context'
import { telemetry } from '@packages/telemetry'

// eslint-disable-next-line no-duplicate-imports
// tslint:disable-next-line no-implicit-dependencies - electron dep needs to be defined
import type { WebContents } from 'electron'
import type { LaunchArgs, Preferences } from '@packages/types'
Expand Down Expand Up @@ -93,7 +92,7 @@ export = {
y: 'appY',
devTools: 'isAppDevToolsOpen',
},
onBlur (this: {webContents: WebContents}) {
onBlur (this: { webContents: WebContents }) {
if (this.webContents.isDevToolsOpened()) {
return
}
Expand Down
2 changes: 0 additions & 2 deletions packages/server/lib/modes/results.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable @cypress/dev/arrow-body-multiline-braces */

import _ from 'lodash'
import type { FoundBrowser, SpecWithRelativeRoot } from '@packages/types'
import path from 'path'
Expand Down
3 changes: 1 addition & 2 deletions packages/server/lib/modes/run.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-console, @cypress/dev/arrow-body-multiline-braces */
/* eslint-disable no-console */
import _ from 'lodash'
import pkg from '@packages/root'
import path from 'path'
Expand Down Expand Up @@ -456,7 +456,6 @@ async function listenForProjectEnd (project: ProjectBase, exit: boolean): Promis
earlyExitTerminator.waitForEarlyExit(project, exit),
]).then((results) => {
if (exit === false) {
// eslint-disable-next-line no-console
console.log('not exiting due to options.exit being false')
} else {
resolve(results)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* global window */
(({ browserFamily, isSpecBridge, key, namespace, scripts, url, win = window, documentDomainContext }) => {
/**
* This file is read as a string in the server and injected into the spec
Expand Down
Loading
Loading