mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-04 22:30:00 -06:00
chore: upgrade cli eslint to 9 (#32446)
* chore: replace dtslint with eslint-plugin-expect-type * update guide * add lint-staged * rm stale script * modify cli eslint and tsconfigs to support ts migration * separate expect-type files * modifications to tsconfigs to make eslint a little easier * revert workflow.yml * further revision * put tslint config for dtslint back in * ensure false negative case is tested * correct tsconfigs * align dtslint tsconfig with eslint 9 config * consolidate / DRY tsconfigs
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
**/__snapshots__
|
||||
/build
|
||||
|
||||
# do not lint package.json, it incorrect re-orders the `exports`
|
||||
# https://github.com/cypress-io/cypress/pull/26630
|
||||
package.json
|
||||
|
||||
# cli/types is linted by tslint/dtslint
|
||||
/types
|
||||
|
||||
# these are all copied from dist'd builds from the individual libs
|
||||
/angular
|
||||
/react
|
||||
/vue
|
||||
/svelte
|
||||
/mount-utils
|
||||
tsconfig.esm.json
|
||||
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"rules": {
|
||||
"no-restricted-syntax": [
|
||||
"error",
|
||||
{
|
||||
"selector": "CallExpression[callee.name='arch']",
|
||||
"message": "Do not use `arch()` to detect the user's machine architecture. Use util.getRealArch() instead."
|
||||
},
|
||||
{
|
||||
"selector": "CallExpression[callee.object.name='os'][callee.property.name='arch']",
|
||||
"message": "Do not use `os.arch()` to detect the user's machine architecture. Use util.getRealArch() instead."
|
||||
},
|
||||
{
|
||||
"selector": "MemberExpression[object.name='process'][property.name='arch']",
|
||||
"message": "Do not use `process.arch` to detect the user's machine architecture. Use util.getRealArch() instead."
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
48
cli/eslint.config.ts
Normal file
48
cli/eslint.config.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { baseConfig, cliOverrides } from '@packages/eslint-config'
|
||||
|
||||
export default [
|
||||
...baseConfig,
|
||||
...cliOverrides,
|
||||
{
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
tsconfigRootDir: __dirname,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
rules: {
|
||||
'@stylistic/comma-dangle': 'warn',
|
||||
'@stylistic/comma-spacing': 'warn',
|
||||
'@stylistic/type-generic-spacing': 'warn',
|
||||
'@stylistic/quotes': 'warn',
|
||||
'@stylistic/arrow-parens': 'warn',
|
||||
'@stylistic/no-multi-spaces': 'warn',
|
||||
'padding-line-between-statements': 'warn',
|
||||
'@stylistic/space-unary-ops': 'warn',
|
||||
'@stylistic/member-delimiter-style': 'warn',
|
||||
'@stylistic/object-curly-spacing': 'warn',
|
||||
'@stylistic/semi': 'warn',
|
||||
'@stylistic/space-in-parens': 'warn',
|
||||
'@stylistic/space-infix-ops': 'warn',
|
||||
'@stylistic/template-tag-spacing': 'warn',
|
||||
'no-var': 'warn',
|
||||
'@stylistic/space-before-function-paren': ['warn', 'always'],
|
||||
},
|
||||
},
|
||||
{
|
||||
ignores: [
|
||||
'**/__snapshots__',
|
||||
'**/build/**/*',
|
||||
'package.json',
|
||||
'**/angular/**/*',
|
||||
'**/react/**/*',
|
||||
'**/vue/**/*',
|
||||
'**/svelte/**/*',
|
||||
'**/mount-utils/**/*',
|
||||
'**/types/{bluebird,chai,chai-jquery,jquery,lodash,minimatch,mocha,sinon,sinon-chai}/**/*',
|
||||
'.mocharc.js',
|
||||
'**/*.js',
|
||||
],
|
||||
},
|
||||
]
|
||||
@@ -4,11 +4,11 @@
|
||||
"private": true,
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"build-cli": "tsc && tsc -p tsconfig.esm.json && tsx ./scripts/build.ts && tsx ./scripts/post-build.ts",
|
||||
"build-cli": "tsc -p tsconfig.build.json && tsc -p tsconfig.esm.json && tsx ./scripts/build.ts && tsx ./scripts/post-build.ts",
|
||||
"clean": "tsx ./scripts/clean.ts",
|
||||
"dtslint": "dtslint types",
|
||||
"postinstall": "patch-package && tsx ./scripts/post-install.ts",
|
||||
"lint": "eslint --ext .ts,.tsx,.json,.vue .",
|
||||
"lint": "eslint",
|
||||
"prebuild": "yarn postinstall && tsx ./scripts/start-build.ts",
|
||||
"size": "t=\"cypress-v0.0.0.tgz\"; yarn pack --filename \"${t}\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";",
|
||||
"test": "yarn test-unit",
|
||||
@@ -70,6 +70,7 @@
|
||||
"@cypress/sinon-chai": "2.9.1",
|
||||
"@cypress/svelte": "0.0.0-development",
|
||||
"@cypress/vue": "0.0.0-development",
|
||||
"@packages/eslint-config": "0.0.0-development",
|
||||
"@packages/root": "0.0.0-development",
|
||||
"@types/bluebird": "3.5.33",
|
||||
"@types/chai": "4.2.15",
|
||||
@@ -83,7 +84,9 @@
|
||||
"cross-env": "7.0.3",
|
||||
"dependency-check": "4.1.0",
|
||||
"dtslint": "4.2.1",
|
||||
"eslint": "^9.31.0",
|
||||
"execa-wrap": "1.4.0",
|
||||
"jiti": "^2.4.2",
|
||||
"mock-fs": "5.4.0",
|
||||
"nock": "13.2.9",
|
||||
"resolve-pkg": "2.0.0",
|
||||
@@ -151,9 +154,13 @@
|
||||
"workspaces": {
|
||||
"nohoist": [
|
||||
"@types/*",
|
||||
"eslint-plugin-expect-type",
|
||||
"tsx"
|
||||
]
|
||||
},
|
||||
"lint-staged": {
|
||||
"**/*.{js,jsx,ts,tsx,json,vue}": "eslint --fix"
|
||||
},
|
||||
"nx": {
|
||||
"targets": {
|
||||
"build-cli": {
|
||||
|
||||
@@ -74,10 +74,9 @@ export default makeUserPackageFile
|
||||
if (require.main === module) {
|
||||
makeUserPackageFile(process.env.BRANCH)
|
||||
.catch((err: any) => {
|
||||
/* eslint-disable no-console */
|
||||
console.error('Could not write user package file')
|
||||
console.error(err)
|
||||
/* eslint-enable no-console */
|
||||
|
||||
process.exit(-1)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
// @ts-check
|
||||
/* eslint-disable no-console */
|
||||
|
||||
import fs from 'fs-extra'
|
||||
import { includeTypes } from './utils'
|
||||
import shell from 'shelljs'
|
||||
|
||||
@@ -23,7 +23,7 @@ includeTypes.forEach((folder: string) => {
|
||||
})
|
||||
|
||||
// build the project and copy the build files over to the build directory
|
||||
shell.exec('tsc -p tsconfig.json')
|
||||
shell.exec('tsc -p tsconfig.build.json')
|
||||
shell.exec('tsc -p tsconfig.esm.json')
|
||||
|
||||
shell.mkdir('-p', 'build/dist')
|
||||
|
||||
22
cli/scripts/tsconfig.json
Normal file
22
cli/scripts/tsconfig.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"node",
|
||||
],
|
||||
"exactOptionalPropertyTypes": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"globals": {
|
||||
"lib": true,
|
||||
"sinon": true
|
||||
},
|
||||
"extends": [
|
||||
"plugin:@cypress/dev/tests"
|
||||
]
|
||||
}
|
||||
@@ -5,6 +5,9 @@
|
||||
"noImplicitAny": false,
|
||||
"types": [
|
||||
"mocha", "chai", "sinon"
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts"
|
||||
]
|
||||
}
|
||||
|
||||
13
cli/tsconfig.build.json
Normal file
13
cli/tsconfig.build.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "./lib",
|
||||
"outDir": "./dist",
|
||||
"target": "es2016",
|
||||
"noEmit": false
|
||||
},
|
||||
"exclude": [
|
||||
"test/**/*",
|
||||
"*.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,18 +1,12 @@
|
||||
{
|
||||
"extends": "./tsconfig.build.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "./lib",
|
||||
"outDir": "./dist",
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "node",
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true,
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"noImplicitAny": false
|
||||
"types": ["node"]
|
||||
},
|
||||
"include": [
|
||||
"lib/**/*.mts"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,39 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"rootDir": "./lib",
|
||||
"rootDir": "./",
|
||||
"outDir": "./dist",
|
||||
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
||||
"module": "commonjs", /* Specify what module code is generated. */
|
||||
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
||||
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
||||
"target": "ES2022",
|
||||
"module": "commonjs",
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true,
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"noImplicitAny": false,
|
||||
"noEmit": true,
|
||||
"types": [
|
||||
"mocha"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"lib/**/*.ts",
|
||||
"test/**/*.ts",
|
||||
"*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"types/bluebird",
|
||||
"types/chai",
|
||||
"types/chai-jquery",
|
||||
"types/jquery",
|
||||
"types/lodash",
|
||||
"types/minimatch",
|
||||
"types/mocha",
|
||||
"types/sinon",
|
||||
"types/sinon-chai",
|
||||
"react",
|
||||
"vue",
|
||||
"angular",
|
||||
"svelte",
|
||||
"mount-utils",
|
||||
]
|
||||
}
|
||||
|
||||
4
cli/types/cypress.d.ts
vendored
4
cli/types/cypress.d.ts
vendored
@@ -1691,7 +1691,7 @@ declare namespace Cypress {
|
||||
* cy.get('h1').should('equal', 'Example Domain')
|
||||
* })
|
||||
*/
|
||||
origin<T extends any>(urlOrDomain: string, fn: () => void): Chainable<T>
|
||||
origin<T>(urlOrDomain: string, fn: () => void): Chainable<T>
|
||||
|
||||
/**
|
||||
* Enables running Cypress commands in a secondary origin.
|
||||
@@ -1702,7 +1702,7 @@ declare namespace Cypress {
|
||||
* expect(foo).to.equal('foo')
|
||||
* })
|
||||
*/
|
||||
origin<T, S extends any>(urlOrDomain: string, options: {
|
||||
origin<T, S>(urlOrDomain: string, options: {
|
||||
args: T
|
||||
}, fn: (args: T) => void): Chainable<S>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace CypressLodashTests {
|
||||
Cypress._ // $ExpectType LoDashStatic
|
||||
Cypress._.each([1], item => {
|
||||
Cypress._.each([1], (item) => {
|
||||
item // $ExpectType number
|
||||
})
|
||||
}
|
||||
@@ -36,7 +36,7 @@ namespace CypressConfigTests {
|
||||
Cypress.config('baseUrl', '.') // $ExpectType void
|
||||
Cypress.config({ e2e: { baseUrl: '.' } }) // $ExpectError
|
||||
Cypress.config({ e2e: { baseUrl: null } }) // $ExpectError
|
||||
Cypress.config({ e2e: { baseUrl: '.', } }) // $ExpectError
|
||||
Cypress.config({ e2e: { baseUrl: '.' } }) // $ExpectError
|
||||
Cypress.config({ component: { baseUrl: '.', devServer: () => ({} as any) } }) // $ExpectError
|
||||
Cypress.config({ e2e: { indexHtmlFile: 'index.html' } }) // $ExpectError
|
||||
Cypress.config({ testIsolation: false }) // $ExpectError
|
||||
@@ -51,20 +51,20 @@ namespace CypressEnvTests {
|
||||
Cypress.env('foo', 'bar')
|
||||
Cypress.env().foo
|
||||
Cypress.env({
|
||||
foo: 'bar'
|
||||
foo: 'bar',
|
||||
})
|
||||
}
|
||||
|
||||
namespace CypressStopTests {
|
||||
Cypress.stop() // $ExpectType void
|
||||
Cypress.stop('foo') // $ExpectError
|
||||
Cypress.stop() // $ExpectType void
|
||||
Cypress.stop('foo') // $ExpectError
|
||||
}
|
||||
|
||||
namespace CypressIsCyTests {
|
||||
Cypress.isCy(cy) // $ExpectType boolean
|
||||
Cypress.isCy(undefined) // $ExpectType boolean
|
||||
|
||||
const chainer = cy.wrap("foo").then(function() {
|
||||
const chainer = cy.wrap('foo').then(function () {
|
||||
if (Cypress.isCy(chainer)) {
|
||||
chainer // $ExpectType Chainable<string>
|
||||
}
|
||||
@@ -82,28 +82,32 @@ namespace CypressCommandsTests {
|
||||
Cypress.Commands.add('newCommand', (arg) => {
|
||||
// $ExpectType string
|
||||
arg
|
||||
|
||||
return
|
||||
})
|
||||
Cypress.Commands.add('newCommand', (arg) => {
|
||||
// $ExpectType string
|
||||
arg
|
||||
})
|
||||
Cypress.Commands.add('newCommand', function(arg) {
|
||||
Cypress.Commands.add('newCommand', function (arg) {
|
||||
this // $ExpectType Context
|
||||
arg // $ExpectType string
|
||||
})
|
||||
Cypress.Commands.add('newCommand', { prevSubject: true }, (subject, arg) => {
|
||||
subject // $ExpectType any
|
||||
arg // $ExpectType string
|
||||
|
||||
return
|
||||
})
|
||||
Cypress.Commands.add('newCommand', { prevSubject: false }, (arg: string) => {
|
||||
arg // $ExpectType string
|
||||
|
||||
return
|
||||
})
|
||||
Cypress.Commands.add('newCommand', { prevSubject: 'optional' }, (subject, arg) => {
|
||||
subject // $ExpectType unknown
|
||||
arg // $ExpectType string
|
||||
|
||||
return
|
||||
})
|
||||
Cypress.Commands.add('newCommand', { prevSubject: 'optional' }, (subject, arg) => {
|
||||
@@ -138,6 +142,7 @@ namespace CypressCommandsTests {
|
||||
} else {
|
||||
subject // $ExpectType JQueryWithSelector<HTMLElement>
|
||||
}
|
||||
|
||||
arg // $ExpectType string
|
||||
})
|
||||
Cypress.Commands.add('newCommand', { prevSubject: ['window', 'document', 'optional', 'element'] }, (subject, arg) => {
|
||||
@@ -150,22 +155,25 @@ namespace CypressCommandsTests {
|
||||
} else {
|
||||
subject // $ExpectType void
|
||||
}
|
||||
|
||||
arg // $ExpectType string
|
||||
})
|
||||
Cypress.Commands.add('newCommand', (arg) => {
|
||||
// $ExpectType string
|
||||
arg
|
||||
|
||||
return cy.wrap(new Promise<number>((resolve) => { resolve(5) }))
|
||||
})
|
||||
|
||||
Cypress.Commands.addAll({
|
||||
newCommand(arg) {
|
||||
newCommand (arg) {
|
||||
// $ExpectType any
|
||||
arg
|
||||
this // $ExpectType Context
|
||||
|
||||
return
|
||||
},
|
||||
newCommand2(arg, arg2) {
|
||||
newCommand2 (arg, arg2) {
|
||||
// $ExpectType any
|
||||
arg
|
||||
// $ExpectType any
|
||||
@@ -174,6 +182,7 @@ namespace CypressCommandsTests {
|
||||
newCommand3: (arg) => {
|
||||
// $ExpectType any
|
||||
arg
|
||||
|
||||
return
|
||||
},
|
||||
newCommand4: (arg) => {
|
||||
@@ -185,12 +194,14 @@ namespace CypressCommandsTests {
|
||||
newCommand: (subject, arg) => {
|
||||
subject // $ExpectType any
|
||||
arg // $ExpectType any
|
||||
|
||||
return
|
||||
},
|
||||
})
|
||||
Cypress.Commands.addAll({ prevSubject: false }, {
|
||||
newCommand: (arg) => {
|
||||
arg // $ExpectType any
|
||||
|
||||
return
|
||||
},
|
||||
})
|
||||
@@ -198,6 +209,7 @@ namespace CypressCommandsTests {
|
||||
newCommand: (subject, arg) => {
|
||||
subject // $ExpectType unknown
|
||||
arg // $ExpectType any
|
||||
|
||||
return
|
||||
},
|
||||
newCommand2: (subject, arg) => {
|
||||
@@ -227,13 +239,13 @@ namespace CypressCommandsTests {
|
||||
newCommand: (subject, arg) => {
|
||||
subject // $ExpectType JQueryWithSelector<HTMLElement>
|
||||
arg // $ExpectType any
|
||||
}
|
||||
},
|
||||
})
|
||||
Cypress.Commands.addAll({ prevSubject: ['element'] }, {
|
||||
newCommand: (subject, arg) => {
|
||||
subject // $ExpectType JQueryWithSelector<HTMLElement>
|
||||
arg // $ExpectType any
|
||||
}
|
||||
},
|
||||
})
|
||||
Cypress.Commands.addAll({ prevSubject: ['element', 'document', 'window'] }, {
|
||||
newCommand: (subject, arg) => {
|
||||
@@ -244,8 +256,9 @@ namespace CypressCommandsTests {
|
||||
} else {
|
||||
subject // $ExpectType JQueryWithSelector<HTMLElement>
|
||||
}
|
||||
|
||||
arg // $ExpectType any
|
||||
}
|
||||
},
|
||||
})
|
||||
Cypress.Commands.addAll({ prevSubject: ['window', 'document', 'optional', 'element'] }, {
|
||||
newCommand: (subject, arg) => {
|
||||
@@ -258,15 +271,17 @@ namespace CypressCommandsTests {
|
||||
} else {
|
||||
subject // $ExpectType void
|
||||
}
|
||||
|
||||
arg // $ExpectType any
|
||||
}
|
||||
},
|
||||
})
|
||||
Cypress.Commands.addAll({
|
||||
newCommand: (arg) => {
|
||||
// $ExpectType any
|
||||
arg
|
||||
|
||||
return cy.wrap(new Promise<number>((resolve) => { resolve(5) }))
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
Cypress.Commands.overwrite('newCommand', (originalFn, arg) => {
|
||||
@@ -274,7 +289,7 @@ namespace CypressCommandsTests {
|
||||
originalFn // $ExpectedType Chainable['newCommand']
|
||||
originalFn(arg) // $ExpectType Chainable<number>
|
||||
})
|
||||
Cypress.Commands.overwrite('newCommand', function(originalFn, arg) {
|
||||
Cypress.Commands.overwrite('newCommand', function (originalFn, arg) {
|
||||
this // $ExpectType Context
|
||||
arg // $ExpectType string
|
||||
originalFn // $ExpectedType Chainable['newCommand']
|
||||
@@ -303,9 +318,10 @@ namespace CypressCommandsTests {
|
||||
options // $ExpectType Partial<Loggable & Timeoutable & ScreenshotOptions> | undefined
|
||||
})
|
||||
|
||||
Cypress.Commands.addQuery('newQuery', function(arg) {
|
||||
Cypress.Commands.addQuery('newQuery', function (arg) {
|
||||
this // $ExpectType Command
|
||||
arg // $ExpectType string
|
||||
|
||||
return () => 3
|
||||
})
|
||||
}
|
||||
@@ -349,7 +365,7 @@ namespace CypressLogsTest {
|
||||
}
|
||||
|
||||
namespace CypressLocalStorageTest {
|
||||
Cypress.LocalStorage.clear = function(keys) {
|
||||
Cypress.LocalStorage.clear = function (keys) {
|
||||
keys // $ExpectType string[] | undefined
|
||||
}
|
||||
}
|
||||
@@ -393,7 +409,7 @@ namespace CypressInvokeTests {
|
||||
// (see https://github.com/cypress-io/cypress/issues/4022)
|
||||
|
||||
// call methods on arbitrary objects with reasonable return types
|
||||
cy.wrap({ fn: () => ({ a: 1 }) }).invoke("fn") // $ExpectType Chainable<{ a: number; }>
|
||||
cy.wrap({ fn: () => ({ a: 1 }) }).invoke('fn') // $ExpectType Chainable<{ a: number; }>
|
||||
|
||||
// call methods on dom elements with reasonable return types
|
||||
cy.get('.trigger-input-range').invoke('val', 25) // $ExpectType Chainable<string | number | string[] | undefined>
|
||||
@@ -411,7 +427,7 @@ cy.wrap({ foo: ['bar', 'baz'] })
|
||||
.each((s: string) => {
|
||||
s // $ExpectType string
|
||||
})
|
||||
.then(s => {
|
||||
.then((s) => {
|
||||
s // $ExpectType string[]
|
||||
})
|
||||
|
||||
@@ -434,45 +450,51 @@ describe('then', () => {
|
||||
// * then<S extends object | any[] | string | number | boolean>(fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<S>
|
||||
// * then<S>(fn: (this: ObjectLike, currentSubject: Subject) => S): ThenReturn<Subject, S>
|
||||
// For our purpose, it doesn't matter.
|
||||
const result = cy.get('foo').then(el => el.attr('foo'))
|
||||
const result = cy.get('foo').then((el) => el.attr('foo'))
|
||||
|
||||
result // $ExpectType Chainable<JQuery<HTMLElement>> | Chainable<string | JQuery<HTMLElement>>
|
||||
|
||||
const result2 = cy.get('foo').then(el => `${el}`)
|
||||
const result2 = cy.get('foo').then((el) => `${el}`)
|
||||
|
||||
result2 // $ExpectType Chainable<string>
|
||||
|
||||
const result3 = cy.get('foo').then({ timeout: 1234 }, el => el.attr('foo'))
|
||||
const result3 = cy.get('foo').then({ timeout: 1234 }, (el) => el.attr('foo'))
|
||||
|
||||
result3 // $ExpectType Chainable<JQuery<HTMLElement>> | Chainable<string | JQuery<HTMLElement>>
|
||||
|
||||
const result4 = cy.get('foo').then({ timeout: 1234 }, el => `${el}`)
|
||||
const result4 = cy.get('foo').then({ timeout: 1234 }, (el) => `${el}`)
|
||||
|
||||
result4 // $ExpectType Chainable<string>
|
||||
})
|
||||
|
||||
it('should have the correct type signature', () => {
|
||||
cy.wrap({ foo: 'bar' })
|
||||
.then(s => {
|
||||
.then((s) => {
|
||||
s // $ExpectType { foo: string; }
|
||||
|
||||
return s
|
||||
})
|
||||
.then(s => {
|
||||
.then((s) => {
|
||||
s // $ExpectType { foo: string; }
|
||||
})
|
||||
.then(s => s.foo)
|
||||
.then(s => {
|
||||
.then((s) => s.foo)
|
||||
.then((s) => {
|
||||
s // $ExpectType string
|
||||
})
|
||||
})
|
||||
|
||||
it('should have the correct type signature with options', () => {
|
||||
cy.wrap({ foo: 'bar' })
|
||||
.then({ timeout: 5000 }, s => {
|
||||
.then({ timeout: 5000 }, (s) => {
|
||||
s // $ExpectType { foo: string; }
|
||||
|
||||
return s
|
||||
})
|
||||
.then({ timeout: 5000 }, s => {
|
||||
.then({ timeout: 5000 }, (s) => {
|
||||
s // $ExpectType { foo: string; }
|
||||
})
|
||||
.then({ timeout: 5000 }, s => s.foo)
|
||||
.then({ timeout: 5000 }, s => {
|
||||
.then({ timeout: 5000 }, (s) => s.foo)
|
||||
.then({ timeout: 5000 }, (s) => {
|
||||
s // $ExpectType string
|
||||
})
|
||||
})
|
||||
@@ -481,6 +503,7 @@ describe('then', () => {
|
||||
cy.get('div')
|
||||
.then(($div) => {
|
||||
$div // $ExpectType JQuery<HTMLDivElement>
|
||||
|
||||
return $div[0]
|
||||
})
|
||||
.then(($div) => {
|
||||
@@ -490,6 +513,7 @@ describe('then', () => {
|
||||
cy.get('div')
|
||||
.then(($div) => {
|
||||
$div // $ExpectType JQuery<HTMLDivElement>
|
||||
|
||||
return [$div[0]]
|
||||
})
|
||||
.then(($div) => {
|
||||
@@ -499,6 +523,7 @@ describe('then', () => {
|
||||
cy.get('p')
|
||||
.then(($p) => {
|
||||
$p // $ExpectType JQuery<HTMLParagraphElement>
|
||||
|
||||
return $p[0]
|
||||
})
|
||||
.then({ timeout: 3000 }, ($p) => {
|
||||
@@ -510,7 +535,7 @@ describe('then', () => {
|
||||
it('any as default', () => {
|
||||
cy.get('body')
|
||||
.then(() => ({} as any))
|
||||
.then(v => {
|
||||
.then((v) => {
|
||||
v // $ExpectType any
|
||||
})
|
||||
})
|
||||
@@ -526,19 +551,19 @@ cy.wait(1234) // $ExpectType Chainable<undefined>
|
||||
cy.wrap('foo').wait(1234) // $ExpectType Chainable<string>
|
||||
|
||||
cy.wrap([{ foo: 'bar' }, { foo: 'baz' }])
|
||||
.then(subject => {
|
||||
.then((subject) => {
|
||||
subject // $ExpectType { foo: string; }[]
|
||||
})
|
||||
.then(([first, second]) => {
|
||||
first // $ExpectType { foo: string; }
|
||||
})
|
||||
.then(subject => {
|
||||
.then((subject) => {
|
||||
subject // $ExpectType { foo: string; }[]
|
||||
})
|
||||
.then(([first, second]) => {
|
||||
return first.foo + second.foo
|
||||
})
|
||||
.then(subject => {
|
||||
.then((subject) => {
|
||||
subject // $ExpectType string
|
||||
})
|
||||
|
||||
@@ -558,30 +583,32 @@ cy.spy().withArgs('').log(false).as('foo')
|
||||
|
||||
cy.get('something').as('foo', { type: 'static' })
|
||||
|
||||
cy.wrap('foo').then(subject => {
|
||||
cy.wrap('foo').then((subject) => {
|
||||
subject // $ExpectType string
|
||||
|
||||
return cy.wrap(subject)
|
||||
}).then(subject => {
|
||||
}).then((subject) => {
|
||||
subject // $ExpectType string
|
||||
})
|
||||
|
||||
cy.wrap('foo').then(subject => {
|
||||
cy.wrap('foo').then((subject) => {
|
||||
subject // $ExpectType string
|
||||
|
||||
return Cypress.Promise.resolve(subject)
|
||||
}).then(subject => {
|
||||
}).then((subject) => {
|
||||
subject // $ExpectType string
|
||||
})
|
||||
|
||||
cy.get('body').within(body => {
|
||||
cy.get('body').within((body) => {
|
||||
body // $ExpectType JQuery<HTMLBodyElement>
|
||||
})
|
||||
|
||||
cy.get('body').within({ log: false }, body => {
|
||||
cy.get('body').within({ log: false }, (body) => {
|
||||
body // $ExpectType JQuery<HTMLBodyElement>
|
||||
})
|
||||
|
||||
cy.get('body').within(() => {
|
||||
cy.get('body', { withinSubject: null }).then(body => {
|
||||
cy.get('body', { withinSubject: null }).then((body) => {
|
||||
body // $ExpectType JQuery<HTMLBodyElement>
|
||||
})
|
||||
})
|
||||
@@ -591,7 +618,7 @@ cy
|
||||
.then(() => {
|
||||
return cy.wrap(undefined)
|
||||
})
|
||||
.then(subject => {
|
||||
.then((subject) => {
|
||||
subject // $ExpectType undefined
|
||||
})
|
||||
|
||||
@@ -604,11 +631,11 @@ namespace CypressAUTWindowTests {
|
||||
win // $ExpectType AUTWindow
|
||||
})
|
||||
|
||||
cy.visit('https://google.com').then(win => {
|
||||
cy.visit('https://google.com').then((win) => {
|
||||
win // $ExpectType AUTWindow
|
||||
})
|
||||
|
||||
cy.window().then(win => {
|
||||
cy.window().then((win) => {
|
||||
win // $ExpectType AUTWindow
|
||||
})
|
||||
}
|
||||
@@ -666,6 +693,7 @@ namespace CypressFilterTests {
|
||||
.filter((index: number, element: HTMLDivElement) => {
|
||||
index // $ExpectType number
|
||||
element // $ExpectType HTMLDivElement
|
||||
|
||||
return true
|
||||
})
|
||||
}
|
||||
@@ -679,11 +707,11 @@ namespace CypressScreenshotTests {
|
||||
cy.screenshot({ log: false })
|
||||
cy.screenshot({
|
||||
log: true,
|
||||
blackout: []
|
||||
blackout: [],
|
||||
})
|
||||
cy.screenshot('example', {
|
||||
log: true,
|
||||
blackout: []
|
||||
blackout: [],
|
||||
})
|
||||
cy.get<HTMLDivElement>('#id').screenshot('example-name', { log: false })
|
||||
cy.get<HTMLDivElement>('#id').screenshot().then((result) => {
|
||||
@@ -700,14 +728,14 @@ namespace CypressTriggerTests {
|
||||
.trigger('click') // .trigger(eventName)
|
||||
.trigger('click', 'center') // .trigger(eventName, position)
|
||||
.trigger('click', { // .trigger(eventName, options)
|
||||
arbitraryProperty: 0
|
||||
arbitraryProperty: 0,
|
||||
})
|
||||
.trigger('click', 0, 0) // .trigger(eventName, x, y)
|
||||
.trigger('click', 'center', { // .trigger(eventName, position, options)
|
||||
arbitraryProperty: 0
|
||||
arbitraryProperty: 0,
|
||||
})
|
||||
.trigger('click', 0, 0, { // .trigger(eventName, x, y, options)
|
||||
arbitraryProperty: 0
|
||||
arbitraryProperty: 0,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -715,25 +743,25 @@ namespace CypressClockTests {
|
||||
// timestamp
|
||||
cy.clock(new Date(2019, 3, 2).getTime(), ['Date'])
|
||||
// timestamp shortcut
|
||||
cy.clock(+ new Date(), ['Date'])
|
||||
cy.clock(+new Date(), ['Date'])
|
||||
// Date object
|
||||
cy.clock(new Date(2019, 3, 2))
|
||||
// restoring the clock
|
||||
cy.clock().then(clock => {
|
||||
cy.clock().then((clock) => {
|
||||
clock.restore()
|
||||
})
|
||||
// restoring the clock shortcut
|
||||
cy.clock().invoke('restore')
|
||||
// setting system time with no argument
|
||||
cy.clock().then(clock => {
|
||||
cy.clock().then((clock) => {
|
||||
clock.setSystemTime()
|
||||
})
|
||||
// setting system time with timestamp
|
||||
cy.clock().then(clock => {
|
||||
cy.clock().then((clock) => {
|
||||
clock.setSystemTime(1000)
|
||||
})
|
||||
// setting system time with date object
|
||||
cy.clock().then(clock => {
|
||||
cy.clock().then((clock) => {
|
||||
clock.setSystemTime(new Date(2019, 3, 2))
|
||||
})
|
||||
// setting system time with no argument and shortcut
|
||||
@@ -873,24 +901,24 @@ namespace CypressTestConfigOverridesTests {
|
||||
taskTimeout: 6000,
|
||||
viewportHeight: 200,
|
||||
viewportWidth: 200,
|
||||
waitForAnimations: false
|
||||
waitForAnimations: false,
|
||||
}, () => { })
|
||||
it('test', {
|
||||
browser: { name: 'firefox' }
|
||||
browser: { name: 'firefox' },
|
||||
}, () => { })
|
||||
it('test', {
|
||||
browser: [{ name: 'firefox' }, { name: 'chrome' }]
|
||||
browser: [{ name: 'firefox' }, { name: 'chrome' }],
|
||||
}, () => { })
|
||||
it('test', {
|
||||
browser: 'firefox',
|
||||
keystrokeDelay: 0
|
||||
keystrokeDelay: 0,
|
||||
}, () => { })
|
||||
it('test', {
|
||||
browser: { foo: 'bar' }, // $ExpectError
|
||||
}, () => { })
|
||||
it('test', {
|
||||
retries: null,
|
||||
keystrokeDelay: 0
|
||||
keystrokeDelay: 0,
|
||||
}, () => { })
|
||||
it('test', {
|
||||
retries: 3,
|
||||
@@ -899,16 +927,16 @@ namespace CypressTestConfigOverridesTests {
|
||||
it('test', {
|
||||
retries: {
|
||||
runMode: 3,
|
||||
openMode: null
|
||||
}
|
||||
openMode: null,
|
||||
},
|
||||
}, () => { })
|
||||
it('test', {
|
||||
retries: {
|
||||
runMode: 3,
|
||||
}
|
||||
},
|
||||
}, () => { })
|
||||
it('test', {
|
||||
retries: { run: 3 } // $ExpectError
|
||||
retries: { run: 3 }, // $ExpectError
|
||||
}, () => { })
|
||||
it('test', {
|
||||
testIsolation: false, // $ExpectError
|
||||
@@ -926,7 +954,7 @@ namespace CypressTestConfigOverridesTests {
|
||||
// set config on a per-suite basis
|
||||
describe('suite', {
|
||||
browser: { family: 'firefox' },
|
||||
keystrokeDelay: 0
|
||||
keystrokeDelay: 0,
|
||||
}, () => { })
|
||||
|
||||
describe('suite', {
|
||||
@@ -937,8 +965,7 @@ namespace CypressTestConfigOverridesTests {
|
||||
|
||||
describe('suite', {
|
||||
browser: { family: 'firefox' },
|
||||
keystrokeDelay: false // $ExpectError
|
||||
foo: 'foo' // $ExpectError
|
||||
keystrokeDelay: false, // $ExpectError
|
||||
}, () => { })
|
||||
|
||||
describe.only('suite', {}, () => { })
|
||||
@@ -946,6 +973,14 @@ namespace CypressTestConfigOverridesTests {
|
||||
xdescribe('suite', {}, () => { })
|
||||
}
|
||||
|
||||
// for whatever reason, this is a false negative if placed in
|
||||
// the CypressTestConfigOverridesTests namespace
|
||||
|
||||
describe('suite', {
|
||||
browser: { family: 'firefox' },
|
||||
foo: 'bar', // $ExpectError
|
||||
}, () => { })
|
||||
|
||||
namespace CypressShadowTests {
|
||||
cy
|
||||
.get('.foo')
|
||||
@@ -977,14 +1012,14 @@ namespace CypressSessionsTests {
|
||||
cy.session({ name: 'bob' }, () => { })
|
||||
cy.session('user', () => { }, {})
|
||||
cy.session('user', () => { }, {
|
||||
validate: () => { }
|
||||
validate: () => { },
|
||||
})
|
||||
|
||||
cy.session() // $ExpectError
|
||||
cy.session('user') // $ExpectError
|
||||
cy.session(null) // $ExpectError
|
||||
cy.session('user', () => { }, {
|
||||
validate: { foo: true } // $ExpectError
|
||||
validate: { foo: true }, // $ExpectError
|
||||
})
|
||||
}
|
||||
|
||||
@@ -996,16 +1031,16 @@ namespace CypressCurrentTest {
|
||||
|
||||
namespace CypressKeyboardTests {
|
||||
Cypress.Keyboard.defaults({
|
||||
keystrokeDelay: 0
|
||||
keystrokeDelay: 0,
|
||||
})
|
||||
Cypress.Keyboard.defaults({
|
||||
keystrokeDelay: 500
|
||||
keystrokeDelay: 500,
|
||||
})
|
||||
Cypress.Keyboard.defaults({
|
||||
keystrokeDelay: false // $ExpectError
|
||||
keystrokeDelay: false, // $ExpectError
|
||||
})
|
||||
Cypress.Keyboard.defaults({
|
||||
delay: 500 // $ExpectError
|
||||
delay: 500, // $ExpectError
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1169,34 +1204,34 @@ namespace CypressLocalStorageTests {
|
||||
namespace CypressRetriesSpec {
|
||||
Cypress.config('retries', {
|
||||
openMode: 0,
|
||||
runMode: 1
|
||||
runMode: 1,
|
||||
})
|
||||
|
||||
Cypress.config('retries', {
|
||||
openMode: false,
|
||||
runMode: false,
|
||||
experimentalStrategy: "detect-flake-and-pass-on-threshold",
|
||||
experimentalStrategy: 'detect-flake-and-pass-on-threshold',
|
||||
experimentalOptions: {
|
||||
maxRetries: 2,
|
||||
passesRequired: 2
|
||||
}
|
||||
passesRequired: 2,
|
||||
},
|
||||
})
|
||||
|
||||
Cypress.config('retries', {
|
||||
openMode: false,
|
||||
runMode: false,
|
||||
experimentalStrategy: "detect-flake-but-always-fail",
|
||||
experimentalStrategy: 'detect-flake-but-always-fail',
|
||||
experimentalOptions: {
|
||||
maxRetries: 2,
|
||||
stopIfAnyPassed: true
|
||||
}
|
||||
stopIfAnyPassed: true,
|
||||
},
|
||||
})
|
||||
|
||||
Cypress.config('retries', { openMode: false, runMode: true, experimentalStrategy: "detect-flake-and-pass-on-threshold", experimentalOptions: { maxRetries: 2 } }) // $ExpectError
|
||||
Cypress.config('retries', { openMode: false, runMode: true, experimentalStrategy: "detect-flake-but-always-fail", experimentalOptions: { maxRetries: 2 } }) // $ExpectError
|
||||
Cypress.config('retries', { openMode: false, runMode: true, experimentalStrategy: 'detect-flake-and-pass-on-threshold', experimentalOptions: { maxRetries: 2 } }) // $ExpectError
|
||||
Cypress.config('retries', { openMode: false, runMode: true, experimentalStrategy: 'detect-flake-but-always-fail', experimentalOptions: { maxRetries: 2 } }) // $ExpectError
|
||||
|
||||
Cypress.config('retries', { openMode: false, runMode: true, experimentalStrategy: "detect-flake-and-pass-on-threshold", experimentalOptions: { passesRequired: 2 } }) // $ExpectError
|
||||
Cypress.config('retries', { openMode: false, runMode: true, experimentalStrategy: "detect-flake-but-always-fail", experimentalOptions: { stopIfAnyPassed: true } }) // $ExpectError
|
||||
Cypress.config('retries', { openMode: false, runMode: true, experimentalStrategy: 'detect-flake-and-pass-on-threshold', experimentalOptions: { passesRequired: 2 } }) // $ExpectError
|
||||
Cypress.config('retries', { openMode: false, runMode: true, experimentalStrategy: 'detect-flake-but-always-fail', experimentalOptions: { stopIfAnyPassed: true } }) // $ExpectError
|
||||
}
|
||||
|
||||
namespace CypressTraversalTests {
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
// in its own file for simplicity
|
||||
"no-single-declare-module": false,
|
||||
// This is detecting necessary qualifiers as unnecessary
|
||||
"no-unnecessary-qualifier": false
|
||||
"no-unnecessary-qualifier": false,
|
||||
"space-before-function-paren": ["warn", "always"]
|
||||
},
|
||||
"linterOptions": {
|
||||
"exclude": [
|
||||
@@ -46,4 +47,4 @@
|
||||
"./net-stubbing.d.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,7 @@
|
||||
- [ ] packages/app
|
||||
|
||||
### Batch 4c: Core packages (part 3)
|
||||
- [x] cli
|
||||
- [ ] packages/config
|
||||
- [ ] packages/root
|
||||
- [ ] packages/resolve-dist
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
export * from './baseConfig'
|
||||
|
||||
export * from './cliOverrides'
|
||||
|
||||
import * as globalImport from 'globals'
|
||||
|
||||
export const globals = {
|
||||
...globalImport,
|
||||
specHelper: {
|
||||
sinon: 'readonly',
|
||||
expect: 'readonly',
|
||||
lib: 'readonly',
|
||||
global: false,
|
||||
},
|
||||
}
|
||||
|
||||
14
yarn.lock
14
yarn.lock
@@ -8742,11 +8742,16 @@
|
||||
"@typescript-eslint/types" "8.37.0"
|
||||
"@typescript-eslint/visitor-keys" "8.37.0"
|
||||
|
||||
"@typescript-eslint/tsconfig-utils@8.37.0", "@typescript-eslint/tsconfig-utils@^8.37.0":
|
||||
"@typescript-eslint/tsconfig-utils@8.37.0":
|
||||
version "8.37.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.37.0.tgz#47a2760d265c6125f8e7864bc5c8537cad2bd053"
|
||||
integrity sha512-1/YHvAVTimMM9mmlPvTec9NP4bobA1RkDbMydxG8omqwJJLEW/Iy2C4adsAESIXU3WGLXFHSZUU+C9EoFWl4Zg==
|
||||
|
||||
"@typescript-eslint/tsconfig-utils@^8.37.0":
|
||||
version "8.41.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.41.0.tgz#134dee36eb16cdd78095a20bca0516d10b5dda75"
|
||||
integrity sha512-TDhxYFPUYRFxFhuU5hTIJk+auzM/wKvWgoNYOPcOf6i4ReYlOoYN8q1dV5kOTjNQNJgzWN3TUUQMtlLOcUgdUw==
|
||||
|
||||
"@typescript-eslint/type-utils@7.2.0":
|
||||
version "7.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-7.2.0.tgz#7be5c30e9b4d49971b79095a1181324ef6089a19"
|
||||
@@ -8773,11 +8778,16 @@
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-7.2.0.tgz#0feb685f16de320e8520f13cca30779c8b7c403f"
|
||||
integrity sha512-XFtUHPI/abFhm4cbCDc5Ykc8npOKBSJePY3a3s+lwumt7XWJuzP5cZcfZ610MIPHjQjNsOLlYK8ASPaNG8UiyA==
|
||||
|
||||
"@typescript-eslint/types@8.37.0", "@typescript-eslint/types@^8.35.0", "@typescript-eslint/types@^8.37.0":
|
||||
"@typescript-eslint/types@8.37.0":
|
||||
version "8.37.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-8.37.0.tgz#09517aa9625eb3c68941dde3ac8835740587b6ff"
|
||||
integrity sha512-ax0nv7PUF9NOVPs+lmQ7yIE7IQmAf8LGcXbMvHX5Gm+YJUYNAl340XkGnrimxZ0elXyoQJuN5sbg6C4evKA4SQ==
|
||||
|
||||
"@typescript-eslint/types@^8.35.0", "@typescript-eslint/types@^8.37.0":
|
||||
version "8.41.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-8.41.0.tgz#9935afeaae65e535abcbcee95383fa649c64d16d"
|
||||
integrity sha512-9EwxsWdVqh42afLbHP90n2VdHaWU/oWgbH2P0CfcNfdKL7CuKpwMQGjwev56vWu9cSKU7FWSu6r9zck6CVfnag==
|
||||
|
||||
"@typescript-eslint/typescript-estree@7.2.0":
|
||||
version "7.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-7.2.0.tgz#5beda2876c4137f8440c5a84b4f0370828682556"
|
||||
|
||||
Reference in New Issue
Block a user