Skip to content

Commit

Permalink
chore: use import type syntax (#17864)
Browse files Browse the repository at this point in the history
* chore: use import type across repo

* chore: use import type across repo

* chore: use import type across repo

* chore: use import type across repo

* update exports

* update test

* update import type

* update types

* use import type in driver

* correctly export function

* revert test

* remove unrelated code

* revert code

* improve type imports

* override for reporter
  • Loading branch information
lmiller1990 authored Aug 24, 2021
1 parent 8988b2c commit ab401ec
Show file tree
Hide file tree
Showing 80 changed files with 154 additions and 153 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getDisplayUrlMatcher } from '@packages/driver/src/cy/net-stubbing/route-matcher-log'
import { RouteMatcherOptions } from '@packages/net-stubbing/lib/external-types'
import type { RouteMatcherOptions } from '@packages/net-stubbing/lib/external-types'

const testFail = (cb, expectedDocsUrl = 'https://on.cypress.io/intercept') => {
cy.on('fail', (err) => {
Expand Down
6 changes: 2 additions & 4 deletions packages/driver/src/cy/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as $dom from '../dom'
import * as $document from '../dom/document'
import * as $elements from '../dom/elements'
// eslint-disable-next-line no-duplicate-imports
import { HTMLTextLikeElement } from '../dom/elements'
import type { HTMLTextLikeElement } from '../dom/elements'
import * as $selection from '../dom/selection'
import $utils from '../cypress/utils'
import $window from '../dom/window'
Expand Down Expand Up @@ -689,9 +689,7 @@ export interface typeOptions {
}

export class Keyboard {
constructor (private state: State) {
null
}
constructor (private state: State) {}

type (opts: typeOptions) {
const options = _.defaults({}, opts, {
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cy/net-stubbing/aliasing.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from 'lodash'
import {
import type {
Interception,
} from './types'

Expand Down
4 changes: 2 additions & 2 deletions packages/driver/src/cy/net-stubbing/events/after-response.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CyHttpMessages } from '@packages/net-stubbing/lib/types'
import { HandlerFn } from '.'
import type { CyHttpMessages } from '@packages/net-stubbing/lib/types'
import type { HandlerFn } from '.'
import { parseJsonBody } from './utils'

export const onAfterResponse: HandlerFn<CyHttpMessages.ResponseComplete> = async (Cypress, frame, userHandler, { getRequest, getRoute }) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/driver/src/cy/net-stubbing/events/before-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import {
parseStaticResponseShorthand,
} from '../static-response-utils'
import * as $errUtils from '../../../cypress/error_utils'
import { HandlerFn, HandlerResult } from '.'
import type { HandlerFn, HandlerResult } from '.'
import Bluebird from 'bluebird'
import { NetEvent } from '@packages/net-stubbing/lib/types'
import type { NetEvent } from '@packages/net-stubbing/lib/types'
import Debug from 'debug'

const debug = Debug('cypress:driver:net-stubbing:events:before-request')
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cy/net-stubbing/events/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Route, Interception, StaticResponse, NetEvent } from '../types'
import type { Route, Interception, StaticResponse, NetEvent } from '../types'
import { onBeforeRequest } from './before-request'
import { onResponse } from './response'
import { onAfterResponse } from './after-response'
Expand Down
4 changes: 2 additions & 2 deletions packages/driver/src/cy/net-stubbing/events/network-error.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { get } from 'lodash'
import { CyHttpMessages } from '@packages/net-stubbing/lib/types'
import type { CyHttpMessages } from '@packages/net-stubbing/lib/types'
import * as $errUtils from '../../../cypress/error_utils'
import { HandlerFn } from '.'
import type { HandlerFn } from '.'

export const onNetworkError: HandlerFn<CyHttpMessages.NetworkError> = async (Cypress, frame, userHandler, { getRequest, getRoute }) => {
const request = getRequest(frame.subscription.routeId, frame.requestId)
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cy/net-stubbing/events/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
STATIC_RESPONSE_KEYS,
} from '../static-response-utils'
import * as $errUtils from '../../../cypress/error_utils'
import { HandlerFn, HandlerResult } from '.'
import type { HandlerFn, HandlerResult } from '.'
import Bluebird from 'bluebird'
import { parseJsonBody, stringifyJsonBody } from './utils'

Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cy/net-stubbing/events/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { find } from 'lodash'
import { CyHttpMessages } from '@packages/net-stubbing/lib/types'
import type { CyHttpMessages } from '@packages/net-stubbing/lib/types'

export function hasJsonContentType (headers: { [k: string]: string | string[] }) {
const contentType = find(headers, (v, k) => /^content-type$/i.test(k))
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cy/net-stubbing/route-matcher-log.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from 'lodash'

import {
import type {
RouteMatcherOptions,
StaticResponse,
} from '@packages/net-stubbing/lib/types'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from 'lodash'

import {
import type {
StaticResponse,
BackendStaticResponseWithArrayBuffer,
FixtureOpts,
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cy/net-stubbing/wait-for-route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Interception,
InterceptionState,
} from './types'
Expand Down
4 changes: 2 additions & 2 deletions packages/driver/src/cypress/proxy-logging.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Interception, Route } from '@packages/net-stubbing/lib/types'
import { BrowserPreRequest, BrowserResponseReceived, RequestError } from '@packages/proxy/lib/types'
import type { Interception, Route } from '@packages/net-stubbing/lib/types'
import type { BrowserPreRequest, BrowserResponseReceived, RequestError } from '@packages/proxy/lib/types'
import * as $errUtils from './error_utils'
import Debug from 'debug'

Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cypress/resolvers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from 'lodash'
import $Cypress from '../..'
import type $Cypress from '../..'

/**
* Fix property reads and writes that could potentially help the AUT to break out of its iframe.
Expand Down
1 change: 1 addition & 0 deletions packages/driver/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"extends": "./../ts/tsconfig.json",
"compilerOptions": {
"target": "ES2016",
"module": "commonjs",
Expand Down
2 changes: 1 addition & 1 deletion packages/launcher/lib/browsers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { log } from './log'
import * as cp from 'child_process'
import { Browser, FoundBrowser } from './types'
import type { Browser, FoundBrowser } from './types'

// Chrome started exposing CDP 1.3 in 64
const MIN_CHROME_VERSION = 64
Expand Down
2 changes: 1 addition & 1 deletion packages/launcher/lib/darwin/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { findApp, FindAppParams } from './util'
import { Browser, DetectedBrowser } from '../types'
import type { Browser, DetectedBrowser } from '../types'
import * as linuxHelper from '../linux'
import { log } from '../log'
import { merge } from 'ramda'
Expand Down
2 changes: 1 addition & 1 deletion packages/launcher/lib/darwin/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as os from 'os'
import * as path from 'path'
import * as plist from 'plist'
import * as semver from 'semver'
import { FoundBrowser } from '../types'
import type { FoundBrowser } from '../types'
import * as findSystemNode from '@packages/server/lib/util/find_system_node'

/** parses Info.plist file from given application and returns a property */
Expand Down
2 changes: 1 addition & 1 deletion packages/launcher/lib/detect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { needsDarwinWorkaround, darwinDetectionWorkaround } from './darwin/util'
import { notDetectedAtPathErr } from './errors'
import * as linuxHelper from './linux'
import { log } from './log'
import {
import type {
Browser,
DetectedBrowser,
FoundBrowser,
Expand Down
2 changes: 1 addition & 1 deletion packages/launcher/lib/errors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NotInstalledError, NotDetectedAtPathError } from './types'
import type { NotInstalledError, NotDetectedAtPathError } from './types'

export const notInstalledErr = (name: string, message?: string) => {
const err = new Error(
Expand Down
2 changes: 1 addition & 1 deletion packages/launcher/lib/linux/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { log } from '../log'
import { partial, trim, tap, prop } from 'ramda'
import { FoundBrowser, Browser, PathData } from '../types'
import type { FoundBrowser, Browser, PathData } from '../types'
import { notInstalledErr } from '../errors'
import { utils } from '../utils'
import os from 'os'
Expand Down
4 changes: 2 additions & 2 deletions packages/launcher/lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChildProcess } from 'child_process'
import * as Bluebird from 'bluebird'
import type { ChildProcess } from 'child_process'
import type Bluebird from 'bluebird'

// TODO: Clean up this file

Expand Down
2 changes: 1 addition & 1 deletion packages/launcher/lib/windows/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { tap, trim, prop } from 'ramda'
import { get } from 'lodash'
import { notInstalledErr } from '../errors'
import { log } from '../log'
import { Browser, FoundBrowser, PathData } from '../types'
import type { Browser, FoundBrowser, PathData } from '../types'
import { utils } from '../utils'

function formFullAppPath (name: string) {
Expand Down
2 changes: 1 addition & 1 deletion packages/net-stubbing/lib/internal-types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as _ from 'lodash'
import {
import type {
RouteMatcherOptionsGeneric,
GenericStaticResponse,
Subscription,
Expand Down
6 changes: 3 additions & 3 deletions packages/net-stubbing/lib/server/driver-events.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from 'lodash'
import Debug from 'debug'
import {
import type {
NetStubbingState,
GetFixtureFn,
BackendRoute,
Expand All @@ -17,8 +17,8 @@ import {
setResponseFromFixture,
} from './util'
import { InterceptedRequest } from './intercepted-request'
import CyServer from '@packages/server'
import { BackendStaticResponse } from '../internal-types'
import type CyServer from '@packages/server'
import type { BackendStaticResponse } from '../internal-types'

const debug = Debug('cypress:net-stubbing:server:driver-events')

Expand Down
14 changes: 7 additions & 7 deletions packages/net-stubbing/lib/server/intercepted-request.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import _ from 'lodash'
import { IncomingMessage } from 'http'
import { Readable } from 'stream'
import {
import type { IncomingMessage } from 'http'
import type { Readable } from 'stream'
import type {
CypressIncomingRequest,
CypressOutgoingResponse,
} from '@packages/proxy'
import {
import type {
NetEvent,
Subscription,
} from '../types'
import { BackendRoute, NetStubbingState } from './types'
import type { BackendRoute, NetStubbingState } from './types'
import { emit, sendStaticResponse } from './util'
import CyServer from '@packages/server'
import { BackendStaticResponse } from '../internal-types'
import type CyServer from '@packages/server'
import type { BackendStaticResponse } from '../internal-types'

export class InterceptedRequest {
id: string
Expand Down
4 changes: 2 additions & 2 deletions packages/net-stubbing/lib/server/middleware/error.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Debug from 'debug'

import { ErrorMiddleware } from '@packages/proxy'
import { CyHttpMessages } from '../../types'
import type { ErrorMiddleware } from '@packages/proxy'
import type { CyHttpMessages } from '../../types'
import _ from 'lodash'
import errors from '@packages/server/lib/errors'

Expand Down
4 changes: 2 additions & 2 deletions packages/net-stubbing/lib/server/middleware/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { concatStream } from '@packages/network'
import Debug from 'debug'
import url from 'url'

import {
import type {
RequestMiddleware,
} from '@packages/proxy'
import {
Expand All @@ -19,7 +19,7 @@ import {
getBodyEncoding,
} from '../util'
import { InterceptedRequest } from '../intercepted-request'
import { BackendRoute } from '../types'
import type { BackendRoute } from '../types'

const debug = Debug('cypress:net-stubbing:server:intercept-request')

Expand Down
4 changes: 2 additions & 2 deletions packages/net-stubbing/lib/server/middleware/response.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import _ from 'lodash'
import { concatStream, httpUtils } from '@packages/network'
import Debug from 'debug'
import { Readable } from 'stream'
import type { Readable } from 'stream'
import { getEncoding } from 'istextorbinary'

import {
import type {
ResponseMiddleware,
} from '@packages/proxy'
import {
Expand Down
6 changes: 3 additions & 3 deletions packages/net-stubbing/lib/server/route-matching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import _ from 'lodash'
import minimatch from 'minimatch'
import url from 'url'

import { CypressIncomingRequest } from '@packages/proxy'
import { BackendRoute } from './types'
import { RouteMatcherOptions } from '../types'
import type { CypressIncomingRequest } from '@packages/proxy'
import type { BackendRoute } from './types'
import type { RouteMatcherOptions } from '../types'
import { getAllStringMatcherFields } from './util'

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/net-stubbing/lib/server/state.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { noop } from 'lodash'
import { NetStubbingState } from './types'
import type { NetStubbingState } from './types'

export function state (): NetStubbingState {
return {
Expand Down
4 changes: 2 additions & 2 deletions packages/net-stubbing/lib/server/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
import type {
RouteMatcherOptions,
BackendStaticResponse,
} from '../types'
import {
import type {
InterceptedRequest,
} from './intercepted-request'

Expand Down
10 changes: 5 additions & 5 deletions packages/net-stubbing/lib/server/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ import {
BackendStaticResponse,
} from '../types'
import { Readable, PassThrough } from 'stream'
import CyServer from '@packages/server'
import type CyServer from '@packages/server'
import { Socket } from 'net'
import { GetFixtureFn } from './types'
import type { GetFixtureFn } from './types'
import ThrottleStream from 'throttle'
import MimeTypes from 'mime-types'
import { CypressIncomingRequest } from '@packages/proxy'
import { InterceptedRequest } from './intercepted-request'
import type { CypressIncomingRequest } from '@packages/proxy'
import type { InterceptedRequest } from './intercepted-request'
import { caseInsensitiveGet, caseInsensitiveHas } from '../util'

// TODO: move this into net-stubbing once cy.route is removed
import { parseContentType } from '@packages/server/lib/controllers/xhrs'
import { CyHttpMessages } from '../external-types'
import type { CyHttpMessages } from '../external-types'
import { getEncoding } from 'istextorbinary'

const debug = Debug('cypress:net-stubbing:server:util')
Expand Down
2 changes: 1 addition & 1 deletion packages/network/lib/allow-destroy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import net from 'net'
import type net from 'net'

/**
* `allowDestroy` adds a `destroy` method to a `net.Server`. `destroy(cb)`
Expand Down
2 changes: 1 addition & 1 deletion packages/network/lib/client-certificates.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Url } from 'url'
import type { Url } from 'url'
import debugModule from 'debug'
import minimatch from 'minimatch'
import Forge from 'node-forge'
Expand Down
2 changes: 1 addition & 1 deletion packages/network/lib/http-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from 'lodash'
import { IncomingMessage } from 'http'
import type { IncomingMessage } from 'http'

// https://github.com/cypress-io/cypress/issues/4298
// https://tools.ietf.org/html/rfc7230#section-3.3.3
Expand Down
6 changes: 3 additions & 3 deletions packages/proxy/lib/http/error-middleware.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import debugModule from 'debug'
import { HttpMiddleware } from '.'
import type { HttpMiddleware } from '.'
import type { Readable } from 'stream'
import { InterceptError } from '@packages/net-stubbing'
import { Readable } from 'stream'
import { Request } from '@cypress/request'
import type { Request } from '@cypress/request'
import errors from '@packages/server/lib/errors'

const debug = debugModule('cypress:proxy:http:error-middleware')
Expand Down
12 changes: 6 additions & 6 deletions packages/proxy/lib/http/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from 'lodash'
import CyServer from '@packages/server'
import {
import type CyServer from '@packages/server'
import type {
CypressIncomingRequest,
CypressOutgoingResponse,
BrowserPreRequest,
Expand All @@ -9,11 +9,11 @@ import Debug from 'debug'
import ErrorMiddleware from './error-middleware'
import { HttpBuffers } from './util/buffers'
import { GetPreRequestCb, PreRequests } from './util/prerequests'
import { IncomingMessage } from 'http'
import { NetStubbingState } from '@packages/net-stubbing'
import type { IncomingMessage } from 'http'
import type { NetStubbingState } from '@packages/net-stubbing'
import Bluebird from 'bluebird'
import { Readable } from 'stream'
import { Request, Response } from 'express'
import type { Readable } from 'stream'
import type { Request, Response } from 'express'
import RequestMiddleware from './request-middleware'
import ResponseMiddleware from './response-middleware'
import { DeferredSourceMapCache } from '@packages/rewriter'
Expand Down
Loading

4 comments on commit ab401ec

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ab401ec Aug 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/8.3.1/circle-develop-ab401ecd359234985b269d8283ff526136eeb4d4/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ab401ec Aug 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/8.3.1/appveyor-develop-ab401ecd359234985b269d8283ff526136eeb4d4/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ab401ec Aug 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 ia32 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/8.3.1/appveyor-develop-ab401ecd359234985b269d8283ff526136eeb4d4/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ab401ec Aug 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/8.3.1/circle-develop-ab401ecd359234985b269d8283ff526136eeb4d4/cypress.tgz

Please sign in to comment.