diff --git a/.circleci/workflows.yml b/.circleci/workflows.yml index df04d4df982a..3408977a9ca5 100644 --- a/.circleci/workflows.yml +++ b/.circleci/workflows.yml @@ -2477,14 +2477,6 @@ jobs: path: npm/grep/test_results - store-npm-logs - npm-eslint-plugin-dev: - <<: *defaults - steps: - - restore_cached_workspace - - run: - name: Run tests - command: yarn workspace @cypress/eslint-plugin-dev test - npm-cypress-schematic: <<: *defaults steps: @@ -3206,9 +3198,6 @@ linux-x64-workflow: &linux-x64-workflow - npm-mount-utils: requires: - build - - npm-eslint-plugin-dev: - requires: - - build - npm-cypress-schematic: requires: - build @@ -3221,7 +3210,6 @@ linux-x64-workflow: &linux-x64-workflow requires: - check-ts - npm-angular - - npm-eslint-plugin-dev - npm-puppeteer-unit-tests - npm-puppeteer-cypress-tests - npm-react @@ -3607,9 +3595,6 @@ linux-x64-contributor-workflow: &linux-x64-contributor-workflow - npm-mount-utils: requires: - build - - npm-eslint-plugin-dev: - requires: - - build - npm-cypress-schematic: requires: - build @@ -3621,7 +3606,6 @@ linux-x64-contributor-workflow: &linux-x64-contributor-workflow requires: - check-ts - npm-angular - - npm-eslint-plugin-dev - npm-puppeteer-unit-tests - npm-puppeteer-cypress-tests - npm-react diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 94dcd6358b39..000000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,109 +0,0 @@ -const fs = require('fs') -const path = require('path') -const { specifiedRules } = require('graphql') - -const graphqlOpts = { - env: 'literal', - tagName: 'gql', - // eslint-disable-next-line no-restricted-syntax - schemaString: fs.readFileSync( - path.join(__dirname, 'packages/graphql/schemas/schema.graphql'), - 'utf8', - ), -} - -const validators = specifiedRules -.map((rule) => rule.name) -.filter( - (ruleName) => { - return [ - 'NoUnusedFragmentsRule', - 'KnownFragmentNamesRule', - 'NoUnusedVariablesRule', - ].findIndex((x) => x === ruleName) === -1 - }, -) - -module.exports = { - root: true, - plugins: [ - '@cypress/dev', - 'graphql', - ], - extends: [ - 'plugin:@cypress/dev/general', - 'plugin:@cypress/dev/tests', - ], - parser: '@typescript-eslint/parser', - ignorePatterns: [ - // cli types are checked by dtslint - 'cli/types/**', - // these fixtures are supposed to fail linting - 'npm/eslint-plugin-dev/test/fixtures/**', - // Cloud generated - 'system-tests/lib/validations/**', - ], - overrides: [ - { - files: [ - // ignore in tests and scripts - '**/scripts/**', - '**/test/**', - '**/system-tests/**', - 'tooling/**', - 'packages/{app,driver,frontend-shared,launchpad}/cypress/**', - '*.test.ts', - ], - rules: { - 'no-restricted-properties': 'off', - 'no-restricted-syntax': 'off', - }, - }, - { - files: ['*.json'], - extends: 'plugin:@cypress/dev/general', - }, - ], - rules: { - 'no-duplicate-imports': 'off', - 'import/no-duplicates': 'error', - 'prefer-spread': 'off', - 'prefer-rest-params': 'off', - 'no-useless-constructor': 'off', - 'no-restricted-properties': [ - 'error', - { - object: 'process', - property: 'geteuid', - message: 'process.geteuid() will throw on Windows. Do not use it unless you catch any potential errors.', - }, - { - object: 'os', - property: 'userInfo', - message: 'os.userInfo() will throw when there is not an `/etc/passwd` entry for the current user (like when running with --user 12345 in Docker). Do not use it unless you catch any potential errors.', - }, - ], - 'no-restricted-syntax': [ - // esquery tool: https://estools.github.io/esquery/ - 'error', - { - // match sync FS methods except for `existsSync` - // examples: fse.readFileSync, fs.readFileSync, this.ctx.fs.readFileSync... - selector: `MemberExpression[object.name='fs'][property.name=/^[A-z]+Sync$/]:not(MemberExpression[property.name='existsSync']), MemberExpression[property.name=/^[A-z]+Sync$/]:not(MemberExpression[property.name='existsSync']):has(MemberExpression[property.name='fs'])`, - message: 'Synchronous fs calls should not be used in Cypress. Use an async API instead.', - }, - ], - 'graphql/capitalized-type-name': ['warn', graphqlOpts], - 'graphql/no-deprecated-fields': ['error', graphqlOpts], - 'graphql/template-strings': ['error', { ...graphqlOpts, validators }], - 'graphql/required-fields': [ - 'error', - { ...graphqlOpts, requiredFields: ['id'] }, - ], - }, - settings: { - react: { - version: '16.8', - }, - }, -} diff --git a/.prettierignore b/.prettierignore index 5ca09b5bd510..d346c50806a5 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,4 +1,8 @@ **/* /.nx/cache -/.nx/workspace-data \ No newline at end of file +/.nx/workspace-data + +!**/*.json +**/package.json +**/package-lock.json \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 3e90e64819c5..fddf83a2ed68 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,16 +8,8 @@ "json" ], "eslint.enable": true, - // this project does not use Prettier - // thus set all settings to disable accidentally running Prettier + // this project only uses Prettier for json files "prettier.requireConfig": true, - "prettier.disableLanguages": [ - "javascript", - "javascriptreact", - "typescript", - "typescriptreact", - "json" - ], "editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit" }, diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6324370c43c1..2478e7dcd174 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -182,7 +182,6 @@ Here is a list of the npm packages in this repository: | Folder Name | Package Name | Purpose | | :----------------------------------------------------- | :--------------------------------- | :--------------------------------------------------------------------------- | | [angular](./npm/angular) | `@cypress/angular` | Cypress component testing for Angular. | - | [eslint-plugin-dev](./npm/eslint-plugin-dev) | `@cypress/eslint-plugin-dev` | Eslint plugin for internal development. | | [grep](./npm/grep) | `@cypress/grep` | Filter tests using substring | | [mount-utils](./npm/mount-utils) | `@cypress/mount-utils` | Common functionality for Vue/React/Angular adapters. | | [react](./npm/react) | `@cypress/react` | Cypress component testing for React. | @@ -341,8 +340,12 @@ Many Cypress packages print out debugging information to console via the `debug` ### Coding Style -We use [eslint](https://eslint.org/) to lint all JavaScript code and follow rules specified in -[@cypress/eslint-plugin-dev](./npm/eslint-plugin-dev) plugin. +Cypress uses [eslint](https://eslint.org/) to lint all JavaScript code. All packages should import the `baseConfig` from the root `eslint.config.ts`. The only overrides in package-specific `eslint.config.ts` files should be regarding: +- Which files get processed +- Which globals are expected for selections of files +- Downgrading inherited rules from `error` to `warn`, if they cannot be `--fix`ed. + +Package-specific `eslint.config.ts` configurations should *never* turn inherited rules off. This is to ensure repository-wide linting standards. If a rule is inappropriately applied to a package or its files, there is likely a better solution than turning the rule off. This project uses a Git pre-commit hook to lint staged files before committing. See the [`lint-staged` project](https://github.com/okonet/lint-staged) for details. `lint-staged` will try to auto-fix any lint errors with `eslint --fix`, so if it fails, you must manually fix the lint errors before committing. diff --git a/autobarrel.json b/autobarrel.json index 3afaf2afc552..6636e6412f5c 100644 --- a/autobarrel.json +++ b/autobarrel.json @@ -1,13 +1,10 @@ { "prefix": "/* eslint-disable padding-line-between-statements */", - "paths": [ - "packages/graphql/src/**/*", - "packages/data-context/src/**/*" - ], + "paths": ["packages/graphql/src/**/*", "packages/data-context/src/**/*"], "ignore": [ "packages/data-context/src/gen", "packages/graphql/src/stitching", "packages/graphql/src/testing", "packages/graphql/src/gen" ] -} \ No newline at end of file +} diff --git a/cli/.eslintignore b/cli/.eslintignore deleted file mode 100644 index 90471aa76fd3..000000000000 --- a/cli/.eslintignore +++ /dev/null @@ -1,16 +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 \ No newline at end of file diff --git a/cli/.eslintrc.json b/cli/.eslintrc.json deleted file mode 100644 index c3cecddc84c3..000000000000 --- a/cli/.eslintrc.json +++ /dev/null @@ -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." - } - ] - } -} diff --git a/cli/eslint.config.ts b/cli/eslint.config.ts new file mode 100644 index 000000000000..193285a41e76 --- /dev/null +++ b/cli/eslint.config.ts @@ -0,0 +1,62 @@ +/* +{ + "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." + } + ] + } +} +*/ +import path from 'path' +import baseConfig from '../eslint.config' +import globals from 'globals' + +export default [ + ...baseConfig, + { + files: ['**/*.{ts,js}'], + languageOptions: { + parserOptions: { + projectService: true, + tsconfigRootDir: path.join(__dirname, '../packages/ts/tsconfig.json'), + }, + globals: { + ...globals.node, + }, + }, + }, + { + ignores: [ + '__snapshots__/**/*', + 'angular/**/*', + 'build/**/*', + 'mount-utils/**/*', + 'node_modules/**/*', + 'react/**/*', + 'svelte/**/*', + 'vue/**/*', + 'types/**/*', + ], + }, + { + files: ['test/**/*.{ts,js}'], + languageOptions: { + globals: { + sinon: 'readonly', + lib: 'readonly', + }, + }, + }, +] diff --git a/cli/lib/util.js b/cli/lib/util.js index 4f7a67e88e9e..0abbe4c13e58 100644 --- a/cli/lib/util.js +++ b/cli/lib/util.js @@ -467,7 +467,7 @@ const util = { async function _getRealArch () { const osPlatform = os.platform() - // eslint-disable-next-line no-restricted-syntax + const osArch = os.arch() debug('detecting arch %o', { osPlatform, osArch }) @@ -492,7 +492,6 @@ const util = { if (['aarch64_be', 'aarch64', 'armv8b', 'armv8l'].includes(stdout)) return 'arm64' } - // eslint-disable-next-line no-restricted-syntax const pkgArch = arch() if (pkgArch === 'x86') return 'ia32' diff --git a/cli/package.json b/cli/package.json index 7b76e4a1318d..0ab803a88b76 100644 --- a/cli/package.json +++ b/cli/package.json @@ -8,7 +8,7 @@ "clean": "node ./scripts/clean.js", "dtslint": "dtslint types", "postinstall": "patch-package && node ./scripts/post-install.js", - "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json,.vue .", + "lint": "eslint .", "prebuild": "yarn postinstall && node ./scripts/start-build.js", "size": "t=\"cypress-v0.0.0.tgz\"; yarn pack --filename \"${t}\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";", "test": "yarn test-unit", diff --git a/cli/scripts/clean.js b/cli/scripts/clean.js index 406d3b225aa4..871bc19bae59 100644 --- a/cli/scripts/clean.js +++ b/cli/scripts/clean.js @@ -2,10 +2,12 @@ const fs = require('fs-extra') const path = require('path') const { includeTypes } = require('./utils') +// eslint-disable-next-line no-restricted-syntax fs.removeSync(path.join(__dirname, '..', 'build')) includeTypes.forEach((folder) => { try { + // eslint-disable-next-line no-restricted-syntax fs.removeSync(path.join(__dirname, '..', 'types', folder)) } catch (e) { // diff --git a/cli/scripts/post-install.js b/cli/scripts/post-install.js index fdc4c6d947a5..412fd5bfe1de 100644 --- a/cli/scripts/post-install.js +++ b/cli/scripts/post-install.js @@ -19,12 +19,13 @@ shell.set('-e') // any error is fatal // This ensures that globals like Cypress.$, Cypress._ etc are property typed // yet we do not install "@types/.." packages with "npm install cypress" // because they can conflict with user's own libraries - +// eslint-disable-next-line no-restricted-syntax fs.ensureDirSync(join(__dirname, '..', 'types')) includeTypes.forEach((folder) => { const source = resolvePkg(`@types/${folder}`, { cwd: __dirname }) + // eslint-disable-next-line no-restricted-syntax fs.copySync(source, join(__dirname, '..', 'types', folder)) }) @@ -75,6 +76,7 @@ shell.sed('-i', 'from \'sinon\';', 'from \'../sinon\';', sinonChaiFilename) // copy experimental network stubbing type definitions // so users can import: `import 'cypress/types/net-stubbing'` +// eslint-disable-next-line no-restricted-syntax fs.copySync(resolvePkg('@packages/net-stubbing/lib/external-types.ts'), 'types/net-stubbing.d.ts') // https://github.com/cypress-io/cypress/issues/18069 @@ -90,11 +92,13 @@ const filesToUncomment = [ filesToUncomment.forEach((file) => { const filePath = join(__dirname, '../types', file) + // eslint-disable-next-line no-restricted-syntax const str = fs.readFileSync(filePath).toString() const result = str.split('\n').map((line) => { return line.startsWith('//z ') ? line.substring(4) : line }).join('\n') + // eslint-disable-next-line no-restricted-syntax fs.writeFileSync(filePath, result) }) diff --git a/cli/test/.eslintrc.json b/cli/test/.eslintrc.json deleted file mode 100644 index 722558a67462..000000000000 --- a/cli/test/.eslintrc.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "globals": { - "lib": true, - "sinon": true - }, - "extends": [ - "plugin:@cypress/dev/tests" - ] -} diff --git a/cli/test/lib/tasks/download_spec.js b/cli/test/lib/tasks/download_spec.js index b808492e0389..759c7adbdbe3 100644 --- a/cli/test/lib/tasks/download_spec.js +++ b/cli/test/lib/tasks/download_spec.js @@ -186,6 +186,7 @@ describe('lib/tasks/download', function () { context('verify downloaded file', function () { before(function () { this.expectedChecksum = hasha.fromFileSync(examplePath) + // eslint-disable-next-line no-restricted-syntax this.expectedFileSize = fs.statSync(examplePath).size this.onProgress = sinon.stub().returns(undefined) debug('example file %s should have checksum %s and file size %d', diff --git a/cli/test/lib/tasks/verify_spec.js b/cli/test/lib/tasks/verify_spec.js index 78a8272eec37..5fa96d5e947f 100644 --- a/cli/test/lib/tasks/verify_spec.js +++ b/cli/test/lib/tasks/verify_spec.js @@ -31,8 +31,6 @@ const DEFAULT_VERIFY_TIMEOUT = 30000 let stdout let spawnedProcess -/* eslint-disable no-octal */ - context('lib/tasks/verify', () => { require('mocha-banner').register() diff --git a/cli/test/spec_helper.js b/cli/test/spec_helper.js index 41ff9d6e8b12..0118c7c46b0c 100644 --- a/cli/test/spec_helper.js +++ b/cli/test/spec_helper.js @@ -69,7 +69,6 @@ function throwIfFnNotStubbed (stub, method) { const $stub = sinon.stub sinon.stub = function (obj, method) { - /* eslint-disable prefer-rest-params */ const stub = $stub.apply(this, arguments) let fns = [method] diff --git a/cli/test/support/stdout.js b/cli/test/support/stdout.js index e6372856873f..b4b34c4861a1 100644 --- a/cli/test/support/stdout.js +++ b/cli/test/support/stdout.js @@ -9,7 +9,6 @@ module.exports = { process.stdout.write = function (str) { logs.push(str) - /* eslint-disable prefer-rest-params */ write.apply(this, arguments) } diff --git a/electron-builder.json b/electron-builder.json index 91a46582f953..73bb534bbde7 100644 --- a/electron-builder.json +++ b/electron-builder.json @@ -16,9 +16,7 @@ "executableName": "Cypress" }, "win": { - "signingHashAlgorithms": [ - "sha256" - ], + "signingHashAlgorithms": ["sha256"], "sign": "./scripts/windows-sign.js", "target": "dir" }, diff --git a/eslint.config.ts b/eslint.config.ts new file mode 100644 index 000000000000..55efef7f7e0c --- /dev/null +++ b/eslint.config.ts @@ -0,0 +1,3 @@ +import baseConfig from './tooling/eslint-config' + +export default baseConfig \ No newline at end of file diff --git a/npm/angular/.eslintignore b/npm/angular/.eslintignore deleted file mode 100644 index 79afe972da7d..000000000000 --- a/npm/angular/.eslintignore +++ /dev/null @@ -1,5 +0,0 @@ -**/dist -**/*.d.ts -**/package-lock.json -**/tsconfig.json -**/cypress/fixtures \ No newline at end of file diff --git a/npm/angular/.eslintrc b/npm/angular/.eslintrc deleted file mode 100644 index f044f320923e..000000000000 --- a/npm/angular/.eslintrc +++ /dev/null @@ -1,8 +0,0 @@ -{ - "plugins": [ - "cypress" - ], - "extends": [ - "plugin:@cypress/dev/tests" - ] -} diff --git a/npm/angular/eslint.config.ts b/npm/angular/eslint.config.ts new file mode 100644 index 000000000000..acb4f6673edf --- /dev/null +++ b/npm/angular/eslint.config.ts @@ -0,0 +1,24 @@ +import baseConfig from '../../eslint.config' +import path from 'path' +import globals from 'globals' + +export default [ + ...baseConfig, + { + ignores: ['dist/**'], + }, + { + languageOptions: { + parserOptions: { + projectService: { + allowDefaultProject: ['eslint.config.ts', 'rollup.config.mjs'], + }, + tsconfigRootDir: path.join(__dirname, '.'), + + }, + globals: { + ...globals.browser, + }, + }, + }, +] diff --git a/npm/angular/package.json b/npm/angular/package.json index a2b02d0cecf4..7409d42028c7 100644 --- a/npm/angular/package.json +++ b/npm/angular/package.json @@ -9,7 +9,7 @@ "postbuild": "node ../../scripts/sync-exported-npm-with-cli.js", "check-ts": "tsc --noEmit", "dev": "rollup -c rollup.config.mjs -w", - "lint": "eslint --ext .js,.ts,.json, ." + "lint": "eslint ." }, "dependencies": {}, "devDependencies": { diff --git a/npm/angular/src/mount.ts b/npm/angular/src/mount.ts index 982c3200adee..b84b33a2706c 100644 --- a/npm/angular/src/mount.ts +++ b/npm/angular/src/mount.ts @@ -73,7 +73,7 @@ export interface MountConfig extends TestModuleMetadata { * }) */ // allow InputSignals to be type primitive and WritableSignal for type compliance - componentProperties?: Partial<{ [P in keyof T]: T[P] extends InputSignal ? InputSignal | WritableSignal | V : T[P]}> + componentProperties?: Partial<{ [P in keyof T]: T[P] extends InputSignal ? InputSignal | WritableSignal | V : T[P] }> } let activeFixture: ComponentFixture | null = null @@ -121,7 +121,7 @@ export type MountResponse = { * @see https://angular.io/api/core/testing/ComponentFixture#componentInstance */ component: T -}; +} // 'zone.js/testing' is not properly aliasing `it.skip` but it does provide `xit`/`xspecify` // Written up under https://github.com/angular/angular/issues/46297 but is not seeing movement @@ -449,7 +449,7 @@ function setupComponent ( acc[key] = new SimpleChange(null, value, true) return acc - }, {} as {[key: string]: SimpleChange}) + }, {} as { [key: string]: SimpleChange }) if (Object.keys(componentProperties).length > 0) { component.ngOnChanges(simpleChanges) diff --git a/npm/cypress-schematic/.eslintignore b/npm/cypress-schematic/.eslintignore deleted file mode 100644 index 79afe972da7d..000000000000 --- a/npm/cypress-schematic/.eslintignore +++ /dev/null @@ -1,5 +0,0 @@ -**/dist -**/*.d.ts -**/package-lock.json -**/tsconfig.json -**/cypress/fixtures \ No newline at end of file diff --git a/npm/cypress-schematic/.eslintrc b/npm/cypress-schematic/.eslintrc deleted file mode 100644 index 0e5150fbeb8f..000000000000 --- a/npm/cypress-schematic/.eslintrc +++ /dev/null @@ -1,16 +0,0 @@ -{ - "plugins": [ - "cypress", - "@cypress/dev" - ], - "extends": [ - "plugin:@cypress/dev/general" - ], - "parser": "@typescript-eslint/parser", - "env": { - "cypress/globals": true - }, - "rules": { - "no-console": "off" - } -} \ No newline at end of file diff --git a/npm/cypress-schematic/eslint-tsconfig.json b/npm/cypress-schematic/eslint-tsconfig.json new file mode 100644 index 000000000000..8a96a8471f69 --- /dev/null +++ b/npm/cypress-schematic/eslint-tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "include": [ + "src/**/*" + ], + "exclude": ["!src/**/files-core/**/*", "!src/**/files-ct/**/*", "!src/**/*.spec.ts"] +} \ No newline at end of file diff --git a/npm/cypress-schematic/eslint.config.ts b/npm/cypress-schematic/eslint.config.ts new file mode 100644 index 000000000000..4f0232b412a5 --- /dev/null +++ b/npm/cypress-schematic/eslint.config.ts @@ -0,0 +1,23 @@ +import baseConfig from '../../eslint.config' +import globals from 'globals' +import path from 'path' + +export default [ + ...baseConfig, + { + ignores: ['src/**/*.{js,js.map,d.ts}', 'src/schematics/cypress/files/cypress/plugins/*.js', '**/*.spec.ts'], + }, + { + languageOptions: { + parserOptions: { + projectService: { + allowDefaultProject: ['eslint.config.ts', 'projects/sandbox/src/fake-component.component.ts'], + }, + project: './tsconfig.json', + }, + globals: { + ...globals.node, + }, + }, + }, +] diff --git a/npm/cypress-schematic/package.json b/npm/cypress-schematic/package.json index 2af4628482e2..5dd6750b1a35 100644 --- a/npm/cypress-schematic/package.json +++ b/npm/cypress-schematic/package.json @@ -6,7 +6,7 @@ "scripts": { "build": "tsc -p tsconfig.json", "build:watch": "tsc -p tsconfig.json --watch", - "lint": "eslint --ext .ts,.json, .", + "lint": "eslint .", "test": "vitest run --no-file-parallelism" }, "dependencies": { diff --git a/npm/cypress-schematic/src/builders/cypress/index.ts b/npm/cypress-schematic/src/builders/cypress/index.ts index c3283d200d0d..61ad88246ab4 100644 --- a/npm/cypress-schematic/src/builders/cypress/index.ts +++ b/npm/cypress-schematic/src/builders/cypress/index.ts @@ -14,7 +14,7 @@ import { catchError, concatMap, first, map, switchMap, tap } from 'rxjs/operator import { CypressBuilderOptions } from './cypressBuilderOptions' type CypressOptions = Partial & -Partial; +Partial type CypressStartDevServerProps = { devServerTarget: string @@ -114,6 +114,7 @@ export function startDevServer ({ // for instance @nguniversal/builders:ssr-dev-server. // see https://github.com/nrwl/nx/blob/f930117ed6ab13dccc40725c7e9551be081cc83d/packages/cypress/src/executors/cypress/cypress.impl.ts if (builderName !== '@nguniversal/builders:ssr-dev-server') { + // eslint-disable-next-line no-console console.info(`Passing watch mode to DevServer - watch mode is ${watch}`) overrides = { watch, diff --git a/npm/cypress-schematic/src/schematics/ng-generate/component/index.ts b/npm/cypress-schematic/src/schematics/ng-generate/component/index.ts index 5f926c54a65e..9829931c2455 100644 --- a/npm/cypress-schematic/src/schematics/ng-generate/component/index.ts +++ b/npm/cypress-schematic/src/schematics/ng-generate/component/index.ts @@ -1,6 +1,6 @@ import { chain, externalSchematic, noop, Rule, SchematicContext, Tree } from '@angular-devkit/schematics' import cypressTest from '../cypress-test' -import path = require('path'); +import path = require('path') export default function (options: any): Rule { return (_: Tree, _context: SchematicContext) => { diff --git a/npm/cypress-schematic/src/schematics/ng-generate/cypress-test/index.ts b/npm/cypress-schematic/src/schematics/ng-generate/cypress-test/index.ts index 9a1b22617553..6200e9ef7ea7 100644 --- a/npm/cypress-schematic/src/schematics/ng-generate/cypress-test/index.ts +++ b/npm/cypress-schematic/src/schematics/ng-generate/cypress-test/index.ts @@ -57,6 +57,7 @@ export default function (options: Schema): Rule { options.path = testType === 'component' ? `${project.sourceRoot}/${project.prefix}` : `${project.root}/cypress/e2e` } + // eslint-disable-next-line no-console console.log(`Creating new ${testType} spec named: ${options.name}`) const templatePath = testType === 'component' ? '../files/ct/__path__' : '../files/e2e/__path__' diff --git a/npm/cypress-schematic/src/schematics/utils/index.ts b/npm/cypress-schematic/src/schematics/utils/index.ts index ef78888d6e33..206d335f8e43 100644 --- a/npm/cypress-schematic/src/schematics/utils/index.ts +++ b/npm/cypress-schematic/src/schematics/utils/index.ts @@ -52,7 +52,7 @@ export function getLatestNodeVersion (packageName: string): Promise } } -const ctSpecContent = ({ componentName, componentFilename }: {componentName: string, componentFilename: string}): string => { +const ctSpecContent = ({ componentName, componentFilename }: { componentName: string, componentFilename: string }): string => { return `import { ${componentName} } from './${componentFilename}.component'\n describe('${componentName}', () => { it('should mount', () => { @@ -62,19 +62,20 @@ const ctSpecContent = ({ componentName, componentFilename }: {componentName: str ` } -function generateCTSpec ({ tree, appPath, component }: { tree: Tree, appPath: string, component: any}): Rule | void { +function generateCTSpec ({ tree, appPath, component }: { tree: Tree, appPath: string, component: any }): Rule | void { const buffer = tree.read(`${appPath}/${component['name']}`) const componentString = buffer?.toString() const componentMatch = componentString?.match(/(?<=class )\S+/g) const componentFilename = component['name'].split('.')[0] const componentName = componentMatch ? componentMatch[0] : componentFilename + // eslint-disable-next-line no-console console.log(`Creating new component spec for: ${componentName}\n`) return tree.create(`${appPath}/${componentFilename}.component.cy.ts`, ctSpecContent({ componentName, componentFilename })) } -export function getDirectoriesAndCreateSpecs ({ appPath, tree }: { appPath: string, tree: Tree}) { +export function getDirectoriesAndCreateSpecs ({ appPath, tree }: { appPath: string, tree: Tree }) { let components = [] let directories = [] @@ -99,7 +100,7 @@ export function getDirectoriesAndCreateSpecs ({ appPath, tree }: { appPath: stri } } -export function createTemplate ({ templatePath, options }: {templatePath: string, options: Schema}): any { +export function createTemplate ({ templatePath, options }: { templatePath: string, options: Schema }): any { return apply(url(templatePath), [ applyTemplates({ classify: strings.classify, diff --git a/npm/cypress-schematic/src/schematics/utils/jsonFile.ts b/npm/cypress-schematic/src/schematics/utils/jsonFile.ts index 3e0f812b20a3..9ea0145606e0 100644 --- a/npm/cypress-schematic/src/schematics/utils/jsonFile.ts +++ b/npm/cypress-schematic/src/schematics/utils/jsonFile.ts @@ -19,9 +19,9 @@ import { printParseErrorCode, } from 'jsonc-parser' -export type InsertionIndex = (properties: string[]) => number; +export type InsertionIndex = (properties: string[]) => number -export type JSONPath = (string | number)[]; +export type JSONPath = (string | number)[] /** @internal */ export class JSONFile { diff --git a/npm/cypress-schematic/tsconfig.json b/npm/cypress-schematic/tsconfig.json index 798d992aa8ec..23e4f1d70211 100644 --- a/npm/cypress-schematic/tsconfig.json +++ b/npm/cypress-schematic/tsconfig.json @@ -22,10 +22,10 @@ "target": "es6", "types": [ "node" - ] + ], }, "include": [ "src/**/*" ], - "exclude": ["src/**/files-core/**/*", "src/**/files-ct/**/*", "src/**/*.spec.ts"] + "exclude": ["src/**/*.spec.ts"] } diff --git a/npm/eslint-plugin-dev/.eslintignore b/npm/eslint-plugin-dev/.eslintignore deleted file mode 100644 index 6fe4231de92b..000000000000 --- a/npm/eslint-plugin-dev/.eslintignore +++ /dev/null @@ -1,3 +0,0 @@ -!.* -**/package-lock.json -test/fixtures diff --git a/npm/eslint-plugin-dev/.eslintrc.json b/npm/eslint-plugin-dev/.eslintrc.json deleted file mode 100644 index b7e94b45ffe6..000000000000 --- a/npm/eslint-plugin-dev/.eslintrc.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "plugins": [ - "@cypress/dev", - "promise" - ], - "extends": [ - "plugin:promise/recommended", - "plugin:@cypress/dev/general" - ] -} diff --git a/npm/eslint-plugin-dev/.npmignore b/npm/eslint-plugin-dev/.npmignore deleted file mode 100644 index 2e5519c0b8ec..000000000000 --- a/npm/eslint-plugin-dev/.npmignore +++ /dev/null @@ -1,2 +0,0 @@ -/* -!lib/ diff --git a/npm/eslint-plugin-dev/CHANGELOG.md b/npm/eslint-plugin-dev/CHANGELOG.md deleted file mode 100644 index 2b0105718a0f..000000000000 --- a/npm/eslint-plugin-dev/CHANGELOG.md +++ /dev/null @@ -1,74 +0,0 @@ -# [@cypress/eslint-plugin-dev-v6.0.0](https://github.com/cypress-io/cypress/compare/@cypress/eslint-plugin-dev-v5.3.3...@cypress/eslint-plugin-dev-v6.0.0) (2024-05-06) - - -### breaking - -* the supported eslint version is 8 for @cypress/eslint-plugin-dev. ([3b799a1](https://github.com/cypress-io/cypress/commit/3b799a158d7af419637d524e811561cd25143c3f)) - - -### BREAKING CHANGES - -* The supported eslint version is 8. @see f14a11aecfbc1e3854daae02b69fb40b4ec801b7 for breaking changes to the plugin. - -# [@cypress/eslint-plugin-dev-v5.3.3](https://github.com/cypress-io/cypress/compare/@cypress/eslint-plugin-dev-v5.3.2...@cypress/eslint-plugin-dev-v5.3.3) (2024-01-12) - - -### Bug Fixes - -* allow for versions greater than 4 for eslint-plugin-mocha to prevent force installing dependencies when eslint-plugin-mocha is bumbed in comsumer packages ([#27944](https://github.com/cypress-io/cypress/issues/27944)) ([bf05978](https://github.com/cypress-io/cypress/commit/bf0597847e71f34303364929f9c34cdd6c0e7ad8)) - -# [@cypress/eslint-plugin-dev-v5.3.2](https://github.com/cypress-io/cypress/compare/@cypress/eslint-plugin-dev-v5.3.1...@cypress/eslint-plugin-dev-v5.3.2) (2022-08-15) - - -### Bug Fixes - -* clear session state when changing specs in open mode ([#23146](https://github.com/cypress-io/cypress/issues/23146)) ([f1122fc](https://github.com/cypress-io/cypress/commit/f1122fcf62c14abddc0ae96116572402c1be2372)) - -# [@cypress/eslint-plugin-dev-v5.3.1](https://github.com/cypress-io/cypress/compare/@cypress/eslint-plugin-dev-v5.3.0...@cypress/eslint-plugin-dev-v5.3.1) (2022-08-11) - - -### Bug Fixes - -* retry on EMFILE always, lint sync FS calls ([#22175](https://github.com/cypress-io/cypress/issues/22175)) ([d01932b](https://github.com/cypress-io/cypress/commit/d01932bf751a6edf758451d8d19a74fe07e799ea)) - -# [@cypress/eslint-plugin-dev-v5.3.1](https://github.com/cypress-io/cypress/compare/@cypress/eslint-plugin-dev-v5.3.0...@cypress/eslint-plugin-dev-v5.3.1) (2022-08-10) - - -### Bug Fixes - -* retry on EMFILE always, lint sync FS calls ([#22175](https://github.com/cypress-io/cypress/issues/22175)) ([d01932b](https://github.com/cypress-io/cypress/commit/d01932bf751a6edf758451d8d19a74fe07e799ea)) - -# [@cypress/eslint-plugin-dev-v5.3.1](https://github.com/cypress-io/cypress/compare/@cypress/eslint-plugin-dev-v5.3.0...@cypress/eslint-plugin-dev-v5.3.1) (2022-06-29) - - -### Bug Fixes - -* retry on EMFILE always, lint sync FS calls ([#22175](https://github.com/cypress-io/cypress/issues/22175)) ([d01932b](https://github.com/cypress-io/cypress/commit/d01932bf751a6edf758451d8d19a74fe07e799ea)) - -# [@cypress/eslint-plugin-dev-v5.3.0](https://github.com/cypress-io/cypress/compare/@cypress/eslint-plugin-dev-v5.2.0...@cypress/eslint-plugin-dev-v5.3.0) (2022-06-01) - - -### Features - -* Turn "no-useless-constructor" off and enable "ignoreRestSiblings" ([#17875](https://github.com/cypress-io/cypress/issues/17875)) ([94541d4](https://github.com/cypress-io/cypress/commit/94541d4f18591e8fa4b8702c39e92b0a7238aa5d)) - -# [@cypress/eslint-plugin-dev-v5.2.0](https://github.com/cypress-io/cypress/compare/@cypress/eslint-plugin-dev-v5.1.0...@cypress/eslint-plugin-dev-v5.2.0) (2021-12-16) - - -### Features - -* use hoisted yarn install in binary build ([#17285](https://github.com/cypress-io/cypress/issues/17285)) ([e4f5b10](https://github.com/cypress-io/cypress/commit/e4f5b106d49d6ac0857c5fdac886f83b99558c88)) - -# [@cypress/eslint-plugin-dev-v5.1.0](https://github.com/cypress-io/cypress/compare/@cypress/eslint-plugin-dev-v5.0.2...@cypress/eslint-plugin-dev-v5.1.0) (2021-02-16) - - -### Features - -* component testing ([#14479](https://github.com/cypress-io/cypress/issues/14479)) ([af26fbe](https://github.com/cypress-io/cypress/commit/af26fbebe6bc609132013a0493a116cc78bb1bd4)) - -# [@cypress/eslint-plugin-dev-v5.0.2](https://github.com/cypress-io/cypress/compare/@cypress/eslint-plugin-dev-v5.0.1...@cypress/eslint-plugin-dev-v5.0.2) (2020-10-29) - - -### Bug Fixes - -* update bugs link in package.json ([#9015](https://github.com/cypress-io/cypress/issues/9015)) ([34186cb](https://github.com/cypress-io/cypress/commit/34186cb8b76c230a2506cabb0358d44c3205e0c4)) diff --git a/npm/eslint-plugin-dev/LICENSE.md b/npm/eslint-plugin-dev/LICENSE.md deleted file mode 100644 index f8b59f26ae10..000000000000 --- a/npm/eslint-plugin-dev/LICENSE.md +++ /dev/null @@ -1,24 +0,0 @@ -## MIT License - -Copyright (c) 2017 Cypress.io https://cypress.io - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/npm/eslint-plugin-dev/README.md b/npm/eslint-plugin-dev/README.md deleted file mode 100644 index 4656cbff22b6..000000000000 --- a/npm/eslint-plugin-dev/README.md +++ /dev/null @@ -1,212 +0,0 @@ - -
- -

[Internal] Cypress Developer ESLint Plugin

- - - -

Common ESLint rules shared by Cypress packages.

- -
- -> ⚠️ This package for _internal development_ of Cypress. Here's the [**Official Cypress ESLint Plugin**](https://github.com/cypress-io/eslint-plugin-cypress) meant for users of Cypress. - - -## Installation - -``` -npm install --save-dev @cypress/eslint-plugin-dev -``` - -## Usage - -> ⚠️ Currently does **not** support ESLint version 9 - -For Eslint 8, use version 6.x.x - -For Eslint 7 and below, use version 5.x.x - -1) install the following `devDependencies`: -```sh -@cypress/eslint-plugin-dev -eslint-plugin-json-format -@typescript-eslint/parser -@typescript-eslint/eslint-plugin -eslint-plugin-mocha -eslint-plugin-import - -# if you have react/jsx files -eslint-plugin-react -@babel/eslint-parser -``` - -2) add the following to your root level `.eslintrc.json`: -```json -{ - "plugins": [ - "@cypress/dev" - ], - "extends": [ - "plugin:@cypress/dev/general" - ] -} -``` - -> Note: also add `"plugin:@cypress/dev/react"`, if you are using `React` - -> Note: if you have a `test/` directory, you should create a `.eslintrc.json` file inside of it, and add: -```json -{ - "extends": [ - "plugin:@cypress/dev/tests" - ] -} -``` - -3) add the following to your `.eslintignore`: -```sh -# don't ignore hidden files, useful for formatting json config files -!.* -``` - -4) (optional) Install and configure your text editor's ESLint Plugin Extension to lint and auto-fix files using ESLint, [detailed below](#editors) - -5) (optional) Install [`husky`](https://github.com/typicode/husky) and enable the lint `pre-commit` hook: - -`package.json`: -```json - "husky": { - "hooks": { - "pre-commit": "lint-pre-commit" - } - }, -``` -> Note: the `lint-pre-commit` hook will automatically lint your staged files, and only `--fix` and `git add` them if there are no unstaged changes existing in that file (this protects partially staged files from being added in the hook). -To auto-fix all staged & unstaged files, run `./node_modules/.bin/lint-changed --fix` - -## Presets - -### general - -_Should usually be used at the root of the package._ -- The majority of the rules. -- auto-fixes `json` files and sorts your `package.json` via [`eslint-plugin-json-format`](https://github.com/bkucera/eslint-plugin-json-format) - - -**requires you to install the following `devDependencies`**: -```sh -eslint-plugin-import -eslint-plugin-json-format -@typescript-eslint/parser -@typescript-eslint/eslint-plugin -``` - -### tests - -Test-specific configuration and rules. Should be used within the `test/` directory. - -**requires you to install the following `devDependencies`**: -```sh -eslint-plugin-mocha -``` - -### react - -React and JSX-specific configuration and rules. - -**requires you to install the following `devDependencies`**: -```sh -@babel/eslint-parser -eslint-plugin-react -``` - -## Configuration Examples - -Change some linting rules: -```js -// .eslintrc.json -{ - "extends": [ - "plugin:@cypress/dev/general" - ], - "rules": { - "comma-dangle": "off", - "no-debugger": "warn" - } -} -``` - -Stop your `package.json` from being formatted: -```json -{ - "settings": { - "json/sort-package-json": false - } -} -``` - -### Custom Rules: -name | description | options | example --|-|-|- -`@cypress/dev/arrow-body-multiline-braces` | Enforces braces in arrow functions ONLY IN multiline function definitions | [`[always|never] always set this to 'always'`] | `'@cypress/dev/arrow-body-multiline-braces': ['error', 'always']` -`@cypress/dev/skip-comment` | Enforces a comment (`// NOTE:`) explaining a `.skip` added to `it`, `describe`, or `context` test blocks | { commentTokens: `[array] tokens that indicate .skip explanation (default: ['NOTE:', 'TODO:', 'FIXME:']`)} | `'@cypress/dev/skip-comment': ['error', { commentTokens: ['TODO:'] }]` -`@cypress/dev/no-return-before` | Disallows `return` statements before certain configurable tokens | { tokens: `[array] tokens that cannot be preceded by 'return' (default: ['it', 'describe', 'context', 'expect']`)} | `'@cypress/dev/no-return-before': ['error', { tokens: ['myfn'] }]` - -## Editors - -### VSCode - -Use plugin [ESLint by Dirk Baeumer](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) to lint and auto fix JS files using ESLint. -After installing, add the following to your User or Workspace (`.vscode/settings.json`) settings: -```json -{ - "eslint.validate": [ - { - "language": "javascript", - "autoFix": true - }, - { - "language": "javascriptreact", - "autoFix": true - }, - { - "language": "typescript", - "autoFix": true - }, - { - "language": "typescriptreact", - "autoFix": true - }, - { - "language": "json", - "autoFix": true - } - ], -} -``` - -### Atom - -Install package [linter-eslint](https://atom.io/packages/linter-eslint) -(and its dependencies) to enable linting. Go into the settings for this package -and enable "Fix on save" option to auto-fix white space issues and other things. - -### Sublime Text - -Install [ESLint-Formatter](https://packagecontrol.io/packages/ESLint-Formatter), -then set the following settings: - -```json -{ - "format_on_save": true, - "debug": true -} -``` - -## License - -This project is licensed under the terms of the [MIT license](/LICENSE.md). - -## Changelog - -[Changelog](./CHANGELOG.md) diff --git a/npm/eslint-plugin-dev/lib/custom-rules/arrow-body-multiline-braces.js b/npm/eslint-plugin-dev/lib/custom-rules/arrow-body-multiline-braces.js deleted file mode 100644 index c196e3a9bd0d..000000000000 --- a/npm/eslint-plugin-dev/lib/custom-rules/arrow-body-multiline-braces.js +++ /dev/null @@ -1,17 +0,0 @@ -const ruleComposer = require('eslint-rule-composer') -const eslint = require('eslint') -const arrowBodyStyle = new eslint.Linter().getRules().get('arrow-body-style') - -module.exports = ruleComposer.filterReports( - arrowBodyStyle, - (problem, metadata) => { - const problemIndex = metadata.sourceCode.getIndexFromLoc(problem.loc.start) - const reportedToken = metadata.sourceCode.getTokenByRangeStart(problemIndex, { includeComments: true }) - - if (problem.node.loc.start.line === problem.node.loc.end.line) { - return - } - - return !(reportedToken && reportedToken.type === 'Line' && /^-{2,}$/u.test(reportedToken.value)) - }, -) diff --git a/npm/eslint-plugin-dev/lib/custom-rules/index.js b/npm/eslint-plugin-dev/lib/custom-rules/index.js deleted file mode 100644 index 8dbc761bc096..000000000000 --- a/npm/eslint-plugin-dev/lib/custom-rules/index.js +++ /dev/null @@ -1,8 +0,0 @@ -const fs = require('fs') -const path = require('path') - -module.exports = - // eslint-disable-next-line no-restricted-syntax - Object.assign({}, ...fs.readdirSync(__dirname) - .filter((filename) => filename.endsWith('.js') && filename !== 'index.js') - .map((filename) => ({ [filename.replace(/\.js$/u, '')]: require(path.resolve(__dirname, filename)) }))) diff --git a/npm/eslint-plugin-dev/lib/custom-rules/no-only.js b/npm/eslint-plugin-dev/lib/custom-rules/no-only.js deleted file mode 100644 index f4fba53f4280..000000000000 --- a/npm/eslint-plugin-dev/lib/custom-rules/no-only.js +++ /dev/null @@ -1,53 +0,0 @@ -// @see https://github.com/eslint/eslint/blob/v8.57.0/lib/shared/ast-utils.js#L12 -// This value is not exported anywhere, but hasn't changed in almost a decade. -// we can directly reference the pattern here -const lineBreakPattern = /\r\n|[\r\n\u2028\u2029]/u - -module.exports = { - meta: { - type: 'problem', - docs: { - description: 'stop .only\'s in spec files', - category: 'Spec Issues', - }, - messages: { - noOnly: 'Found only: `{{callee}}`.', - }, - - // uncomment to enable autoFix - // fixable: 'code', - }, - - create (context) { - const sourceCode = context.getSourceCode() - - function getPropertyText (node) { - const lines = sourceCode.getText(node).split(lineBreakPattern) - - return lines[0] - } - - return { - 'CallExpression:exit' (node) { - const callee = node.callee - - if (node.type === 'CallExpression' && callee.type === 'MemberExpression' && callee.property.name === 'only') { - if (['it', 'describe', 'context'].includes(callee.object.name)) { - context.report({ - node: callee.property, - loc: callee.property.loc.start, - messageId: 'noOnly', - data: { - callee: getPropertyText(callee.parent), - }, - // uncomment to enable autoFix - // fix(fixer) { - // return fixer.replaceTextRange([callee.property.start - 1, callee.property.end], '') - // } - }) - } - } - }, - } - }, -} diff --git a/npm/eslint-plugin-dev/lib/custom-rules/no-return-before.js b/npm/eslint-plugin-dev/lib/custom-rules/no-return-before.js deleted file mode 100644 index 30b68f329311..000000000000 --- a/npm/eslint-plugin-dev/lib/custom-rules/no-return-before.js +++ /dev/null @@ -1,73 +0,0 @@ -const defaultTokens = ['it', 'describe', 'context', 'expect'] -// const debug = require('debug')('@cypress/dev') - -module.exports = { - meta: { - type: 'problem', - docs: { - description: 'Enforce no return before certain token names', - category: 'Misc', - }, - messages: { - errorMessage: `\ -Found a 'return' after '{{token}}'\ -`, - }, - - schema: [ - { - type: 'object', - properties: { - tokens: { - type: 'array', - default: defaultTokens, - }, - }, - additionalProperties: false, - }, - ], - // uncomment to enable autoFix - fixable: 'code', - - }, - - create (context) { - let tokens = defaultTokens - - if (context.options.length) { - tokens = typeof context.options[0].tokens === 'object' ? context.options[0].tokens : tokens - } - - return { - 'CallExpression:exit' (node) { - const callee = node.callee - - if ( - (callee.type === 'Identifier') - && tokens.includes(callee.name) - ) { - const t = context.getSourceCode().getTokenBefore(node) - - // debug(t) - - if (!(t && t.type === 'Keyword' && t.value === 'return')) return - - const returnNode = t - - context.report({ - node: callee, - loc: callee.loc.start, - messageId: 'errorMessage', - data: { - token: callee.name, - }, - // uncomment to enable autoFix - fix (fixer) { - return fixer.replaceTextRange([returnNode.range[0], returnNode.range[1] + 1], '') - }, - }) - } - }, - } - }, -} diff --git a/npm/eslint-plugin-dev/lib/custom-rules/skip-comment.js b/npm/eslint-plugin-dev/lib/custom-rules/skip-comment.js deleted file mode 100644 index cf3aaf2ff69f..000000000000 --- a/npm/eslint-plugin-dev/lib/custom-rules/skip-comment.js +++ /dev/null @@ -1,84 +0,0 @@ -const defaultCommentTokens = ['NOTE:', 'TODO:', 'FIXME:'] - -module.exports = { - meta: { - type: 'problem', - docs: { - description: 'stop .skip\'s in spec files', - category: 'Spec Issues', - }, - messages: { - noOnly: `\ -Found a {{test-scope}}.skip(⋯) without an explanation. -Add a comment above the '{{test-scope}}' starting with one of: -{{commentTokens}} - -e.g. -// {{exampleCommentToken}} -{{test-scope}}.skip(⋯) - -`, - }, - - schema: [ - { - type: 'object', - properties: { - commentTokens: { - type: 'array', - default: defaultCommentTokens, - }, - }, - additionalProperties: false, - }, - ], - // uncomment to enable autoFix - // fixable: 'code', - - }, - - create (context) { - let commentTokens = defaultCommentTokens - - if (context.options.length) { - commentTokens = typeof context.options[0].commentTokens === 'object' ? context.options[0].commentTokens : commentTokens - } - - const sourceCode = context.getSourceCode() - - return { - 'CallExpression:exit' (node) { - const callee = node.callee - - const commentBefore = sourceCode.getCommentsBefore(node) - - const hasExplain = commentBefore && commentBefore.map( - (v) => commentTokens.concat(commentTokens.map((v) => `# ${v}`)).map((commentToken) => v.value.trim().startsWith(commentToken)).filter(Boolean)[0], - ).filter(Boolean)[0] - - if (hasExplain) { - return - } - - if (node.type === 'CallExpression' && callee.type === 'MemberExpression' && callee.property.name === 'skip') { - if (['it', 'describe', 'context'].includes(callee.object.name)) { - context.report({ - node: callee.property, - loc: callee.property.loc.start, - messageId: 'noOnly', - data: { - 'test-scope': callee.object.name, - commentTokens: commentTokens.join(' '), - exampleCommentToken: commentTokens[0], - }, - // uncomment to enable autoFix - // fix(fixer) { - // return fixer.replaceTextRange([callee.property.start - 1, callee.property.end], '') - // } - }) - } - } - }, - } - }, -} diff --git a/npm/eslint-plugin-dev/lib/index.js b/npm/eslint-plugin-dev/lib/index.js deleted file mode 100644 index eab453c761c6..000000000000 --- a/npm/eslint-plugin-dev/lib/index.js +++ /dev/null @@ -1,357 +0,0 @@ -const customRules = require('./custom-rules') -const baseRules = { - '@cypress/dev/arrow-body-multiline-braces': [ - 'error', - 'always', - ], - 'array-bracket-newline': [ - 'error', - 'consistent', - ], - 'array-bracket-spacing': [ - 'error', - 'never', - ], - 'arrow-parens': [ - 'error', - 'always', - ], - 'arrow-spacing': 'error', - 'block-spacing': 'error', - 'brace-style': [ - 'error', - '1tbs', - { - 'allowSingleLine': false, - }, - ], - 'function-paren-newline': [ - 'error', - 'consistent', - ], - 'comma-dangle': [ - 'error', - 'always-multiline', - ], - 'comma-spacing': 'error', - 'curly': [ - 'error', - 'multi-line', - 'consistent', - ], - 'constructor-super': 'error', - 'default-case': 'error', - 'eol-last': 'error', - 'eqeqeq': [ - 'error', - 'allow-null', - ], - 'indent': [ - 'error', - 2, - { - // TODO: fix this, we shouldn't need to ignore TemplateLiterals - 'ignoredNodes': ['TemplateLiteral'], - 'SwitchCase': 1, - 'MemberExpression': 0, - }, - ], - 'key-spacing': 'error', - 'keyword-spacing': 'error', - 'no-buffer-constructor': 'error', - 'no-case-declarations': 'error', - 'no-class-assign': 'error', - 'no-cond-assign': 'error', - 'no-console': 'error', - 'no-const-assign': 'error', - 'no-constant-condition': 'error', - 'no-control-regex': 'error', - 'no-debugger': 'error', - 'no-delete-var': 'error', - 'no-dupe-class-members': 'error', - 'no-dupe-keys': 'error', - 'no-dupe-args': 'error', - 'no-duplicate-case': 'error', - 'no-duplicate-imports': 'error', - 'no-else-return': [ - 'error', - { - 'allowElseIf': false, - }, - ], - 'no-empty': 'error', - 'no-empty-character-class': 'error', - 'no-empty-pattern': 'error', - 'no-ex-assign': 'error', - 'no-extra-boolean-cast': 'error', - 'no-extra-semi': 'error', - 'no-fallthrough': 'error', - 'no-func-assign': 'error', - 'no-inner-declarations': 'error', - 'no-invalid-regexp': 'error', - 'no-irregular-whitespace': 'error', - 'no-mixed-spaces-and-tabs': 'error', - 'no-multiple-empty-lines': [ - 'error', - { - 'max': 1, - 'maxEOF': 0, - 'maxBOF': 0, - }, - ], - 'no-multi-spaces': 'error', - 'no-negated-in-lhs': 'error', - 'no-new-symbol': 'error', - 'no-obj-calls': 'error', - 'no-octal': 'error', - 'no-redeclare': 'error', - 'no-regex-spaces': 'error', - 'no-self-assign': 'error', - 'no-spaced-func': 'error', - 'no-sparse-arrays': 'error', - 'no-this-before-super': 'error', - 'no-trailing-spaces': 'error', - 'no-undef': 'error', - 'no-unexpected-multiline': 'error', - 'no-unneeded-ternary': 'error', - 'no-unreachable': 'error', - 'no-unused-labels': 'error', - 'no-unused-vars': ['error', { args: 'none', ignoreRestSiblings: true }], - 'no-useless-concat': 'error', - 'no-useless-constructor': 'error', - 'no-var': 'error', - 'no-whitespace-before-property': 'error', - 'object-curly-spacing': [ - 'error', - 'always', - ], - 'object-shorthand': 'error', - 'one-var': [ - 'error', - 'never', - ], - 'padded-blocks': ['error', 'never'], - 'padding-line-between-statements': [ - 'error', - { - 'blankLine': 'always', - 'prev': '*', - 'next': 'return', - }, - { - 'blankLine': 'always', - 'prev': [ - 'const', - 'let', - 'var', - 'if', - 'while', - 'export', - 'cjs-export', - 'import', - 'cjs-import', - 'multiline-expression', - ], - 'next': '*', - }, - { - 'blankLine': 'any', - 'prev': [ - 'const', - 'let', - 'var', - 'import', - 'cjs-import', - ], - 'next': [ - 'const', - 'let', - 'var', - 'import', - 'cjs-import', - ], - }, - ], - 'prefer-rest-params': 'error', - 'prefer-spread': 'error', - 'prefer-template': 'error', - 'quotes': [ - 'error', - 'single', - { - 'allowTemplateLiterals': true, - }, - ], - 'semi': [ - 'error', - 'never', - ], - 'semi-spacing': 'error', - 'space-before-blocks': 'error', - 'space-before-function-paren': 'error', - 'space-in-parens': [ - 'error', - 'never', - ], - 'space-infix-ops': 'error', - 'space-unary-ops': 'error', - // TODO: change this back to 'error' - 'template-curly-spacing': 'off', - 'use-isnan': 'error', - 'valid-typeof': 'error', -} - -// '@cypress/dev/no-only': 'error', - -module.exports = { - configs: { - general: { - parserOptions: { - ecmaVersion: 2018, - sourceType: 'module', - }, - plugins: [ - 'json-format', - ], - settings: { - json: { - 'sort-package-json': 'pro', - }, - react: { - version: 'detect', - }, - }, - env: { - node: true, - es6: true, - }, - rules: { - ...baseRules, - }, - overrides: [ - { - files: [ - '*.jsx', - '*.tsx', - ], - rules: { - '@cypress/dev/arrow-body-multiline-braces': 'off', - }, - }, - { - files: [ - '*.ts', - '*.tsx', - '*.vue', - ], - parser: '@typescript-eslint/parser', - plugins: [ - '@typescript-eslint', - 'import', - ], - rules: { - 'no-undef': 'off', - 'no-unused-vars': 'off', - 'indent': 'off', - 'no-useless-constructor': 'off', - 'no-duplicate-imports': 'off', - 'import/no-duplicates': 'error', - '@typescript-eslint/no-unused-vars': [ - 'error', - { - 'args': 'none', - 'ignoreRestSiblings': true, - 'argsIgnorePattern': '^_', - }, - ], - '@typescript-eslint/type-annotation-spacing': 'error', - '@typescript-eslint/no-useless-constructor': [ - 'error', - ], - '@typescript-eslint/member-delimiter-style': [ - 'error', - { - 'multiline': { - 'delimiter': 'none', - }, - 'singleline': { - 'delimiter': 'comma', - }, - }, - ], - '@typescript-eslint/indent': [ - 'error', - 2, - { - 'ignoredNodes': ['TemplateLiteral', 'TSTypeParameterInstantiation'], - 'SwitchCase': 1, - 'MemberExpression': 0, - }, - ], - }, - }, - ], - }, - - tests: { - env: { - mocha: true, - }, - globals: { - expect: true, - }, - plugins: ['mocha'], - rules: { - 'mocha/handle-done-callback': 'error', - 'mocha/no-exclusive-tests': 'error', - 'mocha/no-global-tests': 'error', - '@cypress/dev/skip-comment': 'error', - }, - overrides: [{ - files: '*.spec.tsx', - parser: '@typescript-eslint/parser', - plugins: [ - '@typescript-eslint', - 'react', - ], - rules: { - 'no-unused-vars': 'off', // avoid interface imports to be warned against - }, - }], - }, - react: { - env: { - browser: true, - }, - parser: '@babel/eslint-parser', - parserOptions: { - ecmaVersion: 2018, - sourceType: 'module', - requireConfigFile: false, - ecmaFeatures: { - jsx: true, - legacyDecorators: true, - }, - }, - plugins: ['react'], - rules: { - 'react/jsx-curly-spacing': 'error', - 'react/jsx-equals-spacing': 'error', - 'react/jsx-no-duplicate-props': 'error', - 'react/jsx-no-undef': 'error', - 'react/jsx-pascal-case': 'error', - 'react/jsx-uses-react': 'error', - 'react/jsx-uses-vars': 'error', - 'react/jsx-wrap-multilines': 'error', - 'react/no-unknown-property': 'error', - 'react/prefer-es6-class': 'error', - 'react/react-in-jsx-scope': 'error', - 'react/require-render-return': 'error', - 'react/jsx-filename-extension': 'error', - }, - }, - }, - rules: { - ...customRules, - }, -} diff --git a/npm/eslint-plugin-dev/lib/scripts/lint-changed.js b/npm/eslint-plugin-dev/lib/scripts/lint-changed.js deleted file mode 100755 index 990468b804fe..000000000000 --- a/npm/eslint-plugin-dev/lib/scripts/lint-changed.js +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env node - -const sh = require('shelljs') -const utils = require('./utils') -const _ = require('lodash') -const chalk = require('chalk') - -const start = () => { - const fix = process.argv.slice(2).includes('--fix') - - return utils.lintFilesByName({ - // list only modified files - getFilenames: () => { - return _.union( - sh.exec(`git diff --name-only --diff-filter=M`).split('\n'), - sh.exec(`git diff --name-only --diff-filter=MA --staged`).split('\n'), - ) - }, - fix, - }) - .then(({ failed, filenames }) => { - if (failed) { - process.exit(failed) - } - - // eslint-disable-next-line no-console - console.log(chalk.bold(`${chalk.green(filenames.length)} files linted successfully`)) - - return - }) -} - -if (!module.parent) { - start() -} - -module.exports = { start } diff --git a/npm/eslint-plugin-dev/lib/scripts/lint-pre-commit.js b/npm/eslint-plugin-dev/lib/scripts/lint-pre-commit.js deleted file mode 100755 index 324ae1cbdf0f..000000000000 --- a/npm/eslint-plugin-dev/lib/scripts/lint-pre-commit.js +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env node - -const _ = require('lodash') -const utils = require('./utils') -const sh = require('shelljs') -const chalk = require('chalk') - -const start = () => { - const filesStaged = sh.exec(`git diff --name-only --diff-filter=MA --staged`).split('\n').filter(Boolean) - const filesUnstaged = sh.exec(`git diff --name-only --diff-filter=M`).split('\n').filter(Boolean) - const filesPartiallyStaged = _.intersection(filesStaged, filesUnstaged) - const filesFullyStaged = _.difference(filesStaged, filesPartiallyStaged) - - let fail = false - let lintedFilesCount = 0 - - return utils.lintFilesByName({ - getFilenames: () => filesFullyStaged, - fix: true, - }) - .then(({ failed, filenames }) => { - sh.exec(`git add ${sh.ShellString(filenames.join(' '))}`) - - if (failed) { - fail = true - } - - lintedFilesCount += filenames.length - - return - }) - .then(() => { - return utils.lintFilesByText({ - getFilenames: () => filesPartiallyStaged, - getFileText: (f) => sh.exec(`git show :${sh.ShellString(f)}`), - }) - }) - .then(({ failCount, filenames }) => { - if (failCount) { - fail = true - } - - lintedFilesCount += filenames.length - - return - }) - .then(() => { - if (fail) { - process.exit(1) - } - - // eslint-disable-next-line no-console - console.log(chalk.bold(`${chalk.green(lintedFilesCount)} files linted successfully`)) - - return - }) -} - -if (!module.parent) { - start() -} - -module.exports = { start } diff --git a/npm/eslint-plugin-dev/lib/scripts/lint-pre-push.js b/npm/eslint-plugin-dev/lib/scripts/lint-pre-push.js deleted file mode 100755 index 42c46a6a189e..000000000000 --- a/npm/eslint-plugin-dev/lib/scripts/lint-pre-push.js +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env node - -const sh = require('shelljs') -const utils = require('./utils') -const chalk = require('chalk') -const debug = require('debug')('lint-pre-push') - -const start = () => { - const getFilenames = () => { - const GIT_PARAMS = (process.env.HUSKY_GIT_PARAMS || 'origin').split(' ') - const gitRemote = GIT_PARAMS[0] - const gitBranch = sh.exec(`git branch`).grep(/\*/).split(/\s/)[1] - const gitRemoteBranch = `${gitRemote}/${gitBranch}` - - debug({ gitRemote }) - debug({ gitBranch }) - - return sh - .exec(`git diff HEAD ${sh.ShellString(gitRemoteBranch)} --name-only`) - .split('\n') - } - - return utils.lintFilesByText({ - getFilenames, - getFileText: (f) => sh.exec(`git show :${sh.ShellString(f)}`), - }) - .then(({ failCount, filenames }) => { - if (failCount) { - process.exit(failCount) - } - - // eslint-disable-next-line no-console - console.log(chalk.bold(`${chalk.green(filenames.length)} files linted successfully`)) - - return - }) -} - -if (!module.parent) { - start() -} - -module.exports = { start } diff --git a/npm/eslint-plugin-dev/lib/scripts/lint-staged.js b/npm/eslint-plugin-dev/lib/scripts/lint-staged.js deleted file mode 100755 index 9a5d836ed4ac..000000000000 --- a/npm/eslint-plugin-dev/lib/scripts/lint-staged.js +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env node - -/* eslint-disable quotes */ -const sh = require('shelljs') -const utils = require('./utils') -const chalk = require('chalk') - -const start = () => { - return utils.lintFilesByText({ - // list only modified and added files - getFilenames: () => sh.exec(`git diff --name-only --diff-filter=MA --staged`).split('\n'), - getFileText: (f) => sh.exec(`git show :${sh.ShellString(f)}`), - }) - .then(({ failCount, filenames }) => { - if (failCount) { - process.exit(failCount) - } - - // eslint-disable-next-line no-console - console.log(chalk.bold(`${chalk.green(filenames.length)} files linted successfully`)) - - return - }) -} - -if (!module.parent) { - start() -} - -module.exports = { start } diff --git a/npm/eslint-plugin-dev/lib/scripts/lint.spec.js b/npm/eslint-plugin-dev/lib/scripts/lint.spec.js deleted file mode 100644 index 4e83961072cd..000000000000 --- a/npm/eslint-plugin-dev/lib/scripts/lint.spec.js +++ /dev/null @@ -1,163 +0,0 @@ -const sh = require('shelljs') -const sinon = require('sinon') -const lintStaged = require('./lint-staged') -const lintChanged = require('./lint-changed') -const lintPrePush = require('./lint-pre-push') -const lintPreCommit = require('./lint-pre-commit') -const chai = require('chai') -const debug = require('debug')('lint.spec') - -const { expect } = chai - -chai.use(require('sinon-chai')) - -const _env = process.env -const _argv = process.argv - -const getStagedFiles = () => sh.ShellString('foo.js\nbar.js') -const getUnstagedFiles = () => sh.ShellString('bar.js\nbaz.js') -const getCommittedFiles = () => sh.ShellString('baz.js\nquux.js') - -const eslintSuccess = (...args) => { - debug('eslintSuccess:', args) - const ret = sh.ShellString(`GOOD JS`) - - ret.exec = sinon.stub().yields(null, 'success') - - return ret -} - -const eslintFailure = (...args) => { - debug('eslintFailure:', args) - const ret = sh.ShellString(`BAD JS`) - - ret.exec = sinon.stub().yields('foo error') - - return ret -} - -beforeEach(() => { - sinon.stub(sh, 'exec') - sinon.stub(sh, 'cat') - sinon.stub(process, 'exit') - - sh.exec - .withArgs(`git branch`).returns(sh.ShellString('* mybranch')) - - .withArgs(`git diff --name-only --diff-filter=MA --staged`) - .returns(getStagedFiles()) - - .withArgs(`git diff --name-only --diff-filter=M`) - .returns(getUnstagedFiles()) - - .withArgs(`git diff HEAD origin/mybranch --name-only`) - .returns(getCommittedFiles()) - - sh.exec.callsFake(eslintSuccess) -}) - -describe('lint-staged', () => { - it('lint success', async () => { - await lintStaged.start() - expect(process.exit).not.calledOnce - }) - - it('lint failures', async () => { - sh.exec.callsFake(eslintFailure) - - await lintStaged.start() - expect(process.exit).calledOnce - }) -}) - -describe('lint-changed', () => { - const filenames = 'bar.js baz.js foo.js' - - beforeEach(() => { - sh.exec - .withArgs(`./node_modules/.bin/eslint --color=true '' ${filenames}`) - .yields(null, 'success') - }) - - it('lint success', async () => { - await lintChanged.start() - expect(process.exit).not.calledOnce - }) - - it('lint failures', async () => { - sh.exec - .withArgs(`./node_modules/.bin/eslint --color=true '' ${filenames}`) - .yields('foo error') - - await lintChanged.start() - expect(process.exit).calledOnce - }) - - it('lint with --fix', async () => { - process.argv = ['_', '_', '--fix'] - sh.exec - .withArgs(`./node_modules/.bin/eslint --color=true --fix '' ${filenames}`) - .yields(null, 'success') - - await lintChanged.start() - expect(process.exit).not.calledOnce - }) -}) - -describe('lint-pre-push', () => { - beforeEach(() => { - process.env.HUSKY_GIT_PARAMS = 'origin git@github.com:cypress-io/cypress.git' - }) - - it('lint success', async () => { - await lintPrePush.start() - expect(process.exit).not.calledOnce - }) - - it('lint failures', async () => { - sh.exec.callsFake(eslintFailure) - - await lintPrePush.start() - expect(process.exit).calledOnce - }) -}) - -describe('lint-pre-commit', () => { - beforeEach(() => { - sh.exec - .withArgs(`./node_modules/.bin/eslint --color=true --fix '' foo.js`) - .yields(null, 'success') - }) - - it('lint success', async () => { - await lintPreCommit.start() - expect(process.exit).not.calledOnce - - expect(sh.exec.withArgs('git add foo.js')).calledOnce - }) - - it('lint failures', async () => { - sh.exec.callsFake(eslintFailure) - - await lintPreCommit.start() - expect(process.exit).calledOnce - }) -}) - -afterEach(() => { - process.argv = _argv - process.env = _env - sinon.restore() -}) - -// sinon.addBehavior('withArgIncludes', (stub, str) => { - -// }) - -// function withArgsInclude() { -// this. -// .callsFake((...args) => { -// args[0].includes() - -// }) -// } diff --git a/npm/eslint-plugin-dev/lib/scripts/utils.js b/npm/eslint-plugin-dev/lib/scripts/utils.js deleted file mode 100644 index d718464f77c9..000000000000 --- a/npm/eslint-plugin-dev/lib/scripts/utils.js +++ /dev/null @@ -1,112 +0,0 @@ -const path = require('path') -const _ = require('lodash') -const EE = require('events') -const sh = require('shelljs') -// const chalk = require('chalk') -const Promise = require('bluebird') -const debug = require('debug')('lint/util') - -const filesRegex = /\.(js|jsx|ts|tsx|coffee|json|eslintrc)$/ - -Promise.config({ - warnings: true, - longStackTraces: true, -}) - -module.exports = { - lintFilesByText: (options) => { - sh.config.silent = true - EE.defaultMaxListeners = 100 - - const opts = _.defaults(options, { - getFilenames: null, - getFileText: null, - }) - - const filenames = opts.getFilenames().filter((v) => filesRegex.test(v)) - - debug(`linting: - ${filenames.join('\n\t')} - `) - - return Promise.map(filenames, (f) => { - debug('started linting', f) - - const fileText = opts.getFileText(f) - - debugTerse('file text:', fileText) - - if (!fileText.toString()) return - - const lintCommand = `./node_modules/.bin/eslint --stdin --stdin-filename ${sh.ShellString(f)} --color=true` - - return Promise.promisify(fileText.exec)( - lintCommand, - { silent: false, async: true }, - ) - .tapCatch(debugTerse) - .return(false) - .catchReturn(true) - .finally(() => { - debug('finished linting ', f) - }) - }, { concurrency: 0 }) - .then((results) => { - const failCount = _.filter(results).length - - debug({ failCount }) - - return { failCount, filenames } - }) - }, - lintFilesByName: (options) => { - sh.config.silent = true - - const opts = _.defaults(options, { - getFilenames: null, - fix: false, - }) - - const filenames = opts.getFilenames().filter((v) => filesRegex.test(v)) - - debug(`linting: - ${filenames.join('\n\t')} - `) - - const filenamesString = sh.ShellString(filenames.join(' ')) - - const lintCommand = opts.fix ? - `npx eslint --color=true --fix ${filenamesString}` - : `npx eslint --color=true ${filenamesString}` - - // always run command in the root of the monorepo! - return Promise.promisify(sh.exec)( - lintCommand, - { silent: false, async: true, cwd: path.resolve(__dirname, '../../../../') }, - ) - .tapCatch(debugTerse) - .return(false) - .catchReturn(true) - .then((failed) => { - return { - failed, - filenames, - } - }) - }, - -} - -const debugTerse = (...args) => { - args = args.map((arg) => { - let truncated = arg.toString().slice(0, 15) - - if (truncated !== arg.toString()) { - truncated = `${truncated}...` - } - - return truncated - }) - - debug(...args) -} diff --git a/npm/eslint-plugin-dev/package.json b/npm/eslint-plugin-dev/package.json deleted file mode 100644 index 717a1e221d92..000000000000 --- a/npm/eslint-plugin-dev/package.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "name": "@cypress/eslint-plugin-dev", - "version": "0.0.0-development", - "description": "Common ESLint rules shared by Cypress development-only packages", - "main": "./lib", - "scripts": { - "lint": "eslint --ext .js,json,.eslintrc .", - "lint-changed": "node ./lib/scripts/lint-changed", - "lint-fix": "npm run lint -- --fix", - "test": "mocha" - }, - "dependencies": { - "bluebird": "3.5.5", - "chalk": "^2.4.2", - "eslint-rule-composer": "^0.3.0", - "lodash": "^4.17.15", - "shelljs": "0.8.5" - }, - "devDependencies": { - "eslint": "^8.56.0", - "eslint-plugin-import": "^2.29.1", - "eslint-plugin-json-format": "^2.0.0", - "eslint-plugin-mocha": "^8.2.0", - "eslint-plugin-promise": "^4.2.1", - "sinon": "^7.3.2", - "sinon-chai": "^3.3.0" - }, - "peerDependencies": { - "@babel/eslint-parser": "^7.25.1", - "@typescript-eslint/eslint-plugin": ">= 7.0.0", - "@typescript-eslint/parser": ">= 7.0.0", - "eslint": "^= 8.0.0", - "eslint-plugin-import": ">= 2.0.0", - "eslint-plugin-json-format": ">= 2.0.0", - "eslint-plugin-mocha": " >= 8.0.0", - "eslint-plugin-react": ">= 7.22.0" - }, - "bin": { - "lint-changed": "./lib/scripts/lint-changed.js", - "lint-pre-commit": "./lib/scripts/lint-pre-commit.js" - }, - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/cypress-io/cypress.git" - }, - "homepage": "https://github.com/cypress-io/cypress/tree/develop/npm/eslint-plugin-dev#readme", - "bugs": { - "url": "https://github.com/cypress-io/cypress/issues/new?assignees=&labels=npm%3A%20%40cypress%2Feslint-plugin-dev&template=bug-report.md" - }, - "keywords": [ - "cypress", - "eslint", - "eslintplugin" - ], - "nx": {} -} diff --git a/npm/eslint-plugin-dev/test/.eslintrc b/npm/eslint-plugin-dev/test/.eslintrc deleted file mode 100644 index b5ed5206d083..000000000000 --- a/npm/eslint-plugin-dev/test/.eslintrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": [ - "plugin:@cypress/dev/tests" - ] -} diff --git a/npm/eslint-plugin-dev/test/arrow-body-multiline-braces.spec.js b/npm/eslint-plugin-dev/test/arrow-body-multiline-braces.spec.js deleted file mode 100644 index 6698ab68db40..000000000000 --- a/npm/eslint-plugin-dev/test/arrow-body-multiline-braces.spec.js +++ /dev/null @@ -1,55 +0,0 @@ -const path = require('path') -const eslint = require('eslint') -const plugin = require('../lib') -const _ = require('lodash') -const { expect } = require('chai') - -const pluginName = '__plugin__' -const ESLint = eslint.ESLint - -async function execute (file, options = {}) { - const defaultConfig = { - fix: true, - ignore: false, - useEslintrc: false, - baseConfig: { - parserOptions: { - ecmaVersion: 2018, - sourceType: 'module', - }, - rules: { - [`${pluginName}/arrow-body-multiline-braces`]: ['error', 'always'], - }, - plugins: [pluginName], - }, - plugins: { - [pluginName]: plugin, - }, - } - const opts = _.defaultsDeep(options, defaultConfig) - - const cli = new ESLint(opts) - - const results = await cli.lintFiles([path.join(__dirname, file)]) - - return results[0] -} - -describe('arrow-body-multiline-braces', () => { - it('lint multiline js', async () => { - const filename = './fixtures/multiline.js' - const result = await execute(filename, { - fix: true, - }) - - expect(result.output).to.contain('{') - }) - - it('lint oneline js', async () => { - const filename = './fixtures/oneline.js' - const result = await execute(filename, { fix: false }) - - expect(result.output).not.ok - expect(result.errorCount).eq(0) - }) -}) diff --git a/npm/eslint-plugin-dev/test/fixtures/multiline.js b/npm/eslint-plugin-dev/test/fixtures/multiline.js deleted file mode 100644 index 76489e2cb108..000000000000 --- a/npm/eslint-plugin-dev/test/fixtures/multiline.js +++ /dev/null @@ -1,9 +0,0 @@ - -const foo = (fn) => - fn( - 'foo', - 'bar', - ) - -foo() - diff --git a/npm/eslint-plugin-dev/test/fixtures/no-return-before-fail.js b/npm/eslint-plugin-dev/test/fixtures/no-return-before-fail.js deleted file mode 100644 index dc4fa2cf2ad2..000000000000 --- a/npm/eslint-plugin-dev/test/fixtures/no-return-before-fail.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('outer', ()=>{ - return describe('some test', ()=>{ - return context('some test', ()=>{ - return it('some test', ()=>{ - return expect('foo').to.eq('bar') - }) - return someFn() - }) - }) -}) diff --git a/npm/eslint-plugin-dev/test/fixtures/no-return-before-pass.js b/npm/eslint-plugin-dev/test/fixtures/no-return-before-pass.js deleted file mode 100644 index 6ef7cc384554..000000000000 --- a/npm/eslint-plugin-dev/test/fixtures/no-return-before-pass.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('outer', ()=>{ - describe('some test', ()=>{ - context('some test', ()=>{ - it('some test', ()=>{ - expect('foo').to.eq('bar') - }) - return someFn() - }) - }) -}) diff --git a/npm/eslint-plugin-dev/test/fixtures/oneline.js b/npm/eslint-plugin-dev/test/fixtures/oneline.js deleted file mode 100644 index bfafd0733d61..000000000000 --- a/npm/eslint-plugin-dev/test/fixtures/oneline.js +++ /dev/null @@ -1,5 +0,0 @@ -const foo = () => console.log('foo') - - -foo() - diff --git a/npm/eslint-plugin-dev/test/fixtures/skip-comment-config.js b/npm/eslint-plugin-dev/test/fixtures/skip-comment-config.js deleted file mode 100644 index 9f4393fe36a7..000000000000 --- a/npm/eslint-plugin-dev/test/fixtures/skip-comment-config.js +++ /dev/null @@ -1,10 +0,0 @@ -// FOOBAR: im skipping this for good reason -it.skip('some test', ()=>{ - -}) - -// NOTE: im skipping this for good reason -it.skip('some test', ()=>{ - -}) - diff --git a/npm/eslint-plugin-dev/test/fixtures/skip-comment-fail.js b/npm/eslint-plugin-dev/test/fixtures/skip-comment-fail.js deleted file mode 100644 index 8f70e0d44711..000000000000 --- a/npm/eslint-plugin-dev/test/fixtures/skip-comment-fail.js +++ /dev/null @@ -1,11 +0,0 @@ -it.skip('some test', ()=>{ - -}) - -describe.skip('some test', ()=>{ - -}) - -context.skip('some test', ()=>{ - -}) diff --git a/npm/eslint-plugin-dev/test/fixtures/skip-comment-pass.js b/npm/eslint-plugin-dev/test/fixtures/skip-comment-pass.js deleted file mode 100644 index 64b242b6fc56..000000000000 --- a/npm/eslint-plugin-dev/test/fixtures/skip-comment-pass.js +++ /dev/null @@ -1,25 +0,0 @@ -// NOTE: im skipping this for good reason - -it.skip('some test', ()=>{ - -}) - -// NOTE: im skipping this for good reason -// some other line -describe.skip('some test', ()=>{ - -}) - -/* NOTE: im skipping this for good reason */ -context.skip('some test', ()=>{ - -}) - -// TODO: im skipping this for good reason -it.skip('some test', ()=>{ - -}) -//# TODO: im skipping this for good reason -it.skip('some test', ()=>{ - -}) diff --git a/npm/eslint-plugin-dev/test/fixtures/with-only.js b/npm/eslint-plugin-dev/test/fixtures/with-only.js deleted file mode 100644 index c8178b523f70..000000000000 --- a/npm/eslint-plugin-dev/test/fixtures/with-only.js +++ /dev/null @@ -1,11 +0,0 @@ -it.only('foo', () => { - 'foo' -}) - -describe.only('foo', () => { - 'foo' -}) - -context.only('foo', () => { - 'foo' -}) diff --git a/npm/eslint-plugin-dev/test/no-only.spec.js b/npm/eslint-plugin-dev/test/no-only.spec.js deleted file mode 100644 index 8162bf14886d..000000000000 --- a/npm/eslint-plugin-dev/test/no-only.spec.js +++ /dev/null @@ -1,53 +0,0 @@ -const path = require('path') -const eslint = require('eslint') -const plugin = require('..') -const _ = require('lodash') -const { expect } = require('chai') - -const ruleName = 'no-only' -const pluginName = '__plugin__' -const ESLint = eslint.ESLint - -async function execute (file, options = {}) { - const defaultConfig = { - fix: true, - ignore: false, - useEslintrc: false, - baseConfig: { - parserOptions: { - ecmaVersion: 2018, - sourceType: 'module', - }, - rules: { - [`${pluginName}/${ruleName}`]: ['error'], - }, - plugins: [pluginName], - }, - plugins: { - [pluginName]: plugin, - }, - } - const opts = _.defaultsDeep(options, defaultConfig) - - const cli = new ESLint(opts) - - const results = await cli.lintFiles([path.join(__dirname, file)]) - - return results[0] -} - -describe('no-only', () => { - it('lint js with only', async () => { - const filename = './fixtures/with-only.js' - const result = await execute(filename, { - fix: true, - }) - - expect(result.errorCount).eq(3) - expect(result.messages[0].message).to.contain('it') - expect(result.messages[1].message).to.contain('describe') - expect(result.messages[2].message).to.contain('context') - - expect(result.output).not.exist - }) -}) diff --git a/npm/eslint-plugin-dev/test/no-return-before.spec.js b/npm/eslint-plugin-dev/test/no-return-before.spec.js deleted file mode 100644 index e53b67d1798f..000000000000 --- a/npm/eslint-plugin-dev/test/no-return-before.spec.js +++ /dev/null @@ -1,99 +0,0 @@ -const path = require('path') -const eslint = require('eslint') -const plugin = require('..') -const _ = require('lodash') -const { stripIndent } = require('common-tags') -const { expect } = require('chai') - -const ruleName = 'no-return-before' -const pluginName = '__plugin__' -const ESLint = eslint.ESLint - -async function execute (file, options = {}) { - const defaultConfig = { - fix: true, - ignore: false, - useEslintrc: false, - baseConfig: { - parserOptions: { - ecmaVersion: 2018, - sourceType: 'module', - }, - rules: { - [`${pluginName}/${ruleName}`]: ['error'], - }, - plugins: [pluginName], - }, - plugins: { - [pluginName]: plugin, - }, - } - const opts = _.defaultsDeep(options, defaultConfig) - - const cli = new ESLint(opts) - - const results = await cli.lintFiles([path.join(__dirname, file)]) - - return results[0] -} - -describe(ruleName, () => { - it('pass', async () => { - const filename = './fixtures/no-return-before-pass.js' - const result = await execute(filename) - - expect(result.errorCount).equal(0) - }) - - it('fail', async () => { - const filename = './fixtures/no-return-before-fail.js' - const result = await execute(filename, { - fix: false, - }) - - expect(result.errorCount).equal(4) - expect(result.messages[0].message).to.contain(`after 'describe'`) - }) - - it('fix fail', async () => { - const filename = './fixtures/no-return-before-fail.js' - const result = await execute(filename) - - expect(result.output).equal(`${stripIndent` - describe('outer', ()=>{ - describe('some test', ()=>{ - context('some test', ()=>{ - it('some test', ()=>{ - expect('foo').to.eq('bar') - }) - return someFn() - }) - }) - }) - `}\n`) - }) - - describe('config', () => { - it('config [tokens]', async () => { - const filename = './fixtures/no-return-before-fail.js' - const result = await execute(filename, { - fix: false, - baseConfig: { - rules: { - [`${pluginName}/${ruleName}`]: [ - 'error', { - tokens: ['someFn'], - }, - ], - }, - }, - }) - - expect(result.errorCount).equal(1) - - expect(result.messages[0].message).to.contain('someFn') - - expect(result.output).not.not.exist - }) - }) -}) diff --git a/npm/eslint-plugin-dev/test/skip-comment.spec.js b/npm/eslint-plugin-dev/test/skip-comment.spec.js deleted file mode 100644 index 10b7008787e2..000000000000 --- a/npm/eslint-plugin-dev/test/skip-comment.spec.js +++ /dev/null @@ -1,92 +0,0 @@ -const path = require('path') -const eslint = require('eslint') -const plugin = require('..') -const _ = require('lodash') -const { expect } = require('chai') - -const ruleName = 'skip-comment' -const pluginName = '__plugin__' -const ESLint = eslint.ESLint - -async function execute (file, options = {}) { - const defaultConfig = { - fix: true, - ignore: false, - useEslintrc: false, - baseConfig: { - parserOptions: { - ecmaVersion: 2018, - sourceType: 'module', - }, - rules: { - [`${pluginName}/${ruleName}`]: ['error'], - }, - plugins: [pluginName], - }, - plugins: { - [pluginName]: plugin, - }, - } - const opts = _.defaultsDeep(options, defaultConfig) - - const cli = new ESLint(opts) - - const results = await cli.lintFiles([path.join(__dirname, file)]) - - return results[0] -} - -describe('skip-comment', () => { - it('skip test with comment', async () => { - const filename = './fixtures/skip-comment-pass.js' - const result = await execute(filename, { - fix: true, - }) - - expect(result.errorCount).equal(0) - }) - - it('skip test without comment', async () => { - const filename = './fixtures/skip-comment-fail.js' - const result = await execute(filename, { - fix: true, - }) - - expect(result.errorCount).equal(3) - - expect(result.messages[0].message).to.contain('it') - expect(result.messages[0].message).to.contain('NOTE:') - expect(result.messages[0].message).to.contain('TODO:') - expect(result.messages[1].message).to.contain('describe') - expect(result.messages[1].message).to.contain('NOTE:') - expect(result.messages[2].message).to.contain('context') - expect(result.messages[2].message).to.contain('NOTE:') - - expect(result.output).not.not.exist - }) - - describe('config', () => { - it('skip test without comment', async () => { - const filename = './fixtures/skip-comment-config.js' - const result = await execute(filename, { - fix: true, - baseConfig: { - rules: { - [`${pluginName}/${ruleName}`]: [ - 'error', { - commentTokens: ['FOOBAR:'], - }, - ], - }, - }, - }) - - expect(result.errorCount).equal(1) - - expect(result.messages[0].message).to.contain('it') - expect(result.messages[0].message).to.contain('FOOBAR:') - - expect(result.output).not.exist - }) - }) -}) diff --git a/npm/grep/.eslintrc b/npm/grep/.eslintrc deleted file mode 100644 index 667197d7aa46..000000000000 --- a/npm/grep/.eslintrc +++ /dev/null @@ -1,16 +0,0 @@ -{ - "plugins": [ - "cypress" - ], - "extends": [ - "plugin:@cypress/dev/tests" - ], - "env": { - "cypress/globals": true - }, - "rules": { - "mocha/no-global-tests": "off", - "no-console": "off", - "no-restricted-syntax": "off" - } -} diff --git a/npm/grep/cypress/e2e/each-spec.js b/npm/grep/cypress/e2e/each-spec.js index 5dfc712ea888..54dabff046ff 100644 --- a/npm/grep/cypress/e2e/each-spec.js +++ b/npm/grep/cypress/e2e/each-spec.js @@ -1,6 +1,5 @@ -/// - // https://github.com/bahmutov/cypress-each +// eslint-disable-next-line import-x/no-unresolved import 'cypress-each' describe('tests that use .each work', () => { diff --git a/npm/grep/cypress/e2e/omit-and-skip-spec.js b/npm/grep/cypress/e2e/omit-and-skip-spec.js index 253ad35be4c6..4c3a029f42a7 100644 --- a/npm/grep/cypress/e2e/omit-and-skip-spec.js +++ b/npm/grep/cypress/e2e/omit-and-skip-spec.js @@ -3,7 +3,6 @@ // @ts-check describe('Page', () => { describe('List', { tags: ['@us1'] }, () => { - // eslint-disable-next-line @cypress/dev/skip-comment it.skip('first test', () => {}) it('second test', () => {}) it('third test', () => {}) diff --git a/npm/grep/cypress/e2e/skip-spec.js b/npm/grep/cypress/e2e/skip-spec.js index 3ca63e02df46..0aa964e482c3 100644 --- a/npm/grep/cypress/e2e/skip-spec.js +++ b/npm/grep/cypress/e2e/skip-spec.js @@ -1,4 +1,3 @@ -/* eslint-disable @cypress/dev/skip-comment */ /// describe('tests that use .skip', () => { // use a template literal diff --git a/npm/grep/cypress/e2e/unit.js b/npm/grep/cypress/e2e/unit.js index da61404ccb22..6e36c9c91174 100644 --- a/npm/grep/cypress/e2e/unit.js +++ b/npm/grep/cypress/e2e/unit.js @@ -1,5 +1,3 @@ -/// - import { parseGrep, parseTitleGrep, diff --git a/npm/grep/cypress/tsconfig.json b/npm/grep/cypress/tsconfig.json index d6ad99370558..8a588d18f5ce 100644 --- a/npm/grep/cypress/tsconfig.json +++ b/npm/grep/cypress/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { - "types": ["cypress"] + "types": ["cypress"], + "allowJs": true, }, - "include": ["e2e/**/*.ts"] + "include": ["**/*"] } diff --git a/npm/grep/eslint.config.ts b/npm/grep/eslint.config.ts new file mode 100644 index 000000000000..b5dbb1aa2b8e --- /dev/null +++ b/npm/grep/eslint.config.ts @@ -0,0 +1,33 @@ +import baseConfig from '@tooling/eslint-config' +import globals from 'globals' + +export default [ + ...baseConfig, + { + languageOptions: { + globals: { + ...globals['shared-node-browser'], + require: 'readonly', + module: 'readonly', + }, + }, + }, + { + files: ['expects/test-npm-module.js', 'src/plugin.js'], + languageOptions: { + globals: { + process: 'readonly', + }, + }, + }, + // These rules emit many errors in this package + { + rules: { + 'import-x/no-unresolved': 'off', + 'import-x/no-duplicates': 'off', + 'import-x/namespace': 'off', + 'import-x/default': 'off', + 'import-x/no-named-as-default': 'off', + }, + }, +] diff --git a/npm/grep/expects/test-npm-module.js b/npm/grep/expects/test-npm-module.js index 0abade82e82f..b101871a26ed 100644 --- a/npm/grep/expects/test-npm-module.js +++ b/npm/grep/expects/test-npm-module.js @@ -1,6 +1,7 @@ // https://github.com/cypress-io/cypress-grep/issues/41 // shows how to pass grep parameters using Cypress NPM Module API // https://on.cypress.io/module-api +/* eslint no-console: 0 */ const cypress = require('cypress') cypress diff --git a/npm/grep/package.json b/npm/grep/package.json index 7cb5f8ae95b6..12647a6d0231 100644 --- a/npm/grep/package.json +++ b/npm/grep/package.json @@ -6,7 +6,7 @@ "scripts": { "cy:open": "node ../../scripts/cypress.js open --e2e -b electron --config specPattern='**/unit.js'", "cy:run": "node ../../scripts/cypress.js run --config specPattern='**/unit.js'", - "lint": "eslint . --ext .js,.ts" + "lint": "eslint ." }, "dependencies": { "debug": "^4.3.4", @@ -14,8 +14,10 @@ "globby": "^11.0.4" }, "devDependencies": { + "@tooling/eslint-config": "0.0.0-development", "cypress-each": "^1.11.0", "cypress-expect": "^2.5.3", + "globals": "^15.14.0", "typescript": "~5.4.5" }, "peerDependencies": { diff --git a/npm/grep/src/plugin.js b/npm/grep/src/plugin.js index 483b3aa85f18..852d89ffb170 100644 --- a/npm/grep/src/plugin.js +++ b/npm/grep/src/plugin.js @@ -1,3 +1,4 @@ +/* eslint no-console: 0 */ const debug = require('debug')('@cypress/grep') const globby = require('globby') const { getTestNames } = require('find-test-names') diff --git a/npm/grep/src/support.js b/npm/grep/src/support.js index 8797d6786990..fd577e93b28c 100644 --- a/npm/grep/src/support.js +++ b/npm/grep/src/support.js @@ -6,6 +6,7 @@ const { parseGrep, shouldTestRun } = require('./utils') const { version } = require('../package.json') const debug = require('debug')('@cypress/grep') +// eslint-disable-next-line no-console debug.log = console.info.bind(console) // preserve the real "it" function diff --git a/npm/grep/src/utils.js b/npm/grep/src/utils.js index 9ba2dc544cc3..bc8d325b8cd3 100644 --- a/npm/grep/src/utils.js +++ b/npm/grep/src/utils.js @@ -88,7 +88,7 @@ function parseTagsGrep (s) { }) if (ORS_filtered.length === 0) { - ORS_filtered[ 0 ] = explicitNotTags + ORS_filtered[0] = explicitNotTags } } @@ -132,7 +132,9 @@ function shouldTestRunTitle (parsedGrep, testName) { } if (!Array.isArray(parsedGrep)) { + // eslint-disable-next-line no-console console.error('Invalid parsed title grep') + // eslint-disable-next-line no-console console.error(parsedGrep) throw new Error('Expected title grep to be an array') } diff --git a/npm/grep/tsconfig.json b/npm/grep/tsconfig.json new file mode 100644 index 000000000000..d79b0d947c6b --- /dev/null +++ b/npm/grep/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../packages/ts/tsconfig.json", + "include": "**/*", + "compilerOptions": { + "noEmit": true, + "allowJs": true, + } +} \ No newline at end of file diff --git a/npm/mount-utils/.eslintignore b/npm/mount-utils/.eslintignore deleted file mode 100644 index 79afe972da7d..000000000000 --- a/npm/mount-utils/.eslintignore +++ /dev/null @@ -1,5 +0,0 @@ -**/dist -**/*.d.ts -**/package-lock.json -**/tsconfig.json -**/cypress/fixtures \ No newline at end of file diff --git a/npm/mount-utils/eslint.config.ts b/npm/mount-utils/eslint.config.ts new file mode 100644 index 000000000000..15597fd274cb --- /dev/null +++ b/npm/mount-utils/eslint.config.ts @@ -0,0 +1,15 @@ +import baseConfig from '../../eslint.config' +import globals from 'globals' + +export default [ + ...baseConfig, + { + languageOptions: { + parserOptions: { + projectService: { + allowDefaultProject: ['eslint.config.ts', 'create-rollup-entry.mjs'], + }, + }, + }, + }, +] diff --git a/npm/mount-utils/package.json b/npm/mount-utils/package.json index 1b85db99c915..3a16a268db5a 100644 --- a/npm/mount-utils/package.json +++ b/npm/mount-utils/package.json @@ -7,7 +7,7 @@ "build": "tsc || echo 'built, with type errors'", "postbuild": "node ../../scripts/sync-exported-npm-with-cli.js", "check-ts": "tsc --noEmit", - "lint": "eslint --ext .js,.ts,.json, .", + "lint": "eslint .", "watch": "tsc -w" }, "dependencies": {}, diff --git a/npm/puppeteer/.eslintignore b/npm/puppeteer/.eslintignore deleted file mode 100644 index 9bd1cd76241e..000000000000 --- a/npm/puppeteer/.eslintignore +++ /dev/null @@ -1,4 +0,0 @@ -**/dist -**/*.d.ts -**/package-lock.json -**/tsconfig.json diff --git a/npm/puppeteer/cypress/tsconfig.json b/npm/puppeteer/cypress/tsconfig.json index ea3daa2c3185..a93c15c15b5b 100644 --- a/npm/puppeteer/cypress/tsconfig.json +++ b/npm/puppeteer/cypress/tsconfig.json @@ -2,10 +2,10 @@ "compilerOptions": { "types": [ "cypress" - ] + ], }, "include": [ "../index.d.ts", - "e2e/**/*.ts" + "**/*.ts" ] } diff --git a/npm/puppeteer/eslint.config.ts b/npm/puppeteer/eslint.config.ts new file mode 100644 index 000000000000..a9de4da56516 --- /dev/null +++ b/npm/puppeteer/eslint.config.ts @@ -0,0 +1,17 @@ +import baseConfig from '../../eslint.config' + +export default [ + ...baseConfig, + { + ignores: ['support/index.js'], + }, + { + languageOptions: { + parserOptions: { + projectService: { + allowDefaultProject: ['eslint.config.ts', 'cypress.config.ts'], + }, + }, + }, + }, +] diff --git a/npm/puppeteer/package.json b/npm/puppeteer/package.json index 6ad77a27c409..d866940fea5d 100644 --- a/npm/puppeteer/package.json +++ b/npm/puppeteer/package.json @@ -10,7 +10,7 @@ "check-ts": "tsc --noEmit", "cypress:open": "node ../../scripts/cypress.js open", "cypress:run": "node ../../scripts/cypress.js run --browser chrome", - "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .", + "lint": "eslint .", "semantic-release": "semantic-release", "test": "mocha test/unit/*.spec.ts", "test-watch": "yarn test & chokidar '**/*.ts' 'test/unit/*.ts' -c 'yarn test'", diff --git a/npm/puppeteer/test/tsconfig.json b/npm/puppeteer/test/tsconfig.json new file mode 100644 index 000000000000..ec187a83ccb4 --- /dev/null +++ b/npm/puppeteer/test/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../ts/tsconfig.json", + "compilerOptions": { + "noEmit": true, + "allowJs": true, + }, + "include": ["**/*"] +} \ No newline at end of file diff --git a/npm/puppeteer/tsconfig.json b/npm/puppeteer/tsconfig.json index faec3a8532de..adca16b2317f 100644 --- a/npm/puppeteer/tsconfig.json +++ b/npm/puppeteer/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { "alwaysStrict": true, + "allowJs": true, "declaration": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, diff --git a/npm/react/.eslintignore b/npm/react/.eslintignore deleted file mode 100644 index 79afe972da7d..000000000000 --- a/npm/react/.eslintignore +++ /dev/null @@ -1,5 +0,0 @@ -**/dist -**/*.d.ts -**/package-lock.json -**/tsconfig.json -**/cypress/fixtures \ No newline at end of file diff --git a/npm/react/.eslintrc b/npm/react/.eslintrc deleted file mode 100644 index ecfd74f652df..000000000000 --- a/npm/react/.eslintrc +++ /dev/null @@ -1,30 +0,0 @@ -{ - "plugins": [ - "cypress", - "@cypress/dev" - ], - "extends": [ - "plugin:@cypress/dev/general", - "plugin:@cypress/dev/tests", - "plugin:@cypress/dev/react" - ], - "parser": "@typescript-eslint/parser", - "env": { - "cypress/globals": true - }, - "root": true, - "rules": { - "no-console": "off", - "mocha/no-global-tests": "off", - "react/jsx-filename-extension": [ - "warn", - { - "extensions": [ - ".js", - ".jsx", - ".tsx" - ] - } - ] - } -} diff --git a/npm/react/cypress/component/advanced/lazy-loaded-suspense/LazyComponent.tsx b/npm/react/cypress/component/advanced/lazy-loaded-suspense/LazyComponent.tsx index 05410fe8182c..62a1d18bb565 100644 --- a/npm/react/cypress/component/advanced/lazy-loaded-suspense/LazyComponent.tsx +++ b/npm/react/cypress/component/advanced/lazy-loaded-suspense/LazyComponent.tsx @@ -11,7 +11,7 @@ export const LazyComponent: React.FC = () => { return (
Loading a dog: - +
diff --git a/npm/react/cypress/component/advanced/renderless/mouse-movement.jsx b/npm/react/cypress/component/advanced/renderless/mouse-movement.jsx index 7782e8f44d69..d86c85cd841b 100644 --- a/npm/react/cypress/component/advanced/renderless/mouse-movement.jsx +++ b/npm/react/cypress/component/advanced/renderless/mouse-movement.jsx @@ -1,5 +1,5 @@ // https://medium.com/@pierrehedkvist/renderless-components-in-react-8d663746314c -// eslint-disable-next-line no-unused-vars + import React, { useState, useEffect } from 'react' import PropTypes from 'prop-types' diff --git a/npm/react/cypress/component/basic/document/document.cy.jsx b/npm/react/cypress/component/basic/document/document.cy.jsx index 8d3947b51932..deaba63b8714 100644 --- a/npm/react/cypress/component/basic/document/document.cy.jsx +++ b/npm/react/cypress/component/basic/document/document.cy.jsx @@ -12,8 +12,7 @@ const DocumentTest = ({ reportHeight }) => { document.documentElement.clientHeight, document.body.clientHeight, ) - } - } + }} > Report height diff --git a/npm/react/cypress/tsconfig.json b/npm/react/cypress/tsconfig.json index d39e69494de9..0d321dcd72e1 100644 --- a/npm/react/cypress/tsconfig.json +++ b/npm/react/cypress/tsconfig.json @@ -1,7 +1,8 @@ { "extends": "../tsconfig.json", - "include": ["./**/*.ts*"], + "include": ["**/*"], "compilerOptions": { + "allowJs": true, "baseUrl": ".", "jsx": "react", "types": ["cypress"], diff --git a/npm/react/eslint.config.ts b/npm/react/eslint.config.ts new file mode 100644 index 000000000000..12badab47e30 --- /dev/null +++ b/npm/react/eslint.config.ts @@ -0,0 +1,23 @@ +import baseConfig from '../../eslint.config' +import globals from 'globals' +import react from 'eslint-plugin-react' + +export default [ + ...baseConfig, + { + languageOptions: { + parserOptions: { + projectService: { + allowDefaultProject: ['babel.config.js', 'cypress.config.js', 'eslint.config.ts', 'rollup.config.mjs', 'vite.config.ts'], + }, + }, + }, + }, + { + rules: { + 'react/prop-types': 'warn', + 'react/display-name': 'warn', + 'no-console': 'warn', + }, + }, +] diff --git a/npm/react/package.json b/npm/react/package.json index e6542d9ebd25..0be88aa001f4 100644 --- a/npm/react/package.json +++ b/npm/react/package.json @@ -11,7 +11,7 @@ "cy:open:debug": "node --inspect-brk ../../scripts/start.js --component-testing --run-project ${PWD}", "cy:run": "node ../../scripts/cypress.js run --component", "cy:run:debug": "node --inspect-brk ../../scripts/start.js --component-testing --run-project ${PWD}", - "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .", + "lint": "eslint .", "test": "yarn cy:run", "watch": "yarn build --watch --watch.exclude ./dist/**/*" }, diff --git a/npm/svelte/.eslintignore b/npm/svelte/.eslintignore deleted file mode 100644 index 79afe972da7d..000000000000 --- a/npm/svelte/.eslintignore +++ /dev/null @@ -1,5 +0,0 @@ -**/dist -**/*.d.ts -**/package-lock.json -**/tsconfig.json -**/cypress/fixtures \ No newline at end of file diff --git a/npm/svelte/.eslintrc b/npm/svelte/.eslintrc deleted file mode 100644 index f191aaa0e6d3..000000000000 --- a/npm/svelte/.eslintrc +++ /dev/null @@ -1,15 +0,0 @@ -{ - "plugins": [ - "cypress" - ], - "extends": [ - "plugin:@cypress/dev/tests" - ], - "env": { - "cypress/globals": true - }, - "rules": { - "mocha/no-global-tests": "off", - "no-console": "off" - } -} diff --git a/npm/svelte/eslint.config.ts b/npm/svelte/eslint.config.ts new file mode 100644 index 000000000000..b648e1635339 --- /dev/null +++ b/npm/svelte/eslint.config.ts @@ -0,0 +1,15 @@ +import baseConfig from '../../eslint.config' +import globals from 'globals' + +export default [ + ...baseConfig, + { + languageOptions: { + parserOptions: { + projectService: { + allowDefaultProject: ['eslint.config.ts', 'rollup.config.mjs'], + }, + }, + }, + }, +] diff --git a/npm/svelte/package.json b/npm/svelte/package.json index 2d871996fe95..fe01969ab3f8 100644 --- a/npm/svelte/package.json +++ b/npm/svelte/package.json @@ -8,7 +8,7 @@ "build": "rollup -c rollup.config.mjs", "postbuild": "node ../../scripts/sync-exported-npm-with-cli.js", "check-ts": "tsc --noEmit", - "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, ." + "lint": "eslint ." }, "devDependencies": { "@cypress/mount-utils": "0.0.0-development", diff --git a/npm/svelte/src/mount.ts b/npm/svelte/src/mount.ts index 1e651a25026c..c1f76eef6db1 100644 --- a/npm/svelte/src/mount.ts +++ b/npm/svelte/src/mount.ts @@ -7,7 +7,7 @@ import type { MountOptions, Component } from 'svelte' const DEFAULT_COMP_NAME = 'unknown' -export interface MountReturn{ +export interface MountReturn { component: Record } @@ -50,7 +50,7 @@ const getComponentDisplayName = (Component: Component, Recor */ export function mount ( Component: Component, Record, any>, - options: Omit & {log?: boolean} = {}, + options: Omit & { log?: boolean } = {}, ): Cypress.Chainable { // In Svelte 5, the component name is no longer easily discoverable and logs as "wrapper" // so we default the logging of it to false as it doesn't provide a lot of value diff --git a/npm/vite-dev-server/.eslintignore b/npm/vite-dev-server/.eslintignore deleted file mode 100644 index 79afe972da7d..000000000000 --- a/npm/vite-dev-server/.eslintignore +++ /dev/null @@ -1,5 +0,0 @@ -**/dist -**/*.d.ts -**/package-lock.json -**/tsconfig.json -**/cypress/fixtures \ No newline at end of file diff --git a/npm/vite-dev-server/.eslintrc b/npm/vite-dev-server/.eslintrc deleted file mode 100644 index 7158598773c0..000000000000 --- a/npm/vite-dev-server/.eslintrc +++ /dev/null @@ -1,32 +0,0 @@ -{ - "plugins": [ - "cypress", - "@cypress/dev" - ], - "extends": [ - "plugin:@cypress/dev/general", - "plugin:@cypress/dev/tests", - "plugin:@cypress/dev/react" - ], - "parser": "vue-eslint-parser", - "parserOptions": { - "parser": "@typescript-eslint/parser" - }, - "env": { - "cypress/globals": true - }, - "rules": { - "no-console": "off", - "mocha/no-global-tests": "off", - "react/jsx-filename-extension": [ - "warn", - { - "extensions": [ - ".js", - ".jsx", - ".tsx" - ] - } - ] - } -} diff --git a/npm/vite-dev-server/cypress/tsconfig.json b/npm/vite-dev-server/cypress/tsconfig.json new file mode 100644 index 000000000000..8a588d18f5ce --- /dev/null +++ b/npm/vite-dev-server/cypress/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "types": ["cypress"], + "allowJs": true, + }, + "include": ["**/*"] +} diff --git a/npm/vite-dev-server/eslint.config.ts b/npm/vite-dev-server/eslint.config.ts new file mode 100644 index 000000000000..776f0f59cd0f --- /dev/null +++ b/npm/vite-dev-server/eslint.config.ts @@ -0,0 +1,21 @@ +import baseConfig from '../../eslint.config' +import globals from 'globals' + +export default [ + ...baseConfig, + { + ignores: ['index.d.ts', 'index.js', 'test/.mocharc.js'], + }, + { + languageOptions: { + parserOptions: { + projectService: { + allowDefaultProject: ['eslint.config.ts', 'cypress.config.ts', 'client/initCypressTests.js'], + }, + }, + globals: { + process: 'readonly', + }, + }, + }, +] diff --git a/npm/vite-dev-server/index.d.ts b/npm/vite-dev-server/index.d.ts index 9ae0af320b63..5d960ddb8bba 100644 --- a/npm/vite-dev-server/index.d.ts +++ b/npm/vite-dev-server/index.d.ts @@ -1 +1 @@ -export * from "./dist" +export * from './dist' diff --git a/npm/vite-dev-server/package.json b/npm/vite-dev-server/package.json index 8bf3fbcd6dff..4fb68e4b0736 100644 --- a/npm/vite-dev-server/package.json +++ b/npm/vite-dev-server/package.json @@ -9,7 +9,7 @@ "cypress:open": "yarn cypress:run-cypress-in-cypress gulp open --project .", "cypress:run": "yarn cypress:run-cypress-in-cypress node ../../scripts/cypress run --project . --browser chrome", "cypress:run-cypress-in-cypress": "cross-env CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT=1 HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS=http://localhost:4455 CYPRESS_REMOTE_DEBUGGING_PORT=6666 TZ=America/New_York", - "lint": "eslint --ext .js,.ts,.json, .", + "lint": "eslint .", "test": "yarn test-unit", "test-unit": "mocha -r ts-node/register/transpile-only --config ./test/.mocharc.js", "watch": "tsc -w" diff --git a/npm/vite-dev-server/src/plugins/cypress.ts b/npm/vite-dev-server/src/plugins/cypress.ts index 7d85fdd07b97..f4345069308c 100644 --- a/npm/vite-dev-server/src/plugins/cypress.ts +++ b/npm/vite-dev-server/src/plugins/cypress.ts @@ -42,7 +42,7 @@ export const Cypress = ( // eslint-disable-next-line no-restricted-syntax let loader = fs.readFileSync(INIT_FILEPATH, 'utf8') - devServerEvents.on('dev-server:specs:changed', ({ specs, options }: { specs: Spec[], options?: { neededForJustInTimeCompile: boolean }}) => { + devServerEvents.on('dev-server:specs:changed', ({ specs, options }: { specs: Spec[], options?: { neededForJustInTimeCompile: boolean } }) => { if (options?.neededForJustInTimeCompile) { // if an option is needed for just in time compile, no-op as this isn't supported in vite return diff --git a/npm/vite-dev-server/test/resolveConfig.spec.ts b/npm/vite-dev-server/test/resolveConfig.spec.ts index f027a8b28a8d..09f82e408d05 100644 --- a/npm/vite-dev-server/test/resolveConfig.spec.ts +++ b/npm/vite-dev-server/test/resolveConfig.spec.ts @@ -23,7 +23,7 @@ const getViteDevServerConfig = (projectRoot: string) => { framework: 'react', } as unknown as ViteDevServerConfig } -const MAJOR_VERSIONS: ({version: 4, vite: any } | {version: 5, vite: any } | {version: 6, vite: any })[] = [ +const MAJOR_VERSIONS: ({ version: 4, vite: any } | { version: 5, vite: any } | { version: 6, vite: any })[] = [ { version: 4, vite: vite4, diff --git a/npm/vite-dev-server/test/tsconfig.json b/npm/vite-dev-server/test/tsconfig.json new file mode 100644 index 000000000000..ec187a83ccb4 --- /dev/null +++ b/npm/vite-dev-server/test/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../ts/tsconfig.json", + "compilerOptions": { + "noEmit": true, + "allowJs": true, + }, + "include": ["**/*"] +} \ No newline at end of file diff --git a/npm/vite-plugin-cypress-esm/.eslintignore b/npm/vite-plugin-cypress-esm/.eslintignore deleted file mode 100644 index 79afe972da7d..000000000000 --- a/npm/vite-plugin-cypress-esm/.eslintignore +++ /dev/null @@ -1,5 +0,0 @@ -**/dist -**/*.d.ts -**/package-lock.json -**/tsconfig.json -**/cypress/fixtures \ No newline at end of file diff --git a/npm/vite-plugin-cypress-esm/.eslintrc b/npm/vite-plugin-cypress-esm/.eslintrc deleted file mode 100644 index 7158598773c0..000000000000 --- a/npm/vite-plugin-cypress-esm/.eslintrc +++ /dev/null @@ -1,32 +0,0 @@ -{ - "plugins": [ - "cypress", - "@cypress/dev" - ], - "extends": [ - "plugin:@cypress/dev/general", - "plugin:@cypress/dev/tests", - "plugin:@cypress/dev/react" - ], - "parser": "vue-eslint-parser", - "parserOptions": { - "parser": "@typescript-eslint/parser" - }, - "env": { - "cypress/globals": true - }, - "rules": { - "no-console": "off", - "mocha/no-global-tests": "off", - "react/jsx-filename-extension": [ - "warn", - { - "extensions": [ - ".js", - ".jsx", - ".tsx" - ] - } - ] - } -} diff --git a/npm/vite-plugin-cypress-esm/client/moduleCache.js b/npm/vite-plugin-cypress-esm/client/moduleCache.js index 3309bdcba58c..831655630228 100644 --- a/npm/vite-plugin-cypress-esm/client/moduleCache.js +++ b/npm/vite-plugin-cypress-esm/client/moduleCache.js @@ -176,6 +176,7 @@ function log (msg) { return } + // eslint-disable-next-line no-console console.log(`[cypress:vite-plugin-cypress-esm]: ${msg}`) } @@ -197,6 +198,7 @@ function cacheAndProxifyModule (id, module) { return moduleProxy } catch (err) { + // eslint-disable-next-line no-console console.warn(`Failed to proxy module ${id}, using original which will *not* support stub/spy`, err) return module diff --git a/npm/vite-plugin-cypress-esm/cypress/component/fixtures/Foo.tsx b/npm/vite-plugin-cypress-esm/cypress/component/fixtures/Foo.tsx index f485f06380d6..bcfae67f75eb 100644 --- a/npm/vite-plugin-cypress-esm/cypress/component/fixtures/Foo.tsx +++ b/npm/vite-plugin-cypress-esm/cypress/component/fixtures/Foo.tsx @@ -22,7 +22,6 @@ export class Dog extends Animal { } export class BarClassComponent extends React.Component<{ msg: string }> { - /* eslint-disable @typescript-eslint/no-useless-constructor */ constructor (props) { super(props) } diff --git a/npm/vite-plugin-cypress-esm/cypress/component/fixtures/MyAsyncMod.ts b/npm/vite-plugin-cypress-esm/cypress/component/fixtures/MyAsyncMod.ts index c73dbed72e89..33efec920397 100644 --- a/npm/vite-plugin-cypress-esm/cypress/component/fixtures/MyAsyncMod.ts +++ b/npm/vite-plugin-cypress-esm/cypress/component/fixtures/MyAsyncMod.ts @@ -1,3 +1,4 @@ export default function foo () { + // eslint-disable-next-line no-console console.log('foo') } diff --git a/npm/vite-plugin-cypress-esm/cypress/component/importSyntax.cy.ts b/npm/vite-plugin-cypress-esm/cypress/component/importSyntax.cy.ts index ee771102568b..51d26b75009c 100644 --- a/npm/vite-plugin-cypress-esm/cypress/component/importSyntax.cy.ts +++ b/npm/vite-plugin-cypress-esm/cypress/component/importSyntax.cy.ts @@ -1,6 +1,5 @@ /// -/* eslint-disable import/no-duplicates */ import defaultExport1 from './fixtures/kitchenSink' import * as name1 from './fixtures/kitchenSink' import { export1 } from './fixtures/kitchenSink' @@ -137,6 +136,7 @@ describe('supports every combination of import syntax in a single file', () => { it(`import defaultExport4, { export5, } from './fixtures/kitchenSink'`, () => { + // eslint-disable-next-line no-console console.log(defaultExport4) expect(defaultExport4).to.deep.eq({ export1: 'export1', diff --git a/npm/vite-plugin-cypress-esm/cypress/component/stub.cy.tsx b/npm/vite-plugin-cypress-esm/cypress/component/stub.cy.tsx index 6ded0642e0df..41c25ca73e0f 100644 --- a/npm/vite-plugin-cypress-esm/cypress/component/stub.cy.tsx +++ b/npm/vite-plugin-cypress-esm/cypress/component/stub.cy.tsx @@ -33,18 +33,18 @@ describe('stubbing ES modules', () => { }) it('works with react class component', () => { - mount() + mount() cy.contains('Hello world').should('exist') }) it('works with react function component', () => { - mount() + mount() cy.contains('Hello world').should('exist') }) it('stubs react component', () => { cy.stub(Foo, 'Foo').callsFake(() =>

Stub Component

) - mount() + mount() cy.contains('Stub Component').should('exist') cy.contains('Hello world').should('not.exist') }) diff --git a/npm/vite-plugin-cypress-esm/cypress/tsconfig.json b/npm/vite-plugin-cypress-esm/cypress/tsconfig.json new file mode 100644 index 000000000000..075cd2f57de9 --- /dev/null +++ b/npm/vite-plugin-cypress-esm/cypress/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "types": [ + "cypress" + ], + }, + "include": [ + "**/*", + ] +} diff --git a/npm/vite-plugin-cypress-esm/eslint.config.ts b/npm/vite-plugin-cypress-esm/eslint.config.ts new file mode 100644 index 000000000000..b5ae185ab7aa --- /dev/null +++ b/npm/vite-plugin-cypress-esm/eslint.config.ts @@ -0,0 +1,17 @@ +import baseConfig from '../../eslint.config' + +export default [ + ...baseConfig, + { + ignores: ['index.d.ts', 'index.js'], + }, + { + languageOptions: { + parserOptions: { + projectService: { + allowDefaultProject: ['eslint.config.ts', 'cypress.config.ts', 'client/moduleCache.js'], + }, + }, + }, + }, +] diff --git a/npm/vite-plugin-cypress-esm/package.json b/npm/vite-plugin-cypress-esm/package.json index f111d493a2b7..7c5f3d82ec0a 100644 --- a/npm/vite-plugin-cypress-esm/package.json +++ b/npm/vite-plugin-cypress-esm/package.json @@ -8,7 +8,7 @@ "check-ts": "tsc --noEmit", "cypress:open": "node ../../scripts/cypress open --project . --component", "cypress:run": "node ../../scripts/cypress run --project . --component", - "lint": "eslint --ext .js,.ts,.json, .", + "lint": "eslint .", "test": "npm run cypress:run", "watch": "tsc -w" }, diff --git a/npm/vue/.eslintignore b/npm/vue/.eslintignore deleted file mode 100644 index 79afe972da7d..000000000000 --- a/npm/vue/.eslintignore +++ /dev/null @@ -1,5 +0,0 @@ -**/dist -**/*.d.ts -**/package-lock.json -**/tsconfig.json -**/cypress/fixtures \ No newline at end of file diff --git a/npm/vue/.eslintrc b/npm/vue/.eslintrc deleted file mode 100644 index 39a4c517a740..000000000000 --- a/npm/vue/.eslintrc +++ /dev/null @@ -1,25 +0,0 @@ -{ - "plugins": [ - "cypress" - ], - "extends": [ - "plugin:@cypress/dev/tests", - "plugin:vue/vue3-recommended" - ], - "parser": "vue-eslint-parser", - "parserOptions": { - "parser": "@typescript-eslint/parser" - }, - "globals": { - "defineProps": "readonly", - "defineEmits": "readonly" - }, - "env": { - "cypress/globals": true - }, - "rules": { - "mocha/no-global-tests": "off", - "no-console": "off", - "vue/multi-word-component-names": "off" - } -} diff --git a/npm/vue/cypress/component/advanced/access-component/Message.vue b/npm/vue/cypress/component/advanced/access-component/Message.vue index 2ab0a3b8c6d7..32aef6e08d02 100644 --- a/npm/vue/cypress/component/advanced/access-component/Message.vue +++ b/npm/vue/cypress/component/advanced/access-component/Message.vue @@ -29,6 +29,7 @@ export default { emits: ['message-clicked'], methods: { handleClick () { + // eslint-disable-next-line no-console console.log('lalala') this.$emit('message-clicked', this.message) }, diff --git a/npm/vue/cypress/component/basic/document-body.cy.js b/npm/vue/cypress/component/basic/document-body.cy.js index b7f396c8e484..f7dbe46004ad 100644 --- a/npm/vue/cypress/component/basic/document-body.cy.js +++ b/npm/vue/cypress/component/basic/document-body.cy.js @@ -5,7 +5,9 @@ describe('document.body', () => { it('is set correctly', () => { mount({ mounted () { + // eslint-disable-next-line no-console console.log('mounted!') + // eslint-disable-next-line no-console console.log('document.body', document.body) document.body.innerText = 'Mounted!' }, diff --git a/npm/vue/cypress/component/basic/hello/Hello.vue b/npm/vue/cypress/component/basic/hello/Hello.vue index e48b2e8f1508..66c36feddf6a 100644 --- a/npm/vue/cypress/component/basic/hello/Hello.vue +++ b/npm/vue/cypress/component/basic/hello/Hello.vue @@ -24,6 +24,7 @@ export default { computed: { error () { + // eslint-disable-next-line no-console console.log(this.username) return this.username.trim().length < 7 diff --git a/npm/vue/cypress/component/setup/HelloWorld.vue b/npm/vue/cypress/component/setup/HelloWorld.vue index 6d6f39efeb5a..290601e1fbe6 100644 --- a/npm/vue/cypress/component/setup/HelloWorld.vue +++ b/npm/vue/cypress/component/setup/HelloWorld.vue @@ -12,7 +12,7 @@ import { ref } from 'vue' defineProps<{ - msg: String + msg: string }>() const count = ref(0) diff --git a/npm/vue/cypress/component/tailwind/plain-html.cy.js b/npm/vue/cypress/component/tailwind/plain-html.cy.js index f8be7146ec28..af5c07d7772a 100644 --- a/npm/vue/cypress/component/tailwind/plain-html.cy.js +++ b/npm/vue/cypress/component/tailwind/plain-html.cy.js @@ -1,4 +1,5 @@ import { mount } from '@cypress/vue' +// eslint-disable-next-line import-x/no-unresolved import '/node_modules/tailwindcss/dist/tailwind.min.css' // example comes from https://tailwindcss.com/components/cards/#horizontal diff --git a/npm/vue/cypress/tsconfig.json b/npm/vue/cypress/tsconfig.json new file mode 100644 index 000000000000..8a588d18f5ce --- /dev/null +++ b/npm/vue/cypress/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "types": ["cypress"], + "allowJs": true, + }, + "include": ["**/*"] +} diff --git a/npm/vue/eslint.config.ts b/npm/vue/eslint.config.ts new file mode 100644 index 000000000000..794f67fe441e --- /dev/null +++ b/npm/vue/eslint.config.ts @@ -0,0 +1,24 @@ +import baseConfig from '../../eslint.config' +import ts from 'typescript-eslint' +import globals from 'globals' + +export default [ + ...baseConfig, + { + languageOptions: { + parserOptions: { + projectService: { + allowDefaultProject: ['eslint.config.ts', 'cypress.config.ts', 'vite.config.ts', 'webpack.config.js', 'rollup.config.mjs'], + }, + }, + }, + }, + { + files: ['**/*.vue'], + languageOptions: { + parserOptions: { + parser: ts.parser, + }, + }, + }, +] diff --git a/npm/vue/package.json b/npm/vue/package.json index bb4da793467a..97a7be93cfe2 100644 --- a/npm/vue/package.json +++ b/npm/vue/package.json @@ -9,7 +9,7 @@ "check-ts": "yarn tsd && vue-tsc --noEmit", "cy:open": "node ../../scripts/cypress.js open --component --project ${PWD}", "cy:run": "node ../../scripts/cypress.js run --component --project ${PWD}", - "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json,.vue .", + "lint": "eslint .", "test": "yarn cy:run", "tsd": "yarn build && yarn tsc -p test-tsd/tsconfig.json", "watch": "yarn build --watch --watch.exclude ./dist/**/*" diff --git a/npm/vue/rollup.config.mjs b/npm/vue/rollup.config.mjs index 20a827b13cae..cc64def81639 100644 --- a/npm/vue/rollup.config.mjs +++ b/npm/vue/rollup.config.mjs @@ -4,14 +4,13 @@ const config = { external: [ 'vue', '@vue/compiler-dom', - '@vue/server-renderer' + '@vue/server-renderer', ], output: { globals: { - vue: 'Vue', vue: 'Vue', '@vue/compiler-dom': 'VueCompilerDOM', - '@vue/server-renderer': 'VueServerRenderer' + '@vue/server-renderer': 'VueServerRenderer', }, }, } diff --git a/npm/vue/src/index.ts b/npm/vue/src/index.ts index b3826b409b69..2e615eb800ad 100644 --- a/npm/vue/src/index.ts +++ b/npm/vue/src/index.ts @@ -1,4 +1,3 @@ -/* eslint-disable no-redeclare */ /// import type { ComponentPublicInstance, @@ -49,7 +48,7 @@ type GlobalMountOptions = Required>['global'] // when we mount a Vue component, we add it to the global Cypress object // so here we extend the global Cypress namespace and its Cypress interface declare global { - // eslint-disable-next-line no-redeclare + namespace Cypress { interface Cypress { vueWrapper: VueWrapper @@ -113,7 +112,7 @@ type ComponentMountingOptions = T extends DefineComponent< : MountingOptions // Class component (without vue-class-component) - no props -export function mount( +export function mount ( originalComponent: { new (...args: any[]): V __vccOpts: any @@ -125,7 +124,7 @@ export function mount( }> // Class component (without vue-class-component) - props -export function mount( +export function mount ( originalComponent: { new (...args: any[]): V __vccOpts: any @@ -138,7 +137,7 @@ export function mount( }> // Class component - no props -export function mount( +export function mount ( originalComponent: { new (...args: any[]): V registerHooks(keys: string[]): void @@ -150,7 +149,7 @@ export function mount( }> // Class component - props -export function mount( +export function mount ( originalComponent: { new (...args: any[]): V props(Props: P): any @@ -163,7 +162,7 @@ export function mount( }> // Functional component with emits -export function mount( +export function mount ( originalComponent: FunctionalComponent, options?: MountingOptions & Record ): Cypress.Chainable<{ @@ -184,8 +183,8 @@ export function mount< EE extends string = string, PP = PublicProps, Props = Readonly>, - Defaults extends {} = ExtractDefaultPropTypes ->( + Defaults extends {} = ExtractDefaultPropTypes, +> ( component: DefineComponent< PropsOrPropOptions, RawBindings, @@ -246,7 +245,7 @@ export function mount< }> // component declared by vue-tsc ScriptSetup -export function mount>( +export function mount> ( component: T, options?: ComponentMountingOptions ): Cypress.Chainable<{ @@ -264,8 +263,8 @@ export function mount< E extends EmitsOptions = Record, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, - EE extends string = string ->( + EE extends string = string, +> ( componentOptions: ComponentOptionsWithoutProps< Props, RawBindings, @@ -304,8 +303,8 @@ export function mount< EE extends string = string, Props extends Readonly<{ [key in PropNames]?: any }> = Readonly<{ [key in PropNames]?: any - }> ->( + }>, +> ( componentOptions: ComponentOptionsWithArrayProps< PropNames, RawBindings, @@ -336,8 +335,8 @@ export function mount< E extends EmitsOptions = Record, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, - EE extends string = string ->( + EE extends string = string, +> ( componentOptions: ComponentOptionsWithObjectProps< PropsOptions, RawBindings, diff --git a/npm/vue/src/shims-vue.d.ts b/npm/vue/src/shims-vue.d.ts index f43ed923b679..ac1ded792334 100644 --- a/npm/vue/src/shims-vue.d.ts +++ b/npm/vue/src/shims-vue.d.ts @@ -1,5 +1,5 @@ declare module '*.vue' { - import { DefineComponent } from 'vue' - const component: DefineComponent<{}, {}, any> - export default component -} \ No newline at end of file + import { DefineComponent } from 'vue' + const component: DefineComponent<{}, {}, any> + export default component +} diff --git a/npm/vue/test-tsd/index.d.ts b/npm/vue/test-tsd/index.d.ts index 61aeaea7a3b2..f369ebae30fe 100644 --- a/npm/vue/test-tsd/index.d.ts +++ b/npm/vue/test-tsd/index.d.ts @@ -1,4 +1,5 @@ -export function expectType(value: T): void -export function expectError(value: T): void -export function expectAssignable(value: T2): void +export function expectType (value: T): void +export function expectError (value: T): void + +export function expectAssignable (value: T2): void diff --git a/npm/vue/test-tsd/mount-test.ts b/npm/vue/test-tsd/mount-test.ts index f4ddecfa0f7d..70a2c4d0dd6d 100644 --- a/npm/vue/test-tsd/mount-test.ts +++ b/npm/vue/test-tsd/mount-test.ts @@ -14,4 +14,5 @@ expectType( // Rewritten relative types match those copied from node_modules // see npm/vue/inline-types.ts for more info. +// eslint-disable-next-line import-x/namespace expectType(VTU['config']['global']) diff --git a/npm/webpack-batteries-included-preprocessor/.eslintignore b/npm/webpack-batteries-included-preprocessor/.eslintignore deleted file mode 100644 index d5857ea71fbd..000000000000 --- a/npm/webpack-batteries-included-preprocessor/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -**/tsconfig.json diff --git a/npm/webpack-batteries-included-preprocessor/eslint.config.ts b/npm/webpack-batteries-included-preprocessor/eslint.config.ts new file mode 100644 index 000000000000..838b98cbaa15 --- /dev/null +++ b/npm/webpack-batteries-included-preprocessor/eslint.config.ts @@ -0,0 +1,19 @@ +import baseConfig from '../../eslint.config' +import globals from 'globals' + +export default [ + ...baseConfig, + { ignores: ['test/fixtures/**/*', 'index.js'] }, + { + languageOptions: { + parserOptions: { + projectService: { + allowDefaultProject: ['eslint.config.ts'], + }, + }, + globals: { + ...globals.node, + }, + }, +}, +] diff --git a/npm/webpack-batteries-included-preprocessor/package.json b/npm/webpack-batteries-included-preprocessor/package.json index 278b6743726c..dfefa621551b 100644 --- a/npm/webpack-batteries-included-preprocessor/package.json +++ b/npm/webpack-batteries-included-preprocessor/package.json @@ -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": { diff --git a/npm/webpack-batteries-included-preprocessor/test/.eslintrc.json b/npm/webpack-batteries-included-preprocessor/test/.eslintrc.json deleted file mode 100644 index 1d9d2fefe4b9..000000000000 --- a/npm/webpack-batteries-included-preprocessor/test/.eslintrc.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "extends": [ - "plugin:@cypress/dev/tests", - "plugin:@cypress/dev/react" - ], - "rules": { - "mocha/no-global-tests": "off", - "react/jsx-filename-extension": [ - "error", - { - "extensions": [ - ".jsx", - ".tsx" - ] - } - ] - }, - "settings": { - "react": { - "version": "detect" - } - } -} diff --git a/npm/webpack-batteries-included-preprocessor/test/fixtures/mjs_spec.mjs b/npm/webpack-batteries-included-preprocessor/test/fixtures/mjs_spec.mjs index babd0da4930f..18454bd2850a 100644 --- a/npm/webpack-batteries-included-preprocessor/test/fixtures/mjs_spec.mjs +++ b/npm/webpack-batteries-included-preprocessor/test/fixtures/mjs_spec.mjs @@ -3,6 +3,6 @@ import { expect } from 'chai' // make sure built in resolves correctly in mjs through the provide plugin, including process & buffer process.env.foo = 'bar' -const buffer = new Buffer('foo'); +const buffer = new Buffer('foo') expect(true).to.be.true diff --git a/npm/webpack-batteries-included-preprocessor/test/fixtures/various_imports_spec.js b/npm/webpack-batteries-included-preprocessor/test/fixtures/various_imports_spec.js index c07ee74a8df6..1172468aec30 100644 --- a/npm/webpack-batteries-included-preprocessor/test/fixtures/various_imports_spec.js +++ b/npm/webpack-batteries-included-preprocessor/test/fixtures/various_imports_spec.js @@ -2,7 +2,7 @@ // for .mjs files. don't upgrade graphql from 14.0.0 or it won't reproduce // the issue properly // https://github.com/cypress-io/cypress/issues/8361 -import graphql from 'graphql' // eslint-disable-line no-unused-vars +import graphql from 'graphql' import { fromJs } from './file-types/js-file' import { fromJsx } from './file-types/jsx-file' diff --git a/npm/webpack-batteries-included-preprocessor/test/tsconfig.json b/npm/webpack-batteries-included-preprocessor/test/tsconfig.json new file mode 100644 index 000000000000..7f572ef2f7a8 --- /dev/null +++ b/npm/webpack-batteries-included-preprocessor/test/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../../../packages/ts/tsconfig.json", + "compilerOptions": { + "noEmit": true, + "allowJs": true, + }, + "include": ["**/*"] +} \ No newline at end of file diff --git a/npm/webpack-dev-server/.eslintignore b/npm/webpack-dev-server/.eslintignore deleted file mode 100644 index 8d2416a026fd..000000000000 --- a/npm/webpack-dev-server/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/dist -**/*.d.ts -**/package-lock.json -**/tsconfig.json -**/cypress/fixtures -**/test/fixtures -**/__snapshots__ \ No newline at end of file diff --git a/npm/webpack-dev-server/cypress/tsconfig.json b/npm/webpack-dev-server/cypress/tsconfig.json new file mode 100644 index 000000000000..8a588d18f5ce --- /dev/null +++ b/npm/webpack-dev-server/cypress/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "types": ["cypress"], + "allowJs": true, + }, + "include": ["**/*"] +} diff --git a/npm/webpack-dev-server/eslint.config.ts b/npm/webpack-dev-server/eslint.config.ts new file mode 100644 index 000000000000..937feb4195a0 --- /dev/null +++ b/npm/webpack-dev-server/eslint.config.ts @@ -0,0 +1,18 @@ +import baseConfig from '../../eslint.config' +import globals from 'globals' + +export default [ + ...baseConfig, + { + ignores: ['__snapshots__/**/*', 'test/fixtures/compilation-fails.spec.js', 'test/.mocharc.js'], + }, + { + languageOptions: { + parserOptions: { + projectService: { + allowDefaultProject: ['eslint.config.ts', 'cypress.config.ts'], + }, + }, + }, + }, +] diff --git a/npm/webpack-dev-server/package.json b/npm/webpack-dev-server/package.json index e5863b5aa6ee..8c734c722721 100644 --- a/npm/webpack-dev-server/package.json +++ b/npm/webpack-dev-server/package.json @@ -12,7 +12,7 @@ "cypress:run": "yarn cypress:run-cypress-in-cypress node ../../scripts/cypress run --project . --browser chrome", "cypress:run-cypress-in-cypress": "cross-env CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT=1 HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS=http://localhost:4455 CYPRESS_REMOTE_DEBUGGING_PORT=6666 TZ=America/New_York", "dev": "tsc --watch", - "lint": "eslint --ext .js,.ts,.json, .", + "lint": "eslint .", "test": "yarn test-unit", "test-unit": "mocha -r ts-node/register/transpile-only --config ./test/.mocharc.js" }, diff --git a/npm/webpack-dev-server/src/CypressCTWebpackPlugin.ts b/npm/webpack-dev-server/src/CypressCTWebpackPlugin.ts index c80f3ab8c294..fd931f82c1f6 100644 --- a/npm/webpack-dev-server/src/CypressCTWebpackPlugin.ts +++ b/npm/webpack-dev-server/src/CypressCTWebpackPlugin.ts @@ -108,7 +108,7 @@ export class CypressCTWebpackPlugin { * * See https://github.com/cypress-io/cypress/issues/24398 */ - private onSpecsChange = async ({ specs, options }: { specs: Cypress.Cypress['spec'][], options?: { neededForJustInTimeCompile: boolean}}) => { + private onSpecsChange = async ({ specs, options }: { specs: Cypress.Cypress['spec'][], options?: { neededForJustInTimeCompile: boolean } }) => { if (!this.compilation || _.isEqual(specs, this.files)) { return } diff --git a/npm/webpack-dev-server/src/helpers/angularHandler.ts b/npm/webpack-dev-server/src/helpers/angularHandler.ts index 707fb65c3dc1..99e65be4f567 100644 --- a/npm/webpack-dev-server/src/helpers/angularHandler.ts +++ b/npm/webpack-dev-server/src/helpers/angularHandler.ts @@ -14,7 +14,7 @@ const debug = debugLib(debugPrefix) export type BuildOptions = Record -export type AngularWebpackDevServerConfig = Extract +export type AngularWebpackDevServerConfig = Extract type Configurations = { configurations?: { diff --git a/npm/webpack-dev-server/src/helpers/sourceRelativeWebpackModules.ts b/npm/webpack-dev-server/src/helpers/sourceRelativeWebpackModules.ts index 627212aaaae0..db01254eca27 100644 --- a/npm/webpack-dev-server/src/helpers/sourceRelativeWebpackModules.ts +++ b/npm/webpack-dev-server/src/helpers/sourceRelativeWebpackModules.ts @@ -132,7 +132,7 @@ export function sourceWebpack (config: WebpackDevServerConfig, framework: Source paths: [searchRoot], }) } catch (e) { - if ((e as {code?: string}).code !== 'MODULE_NOT_FOUND') { + if ((e as { code?: string }).code !== 'MODULE_NOT_FOUND') { debug('Webpack: Failed to source webpack - %s', e) throw e } @@ -196,7 +196,7 @@ export function sourceWebpackDevServer (config: WebpackDevServerConfig, webpackM paths: [searchRoot], }) } catch (e) { - if ((e as {code?: string}).code !== 'MODULE_NOT_FOUND') { + if ((e as { code?: string }).code !== 'MODULE_NOT_FOUND') { debug('WebpackDevServer: Failed to source webpack-dev-server - %s', e) throw e } @@ -248,7 +248,7 @@ export function sourceHtmlWebpackPlugin (config: WebpackDevServerConfig, framewo // we shouldn't be concerned with using our own copy if they've shipped w/ an earlier version htmlWebpackPlugin.majorVersion = getMajorVersion(htmlWebpackPlugin.packageJson, [4, 5]) } catch (e) { - const err = e as Error & {code?: string} + const err = e as Error & { code?: string } if (err.code !== 'MODULE_NOT_FOUND' && !err.message.includes('Unexpected major version')) { debug('HtmlWebpackPlugin: Failed to source html-webpack-plugin - %s', e) @@ -291,7 +291,7 @@ export function sourceDefaultWebpackDependencies (config: WebpackDevServerConfig } } -export function getMajorVersion (json: PackageJson, acceptedVersions: T[]): T { +export function getMajorVersion (json: PackageJson, acceptedVersions: T[]): T { const major = Number(json.version.split('.')[0]) if (!acceptedVersions.includes(major as T)) { diff --git a/npm/webpack-dev-server/test/devServer-e2e.spec.ts b/npm/webpack-dev-server/test/devServer-e2e.spec.ts index cf6d3c863a73..0bb6c96dfb6d 100644 --- a/npm/webpack-dev-server/test/devServer-e2e.spec.ts +++ b/npm/webpack-dev-server/test/devServer-e2e.spec.ts @@ -187,6 +187,7 @@ describe('#devServer', () => { absolute: `${root}/test/fixtures/bar.spec.js`, } + // eslint-disable-next-line no-restricted-syntax const oldmtime = fs.statSync(cypressConfig.indexHtmlFile).mtimeMs await once(devServerEvents, 'dev-server:compile:success') @@ -195,6 +196,7 @@ describe('#devServer', () => { }) await once(devServerEvents, 'dev-server:compile:success') + // eslint-disable-next-line no-restricted-syntax const updatedmtime = fs.statSync(cypressConfig.indexHtmlFile).mtimeMs expect(oldmtime).to.not.equal(updatedmtime) diff --git a/npm/webpack-dev-server/test/fixtures/dependency.js b/npm/webpack-dev-server/test/fixtures/dependency.js index 693da49fc40b..336ce12bb910 100644 --- a/npm/webpack-dev-server/test/fixtures/dependency.js +++ b/npm/webpack-dev-server/test/fixtures/dependency.js @@ -1 +1 @@ -export {} \ No newline at end of file +export {} diff --git a/npm/webpack-dev-server/test/fixtures/webpack.config.js b/npm/webpack-dev-server/test/fixtures/webpack.config.js index ae138660dd9d..c8b08781bdfc 100644 --- a/npm/webpack-dev-server/test/fixtures/webpack.config.js +++ b/npm/webpack-dev-server/test/fixtures/webpack.config.js @@ -1,11 +1,11 @@ class FromWebpackConfigFile { - apply() { + apply () { } } module.exports = { plugins: [ - new FromWebpackConfigFile() - ] -} \ No newline at end of file + new FromWebpackConfigFile(), + ], +} diff --git a/npm/webpack-dev-server/test/sourceRelativeWebpackModules.spec.ts b/npm/webpack-dev-server/test/sourceRelativeWebpackModules.spec.ts index 94c5663aafee..9e667ea84b84 100644 --- a/npm/webpack-dev-server/test/sourceRelativeWebpackModules.spec.ts +++ b/npm/webpack-dev-server/test/sourceRelativeWebpackModules.spec.ts @@ -57,6 +57,7 @@ describe('sourceDefaultWebpackDependencies', () => { describe(fixture, () => { it(`sources the correct webpack versions for ${fixture}`, async () => { const { result, projectRoot } = await sourceModulesForProject(fixture as ProjectDirs[number]) + // eslint-disable-next-line no-restricted-syntax const projectNodeModules = fs.realpathSync(path.resolve(projectRoot, 'node_modules')) expect(result.webpack.majorVersion).to.eq(versionsToMatch.webpack, 'match webpackVersion') @@ -72,6 +73,7 @@ describe('sourceDefaultWebpackDependencies', () => { const localWebpack = require('webpack') const { result, projectRoot } = await sourceModulesForProject('webpack5_wds5-react') + // eslint-disable-next-line no-restricted-syntax const projectNodeModules = fs.realpathSync(path.resolve(projectRoot, 'node_modules')) expect(localWebpack).not.to.eq(result.webpack.module) diff --git a/npm/webpack-dev-server/test/test-helpers/createModuleMatrixResult.ts b/npm/webpack-dev-server/test/test-helpers/createModuleMatrixResult.ts index 01518f415aa6..bc5ed5a44460 100644 --- a/npm/webpack-dev-server/test/test-helpers/createModuleMatrixResult.ts +++ b/npm/webpack-dev-server/test/test-helpers/createModuleMatrixResult.ts @@ -1,7 +1,7 @@ import path from 'path' import type { SourceRelativeWebpackResult } from '../../src/helpers/sourceRelativeWebpackModules' -type ModulesDef = {[K in keyof ModuleMatrixResultOptions]: Record} +type ModulesDef = { [K in keyof ModuleMatrixResultOptions]: Record } const moduleSources: ModulesDef = { webpack: { diff --git a/npm/webpack-dev-server/test/tsconfig.json b/npm/webpack-dev-server/test/tsconfig.json new file mode 100644 index 000000000000..fd5c47307046 --- /dev/null +++ b/npm/webpack-dev-server/test/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../../packages/ts/tsconfig.json", + "compilerOptions": { + "noEmit": true, + "allowJs": true, + }, + "include": ["**/*"] +} \ No newline at end of file diff --git a/npm/webpack-preprocessor/.eslintignore b/npm/webpack-preprocessor/.eslintignore deleted file mode 100644 index 465e063be1c1..000000000000 --- a/npm/webpack-preprocessor/.eslintignore +++ /dev/null @@ -1,8 +0,0 @@ -**/dist -**/*.d.ts -**/package-lock.json -**/tsconfig.json -**/cypress/fixtures -**/test/fixtures -**/_test-output -/cypress/tests/e2e/compile-error.js \ No newline at end of file diff --git a/npm/webpack-preprocessor/cypress/tsconfig.json b/npm/webpack-preprocessor/cypress/tsconfig.json new file mode 100644 index 000000000000..8752f2608138 --- /dev/null +++ b/npm/webpack-preprocessor/cypress/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../../ts/tsconfig.json", + "compilerOptions": { + "noEmit": true, + "allowJs": true, + }, + "include": ["**/*"] +} \ No newline at end of file diff --git a/npm/webpack-preprocessor/eslint.config.ts b/npm/webpack-preprocessor/eslint.config.ts new file mode 100644 index 000000000000..27452065f89b --- /dev/null +++ b/npm/webpack-preprocessor/eslint.config.ts @@ -0,0 +1,21 @@ +import baseConfig from '../../eslint.config' +import globals from 'globals' + +export default [ + ...baseConfig, + { + ignores: ['__snapshots__/**/*', 'cypress/tests/e2e/compile-error.js', 'test/fixtures/**/*'], + }, + { + languageOptions: { + parserOptions: { + projectService: { + allowDefaultProject: ['cypress.config.js', 'scripts/test-webpack-5.js'], + }, + }, + globals: { + ...globals.node, + }, + }, + }, +] diff --git a/npm/webpack-preprocessor/index.ts b/npm/webpack-preprocessor/index.ts index 7e5c8af2696d..3c5f3a2239f1 100644 --- a/npm/webpack-preprocessor/index.ts +++ b/npm/webpack-preprocessor/index.ts @@ -1,7 +1,7 @@ import Bluebird from 'bluebird' import Debug from 'debug' import _ from 'lodash' -import * as events from 'events' +import type * as events from 'events' import * as path from 'path' import webpack from 'webpack' import utils from './lib/utils' @@ -18,7 +18,7 @@ interface BundleObject { } // bundle promises from input spec filename to output bundled file paths -let bundles: {[key: string]: BundleObject} = {} +let bundles: { [key: string]: BundleObject } = {} // we don't automatically load the rules, so that the babel dependencies are // not required if a user passes in their own configuration @@ -275,7 +275,7 @@ const preprocessor: WebpackPreprocessor = (options: PreprocessorOptions = {}): F const jsonStats = stats.toJson() // these stats are really only useful for debugging - if (jsonStats.warnings.length > 0) { + if (jsonStats.warnings !== undefined && jsonStats.warnings.length > 0) { debug(`warnings for ${outputPath} %o`, jsonStats.warnings) } @@ -284,7 +284,7 @@ const preprocessor: WebpackPreprocessor = (options: PreprocessorOptions = {}): F const errorsToAppend = jsonStats.errors // remove stack trace lines since they're useless for debugging - .map(cleanseError) + ?.map(cleanseError) // multiple errors separated by newline .join('\n\n') @@ -372,6 +372,7 @@ const preprocessor: WebpackPreprocessor = (options: PreprocessorOptions = {}): F } } + // @ts-ignore - this results in an error when check-ts'ing packages/driver, but not when check-ts webpack-preprocessor const bundler = file.shouldWatch ? compiler.watch(watchOptions, handle) : compiler.run(handle) // when the spec or project is closed, we need to clean up the cached diff --git a/npm/webpack-preprocessor/lib/typescript-overrides.ts b/npm/webpack-preprocessor/lib/typescript-overrides.ts index 262d51833090..60848d8bf3ab 100644 --- a/npm/webpack-preprocessor/lib/typescript-overrides.ts +++ b/npm/webpack-preprocessor/lib/typescript-overrides.ts @@ -1,7 +1,7 @@ const debug = require('debug')('cypress:webpack') const _ = require('lodash') -import { CompilerOptions, CreateProgramOptions } from 'typescript' +import type { CompilerOptions, CreateProgramOptions } from 'typescript' let patched = false diff --git a/npm/webpack-preprocessor/package.json b/npm/webpack-preprocessor/package.json index 0a614f0051c1..719378691e6a 100644 --- a/npm/webpack-preprocessor/package.json +++ b/npm/webpack-preprocessor/package.json @@ -7,7 +7,7 @@ "scripts": { "build": "rimraf dist && tsc || echo 'built, with errors'", "check-ts": "tsc --noEmit", - "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .", + "lint": "eslint .", "secure": "nsp check", "semantic-release": "semantic-release", "size": "npm pack --dry", diff --git a/npm/webpack-preprocessor/scripts/test-webpack-5.js b/npm/webpack-preprocessor/scripts/test-webpack-5.js index bb0945ee56a2..a1f290865915 100644 --- a/npm/webpack-preprocessor/scripts/test-webpack-5.js +++ b/npm/webpack-preprocessor/scripts/test-webpack-5.js @@ -20,6 +20,7 @@ const main = async () => { const install = () => execa('yarn', ['install', '--ignore-scripts'], { stdio: 'inherit' }) const resetPkg = async () => { + // eslint-disable-next-line no-restricted-syntax fs.writeFileSync(pkgJsonPath, originalPkg, 'utf8') await install() } @@ -41,6 +42,7 @@ const main = async () => { delete pkg.devDependencies['webpack'] // eslint-disable-next-line no-console console.log('[@cypress/webpack-preprocessor]: updating package.json...') + // eslint-disable-next-line no-restricted-syntax fs.writeFileSync(pkgJsonPath, JSON.stringify(pkg, null, 2)) // eslint-disable-next-line no-console diff --git a/npm/webpack-preprocessor/test/.eslintrc.json b/npm/webpack-preprocessor/test/.eslintrc.json deleted file mode 100644 index b5ed5206d083..000000000000 --- a/npm/webpack-preprocessor/test/.eslintrc.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": [ - "plugin:@cypress/dev/tests" - ] -} diff --git a/npm/webpack-preprocessor/test/e2e/compilation.spec.js b/npm/webpack-preprocessor/test/e2e/compilation.spec.js index 1d1816f4a43a..c085ed999630 100644 --- a/npm/webpack-preprocessor/test/e2e/compilation.spec.js +++ b/npm/webpack-preprocessor/test/e2e/compilation.spec.js @@ -52,6 +52,7 @@ describe('webpack preprocessor - e2e', () => { file = createFile() return preprocessor(options)(file).then((outputPath) => { + // eslint-disable-next-line no-restricted-syntax snapshot(fs.readFileSync(outputPath).toString()) }) }) diff --git a/npm/webpack-preprocessor/test/e2e/helpers.js b/npm/webpack-preprocessor/test/e2e/helpers.js index 621155b7f1df..12c42bf7839c 100644 --- a/npm/webpack-preprocessor/test/e2e/helpers.js +++ b/npm/webpack-preprocessor/test/e2e/helpers.js @@ -1,4 +1,4 @@ -/* eslint-disable no-console, prefer-rest-params */ +/* eslint-disable no-console */ const { codeFrameColumns } = require('@babel/code-frame') const fs = require('fs-extra') diff --git a/npm/webpack-preprocessor/test/tsconfig.json b/npm/webpack-preprocessor/test/tsconfig.json new file mode 100644 index 000000000000..c868fade2b98 --- /dev/null +++ b/npm/webpack-preprocessor/test/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../../ts/tsconfig.json", + "compilerOptions": { + "noEmit": true, + "allowJs": true, + "esModuleInterop": true + }, + "include": ["**/*"] +} \ No newline at end of file diff --git a/npm/webpack-preprocessor/test/unit/typescript-overrides.spec.ts b/npm/webpack-preprocessor/test/unit/typescript-overrides.spec.ts index 6de4166cc6c1..48f645717c50 100644 --- a/npm/webpack-preprocessor/test/unit/typescript-overrides.spec.ts +++ b/npm/webpack-preprocessor/test/unit/typescript-overrides.spec.ts @@ -1,4 +1,4 @@ -import * as sinon from 'sinon' +import sinon from 'sinon' const { expect } = require('chai') const proxyquire = require('proxyquire').noPreserveCache() diff --git a/nx.json b/nx.json index e698a49a0163..3aec702724e3 100644 --- a/nx.json +++ b/nx.json @@ -1,36 +1,24 @@ { "targetDefaults": { "lint": { - "inputs": [ - "default", - "{workspaceRoot}/.eslintrc.js" - ], + "inputs": ["default", "{workspaceRoot}/.eslintrc.js"], "cache": false }, "check-ts": { - "inputs": [ - "default", - "sharedGlobals" - ], + "inputs": ["default", "sharedGlobals"], "cache": false }, "build": { - "dependsOn": [ - "^build" - ], + "dependsOn": ["^build"], "cache": false }, "build-prod": { - "dependsOn": [ - "^build-prod" - ], + "dependsOn": ["^build-prod"], "cache": false } }, "namedInputs": { - "sharedGlobals": [ - "{workspaceRoot}/scripts" - ], + "sharedGlobals": ["{workspaceRoot}/scripts"], "default": [ "{projectRoot}/**/*", "sharedGlobals", diff --git a/package.json b/package.json index e71378a6e100..2e89beeb0e73 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,17 @@ { + "private": true, "name": "cypress", "version": "14.2.0", "description": "Cypress is a next generation front end testing tool built for the modern web", - "private": true, + "license": "MIT", + "homepage": "https://cypress.io", + "repository": { + "type": "git", + "url": "https://github.com/cypress-io/cypress.git" + }, + "bugs": { + "url": "https://github.com/cypress-io/cypress/issues" + }, "scripts": { "binary-build": "cross-env NODE_OPTIONS=--max_old_space_size=8192 node ./scripts/binary.js build", "binary-deploy": "node ./scripts/binary.js deploy", @@ -36,15 +45,15 @@ "cypress:run:debug": "node ./scripts/debug.js cypress:run", "cypress:verify": "cypress verify --dev", "dev": "gulp dev", - "dev-debug": "node ./scripts/debug.js dev", "dev:clean": "gulp dev:clean", + "dev-debug": "node ./scripts/debug.js dev", "docker": "./scripts/run-docker-local.sh", "docker-dev": "./scripts/run-docker-local.sh dev", "ensure-deps": "./scripts/ensure-dependencies.sh", "get-next-version": "node scripts/get-next-version.js", "gulp:debug": "node --inspect-brk ./node_modules/.bin/gulp", "postinstall": "node ./scripts/run-postInstall.js", - "lint": "lerna run lint --no-bail --concurrency 2", + "lint": "lerna run lint --concurrency 2", "npm-release": "node scripts/npm-release.js", "prepare": "husky install", "prepare-release-artifacts": "node ./scripts/prepare-release-artifacts.js", @@ -63,13 +72,48 @@ "test-scripts-watch": "yarn test-scripts --watch --watch-extensions 'ts,js'", "test-system": "yarn workspace @tooling/system-tests test", "pretest-unit": "yarn ensure-deps", - "test-unit": "lerna exec yarn test-unit --ignore={@packages/{driver,root,static,web-config,net-stubbing,rewriter},@cypress/{webpack-dev-server,eslint-plugin-dev}}", + "test-unit": "lerna exec yarn test-unit --ignore={@packages/{driver,root,static,web-config,net-stubbing,rewriter},@cypress/{webpack-dev-server}}", "pretest-watch": "yarn ensure-deps", "test-watch": "lerna exec yarn test-watch --ignore=@packages/{driver,root,static,web-config}", "type-check": "yarn lerna exec yarn type-check --scope=@tooling/system-tests && node scripts/type_check", "verify:mocha:results": "node ./scripts/verify-mocha-results", "watch": "yarn gulp watch" }, + "workspaces": { + "packages": [ + "cli", + "packages/*", + "npm/*", + "tooling/*", + "system-tests", + "scripts" + ], + "nohoist": [ + "**/@wdio/*", + "**/webpack-preprocessor/babel-loader", + "**/webpack-preprocessor/**/merge-source-map", + "**/webpack-preprocessor/**/patch-package", + "**/webpack-batteries-included-preprocessor/ts-loader", + "**/jest", + "**/jest*", + "**/expect" + ] + }, + "resolutions": { + "**/@types/cheerio": "0.22.21", + "**/@types/enzyme": "3.10.5", + "**/@wdio/logger": "9.0.0", + "**/jquery": "3.7.1", + "**/pretty-format": "26.4.0", + "**/sharp": "0.29.3", + "**/socket.io-parser": "4.0.5", + "**/ua-parser-js": "0.7.33", + "@types/react": "18.3.12", + "browserify-sign": "4.2.2", + "devtools-protocol": "0.0.1413303", + "sharp": "0.29.3", + "vue-template-compiler": "2.6.12" + }, "devDependencies": { "@aws-sdk/client-s3": "3.485.0", "@aws-sdk/credential-providers": "3.53.0", @@ -78,6 +122,7 @@ "@cypress/request-promise": "^5.0.0", "@electron/fuses": "1.8.0", "@electron/notarize": "^2.5.0", + "@eslint/js": "^9.18.0", "@fellow/eslint-plugin-coffee": "0.4.13", "@graphql-codegen/add": "3.1.0", "@graphql-codegen/cli": "2.2.0", @@ -87,6 +132,7 @@ "@graphql-codegen/typescript-operations": "2.2.3", "@graphql-codegen/typescript-resolvers": "^2.6.4", "@graphql-codegen/typescript-urql-graphcache": "2.2.3", + "@graphql-eslint/eslint-plugin": "^3", "@graphql-tools/delegate": "8.2.1", "@graphql-tools/utils": "8.2.3", "@graphql-tools/wrap": "8.1.1", @@ -97,12 +143,14 @@ "@reach/dialog": "0.10.5", "@semantic-release/changelog": "6.0.3", "@semantic-release/git": "10.0.1", + "@stylistic/eslint-plugin": "^2.13.0", "@types/better-sqlite3": "^7.6.3", "@types/bluebird": "3.5.29", "@types/chai-enzyme": "0.6.7", "@types/debug": "4.1.7", "@types/detect-port": "^1.3.5", "@types/enzyme-adapter-react-16": "1.0.5", + "@types/eslint-plugin-mocha": "^10.4.0", "@types/fluent-ffmpeg": "^2.1.18", "@types/fs-extra": "^9.0.13", "@types/getenv": "^1.0.0", @@ -144,21 +192,21 @@ "electron": "33.2.1", "electron-builder": "^25.1.8", "enzyme-adapter-react-16": "1.12.1", - "eslint": "^8.56.0", - "eslint-plugin-cypress": "3.5.0", - "eslint-plugin-graphql": "4.0.0", - "eslint-plugin-import": "2.25.4", - "eslint-plugin-json-format": "2.0.1", - "eslint-plugin-mocha": "8.2.0", - "eslint-plugin-react": "7.22.0", - "eslint-plugin-react-hooks": "4.2.0", - "eslint-plugin-vue": "7.18.0", + "eslint": "^9.18.0", + "eslint-import-resolver-typescript": "3.8.2", + "eslint-plugin-cypress": "^4.1.0", + "eslint-plugin-import": "2.31.0", + "eslint-plugin-import-x": "^4.6.1", + "eslint-plugin-mocha": "^10.5.0", + "eslint-plugin-react": "^7.37.4", + "eslint-plugin-vue": "^9.32.0", "execa": "4.0.0", "fast-xml-parser": "^4.5.1", "filesize": "10.1.1", "fs-extra": "9.1.0", "getenv": "^1.0.0", "glob": "7.1.6", + "globals": "^15.14.0", "graphql": "^15.5.1", "graphql-executor": "0.0.23", "gulp": "4.0.2", @@ -171,6 +219,7 @@ "husky": "7.0.2", "inquirer": "8.2.4", "inquirer-confirm": "2.0.3", + "jiti": "^2.4.2", "lazy-ass": "1.6.0", "lerna": "8.1.9", "lint-staged": "11.1.2", @@ -189,6 +238,8 @@ "patch-package": "6.4.7", "playwright-webkit": "1.24.2", "pluralize": "8.0.0", + "prettier": "^2.8.8", + "prettier-package-json": "^2.8.0", "print-arch": "1.0.0", "proxyquire": "2.1.3", "react": "18.3.1", @@ -210,32 +261,19 @@ "tree-kill": "1.2.2", "ts-node": "^10.9.2", "typescript": "5.3.3", + "typescript-eslint": "^8.20.0", "yaml": "2.7.0", "yarn-deduplicate": "3.1.0" }, - "engines": { - "node": ">=20.18.1", - "yarn": ">=1.22.22" - }, - "productName": "Cypress", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/cypress-io/cypress.git" - }, - "homepage": "https://cypress.io", - "bugs": { - "url": "https://github.com/cypress-io/cypress/issues" - }, "keywords": [ "automation", "browser", + "component", "cypress", "cypress.io", "e2e", "end-to-end", "integration", - "component", "mocks", "runner", "spies", @@ -243,44 +281,16 @@ "test", "testing" ], - "workspaces": { - "packages": [ - "cli", - "packages/*", - "npm/*", - "tooling/*", - "system-tests", - "scripts" - ], - "nohoist": [ - "**/@wdio/*", - "**/webpack-preprocessor/babel-loader", - "**/webpack-preprocessor/**/merge-source-map", - "**/webpack-preprocessor/**/patch-package", - "**/webpack-batteries-included-preprocessor/ts-loader", - "**/jest", - "**/jest*", - "**/expect" - ] + "engines": { + "node": ">=20.18.1", + "yarn": ">=1.22.22" }, "lint-staged": { "*.coffee": "yarn stop-only --folder", - "*.{js,jsx,ts,tsx,json,eslintrc,vue}": "eslint --fix", - "*workflows.yml": "node scripts/format-workflow-file.js" - }, - "resolutions": { - "**/@types/cheerio": "0.22.21", - "**/@types/enzyme": "3.10.5", - "**/jquery": "3.7.1", - "**/pretty-format": "26.4.0", - "**/sharp": "0.29.3", - "**/socket.io-parser": "4.0.5", - "**/ua-parser-js": "0.7.33", - "@types/react": "18.3.12", - "browserify-sign": "4.2.2", - "devtools-protocol": "0.0.1413303", - "sharp": "0.29.3", - "vue-template-compiler": "2.6.12" + "*.{js,jsx,ts,tsx,eslintrc,vue}": "eslint --fix", + "*.json": "prettier --write", + "package.json": "prettier-package-json --write" }, - "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" + "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e", + "productName": "Cypress" } diff --git a/packages/app/.eslintignore b/packages/app/.eslintignore deleted file mode 100644 index 0a4f19fad609..000000000000 --- a/packages/app/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/dist -**/dist-* -**/*.d.ts -**/package-lock.json -**/tsconfig.json -**/cypress/fixtures -/src/store/mobx-runner-store.ts \ No newline at end of file diff --git a/packages/app/.eslintrc.json b/packages/app/.eslintrc.json deleted file mode 100644 index 6eeb52459992..000000000000 --- a/packages/app/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "../frontend-shared/.eslintrc.json" -} diff --git a/packages/app/cypress/e2e/run-all-specs.cy.ts b/packages/app/cypress/e2e/run-all-specs.cy.ts index d5f17c82eb23..a1e6f827335b 100644 --- a/packages/app/cypress/e2e/run-all-specs.cy.ts +++ b/packages/app/cypress/e2e/run-all-specs.cy.ts @@ -18,6 +18,7 @@ describe('run-all-specs', () => { return cy.findByTestId('run-all-specs-for-all').click() } + // eslint-disable cypress/no-assigning-return-values const command = cy.get('[data-cy=spec-item-directory]').contains(platformDir) return command.realHover().then(() => { diff --git a/packages/app/cypress/e2e/runner/reporter-ct-mount-hover.cy.ts b/packages/app/cypress/e2e/runner/reporter-ct-mount-hover.cy.ts index ded41c185eeb..7ae3afd18417 100644 --- a/packages/app/cypress/e2e/runner/reporter-ct-mount-hover.cy.ts +++ b/packages/app/cypress/e2e/runner/reporter-ct-mount-hover.cy.ts @@ -2,7 +2,7 @@ import type { fixtureDirs } from '@tooling/system-tests' type ProjectDirs = typeof fixtureDirs -const PROJECTS: {projectName: ProjectDirs[number], test: string}[] = [ +const PROJECTS: { projectName: ProjectDirs[number], test: string }[] = [ { projectName: 'angular-19', test: 'app.component' }, { projectName: 'react-vite-ts-configured', test: 'App.cy' }, { projectName: 'react18', test: 'App.cy' }, diff --git a/packages/app/cypress/e2e/runner/runner-ct.justInTimeCompile.cy.ts b/packages/app/cypress/e2e/runner/runner-ct.justInTimeCompile.cy.ts index 1e003516c0e7..6cab0b46132a 100644 --- a/packages/app/cypress/e2e/runner/runner-ct.justInTimeCompile.cy.ts +++ b/packages/app/cypress/e2e/runner/runner-ct.justInTimeCompile.cy.ts @@ -4,7 +4,7 @@ type ProjectDirs = typeof fixtureDirs const JIT_DIR: ProjectDirs[number] = 'justInTimeCompile' -const PROJECTS: {bundler: 'vite' | 'webpack'}[] = [ +const PROJECTS: { bundler: 'vite' | 'webpack' }[] = [ // when running for vite, justInTimeCompile=true is set but is a no-op for vite since JIT compiling is not supported in vite { bundler: 'vite' }, { bundler: 'webpack' }, diff --git a/packages/app/cypress/e2e/specs_list_actual_git_repo.cy.ts b/packages/app/cypress/e2e/specs_list_actual_git_repo.cy.ts index 593db486e42b..7fcc362c59ce 100644 --- a/packages/app/cypress/e2e/specs_list_actual_git_repo.cy.ts +++ b/packages/app/cypress/e2e/specs_list_actual_git_repo.cy.ts @@ -54,6 +54,7 @@ describe('Spec List - Last updated with git info', () => { .trigger('mouseleave') cy.withCtx((ctx) => { + // eslint-disable-next-line no-restricted-syntax ctx.fs.appendFileSync( ctx.path.join(ctx.currentProject!, 'cypress', 'e2e', 'dom-container.spec.js'), '// modifying the spec.', @@ -74,6 +75,7 @@ describe('Spec List - Last updated with git info', () => { .trigger('mouseleave') cy.withCtx((ctx) => { + // eslint-disable-next-line no-restricted-syntax ctx.fs.appendFileSync( ctx.path.join(ctx.currentProject!, 'cypress', 'e2e', 'foo.spec.js'), '// modifying the spec.', diff --git a/packages/app/cypress/e2e/specs_list_latest_runs.cy.ts b/packages/app/cypress/e2e/specs_list_latest_runs.cy.ts index 80923b676e9a..ca7753a40fdf 100644 --- a/packages/app/cypress/e2e/specs_list_latest_runs.cy.ts +++ b/packages/app/cypress/e2e/specs_list_latest_runs.cy.ts @@ -5,7 +5,7 @@ function specRowSelector (specFileName: string) { return `[data-cy-row="${specFileName}"]` } -function dotSelector (specFileName: string, dotNumber: 0 | 1 | 2 |'latest') { +function dotSelector (specFileName: string, dotNumber: 0 | 1 | 2 | 'latest') { return `${specRowSelector(specFileName)} [data-cy="run-status-dot-${dotNumber}"]` } @@ -44,10 +44,10 @@ function validateTooltip (status: string) { }) } -function specShouldShow (specFileName: string, runDotsClasses: string[], latestRunStatus: CloudRunStatus|'PLACEHOLDER') { +function specShouldShow (specFileName: string, runDotsClasses: string[], latestRunStatus: CloudRunStatus | 'PLACEHOLDER') { const latestStatusSpinning = latestRunStatus === 'RUNNING' - type dotIndex = Parameters[1]; + type dotIndex = Parameters[1] const indexes: Exclude[] = [0, 1, 2] indexes.forEach((i) => { diff --git a/packages/app/cypress/e2e/specs_list_no_git_repo.cy.ts b/packages/app/cypress/e2e/specs_list_no_git_repo.cy.ts index 7a9e55c0f682..0107c00b9bc1 100644 --- a/packages/app/cypress/e2e/specs_list_no_git_repo.cy.ts +++ b/packages/app/cypress/e2e/specs_list_no_git_repo.cy.ts @@ -13,6 +13,7 @@ describe('Spec List - Last updated with no git info', () => { .should('not.exist') cy.withCtx((ctx) => { + // eslint-disable-next-line no-restricted-syntax ctx.fs.appendFileSync( ctx.path.join(ctx.currentProject!, 'cypress', 'e2e', 'blank-contents.spec.js'), '// touching the spec.', diff --git a/packages/app/cypress/tasks/git.ts b/packages/app/cypress/tasks/git.ts index 9500c47a6108..b283fceea721 100644 --- a/packages/app/cypress/tasks/git.ts +++ b/packages/app/cypress/tasks/git.ts @@ -14,6 +14,7 @@ export async function initGitRepoForTestProject (projectPath: string) { } const e2eFolder = path.join(projectPath, 'cypress', 'e2e') + // eslint-disable-next-line no-restricted-syntax const allSpecs = fs.readdirSync(e2eFolder) await git.init() @@ -25,7 +26,9 @@ export async function initGitRepoForTestProject (projectPath: string) { const fooSpec = path.join(e2eFolder, 'foo.spec.js') const blankContentsSpec = path.join(e2eFolder, 'blank-contents.spec.js') + // eslint-disable-next-line no-restricted-syntax fs.createFileSync(fooSpec) + // eslint-disable-next-line no-restricted-syntax fs.writeFileSync(blankContentsSpec, 'it(\'modifies the file\', () => {})') return null diff --git a/packages/app/cypress/tasks/mochaEvents.ts b/packages/app/cypress/tasks/mochaEvents.ts index 99d6598e05d4..1da7c0f43c2b 100644 --- a/packages/app/cypress/tasks/mochaEvents.ts +++ b/packages/app/cypress/tasks/mochaEvents.ts @@ -6,7 +6,9 @@ const snapshotFile = (filename: string) => path.join(__dirname, '..', 'e2e', 'ru export const writeMochaEventSnapshot = ({ filename, snapshots }) => { const jsonFile = snapshotFile(filename) + // eslint-disable-next-line no-restricted-syntax fs.ensureFileSync(jsonFile) + // eslint-disable-next-line no-restricted-syntax fs.writeFileSync(jsonFile, JSON.stringify(snapshots, null, 2)) return null @@ -19,5 +21,6 @@ export const readMochaEventSnapshot = ({ filename }) => { return null } + // eslint-disable-next-line no-restricted-syntax return fs.readJsonSync(jsonFile) } diff --git a/packages/app/cypress/tsconfig.json b/packages/app/cypress/tsconfig.json new file mode 100644 index 000000000000..8a588d18f5ce --- /dev/null +++ b/packages/app/cypress/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "types": ["cypress"], + "allowJs": true, + }, + "include": ["**/*"] +} diff --git a/packages/app/eslint.config.ts b/packages/app/eslint.config.ts new file mode 100644 index 000000000000..1b6c347d7d02 --- /dev/null +++ b/packages/app/eslint.config.ts @@ -0,0 +1,57 @@ +import baseConfig from '@tooling/eslint-config' +import globals from 'globals' +import react from 'eslint-plugin-react' + +export default [ + ...baseConfig, + + { + languageOptions: { + parserOptions: { + projectService: { + allowDefaultProject: ['*.config.{ts,js,cjs,mjs}'], + }, + }, + }, + }, + + { + files: ['**/*.{tsx,jsx,vue,ts,js'], + languageOptions: { + globals: { + ...globals.browser, + }, + }, + }, + { + files: ['vite.config.mjs'], + languageOptions: { + globals: { + ...globals.node, + }, + }, + }, + + // {cy,spec}.tsx files in the src/ dir are component tests, + // and since the components that are being rendered are vue + // components and not react components, react rules do not apply. + { + files: ['src/**/*.{spec,cy}.tsx'], + rules: { + ...Object.keys(react.configs.flat.recommended.rules).reduce((rules, rule) => { + return { + ...rules, + [rule]: 'off', + } + }, {}), + 'react/no-unknown-property': 'off', + }, + }, + + { + rules: { + // TODO: configure import-x so that it doesn't error on importing svg, css, etc + 'import-x/no-unresolved': 'warn', + }, + }, +] diff --git a/packages/app/index.d.ts b/packages/app/index.d.ts index 09b67d94269b..8186987427f9 100644 --- a/packages/app/index.d.ts +++ b/packages/app/index.d.ts @@ -1,6 +1,7 @@ /// import type { SocketShape } from '@packages/socket/lib/types' +// eslint-disable-next-line import-x/default import type MobX from 'mobx' import type { EventManager } from './src/runner/event-manager' diff --git a/packages/app/package.json b/packages/app/package.json index 24f6eae7e04f..8840bc27e046 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "build": "vite build", - "check-ts": "vue-tsc --noEmit && yarn -s tslint", + "check-ts": "vue-tsc --noEmit", "clean": "rimraf dist && echo 'cleaned'", "clean-deps": "rimraf node_modules", "cypress:launch": "yarn cypress:run-cypress-in-cypress gulp open --project .", @@ -14,10 +14,9 @@ "cypress:run:e2e": "yarn cypress:run-cypress-in-cypress node ../../scripts/cypress run --project .", "cypress:run:e2e:update:snapshots": "CYPRESS_SNAPSHOT_UPDATE=1 yarn cypress:run-cypress-in-cypress node ../../scripts/cypress run --project . --spec **/*mochaEvents* --browser chrome", "dev": "yarn cypress:run-cypress-in-cypress gulp dev --project .", - "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .", + "lint": "eslint .", "start": "echo \"run 'yarn dev' or 'yarn watch' from the root\" && exit 1", "test": "echo 'ok'", - "tslint": "tslint --config ../ts/tslint.json --project . --exclude ./src/router/router.ts, *.gen.ts", "watch": "echo \"run 'yarn dev' or 'yarn watch' from the root\" && exit 1" }, "dependencies": {}, diff --git a/packages/app/src/components/FileMatch.cy.tsx b/packages/app/src/components/FileMatch.cy.tsx index 1a0dff3843be..ac882116fd71 100644 --- a/packages/app/src/components/FileMatch.cy.tsx +++ b/packages/app/src/components/FileMatch.cy.tsx @@ -156,7 +156,7 @@ describe('', { viewportWidth: 600, viewportHeight: 300 }, () => { /*---------- Fixtures ----------*/ // Matches const total = 10 - const matchesData: Record = { + const matchesData: Record = { all: [ { matches: { found: 10, total } }, '10 matches', diff --git a/packages/app/src/composables/useTestingType.cy.tsx b/packages/app/src/composables/useTestingType.cy.tsx index aee4f5fe0509..605cf21784a5 100644 --- a/packages/app/src/composables/useTestingType.cy.tsx +++ b/packages/app/src/composables/useTestingType.cy.tsx @@ -5,7 +5,7 @@ import type { FunctionalComponent } from 'vue' describe('useTestingType', () => { type ComposableWrapperProps = { useComposable: () => R, callback: (result: R) => void } - const ComposableWrapper: FunctionalComponent> = ({ useComposable, callback }: ComposableWrapperProps) => { + const ComposableWrapper: FunctionalComponent> = ({ useComposable, callback }: ComposableWrapperProps) => { const result = useComposable() callback(result) diff --git a/packages/app/src/debug/DebugArtifactLink.cy.tsx b/packages/app/src/debug/DebugArtifactLink.cy.tsx index c6f3732fead0..a9c74eac428b 100644 --- a/packages/app/src/debug/DebugArtifactLink.cy.tsx +++ b/packages/app/src/debug/DebugArtifactLink.cy.tsx @@ -2,7 +2,7 @@ import DebugArtifactLink from './DebugArtifactLink.vue' import type { ArtifactType } from './utils/debugArtifacts' describe('', () => { - const artifactMapping: {icon: ArtifactType, text: string, url: string}[] = [ + const artifactMapping: { icon: ArtifactType, text: string, url: string }[] = [ { icon: 'TERMINAL_LOG', text: 'View Log', url: 'www.cypress.io' }, { icon: 'IMAGE_SCREENSHOT', text: 'View Screenshot', url: 'cloud.cypress.io' }, { icon: 'PLAY', text: 'View Video', url: 'www.cypress.io' }, diff --git a/packages/app/src/debug/DebugRunNavigation.vue b/packages/app/src/debug/DebugRunNavigation.vue index 7bd9be4e92d2..c18fd07ddef1 100644 --- a/packages/app/src/debug/DebugRunNavigation.vue +++ b/packages/app/src/debug/DebugRunNavigation.vue @@ -237,7 +237,7 @@ const groupByCommit = computed(() => { mapped[props.currentCommitInfo.sha] = props.currentCommitInfo } - const result = Object.keys(grouped).reduce>((acc, curr) => { + const result = Object.keys(grouped).reduce>((acc, curr) => { acc[curr] = { sha: curr, message: grouped[curr][0].commitInfo?.summary, diff --git a/packages/app/src/debug/DebugSpec.cy.tsx b/packages/app/src/debug/DebugSpec.cy.tsx index 3efb8dfb926d..140f3ae22b24 100644 --- a/packages/app/src/debug/DebugSpec.cy.tsx +++ b/packages/app/src/debug/DebugSpec.cy.tsx @@ -9,7 +9,7 @@ const resultCounts = (min: number, max: number) => { } } -const multipleGroups: {[groupId: string]: any} = { +const multipleGroups: { [groupId: string]: any } = { '123': { os: { name: 'Linux', @@ -36,7 +36,7 @@ const multipleGroups: {[groupId: string]: any} = { }, } -const singleGroup: {[groupId: string]: any} = { +const singleGroup: { [groupId: string]: any } = { '123': { os: { name: 'Linux', @@ -51,7 +51,7 @@ const singleGroup: {[groupId: string]: any} = { }, } -const testResultMultipleGroups: {[thumbprint: string]: TestResults[]} = { +const testResultMultipleGroups: { [thumbprint: string]: TestResults[] } = { 'abcd': [ { id: '676df87878', @@ -124,7 +124,7 @@ const testResultMultipleGroups: {[thumbprint: string]: TestResults[]} = { ], } -const testResultSingleGroup: {[thumbprint: string]: TestResults[]} = { +const testResultSingleGroup: { [thumbprint: string]: TestResults[] } = { 'abcd': [ { id: '676df87878', @@ -271,7 +271,7 @@ describe(' responsive UI', () => { }, } - const testResult: {[thumbprint: string]: TestResults[]} = { + const testResult: { [thumbprint: string]: TestResults[] } = { 'abcd': [ { id: '676df87878', @@ -379,7 +379,7 @@ describe('testing groupings', () => { }, } - const repeatedValueGroups: {[groupId: string]: any} = { + const repeatedValueGroups: { [groupId: string]: any } = { '456': { os: { name: 'Apple', @@ -406,7 +406,7 @@ describe('testing groupings', () => { }, } - const tests: {[thumbprint: string]: TestResults[]} = { + const tests: { [thumbprint: string]: TestResults[] } = { 'abcd': [ { id: '676df87878', diff --git a/packages/app/src/debug/DebugSpec.vue b/packages/app/src/debug/DebugSpec.vue index 61aa90af937a..df0ba94ce398 100644 --- a/packages/app/src/debug/DebugSpec.vue +++ b/packages/app/src/debug/DebugSpec.vue @@ -256,8 +256,8 @@ const { t } = useI18n() const props = defineProps<{ spec: Spec - testResults: {[thumbprint: string]: TestResults[]} - groups: {[groupId: string]: StatsMetadata_GroupsFragment } + testResults: { [thumbprint: string]: TestResults[] } + groups: { [groupId: string]: StatsMetadata_GroupsFragment } testingType: TestingTypeEnum foundLocally: boolean matchesCurrentTestingType: boolean diff --git a/packages/app/src/debug/GroupedDebugFailedTest.vue b/packages/app/src/debug/GroupedDebugFailedTest.vue index c19df850a6a2..97fbbd4562b1 100644 --- a/packages/app/src/debug/GroupedDebugFailedTest.vue +++ b/packages/app/src/debug/GroupedDebugFailedTest.vue @@ -53,7 +53,7 @@ const props = defineProps<{ const { t } = useI18n() const debugArtifacts = computed(() => { - return props.failedTests.reduce<{[groupID: string]: DebugArtifact[] }>((acc, curr) => { + return props.failedTests.reduce<{ [groupID: string]: DebugArtifact[] }>((acc, curr) => { acc[curr.instance?.groupId ?? ''] = getDebugArtifacts(curr.instance, t) return acc diff --git a/packages/app/src/debug/StatsMetadata.vue b/packages/app/src/debug/StatsMetadata.vue index c61edb1db0be..6903db67c738 100644 --- a/packages/app/src/debug/StatsMetadata.vue +++ b/packages/app/src/debug/StatsMetadata.vue @@ -127,7 +127,7 @@ const results = computed(() => { }) const arrMapping = computed(() => { - const acc: {browsers: string[], oses: string[], firstBrowser: string, firstOs: string} = { browsers: [], oses: [], firstBrowser: '', firstOs: '' } + const acc: { browsers: string[], oses: string[], firstBrowser: string, firstOs: string } = { browsers: [], oses: [], firstBrowser: '', firstOs: '' } const uniqueBrowsers = new Set() const uniqueOSes = new Set() diff --git a/packages/app/src/debug/utils/DebugMapping.ts b/packages/app/src/debug/utils/DebugMapping.ts index cbd8627dd6f9..996ffd7121cb 100644 --- a/packages/app/src/debug/utils/DebugMapping.ts +++ b/packages/app/src/debug/utils/DebugMapping.ts @@ -20,9 +20,9 @@ export type CloudDebugSpec = { export const specsList = ({ specs, tests, localSpecs, currentTestingType, groups }: DebugSpecsArgs): CloudDebugSpec[] => { const localSpecsSet = new Set(localSpecs.map(((spec) => posixify(spec.relative)))) - const groupsMap = groups.reduce<{[id: string]: DebugSpecListGroupsFragment}>((acc, group) => ({ ...acc, [group.id]: group }), {}) + const groupsMap = groups.reduce<{ [id: string]: DebugSpecListGroupsFragment }>((acc, group) => ({ ...acc, [group.id]: group }), {}) - const mappedTests = tests.reduce<{[id: string]: CloudDebugSpec}>((acc, curr) => { + const mappedTests = tests.reduce<{ [id: string]: CloudDebugSpec }>((acc, curr) => { let debugResult = acc[curr.specId] if (!debugResult) { @@ -34,7 +34,7 @@ export const specsList = ({ specs, tests, localSpecs, currentTestingType, groups throw new Error(`Could not find spec for id ${ curr.specId}`) } - const groupsMapping = (foundSpec.groupIds || []).reduce<{[grpId: string]: DebugSpecListGroupsFragment}>((acc, id) => { + const groupsMapping = (foundSpec.groupIds || []).reduce<{ [grpId: string]: DebugSpecListGroupsFragment }>((acc, id) => { if (id) { acc[id] = groupsMap[id] } diff --git a/packages/app/src/navigation/SidebarNavigation.cy.tsx b/packages/app/src/navigation/SidebarNavigation.cy.tsx index a4f21b3ceed6..7fbfba68e46c 100644 --- a/packages/app/src/navigation/SidebarNavigation.cy.tsx +++ b/packages/app/src/navigation/SidebarNavigation.cy.tsx @@ -6,7 +6,7 @@ import { CloudRunStubs } from '@packages/graphql/test/stubCloudTypes' import { cloneDeep } from 'lodash' import { useUserProjectStatusStore } from '@packages/frontend-shared/src/store/user-project-status-store' -function mountComponent (props: { initialNavExpandedVal?: boolean, cloudProject?: { status: CloudRunStatus, numFailedTests: number }, latestCloudProject?: { status: CloudRunStatus, numFailedTests: number }, isLoading?: boolean, online?: boolean} = {}) { +function mountComponent (props: { initialNavExpandedVal?: boolean, cloudProject?: { status: CloudRunStatus, numFailedTests: number }, latestCloudProject?: { status: CloudRunStatus, numFailedTests: number }, isLoading?: boolean, online?: boolean } = {}) { const withDefaults = { initialNavExpandedVal: false, isLoading: false, online: true, ...props } let _gql: SidebarNavigationFragment diff --git a/packages/app/src/pages/Debug.vue b/packages/app/src/pages/Debug.vue index 960792e4c63d..d09971152ecf 100644 --- a/packages/app/src/pages/Debug.vue +++ b/packages/app/src/pages/Debug.vue @@ -36,7 +36,7 @@ subscription Debug_specsChange { } ` -gql ` +gql` query Debug($runNumber: Int!, $commitShas: [String!]!) { ...DebugSpecs } diff --git a/packages/app/src/paths.ts b/packages/app/src/paths.ts index 1c889ca8fbf1..39010723e441 100644 --- a/packages/app/src/paths.ts +++ b/packages/app/src/paths.ts @@ -1,9 +1,8 @@ -/* eslint-disable no-redeclare */ import { decodeBase64Unicode } from '@packages/frontend-shared/src/utils/base64' -export function getPathForPlatform(): null +export function getPathForPlatform (): null -export function getPathForPlatform(posixPath: string): string +export function getPathForPlatform (posixPath: string): string export function getPathForPlatform (posixPath?: string) { if (!posixPath) { diff --git a/packages/app/src/runner/ResizablePanels.vue b/packages/app/src/runner/ResizablePanels.vue index fbdd2db6094f..5eff362abf63 100644 --- a/packages/app/src/runner/ResizablePanels.vue +++ b/packages/app/src/runner/ResizablePanels.vue @@ -106,7 +106,7 @@ const props = withDefaults(defineProps<{ const emit = defineEmits<{ (e: 'resizeEnd', value: DraggablePanel): void - (e: 'panelWidthUpdated', value: {panel: DraggablePanel, width: number}): void + (e: 'panelWidthUpdated', value: { panel: DraggablePanel, width: number }): void }>() const panel1HandleX = ref(props.initialPanel1Width) diff --git a/packages/app/src/runner/aut-iframe.ts b/packages/app/src/runner/aut-iframe.ts index c73aff2da0a3..e52debb2cbb9 100644 --- a/packages/app/src/runner/aut-iframe.ts +++ b/packages/app/src/runner/aut-iframe.ts @@ -2,7 +2,7 @@ import { useSelectorPlaygroundStore } from '../store/selector-playground-store' import { blankContents } from '../components/Blank' import { logger } from './logger' import _ from 'lodash' -/* eslint-disable no-duplicate-imports */ + import type { DebouncedFunc } from 'lodash' import { useStudioStore } from '../store/studio-store' import { getElementDimensions, setOffset } from './dimensions' diff --git a/packages/app/src/runner/event-manager.ts b/packages/app/src/runner/event-manager.ts index 172b316dadc3..b8e8d6261d73 100644 --- a/packages/app/src/runner/event-manager.ts +++ b/packages/app/src/runner/event-manager.ts @@ -1,4 +1,3 @@ -/* eslint-disable no-dupe-class-members */ import Bluebird from 'bluebird' import { EventEmitter } from 'events' import type { MobxRunnerStore } from '../store/mobx-runner-store' @@ -32,7 +31,7 @@ let crossOriginOnMessageRef = ({ data, source }: MessageEvent<{ }>) => { return undefined } -let crossOriginLogs: {[key: string]: Cypress.Log} = {} +let crossOriginLogs: { [key: string]: Cypress.Log } = {} let hasMochaRunEnded: boolean = false interface AddGlobalListenerOptions { diff --git a/packages/app/src/runner/events/capture-protocol.ts b/packages/app/src/runner/events/capture-protocol.ts index f03576969b64..82fa1d6e1647 100644 --- a/packages/app/src/runner/events/capture-protocol.ts +++ b/packages/app/src/runner/events/capture-protocol.ts @@ -1,5 +1,5 @@ type ProtocolInfo = { - type: 'cy:protocol-snapshot' | 'log:added' | 'log:changed' | 'page:loading'| 'test:before:run:async' | 'test:before:after:run:async' | 'test:after:run:async' | 'url:changed' | 'viewport:changed' + type: 'cy:protocol-snapshot' | 'log:added' | 'log:changed' | 'page:loading' | 'test:before:run:async' | 'test:before:after:run:async' | 'test:after:run:async' | 'url:changed' | 'viewport:changed' timestamp: DOMHighResTimeStamp } diff --git a/packages/app/src/runner/studio/AssertionsMenu.ce.vue b/packages/app/src/runner/studio/AssertionsMenu.ce.vue index 6ce79f6b9602..e7fc86e74c1e 100644 --- a/packages/app/src/runner/studio/AssertionsMenu.ce.vue +++ b/packages/app/src/runner/studio/AssertionsMenu.ce.vue @@ -52,6 +52,7 @@ import { nextTick, onMounted, Ref, ref, StyleValue } from 'vue' import type { PossibleAssertions, AddAssertion, AssertionArgs } from './types' const props = defineProps <{ + // eslint-disable-next-line no-undef jqueryElement: JQuery possibleAssertions: PossibleAssertions addAssertion: AddAssertion diff --git a/packages/app/src/runs/RunCard.vue b/packages/app/src/runs/RunCard.vue index 1dac4f95d8a6..6e1007d4ebd3 100644 --- a/packages/app/src/runs/RunCard.vue +++ b/packages/app/src/runs/RunCard.vue @@ -162,9 +162,9 @@ const { t } = useI18n() gql` fragment RunCard on CloudRun { - id - createdAt - status + id + createdAt + status totalDuration url runNumber @@ -172,14 +172,14 @@ fragment RunCard on CloudRun { id name } - ...RunResults - commitInfo { - authorName - authorEmail - summary - branch - sha - } + ...RunResults + commitInfo { + authorName + authorEmail + summary + branch + sha + } } ` diff --git a/packages/app/src/runs/RunsLayout.vue b/packages/app/src/runs/RunsLayout.vue index f944d4419690..3fe63d7ba334 100644 --- a/packages/app/src/runs/RunsLayout.vue +++ b/packages/app/src/runs/RunsLayout.vue @@ -141,7 +141,7 @@ const groupByCommit = computed(() => { mapped[props.currentCommitInfo.sha] = props.currentCommitInfo } - const result = Object.keys(grouped).reduce>((acc, curr) => { + const result = Object.keys(grouped).reduce>((acc, curr) => { acc[curr] = { sha: curr, message: grouped[curr][0].commitInfo?.summary, diff --git a/packages/app/src/runs/useGitTreeRuns.ts b/packages/app/src/runs/useGitTreeRuns.ts index 5a4eb6ff919f..430afcfadff8 100644 --- a/packages/app/src/runs/useGitTreeRuns.ts +++ b/packages/app/src/runs/useGitTreeRuns.ts @@ -10,7 +10,7 @@ gql` } ` -gql ` +gql` fragment RunsGitTreeProject on Query { ...RunsErrorRenderer currentProject { diff --git a/packages/app/src/settings/project/projectSettings.ts b/packages/app/src/settings/project/projectSettings.ts index 317d5cc33bc7..8e9b443576b2 100644 --- a/packages/app/src/settings/project/projectSettings.ts +++ b/packages/app/src/settings/project/projectSettings.ts @@ -17,6 +17,6 @@ export interface Experiment { export type CypressResolvedConfig = Array<{ field: string - from: 'default'| 'config' | 'plugin' | 'env' + from: 'default' | 'config' | 'plugin' | 'env' value: string | number | boolean | Record | Array }> diff --git a/packages/app/src/settings/project/renderers/RenderPrimitive.vue b/packages/app/src/settings/project/renderers/RenderPrimitive.vue index 2bc9a6f89026..852ca834cb70 100644 --- a/packages/app/src/settings/project/renderers/RenderPrimitive.vue +++ b/packages/app/src/settings/project/renderers/RenderPrimitive.vue @@ -20,7 +20,7 @@ import Tooltip from '@packages/frontend-shared/src/components/Tooltip.vue' import { computed } from 'vue' const props = defineProps<{ - value?: string | number| null + value?: string | number | null from: string class?: string }>() diff --git a/packages/app/src/settings/project/renderers/RendererPrimitive.cy.tsx b/packages/app/src/settings/project/renderers/RendererPrimitive.cy.tsx index c2badda615ec..e0e91427b791 100644 --- a/packages/app/src/settings/project/renderers/RendererPrimitive.cy.tsx +++ b/packages/app/src/settings/project/renderers/RendererPrimitive.cy.tsx @@ -1,7 +1,7 @@ import { CONFIG_LEGEND_COLOR_MAP } from '../ConfigSourceColors' import RenderPrimitive from './RenderPrimitive.vue' -function mountWithPrimitive (value: string| number | null, from: string) { +function mountWithPrimitive (value: string | number | null, from: string) { cy.mount(() => { return (
diff --git a/packages/app/src/specs/HighlightedText.vue b/packages/app/src/specs/HighlightedText.vue index 020bc67fef4a..9e4809992a24 100644 --- a/packages/app/src/specs/HighlightedText.vue +++ b/packages/app/src/specs/HighlightedText.vue @@ -21,7 +21,7 @@ import { computed } from 'vue' const props = withDefaults( - defineProps<{text: string, indexes: number[], highlightClasses?: string}>(), + defineProps<{ text: string, indexes: number[], highlightClasses?: string }>(), { text: '', indexes: () => [], highlightClasses: 'text-white' }, ) diff --git a/packages/app/src/specs/InlineSpecList.cy.tsx b/packages/app/src/specs/InlineSpecList.cy.tsx index a7c1965bb09f..bd1ce33ab623 100644 --- a/packages/app/src/specs/InlineSpecList.cy.tsx +++ b/packages/app/src/specs/InlineSpecList.cy.tsx @@ -6,7 +6,7 @@ import { defaultMessages } from '@cy/i18n' let specs: Array = [] describe('InlineSpecList', () => { - const mountInlineSpecList = ({ specFilter, experimentalRunAllSpecs }: {specFilter?: string, experimentalRunAllSpecs?: boolean} = {}) => cy.mountFragment(Specs_InlineSpecListFragmentDoc, { + const mountInlineSpecList = ({ specFilter, experimentalRunAllSpecs }: { specFilter?: string, experimentalRunAllSpecs?: boolean } = {}) => cy.mountFragment(Specs_InlineSpecListFragmentDoc, { onResult: (ctx) => { if (!ctx.currentProject?.specs) { return ctx diff --git a/packages/app/src/specs/InlineSpecListHeader.cy.tsx b/packages/app/src/specs/InlineSpecListHeader.cy.tsx index b59f7622aa84..4dbc531d41e6 100644 --- a/packages/app/src/specs/InlineSpecListHeader.cy.tsx +++ b/packages/app/src/specs/InlineSpecListHeader.cy.tsx @@ -5,7 +5,7 @@ import { defaultMessages } from '@cy/i18n' import { defineStore } from 'pinia' describe('InlineSpecListHeader', () => { - const mountWithProps = (props: {resultCount?: number, isRunAllSpecsAllowed?: boolean} = {}) => { + const mountWithProps = (props: { resultCount?: number, isRunAllSpecsAllowed?: boolean } = {}) => { const specFilterModel = ref('') const propsWithDefaults = { diff --git a/packages/app/src/specs/SpecsListRunWatcher.vue b/packages/app/src/specs/SpecsListRunWatcher.vue index eef02c194e9d..aa99491000e9 100644 --- a/packages/app/src/specs/SpecsListRunWatcher.vue +++ b/packages/app/src/specs/SpecsListRunWatcher.vue @@ -26,7 +26,7 @@ subscription SpecsListRunWatcher($id: ID!) { ` const props = defineProps<{ - run: {runId: string, status: CloudRunStatus | null } + run: { runId: string, status: CloudRunStatus | null } }>() const emits = defineEmits<{ diff --git a/packages/app/src/specs/generators/ExpandableFileChooser.vue b/packages/app/src/specs/generators/ExpandableFileChooser.vue index 2618152a5cc5..6c68abc3e7e0 100644 --- a/packages/app/src/specs/generators/ExpandableFileChooser.vue +++ b/packages/app/src/specs/generators/ExpandableFileChooser.vue @@ -98,7 +98,6 @@ const emits = defineEmits<{ (eventName: 'update:extensionPattern', value: string) }>() -// eslint-disable-next-line const initialExtensionPattern = props.extensionPattern const localExtensionPattern = ref(props.extensionPattern) const filePathSearch = ref('') diff --git a/packages/app/src/specs/generators/ExpandableFileList.vue b/packages/app/src/specs/generators/ExpandableFileList.vue index afec6a6f5c67..152be57ad4e2 100644 --- a/packages/app/src/specs/generators/ExpandableFileList.vue +++ b/packages/app/src/specs/generators/ExpandableFileList.vue @@ -70,7 +70,7 @@ defineProps<{ }>() defineEmits<{ - (eventName: 'selectItem', value: {file: FileListItemFragment, item: any}) + (eventName: 'selectItem', value: { file: FileListItemFragment, item: any }) }>() // [...all].vue returns as [ when using the normal fileName diff --git a/packages/app/src/specs/generators/FileChooser.vue b/packages/app/src/specs/generators/FileChooser.vue index 796527ade2cf..1ff279623fc1 100644 --- a/packages/app/src/specs/generators/FileChooser.vue +++ b/packages/app/src/specs/generators/FileChooser.vue @@ -99,7 +99,6 @@ const emits = defineEmits<{ (eventName: 'update:extensionPattern', value: string) }>() -// eslint-disable-next-line const initialExtensionPattern = props.extensionPattern const localExtensionPattern = ref(props.extensionPattern) const filePathSearch = ref('') diff --git a/packages/app/src/specs/spec-utils.ts b/packages/app/src/specs/spec-utils.ts index 8ead50a2c436..e9f7fc8cf2cd 100644 --- a/packages/app/src/specs/spec-utils.ts +++ b/packages/app/src/specs/spec-utils.ts @@ -4,7 +4,7 @@ import { ComputedRef, Ref, ref, watch } from 'vue' import _ from 'lodash' import { FuzzyFoundSpec, getPlatform } from './tree/useCollapsibleTree' -export function fuzzySortSpecs (specs: T[], searchValue: string) { +export function fuzzySortSpecs (specs: T[], searchValue: string) { const normalizedSearchValue = normalizeSpecValue(searchValue) const fuzzySortResult = fuzzySort diff --git a/packages/app/src/specs/tree/useCollapsibleTree.ts b/packages/app/src/specs/tree/useCollapsibleTree.ts index 7770c70164ad..ab67a7c3876c 100644 --- a/packages/app/src/specs/tree/useCollapsibleTree.ts +++ b/packages/app/src/specs/tree/useCollapsibleTree.ts @@ -4,7 +4,7 @@ import { useToggle } from '@vueuse/core' import type { FoundSpec } from '@packages/types/src' import { getRunnerConfigFromWindow } from '../../runner/get-runner-config-from-window' -export type RawNode = { +export type RawNode = { id: string name: string children: RawNode[] @@ -62,7 +62,7 @@ export function buildSpecTree (specs: FoundSpec[], root: Sp // - components // - index.ts // tree (given that src/comp is not collapsed) -function getHighlightIndexes (node: SpecTreeNode) { +function getHighlightIndexes (node: SpecTreeNode) { if (!(node.data as any)?.fuzzyIndexes) { return [] } @@ -135,7 +135,7 @@ function collapseEmptyChildren (node: SpecTreeNode) { return } -export type UseCollapsibleTreeNode > = { +export type UseCollapsibleTreeNode> = { // control open/close state hidden: ComputedRef expanded: Ref @@ -146,7 +146,7 @@ export type UseCollapsibleTreeNode > = { parent?: UseCollapsibleTreeNode children: UseCollapsibleTreeNode[] -} & { [K in keyof T]: T[K]} +} & { [K in keyof T]: T[K] } export interface UseCollapsibleTreeOptions { expandInitially?: boolean @@ -246,7 +246,7 @@ function sortTree> (tree: T) { } } -export function useCollapsibleTree > (tree: T, options: UseCollapsibleTreeOptions = {}) { +export function useCollapsibleTree> (tree: T, options: UseCollapsibleTreeOptions = {}) { options.expandInitially = options.expandInitially ?? true sortTree(tree) const collapsibleTree = buildTree(tree, options) diff --git a/packages/app/src/specs/tree/useVirtualListNavigation.ts b/packages/app/src/specs/tree/useVirtualListNavigation.ts index 1b514c69aadd..ae82412e2249 100644 --- a/packages/app/src/specs/tree/useVirtualListNavigation.ts +++ b/packages/app/src/specs/tree/useVirtualListNavigation.ts @@ -19,7 +19,7 @@ export function useVirtualListNavigation ({ scrollTo, }: UseVirtualListApi) { const activeItem = ref(null) - const itemRefs = ref<{[key: number]: any}>({}) + const itemRefs = ref<{ [key: number]: any }>({}) const setItemRef = (el, index: number) => { if (el) { itemRefs.value[index] = el diff --git a/packages/config/.eslintignore b/packages/config/.eslintignore deleted file mode 100644 index d9c909f1aed8..000000000000 --- a/packages/config/.eslintignore +++ /dev/null @@ -1,8 +0,0 @@ -**/dist -**/*.d.ts -**/package-lock.json -**/tsconfig.json -**/cypress/fixtures -/test/__fixtures__/**/* -/test/__babel_fixtures__/**/* -**/__snapshots__ \ No newline at end of file diff --git a/packages/config/eslint.config.ts b/packages/config/eslint.config.ts new file mode 100644 index 000000000000..d77dda1b384a --- /dev/null +++ b/packages/config/eslint.config.ts @@ -0,0 +1,23 @@ +import baseConfig from '../../eslint.config' +import globals from 'globals' + +export default [ + ...baseConfig, + { + ignores: ['**/__babel_fixtures__/**/*', 'index.js'], + }, + { + languageOptions: { + parserOptions: { + projectService: { + allowDefaultProject: ['eslint.config.ts'], + }, + }, + globals: { + exports: 'readonly', + process: 'readonly', + __dirname: 'readonly', + }, + }, + }, +] diff --git a/packages/config/package.json b/packages/config/package.json index 951878c791ab..b48e5bea00cd 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -7,15 +7,14 @@ "browser": "src/browser.ts", "scripts": { "build-prod": "tsc || echo 'built, with errors'", - "check-ts": "tsc --noEmit && yarn -s tslint", + "check-ts": "tsc --noEmit", "clean": "rimraf --glob ./src/*.js ./src/**/*.js ./src/**/**/*.js ./test/!**__fixtures__**/**/*.js || echo 'cleaned'", "clean-deps": "rimraf node_modules", - "lint": "eslint --ext .js,.ts,.json, .", + "lint": "eslint .", "test": "yarn test-unit", "test-debug": "yarn test-unit --inspect-brk=5566", "test-unit": "mocha --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json -r @packages/ts/register 'test/**/*.spec.ts' --exit --timeout 5000", - "test:clean": "find ./test/__fixtures__ -depth -name 'output.*' -type f -exec rm {} \\;", - "tslint": "tslint --config ../ts/tslint.json --project ." + "test:clean": "find ./test/__fixtures__ -depth -name 'output.*' -type f -exec rm {} \\;" }, "dependencies": { "@babel/core": "^7.25.2", diff --git a/packages/config/src/ast-utils/addToCypressConfig.ts b/packages/config/src/ast-utils/addToCypressConfig.ts index 5c5a7896b4cc..c70a846efb31 100644 --- a/packages/config/src/ast-utils/addToCypressConfig.ts +++ b/packages/config/src/ast-utils/addToCypressConfig.ts @@ -155,7 +155,7 @@ type OutputExtension = '.ts' | '.mjs' | '.js' // Necessary to handle the edge case of them deleting the contents of their Cypress // config file, just before we merge in the testing type -function getEmptyCodeBlock ({ outputType, isProjectUsingESModules, projectRoot }: { outputType: OutputExtension, isProjectUsingESModules: boolean, projectRoot: string}) { +function getEmptyCodeBlock ({ outputType, isProjectUsingESModules, projectRoot }: { outputType: OutputExtension, isProjectUsingESModules: boolean, projectRoot: string }) { if (defineConfigAvailable(projectRoot)) { if (outputType === '.ts' || outputType === '.mjs' || isProjectUsingESModules) { return dedent` diff --git a/packages/config/src/validation.ts b/packages/config/src/validation.ts index 8143038e5b7c..51c1de1f2032 100644 --- a/packages/config/src/validation.ts +++ b/packages/config/src/validation.ts @@ -40,7 +40,7 @@ const isFalse = (value: any): boolean => { return value === false } -type ValidationResult = ErrResult | boolean | string; +type ValidationResult = ErrResult | boolean | string type ValidationFn = (key: string, value: any) => ValidationResult export const validateAny = (...validations: ValidationFn[]): ValidationFn => { @@ -107,7 +107,7 @@ export const isValidBrowserList = (_key: string, browsers: any): ErrResult | tru } for (let k = 0; k < browsers.length; k += 1) { - const validationResult: boolean | {key: string, value: string, type: string, list?: string} = isValidBrowser(browsers[k]) + const validationResult: boolean | { key: string, value: string, type: string, list?: string } = isValidBrowser(browsers[k]) if (validationResult !== true) { validationResult.list = 'browsers' @@ -168,7 +168,7 @@ const isValidExperimentalRetryOptionsConfig = (key: string, value: any, strategy return true } -const isValidRetryValue = (key: string, value: any, minimumValue: 0|1): ErrResult | true => { +const isValidRetryValue = (key: string, value: any, minimumValue: 0 | 1): ErrResult | true => { if (_.isNull(value)) return true if (Number.isInteger(value) && value >= minimumValue) return true @@ -330,7 +330,7 @@ export const isValidClientCertificatesSet = (_key: string, certsForUrls: Array<{ key: string cert: string pfx: string - }>}>): ErrResult | true | string => { + }> }>): ErrResult | true | string => { debug('clientCerts: %o', certsForUrls) if (!Array.isArray(certsForUrls)) { diff --git a/packages/config/test/__fixtures__/has-e2e.config.ts b/packages/config/test/__fixtures__/has-e2e.config.ts index 5ab096df40a2..2fc45a20fc41 100644 --- a/packages/config/test/__fixtures__/has-e2e.config.ts +++ b/packages/config/test/__fixtures__/has-e2e.config.ts @@ -1,3 +1,3 @@ export default { - e2e: {} -} \ No newline at end of file + e2e: {}, +} diff --git a/packages/config/test/__fixtures__/invalid.config.ts b/packages/config/test/__fixtures__/invalid.config.ts index 5d42783117b5..0eb88e62b23f 100644 --- a/packages/config/test/__fixtures__/invalid.config.ts +++ b/packages/config/test/__fixtures__/invalid.config.ts @@ -1 +1 @@ -const x = {} \ No newline at end of file +const x = {} diff --git a/packages/config/test/tsconfig.json b/packages/config/test/tsconfig.json new file mode 100644 index 000000000000..ec187a83ccb4 --- /dev/null +++ b/packages/config/test/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../ts/tsconfig.json", + "compilerOptions": { + "noEmit": true, + "allowJs": true, + }, + "include": ["**/*"] +} \ No newline at end of file diff --git a/packages/config/test/validation.spec.ts b/packages/config/test/validation.spec.ts index a698dbef73af..dc4516cda579 100644 --- a/packages/config/test/validation.spec.ts +++ b/packages/config/test/validation.spec.ts @@ -117,7 +117,7 @@ describe('config/src/validation', () => { // data-driven testing - computers snapshot value for each item in the list passed through the function // https://github.com/bahmutov/snap-shot-it#data-driven-testing - return snapshot.apply(null, [validation.isValidBrowser].concat(browsers as any)) + return snapshot.apply(null, [validation.isValidBrowser, ...browsers]) }) }) diff --git a/packages/data-context/.eslintignore b/packages/data-context/.eslintignore deleted file mode 100644 index 055ebf00d392..000000000000 --- a/packages/data-context/.eslintignore +++ /dev/null @@ -1,9 +0,0 @@ -**/dist -**/*.d.ts -**/package-lock.json -**/tsconfig.json -**/cypress/fixtures -/test/unit/codegen/files -/test/unit/codegen/tmp -/test/fixtures/** -**/__snapshots__ \ No newline at end of file diff --git a/packages/data-context/eslint.config.ts b/packages/data-context/eslint.config.ts new file mode 100644 index 000000000000..6c31258bc424 --- /dev/null +++ b/packages/data-context/eslint.config.ts @@ -0,0 +1,28 @@ +import baseConfig from '../../eslint.config' +import globals from 'globals' + +export default [ + ...baseConfig, + { + ignores: ['index.js'], + }, + { + languageOptions: { + globals: { + ...globals.node, + }, + parserOptions: { + projectService: { + allowDefaultProject: ['eslint.config.ts', 'scripts/build.js'], + }, + }, + }, + }, + { + // this package uses autobarrel, and autobarrel isn't smart enough to understand when + // it's exporting * from a module that doesn't have any named exports + rules: { + 'import-x/export': 'warn', + }, + }, +] diff --git a/packages/data-context/package.json b/packages/data-context/package.json index fcb656b887ee..c877e6dd9584 100644 --- a/packages/data-context/package.json +++ b/packages/data-context/package.json @@ -7,13 +7,12 @@ "scripts": { "build": "node ./scripts/build.js", "build-prod": "tsc || echo 'built, with errors'", - "check-ts": "tsc --noEmit && yarn -s tslint", + "check-ts": "tsc --noEmit", "clean": "rimraf --glob \"./{src,test}/**/*.js\"", "clean-deps": "rimraf node_modules", - "lint": "eslint --ext .js,.ts,.json, .", + "lint": "eslint .", "test": "yarn test-unit", - "test-unit": "mocha -r @packages/ts/register --config ./test/.mocharc.js --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json", - "tslint": "tslint --config ../ts/tslint.json --project ." + "test-unit": "mocha -r @packages/ts/register --config ./test/.mocharc.js --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json" }, "dependencies": { "@babel/code-frame": "7.24.7", @@ -93,8 +92,7 @@ "mocha-multi-reporters": "1.5.1", "nexus": "^1.2.0-next.15", "sinon": "13.0.2", - "sinon-chai": "3.7.0", - "tslint": "^6.1.3" + "sinon-chai": "3.7.0" }, "files": [ "src" diff --git a/packages/data-context/src/actions/CodegenActions.ts b/packages/data-context/src/actions/CodegenActions.ts index d777923df7aa..210db2199da9 100644 --- a/packages/data-context/src/actions/CodegenActions.ts +++ b/packages/data-context/src/actions/CodegenActions.ts @@ -15,7 +15,7 @@ export interface ReactComponentDescriptor { export class CodegenActions { constructor (private ctx: DataContext) {} - async getReactComponentsFromFile (filePath: string, reactDocgen?: typeof import('react-docgen')): Promise<{components: ReactComponentDescriptor[], errored?: boolean }> { + async getReactComponentsFromFile (filePath: string, reactDocgen?: typeof import('react-docgen')): Promise<{ components: ReactComponentDescriptor[], errored?: boolean }> { try { // this dance to get react-docgen is for now because react-docgen is a module and our typescript settings are set up to transpile to commonjs // which will require the module, which will fail because it's an es module. This is a temporary workaround. diff --git a/packages/data-context/src/actions/DataEmitterActions.ts b/packages/data-context/src/actions/DataEmitterActions.ts index 90215793c763..fd6ab3f5ceda 100644 --- a/packages/data-context/src/actions/DataEmitterActions.ts +++ b/packages/data-context/src/actions/DataEmitterActions.ts @@ -226,7 +226,7 @@ export class DataEmitterActions extends DataEmitterEvents { * the particular event. When the `listenerCount` is zero, then there are no * longer any subscribers for that event */ - subscribeTo (evt: keyof DataEmitterEvents, opts?: {sendInitial: boolean, initialValue?: T, filter?: (val: any) => boolean, onUnsubscribe?: (listenerCount: number) => void }): AsyncGenerator { + subscribeTo (evt: keyof DataEmitterEvents, opts?: { sendInitial: boolean, initialValue?: T, filter?: (val: any) => boolean, onUnsubscribe?: (listenerCount: number) => void }): AsyncGenerator { const { sendInitial = true } = opts ?? {} let hasSentInitial = false let dfd: pDefer.DeferredPromise | undefined @@ -279,7 +279,7 @@ export class DataEmitterActions extends DataEmitterEvents { throw: async (error: Error) => { throw error }, - return: async (): Promise<{ done: true, value: T | undefined}> => { + return: async (): Promise<{ done: true, value: T | undefined }> => { this.pub.off(evt, subscribed) if (opts?.onUnsubscribe) { diff --git a/packages/data-context/src/actions/MigrationActions.ts b/packages/data-context/src/actions/MigrationActions.ts index ab40842bd032..90cc7b9fce44 100644 --- a/packages/data-context/src/actions/MigrationActions.ts +++ b/packages/data-context/src/actions/MigrationActions.ts @@ -1,4 +1,3 @@ -/* eslint-disable no-dupe-class-members */ import path from 'path' import debugLib from 'debug' import { fork } from 'child_process' diff --git a/packages/data-context/src/actions/ProjectActions.ts b/packages/data-context/src/actions/ProjectActions.ts index fb9a8fa2acb0..1ae84aecc19d 100644 --- a/packages/data-context/src/actions/ProjectActions.ts +++ b/packages/data-context/src/actions/ProjectActions.ts @@ -47,7 +47,7 @@ export interface ProjectApiShape { makeProjectSavedState(projectRoot: string): void getDevServer (): { updateSpecs(specs: SpecWithRelativeRoot[]): void - start(options: {specs: Cypress.Spec[], config: FullConfig}): Promise<{port: number}> + start(options: { specs: Cypress.Spec[], config: FullConfig }): Promise<{ port: number }> close(): void emitter: EventEmitter } @@ -490,7 +490,7 @@ export class ProjectActions { } } - async runSpec ({ specPath }: { specPath: string}) { + async runSpec ({ specPath }: { specPath: string }) { const waitForBrowserToOpen = async () => { const browserStatusSubscription = this.ctx.emitter.subscribeTo('browserStatusChange', { sendInitial: false }) diff --git a/packages/data-context/src/codegen/code-generator.ts b/packages/data-context/src/codegen/code-generator.ts index f9c7250797a8..6452bedb87b2 100644 --- a/packages/data-context/src/codegen/code-generator.ts +++ b/packages/data-context/src/codegen/code-generator.ts @@ -1,4 +1,5 @@ import * as fs from 'fs-extra' +import { constants as fsConstants } from 'fs' import { isBinaryFile } from 'isbinaryfile' import * as path from 'path' import * as ejs from 'ejs' @@ -155,7 +156,7 @@ function frontMatter (content: string, args: { [key: string]: any }) { async function fileExists (absolute: string) { try { - await fs.access(absolute, fs.constants.F_OK) + await fs.access(absolute, fsConstants.F_OK) return true } catch (e) { diff --git a/packages/data-context/src/data/LegacyPluginsIpc.ts b/packages/data-context/src/data/LegacyPluginsIpc.ts index 7687e4bc403e..3a7962d62081 100644 --- a/packages/data-context/src/data/LegacyPluginsIpc.ts +++ b/packages/data-context/src/data/LegacyPluginsIpc.ts @@ -1,4 +1,3 @@ -/* eslint-disable no-dupe-class-members */ import type { ChildProcess } from 'child_process' import EventEmitter from 'events' import type { CypressError } from '@packages/errors' @@ -16,7 +15,7 @@ export class LegacyPluginsIpc extends EventEmitter { }) } - send(event: 'loadLegacyPlugins', legacyConfig: LegacyCypressConfigJson): boolean + send (event: 'loadLegacyPlugins', legacyConfig: LegacyCypressConfigJson): boolean send (event: string, ...args: any[]) { if (this.childProcess.killed || !this.childProcess.connected) { return false @@ -25,10 +24,10 @@ export class LegacyPluginsIpc extends EventEmitter { return this.childProcess.send({ event, args }) } - on(event: 'ready', listener: () => void): this - on(event: 'loadLegacyPlugins:error', listener: (error: CypressError) => void): this - on(event: 'childProcess:unhandledError', listener: (legacyConfig: LegacyCypressConfigJson) => void): this - on(event: 'loadLegacyPlugins:reply', listener: (legacyConfig: LegacyCypressConfigJson) => void): this + on (event: 'ready', listener: () => void): this + on (event: 'loadLegacyPlugins:error', listener: (error: CypressError) => void): this + on (event: 'childProcess:unhandledError', listener: (legacyConfig: LegacyCypressConfigJson) => void): this + on (event: 'loadLegacyPlugins:reply', listener: (legacyConfig: LegacyCypressConfigJson) => void): this on (evt: string, listener: (...args: any[]) => void) { return super.on(evt, listener) } diff --git a/packages/data-context/src/data/ProjectConfigIpc.ts b/packages/data-context/src/data/ProjectConfigIpc.ts index b5c4ee725677..515eccb75f02 100644 --- a/packages/data-context/src/data/ProjectConfigIpc.ts +++ b/packages/data-context/src/data/ProjectConfigIpc.ts @@ -1,4 +1,3 @@ -/* eslint-disable no-dupe-class-members */ import { CypressError, getError } from '@packages/errors' import type { FullConfig, TestingType } from '@packages/types' import { ChildProcess, fork, ForkOptions, spawn } from 'child_process' @@ -36,7 +35,7 @@ const isSandboxNeeded = () => { export interface SetupNodeEventsReply { setupConfig: Cypress.ConfigOptions | null requires: string[] - registrations: Array<{event: string, eventId: string}> + registrations: Array<{ event: string, eventId: string }> } export interface LoadConfigReply { @@ -101,10 +100,10 @@ export class ProjectConfigIpc extends EventEmitter { } // TODO: options => Cypress.TestingTypeOptions - send(event: 'execute:plugins', evt: string, ids: {eventId: string, invocationId: string}, args: any[]): boolean - send(event: 'setupTestingType', testingType: TestingType, options: Cypress.PluginConfigOptions): boolean - send(event: 'loadConfig'): boolean - send(event: 'main:process:will:disconnect'): void + send (event: 'execute:plugins', evt: string, ids: { eventId: string, invocationId: string }, args: any[]): boolean + send (event: 'setupTestingType', testingType: TestingType, options: Cypress.PluginConfigOptions): boolean + send (event: 'loadConfig'): boolean + send (event: 'main:process:will:disconnect'): void send (event: string, ...args: any[]) { if (this._childProcess.killed || !this._childProcess.connected) { return false @@ -113,30 +112,30 @@ export class ProjectConfigIpc extends EventEmitter { return this._childProcess.send({ event, args }) } - on(evt: 'childProcess:unhandledError', listener: (err: CypressError) => void): this - on(evt: 'export:telemetry', listener: (data: string) => void): void - on(evt: 'main:process:will:disconnect:ack', listener: () => void): void - on(evt: 'warning', listener: (warningErr: CypressError) => void): this + on (evt: 'childProcess:unhandledError', listener: (err: CypressError) => void): this + on (evt: 'export:telemetry', listener: (data: string) => void): void + on (evt: 'main:process:will:disconnect:ack', listener: () => void): void + on (evt: 'warning', listener: (warningErr: CypressError) => void): this on (evt: string, listener: (...args: any[]) => void) { return super.on(evt, listener) } - once(evt: `promise:fulfilled:${string}`, listener: (err: any, value: any) => void): this + once (evt: `promise:fulfilled:${string}`, listener: (err: any, value: any) => void): this /** * When the config is loaded, it comes back with either a "reply", or an "error" if there was a problem * sourcing the config (script error, etc.) */ - once(evt: 'ready', listener: () => void): this - once(evt: 'loadConfig:reply', listener: (payload: SerializedLoadConfigReply) => void): this - once(evt: 'loadConfig:error', listener: (err: CypressError) => void): this + once (evt: 'ready', listener: () => void): this + once (evt: 'loadConfig:reply', listener: (payload: SerializedLoadConfigReply) => void): this + once (evt: 'loadConfig:error', listener: (err: CypressError) => void): this /** * When */ - once(evt: 'setupTestingType:reply', listener: (payload: SetupNodeEventsReply) => void): this - once(evt: 'setupTestingType:error', listener: (error: CypressError) => void): this - once(evt: 'file:preprocessor:overridden', listener: (payload: { handlerText: string }) => void): this + once (evt: 'setupTestingType:reply', listener: (payload: SetupNodeEventsReply) => void): this + once (evt: 'setupTestingType:error', listener: (error: CypressError) => void): this + once (evt: 'file:preprocessor:overridden', listener: (payload: { handlerText: string }) => void): this once (evt: string, listener: (...args: any[]) => void) { return super.once(evt, listener) } diff --git a/packages/data-context/src/globalPubSub.ts b/packages/data-context/src/globalPubSub.ts index 9f6afdaf45cb..868879a47e9b 100644 --- a/packages/data-context/src/globalPubSub.ts +++ b/packages/data-context/src/globalPubSub.ts @@ -1,4 +1,3 @@ -/* eslint-disable no-dupe-class-members */ import EventEmitter from 'events' import type { DataContext } from './DataContext' @@ -11,20 +10,20 @@ type MenuItem = 'log:out' * to reset the global state for testing / resetting when there is an error */ export class GlobalPubSub extends EventEmitter { - on(msg: 'reset:data-context', listener: (ctx: DataContext) => void): this - on(msg: 'menu:item:clicked', listener: (item: MenuItem) => void): this - on(msg: 'test:cleanup', listener: (...args: any[]) => void): this + on (msg: 'reset:data-context', listener: (ctx: DataContext) => void): this + on (msg: 'menu:item:clicked', listener: (item: MenuItem) => void): this + on (msg: 'test:cleanup', listener: (...args: any[]) => void): this on (msg: string, listener: (...args: any[]) => void) { return super.on(msg, listener) } - emit(msg: 'menu:item:clicked', arg: MenuItem): boolean - emit(msg: 'reset:data-context', arg: DataContext): boolean + emit (msg: 'menu:item:clicked', arg: MenuItem): boolean + emit (msg: 'reset:data-context', arg: DataContext): boolean emit (msg: string, ...args: any[]) { return super.emit(msg, ...args) } - emitThen(msg: 'test:cleanup'): Promise + emitThen (msg: 'test:cleanup'): Promise async emitThen (msg: string, ...args: any[]): Promise { // @ts-expect-error const events = this._events diff --git a/packages/data-context/src/polling/index.ts b/packages/data-context/src/polling/index.ts index be30f9691070..af7675ce0222 100644 --- a/packages/data-context/src/polling/index.ts +++ b/packages/data-context/src/polling/index.ts @@ -1,4 +1,3 @@ -/* eslint-disable padding-line-between-statements */ // created by autobarrel, do not modify directly export * from './poller' diff --git a/packages/data-context/src/polling/poller.ts b/packages/data-context/src/polling/poller.ts index ba78cbe9e43a..eabf6219d7b5 100644 --- a/packages/data-context/src/polling/poller.ts +++ b/packages/data-context/src/polling/poller.ts @@ -25,7 +25,7 @@ export class Poller { this.pollingInterval = interval } - start (config: {initialValue?: T, meta?: M, filter?: (val: any) => boolean} = {}) { + start (config: { initialValue?: T, meta?: M, filter?: (val: any) => boolean } = {}) { const subscriptionId = ++this.#subscriptionId debug(`subscribing to ${this.event} with initial value %o and meta %o`, config?.initialValue, config?.meta) diff --git a/packages/data-context/src/sources/BrowserDataSource.ts b/packages/data-context/src/sources/BrowserDataSource.ts index e8a933f58b9d..81abf61b6a04 100644 --- a/packages/data-context/src/sources/BrowserDataSource.ts +++ b/packages/data-context/src/sources/BrowserDataSource.ts @@ -23,7 +23,7 @@ if (os.platform() === 'win32') { const platform = os.platform() -function getBrowserKey (browser: T) { +function getBrowserKey (browser: T) { return `${browser.name}-${browser.version}` } diff --git a/packages/data-context/src/sources/CloudDataSource.ts b/packages/data-context/src/sources/CloudDataSource.ts index 510e8fc4a136..586a5579db22 100644 --- a/packages/data-context/src/sources/CloudDataSource.ts +++ b/packages/data-context/src/sources/CloudDataSource.ts @@ -38,7 +38,6 @@ const REMOTE_SCHEMA_URLS = { production: 'https://cloud.cypress.io', } -// eslint-disable-next-line @typescript-eslint/no-unused-vars type StartsWith = T extends `${Prefix}${infer _U}` ? T : never type CloudQueryField = StartsWith @@ -121,10 +120,10 @@ export class CloudDataSource { ...urqlCacheKeys, updates: { Mutation: { - _cloudCacheInvalidate: (parent, { args }: {args: Parameters}, cache, info) => { + _cloudCacheInvalidate: (parent, { args }: { args: Parameters }, cache, info) => { cache.invalidate(...args) }, - _showUrqlCache: (parent, { args }: {args: Parameters}, cache, info) => { + _showUrqlCache: (parent, { args }: { args: Parameters }, cache, info) => { this.#lastCache = JSON.stringify(cache, function replacer (key, value) { if (value instanceof Map) { const reducer = (obj: any, mapKey: any) => { diff --git a/packages/data-context/src/sources/ProjectDataSource.ts b/packages/data-context/src/sources/ProjectDataSource.ts index 8476c15c6f2c..75997a247a3e 100644 --- a/packages/data-context/src/sources/ProjectDataSource.ts +++ b/packages/data-context/src/sources/ProjectDataSource.ts @@ -149,7 +149,7 @@ export function getPathFromSpecPattern ({ { specPattern: string testingType: TestingType fileExtensionToUse?: FileExtension - name?: string}) { + name?: string }) { function replaceWildCard (s: string, fallback: string) { return s.replace(/\*/g, fallback) } diff --git a/packages/data-context/src/sources/RelevantRunsDataSource.ts b/packages/data-context/src/sources/RelevantRunsDataSource.ts index 0d378bbd117d..cf37a827400e 100644 --- a/packages/data-context/src/sources/RelevantRunsDataSource.ts +++ b/packages/data-context/src/sources/RelevantRunsDataSource.ts @@ -44,7 +44,7 @@ export class RelevantRunsDataSource { #pollingInterval: number = 30 #cached: RelevantRun = RUNS_EMPTY_RETURN - #runsPoller?: Poller<'relevantRunChange', RelevantRun, { name: RelevantRunLocationEnum}> + #runsPoller?: Poller<'relevantRunChange', RelevantRun, { name: RelevantRunLocationEnum }> constructor (private ctx: DataContext) {} diff --git a/packages/data-context/src/sources/RemoteRequestDataSource.ts b/packages/data-context/src/sources/RemoteRequestDataSource.ts index 67b4cbfed821..015063918da5 100644 --- a/packages/data-context/src/sources/RemoteRequestDataSource.ts +++ b/packages/data-context/src/sources/RemoteRequestDataSource.ts @@ -27,7 +27,7 @@ interface OperationDefinition { operation: string operationDoc: DocumentNode operationHash: string - operationVariableDefs: [string, {type: TypeNode, defaultValue?: ValueNode}][] + operationVariableDefs: [string, { type: TypeNode, defaultValue?: ValueNode }][] remoteQueryField: string fieldArgMapping: Record } @@ -312,7 +312,7 @@ export class RemoteRequestDataSource { const remoteFieldArgs = queryFieldDef.args - const operationVariableDefs: [string, {type: TypeNode, defaultValue?: ValueNode}][] = [] + const operationVariableDefs: [string, { type: TypeNode, defaultValue?: ValueNode }][] = [] const fieldArgs: [string, ValueNode][] = [] const fieldArgMapping: Record = {} @@ -371,7 +371,7 @@ export class RemoteRequestDataSource { // Gather the referenced variables from each of the field nodes we // are generating a query with #getReferencedVariables (selectionNodes: readonly SelectionNode[], outerVariableDefs: readonly VariableDefinitionNode[]) { - const variableDefinitions: Record = {} + const variableDefinitions: Record = {} selectionNodes.map((node) => { visit(node, { @@ -410,7 +410,7 @@ export class RemoteRequestDataSource { fieldName: string fieldArgs: [string, ValueNode][] fieldNodes: readonly SelectionNode[] - operationVariableDefs: [string, {type: TypeNode, defaultValue?: ValueNode}][] + operationVariableDefs: [string, { type: TypeNode, defaultValue?: ValueNode }][] }, ): DocumentNode { const { operationVariableDefs = [], fieldArgs = [] } = params diff --git a/packages/data-context/src/sources/VersionsDataSource.ts b/packages/data-context/src/sources/VersionsDataSource.ts index 4c464884374c..f72f1fa95a64 100644 --- a/packages/data-context/src/sources/VersionsDataSource.ts +++ b/packages/data-context/src/sources/VersionsDataSource.ts @@ -110,7 +110,7 @@ export class VersionsDataSource { try { response = await this.ctx.util.fetch(NPM_CYPRESS_REGISTRY_URL) - const responseJson = await response.json() as { time: Record} + const responseJson = await response.json() as { time: Record } debug('NPM release dates received %o', { modified: responseJson.time.modified }) diff --git a/packages/data-context/src/sources/migration/legacyOptions.ts b/packages/data-context/src/sources/migration/legacyOptions.ts index c0cd4ba8da2a..f7ee9af2d694 100644 --- a/packages/data-context/src/sources/migration/legacyOptions.ts +++ b/packages/data-context/src/sources/migration/legacyOptions.ts @@ -290,7 +290,7 @@ const runtimeOptions: Array = [ }, ] -export const legacyOptions: Array = [ +export const legacyOptions: Array = [ ...resolvedOptions, ...runtimeOptions, ] diff --git a/packages/data-context/src/util/DocumentNodeBuilder.ts b/packages/data-context/src/util/DocumentNodeBuilder.ts index f71fc6c799ab..230f17932b9a 100644 --- a/packages/data-context/src/util/DocumentNodeBuilder.ts +++ b/packages/data-context/src/util/DocumentNodeBuilder.ts @@ -5,7 +5,7 @@ export interface RemoteQueryConfig { variableDefinitions: VariableDefinitionNode[] } -export type DocumentNodeBuilderParams = Pick & {isNode?: boolean, isRemoteFetchable?: boolean, variableDefinitions: readonly VariableDefinitionNode[] | undefined, operationName: string} +export type DocumentNodeBuilderParams = Pick & { isNode?: boolean, isRemoteFetchable?: boolean, variableDefinitions: readonly VariableDefinitionNode[] | undefined, operationName: string } /** * Builds a DocumentNode from a given GraphQLResolveInfo payload diff --git a/packages/data-context/src/util/autoBindDebug.ts b/packages/data-context/src/util/autoBindDebug.ts index b88d80657d34..b4726d990f61 100644 --- a/packages/data-context/src/util/autoBindDebug.ts +++ b/packages/data-context/src/util/autoBindDebug.ts @@ -11,7 +11,7 @@ const debugLibCache: Record = {} * to the constructor of the class for which you want to enable logging, you can then * set DEBUG=cypress-trace: to utilize the logging */ -export function autoBindDebug (obj: T): T { +export function autoBindDebug (obj: T): T { const ns = `trace-cypress:${obj.constructor.name}` const debug = debugLibCache[ns] = debugLibCache[ns] || debugLib(ns) diff --git a/packages/data-context/src/util/cached.ts b/packages/data-context/src/util/cached.ts index f93c68b84f21..9d5db8d1d96b 100644 --- a/packages/data-context/src/util/cached.ts +++ b/packages/data-context/src/util/cached.ts @@ -27,7 +27,6 @@ export const cached = ( throw new Error('@cached target must be configurable') } else { descriptor.get = function () { - // eslint-disable-next-line const value = originalMethod.apply(this, arguments as any) const newDescriptor: PropertyDescriptor = { configurable: false, diff --git a/packages/data-context/src/util/config-file-updater.ts b/packages/data-context/src/util/config-file-updater.ts index 421136c73385..ac5be8a2889e 100644 --- a/packages/data-context/src/util/config-file-updater.ts +++ b/packages/data-context/src/util/config-file-updater.ts @@ -200,7 +200,7 @@ function setSubKeysSplicers ( const keysToUpdateWithObjects: string[] = [] - const objSubkeys = Object.keys(obj).filter((key) => typeof obj[key] === 'object').reduce((acc: Array<{parent: string, subkey: string}>, key) => { + const objSubkeys = Object.keys(obj).filter((key) => typeof obj[key] === 'object').reduce((acc: Array<{ parent: string, subkey: string }>, key) => { keysToUpdateWithObjects.push(key) Object.entries(obj[key]).forEach(([subkey, value]) => { if (['boolean', 'number', 'string'].includes(typeof value)) { @@ -294,7 +294,7 @@ function isUndefinedOrNull (value: NodePath['node']): value is namedTypes.Identi return value.type === 'Identifier' && ['undefined', 'null'].includes(value.name) } -interface Splicer{ +interface Splicer { start: number end: number replaceString: string diff --git a/packages/data-context/src/util/testCounts.ts b/packages/data-context/src/util/testCounts.ts index 1607c2721914..a645961ee1f1 100644 --- a/packages/data-context/src/util/testCounts.ts +++ b/packages/data-context/src/util/testCounts.ts @@ -13,7 +13,7 @@ export async function getTestCounts (specs: SpecWithRelativeRoot[]) { const startTime = performance.now() const specCountPromises = specs.map((spec) => { - return new Promise<{path: string, isExample: boolean, testCounts: number}>((resolve, reject) => { + return new Promise<{ path: string, isExample: boolean, testCounts: number }>((resolve, reject) => { let testCounts = 0 readline.createInterface({ diff --git a/packages/data-context/test/fixtures/browsers.ts b/packages/data-context/test/fixtures/browsers.ts index 4a2772dc405c..466ec96338bd 100644 --- a/packages/data-context/test/fixtures/browsers.ts +++ b/packages/data-context/test/fixtures/browsers.ts @@ -1,4 +1,4 @@ -import { FoundBrowser } from "@packages/types"; +import { FoundBrowser } from '@packages/types' export const foundBrowserChrome: FoundBrowser = { name: 'chrome', @@ -6,7 +6,7 @@ export const foundBrowserChrome: FoundBrowser = { channel: 'stable', displayName: 'Chrome', path: '/usr/bin/chrome', - version: '100.0.0' + version: '100.0.0', } as const export const userBrowser: Cypress.Browser = { @@ -16,4 +16,4 @@ export const userBrowser: Cypress.Browser = { isHeadless: false, family: 'chromium', majorVersion: '100', -} \ No newline at end of file +} diff --git a/packages/data-context/test/tsconfig.json b/packages/data-context/test/tsconfig.json new file mode 100644 index 000000000000..ec187a83ccb4 --- /dev/null +++ b/packages/data-context/test/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../ts/tsconfig.json", + "compilerOptions": { + "noEmit": true, + "allowJs": true, + }, + "include": ["**/*"] +} \ No newline at end of file diff --git a/packages/data-context/test/unit/actions/DataEmitterActions.spec.ts b/packages/data-context/test/unit/actions/DataEmitterActions.spec.ts index be7aa26c83d6..03b1c27d214e 100644 --- a/packages/data-context/test/unit/actions/DataEmitterActions.spec.ts +++ b/packages/data-context/test/unit/actions/DataEmitterActions.spec.ts @@ -20,7 +20,6 @@ describe('DataEmitterActions', () => { let completed = false const testIterator = async () => { - // eslint-disable-next-line @typescript-eslint/no-unused-vars for await (const _value of subscription) { items += 1 } @@ -56,7 +55,6 @@ describe('DataEmitterActions', () => { let completed = false const testIterator = async () => { - // eslint-disable-next-line @typescript-eslint/no-unused-vars for await (const _value of subscription) { items += 1 } @@ -87,7 +85,6 @@ describe('DataEmitterActions', () => { let completed = false const testIterator = async () => { - // eslint-disable-next-line @typescript-eslint/no-unused-vars for await (const _value of subscription) { items += 1 } @@ -115,7 +112,6 @@ describe('DataEmitterActions', () => { } const testIterator = async () => { - // eslint-disable-next-line @typescript-eslint/no-unused-vars for await (const _value of subscription) { returnVal.items += 1 } diff --git a/packages/data-context/test/unit/codegen/files/react/Button.jsx b/packages/data-context/test/unit/codegen/files/react/Button.jsx index a7990e65bb99..24a765852fcb 100644 --- a/packages/data-context/test/unit/codegen/files/react/Button.jsx +++ b/packages/data-context/test/unit/codegen/files/react/Button.jsx @@ -1,13 +1,14 @@ -// @ts-nocheck -import React from 'react'; -import PropTypes from 'prop-types'; -import './button.css'; +import React from 'react' +import PropTypes from 'prop-types' +// eslint-disable-next-line import-x/no-unresolved +import './button.css' /** * Primary UI component for user interaction */ -export default Button = ({ primary, backgroundColor, size, label, ...props }) => { - const mode = primary ? 'button--primary' : 'button--secondary'; +const Button = ({ primary, backgroundColor, size, label, ...props }) => { + const mode = primary ? 'button--primary' : 'button--secondary' + return ( - ); -}; + ) +} + +export default Button Button.propTypes = { /** @@ -41,11 +44,11 @@ Button.propTypes = { * Optional click handler */ onClick: PropTypes.func, -}; +} Button.defaultProps = { backgroundColor: null, primary: false, size: 'medium', onClick: undefined, -}; +} diff --git a/packages/data-context/test/unit/codegen/files/vue/Button.vue b/packages/data-context/test/unit/codegen/files/vue/Button.vue index f010c2cc6083..3f12c74d408c 100644 --- a/packages/data-context/test/unit/codegen/files/vue/Button.vue +++ b/packages/data-context/test/unit/codegen/files/vue/Button.vue @@ -1,14 +1,21 @@ diff --git a/packages/data-context/test/unit/polling/poller.spec.ts b/packages/data-context/test/unit/polling/poller.spec.ts index 56609186439f..4a27f5038c97 100644 --- a/packages/data-context/test/unit/polling/poller.spec.ts +++ b/packages/data-context/test/unit/polling/poller.spec.ts @@ -111,7 +111,7 @@ describe('Poller', () => { const callback = sinon.stub() const interval = 5 - const poller = new Poller<'relevantRunChange', { name: string }, { name: string}>(ctx, 'relevantRunChange', interval, callback) + const poller = new Poller<'relevantRunChange', { name: string }, { name: string }>(ctx, 'relevantRunChange', interval, callback) expect(poller.subscriptions).to.have.length(0) diff --git a/packages/driver/.eslintignore b/packages/driver/.eslintignore deleted file mode 100644 index 2b42008bda67..000000000000 --- a/packages/driver/.eslintignore +++ /dev/null @@ -1,5 +0,0 @@ -**/dist -**/*.d.ts -**/package-lock.json -**/tsconfig.json -**/cypress/fixtures diff --git a/packages/driver/cypress/.eslintrc.json b/packages/driver/cypress/.eslintrc.json deleted file mode 100644 index 9b012d59420f..000000000000 --- a/packages/driver/cypress/.eslintrc.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "plugins": [ - "cypress" - ], - "extends": [ - "plugin:@cypress/dev/tests" - ], - "env": { - "cypress/globals": true - }, - "rules": { - "mocha/no-global-tests": "off" - } -} diff --git a/packages/driver/cypress/e2e/commands/assertions.cy.js b/packages/driver/cypress/e2e/commands/assertions.cy.js index e13b1da54ab1..24d4f72e09e5 100644 --- a/packages/driver/cypress/e2e/commands/assertions.cy.js +++ b/packages/driver/cypress/e2e/commands/assertions.cy.js @@ -1200,6 +1200,7 @@ describe('src/cy/commands/assertions', () => { describe('message formatting', () => { const expectMarkdown = (test, message, done) => { cy.then(() => { + // eslint-disable-next-line mocha/no-empty-description test() }) @@ -1336,7 +1337,7 @@ describe('src/cy/commands/assertions', () => { describe('#contain', () => { it('can find input type submit by value', function () { // $input creates an HTML element to be tested. - // eslint-disable-next-line no-unused-vars + const $input = cy.$$('').appendTo(this.$body) cy.get('input[type=submit]').should('contain', 'click me') diff --git a/packages/driver/cypress/e2e/commands/files.cy.js b/packages/driver/cypress/e2e/commands/files.cy.js index 395b4b5f55f5..e0f192057b6e 100644 --- a/packages/driver/cypress/e2e/commands/files.cy.js +++ b/packages/driver/cypress/e2e/commands/files.cy.js @@ -1,3 +1,4 @@ +/* global Buffer */ const { assertLogLength } = require('../../support/utils') const { stripIndent } = require('common-tags') diff --git a/packages/driver/cypress/e2e/commands/fixtures.cy.js b/packages/driver/cypress/e2e/commands/fixtures.cy.js index 7ae0bf999ac9..1f8e84cef185 100644 --- a/packages/driver/cypress/e2e/commands/fixtures.cy.js +++ b/packages/driver/cypress/e2e/commands/fixtures.cy.js @@ -1,3 +1,4 @@ +/* global Buffer */ const stripAnsi = require('strip-ansi') const { assertLogLength } = require('../../support/utils') diff --git a/packages/driver/cypress/e2e/e2e/origin/events.cy.ts b/packages/driver/cypress/e2e/e2e/origin/events.cy.ts index e0c80a28bdb8..335f734e0470 100644 --- a/packages/driver/cypress/e2e/e2e/origin/events.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/events.cy.ts @@ -1,7 +1,7 @@ describe('cy.origin', { browser: '!webkit' }, () => { it('window:before:load event', () => { cy.visit('/fixtures/primary-origin.html') - cy.on('window:before:load', (win: {testPrimaryOriginBeforeLoad: boolean}) => { + cy.on('window:before:load', (win: { testPrimaryOriginBeforeLoad: boolean }) => { win.testPrimaryOriginBeforeLoad = true }) @@ -9,7 +9,7 @@ describe('cy.origin', { browser: '!webkit' }, () => { // Needs to be declared before the visit cy.origin('http://www.foobar.com:3500', () => { - cy.on('window:before:load', (win: {testSecondaryWindowBeforeLoad: boolean}) => { + cy.on('window:before:load', (win: { testSecondaryWindowBeforeLoad: boolean }) => { win.testSecondaryWindowBeforeLoad = true }) }) diff --git a/packages/driver/cypress/e2e/e2e/origin/integrity.cy.ts b/packages/driver/cypress/e2e/e2e/origin/integrity.cy.ts index bdf1ae2f1014..c1bea3c6441c 100644 --- a/packages/driver/cypress/e2e/e2e/origin/integrity.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/integrity.cy.ts @@ -14,8 +14,8 @@ describe('Integrity Preservation', { browser: '!webkit' }, () => { // See https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity on SRI integrity. const availableDigests = ['SHA256', 'SHA384', 'SHA512'] - const integrityJSDigests: {[key: string]: string} = {} - const integrityCSSDigests: {[key: string]: string} = {} + const integrityJSDigests: { [key: string]: string } = {} + const integrityCSSDigests: { [key: string]: string } = {} let templateExecutor: TemplateExecutor before(() => { diff --git a/packages/driver/cypress/e2e/e2e/origin/uncaught_errors.cy.ts b/packages/driver/cypress/e2e/e2e/origin/uncaught_errors.cy.ts index 12a27d114263..3ecf8bc67057 100644 --- a/packages/driver/cypress/e2e/e2e/origin/uncaught_errors.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/uncaught_errors.cy.ts @@ -365,6 +365,7 @@ describe('cy.origin - uncaught errors', { browser: '!webkit' }, () => { get name () { return this._name } + set name (name: string) { this._name = name } @@ -401,6 +402,7 @@ describe('cy.origin - uncaught errors', { browser: '!webkit' }, () => { get metasyntaticList (): string[] { return this._metasyntaticList } + set metasyntaticList (itemsToAdd: string[]) { this._metasyntaticList = this._metasyntaticList.concat(itemsToAdd) } diff --git a/packages/driver/cypress/e2e/e2e/testConfigOverrides.cy.js b/packages/driver/cypress/e2e/e2e/testConfigOverrides.cy.js index d7431df2f1c3..f58af1d9c80c 100644 --- a/packages/driver/cypress/e2e/e2e/testConfigOverrides.cy.js +++ b/packages/driver/cypress/e2e/e2e/testConfigOverrides.cy.js @@ -1,5 +1,3 @@ -/* eslint-disable @cypress/dev/skip-comment,mocha/no-exclusive-tests */ - describe('per-test config', () => { const testState = { ranFirefox: false, diff --git a/packages/driver/eslint.config.ts b/packages/driver/eslint.config.ts new file mode 100644 index 000000000000..90ba32e239e6 --- /dev/null +++ b/packages/driver/eslint.config.ts @@ -0,0 +1,29 @@ +import baseConfig from '../../eslint.config' +import globals from 'globals' + +export default [ + ...baseConfig, + { + ignores: ['cypress/fixtures/**/*', 'src/config/jquery.scrollto.ts'], + }, + { + languageOptions: { + parserOptions: { + projectService: { + allowDefaultProject: ['index.d.ts', 'cypress/e2e/e2e/origin/dependencies.cy.jsx', 'src/cypress/setter_getter.d.ts'], + }, + }, + globals: { + ...globals['shared-node-browser'], + }, + }, + }, + { + files: ['cypress/plugins/*'], + languageOptions: { + globals: { + ...globals['node'], + }, + }, + }, +] diff --git a/packages/driver/index.d.ts b/packages/driver/index.d.ts index 10d847e97a11..434e09c3fea0 100644 --- a/packages/driver/index.d.ts +++ b/packages/driver/index.d.ts @@ -4,4 +4,5 @@ export const $Cypress: Cypress.Cypress export const $: JQuery -export default $Cypress \ No newline at end of file + +export default $Cypress diff --git a/packages/driver/package.json b/packages/driver/package.json index e16e4937cc26..14cefc429ef1 100644 --- a/packages/driver/package.json +++ b/packages/driver/package.json @@ -3,17 +3,16 @@ "version": "0.0.0-development", "private": true, "scripts": { - "check-ts": "tsc --noEmit && yarn -s tslint", + "check-ts": "tsc --noEmit", "clean-deps": "rimraf node_modules", "cypress:open": "node ../../scripts/cypress open", "cypress:run": "node ../../scripts/cypress run --config-file ./cypress.config.ts", "cypress:run:inject-document-domain": "node ../../scripts/cypress run --config-file ./cypress.config-injectDocumentDomain.ts", "postinstall": "patch-package", - "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .", + "lint": "eslint .", "start": "node -e 'console.log(require(`chalk`).red(`\nError:\n\tRunning \\`yarn start\\` is no longer needed for driver/cypress tests.\n\tWe now automatically spawn the server in e2e.setupNodeEvents config.\n\tChanges to the server will be watched and reloaded automatically.`))'", "test": "vitest run", - "test:watch": "vitest watch", - "tslint": "tslint --config ../ts/tslint.json --project ." + "test:watch": "vitest watch" }, "dependencies": {}, "devDependencies": { diff --git a/packages/driver/src/cross-origin/communicator.ts b/packages/driver/src/cross-origin/communicator.ts index 550a6955f79c..f8cacf1faa37 100644 --- a/packages/driver/src/cross-origin/communicator.ts +++ b/packages/driver/src/cross-origin/communicator.ts @@ -68,7 +68,7 @@ const sharedPromiseSetup = ({ * @extends EventEmitter */ export class PrimaryOriginCommunicator extends EventEmitter { - private crossOriginDriverWindows: {[key: string]: Window} = {} + private crossOriginDriverWindows: { [key: string]: Window } = {} userInvocationStack?: string /** @@ -320,6 +320,7 @@ export class SpecBridgeCommunicator extends EventEmitter { }, '*') }) } + /** * Promisified event sent to the primary communicator that expects the same event reflected back with the response. * @param {string} event - the name of the event to be sent. @@ -336,7 +337,7 @@ export class SpecBridgeCommunicator extends EventEmitter { }: { event: string data?: Cypress.ObjectLike - options: {syncGlobals: boolean} + options: { syncGlobals: boolean } timeout: number }) { return new Promise((resolve, reject) => { diff --git a/packages/driver/src/cross-origin/cypress.ts b/packages/driver/src/cross-origin/cypress.ts index c6af33aad03c..a98bd01599f3 100644 --- a/packages/driver/src/cross-origin/cypress.ts +++ b/packages/driver/src/cross-origin/cypress.ts @@ -151,7 +151,6 @@ const setup = ({ cypressConfig, env, isProtocolEnabled }: { cypressConfig: Cypre cy.onBeforeAppWindowLoad = onBeforeAppWindowLoad(Cypress, cy) } -// eslint-disable-next-line @cypress/dev/arrow-body-multiline-braces const onBeforeAppWindowLoad = (Cypress: Cypress.Cypress, cy: $Cy) => (autWindow: Window) => { autWindow.Cypress = Cypress diff --git a/packages/driver/src/cross-origin/origin_fn.ts b/packages/driver/src/cross-origin/origin_fn.ts index 3a6106886e2a..cf9dfd5750f7 100644 --- a/packages/driver/src/cross-origin/origin_fn.ts +++ b/packages/driver/src/cross-origin/origin_fn.ts @@ -33,7 +33,7 @@ interface GetFileResult { error?: string } -const rehydrateRunnable = (data: serializedRunnable): Runnable|Test => { +const rehydrateRunnable = (data: serializedRunnable): Runnable | Test => { let runnable if (data.type === 'test') { diff --git a/packages/driver/src/cy/aliases.ts b/packages/driver/src/cy/aliases.ts index ab88f6ec5f9f..e2e938436113 100644 --- a/packages/driver/src/cy/aliases.ts +++ b/packages/driver/src/cy/aliases.ts @@ -16,7 +16,6 @@ export const aliasDisplayName = (name) => { return name.replace(aliasDisplayRe, '') } -// eslint-disable-next-line @cypress/dev/arrow-body-multiline-braces export const create = (cy: $Cy) => ({ addAlias (ctx, aliasObj) { const { alias } = aliasObj diff --git a/packages/driver/src/cy/chai.ts b/packages/driver/src/cy/chai.ts index 948fd67eccef..c91685b83054 100644 --- a/packages/driver/src/cy/chai.ts +++ b/packages/driver/src/cy/chai.ts @@ -1,4 +1,3 @@ -/* eslint-disable prefer-rest-params */ // tests in driver/cypress/integration/commands/assertions_spec.js import _ from 'lodash' diff --git a/packages/driver/src/cy/chai/inspect.ts b/packages/driver/src/cy/chai/inspect.ts index 5dfccd83fdc0..46e51d3e6482 100644 --- a/packages/driver/src/cy/chai/inspect.ts +++ b/packages/driver/src/cy/chai/inspect.ts @@ -215,7 +215,6 @@ export function create (chai) { return formatError(value) } - // eslint-disable-next-line eqeqeq if (keys.length === 0 && (!array || value.length == 0)) { return braces[0] + base + braces[1] } diff --git a/packages/driver/src/cy/commands/actions/submit.ts b/packages/driver/src/cy/commands/actions/submit.ts index 62f382792b36..b48e426de7d0 100644 --- a/packages/driver/src/cy/commands/actions/submit.ts +++ b/packages/driver/src/cy/commands/actions/submit.ts @@ -7,7 +7,7 @@ import $errUtils from '../../../cypress/error_utils' import $actionability from '../../actionability' import type { Log } from '../../../cypress/log' -interface InternalSubmitOptions extends Partial{ +interface InternalSubmitOptions extends Partial { _log?: Log $el: JQuery } diff --git a/packages/driver/src/cy/commands/asserting.ts b/packages/driver/src/cy/commands/asserting.ts index ac480e549dc8..c9e6df76217a 100644 --- a/packages/driver/src/cy/commands/asserting.ts +++ b/packages/driver/src/cy/commands/asserting.ts @@ -216,13 +216,13 @@ export default function (Commands, Cypress, cy, state) { Commands.addAll({ type: 'assertion', prevSubject: true }, { should () { // Cast to `any` to pass all arguments - // eslint-disable-next-line prefer-rest-params + return shouldFn.apply(this, arguments as any) }, and () { // Cast to `any` to pass all arguments - // eslint-disable-next-line prefer-rest-params + return shouldFn.apply(this, arguments as any) }, }) diff --git a/packages/driver/src/cy/commands/commands.ts b/packages/driver/src/cy/commands/commands.ts index f0169ea33ea4..27af454b9186 100644 --- a/packages/driver/src/cy/commands/commands.ts +++ b/packages/driver/src/cy/commands/commands.ts @@ -12,7 +12,7 @@ const command = function (ctx, name, ...args) { }) } - return ctx[name].apply(ctx, args) + return ctx[name](...args) } export default function (Commands, Cypress, cy) { diff --git a/packages/driver/src/cy/commands/connectors.ts b/packages/driver/src/cy/commands/connectors.ts index 5c54c52dff1f..237a00549887 100644 --- a/packages/driver/src/cy/commands/connectors.ts +++ b/packages/driver/src/cy/commands/connectors.ts @@ -372,7 +372,6 @@ export default function (Commands, Cypress, cy, state) { Commands.addAll({ prevSubject: 'optional' }, { then (subject, userOptions, fn) { - // eslint-disable-next-line prefer-rest-params return thenFn.apply(this, [subject, userOptions, fn]) }, }) diff --git a/packages/driver/src/cy/commands/screenshot.ts b/packages/driver/src/cy/commands/screenshot.ts index 6437d54a4f6e..0d9c6b767ca9 100644 --- a/packages/driver/src/cy/commands/screenshot.ts +++ b/packages/driver/src/cy/commands/screenshot.ts @@ -33,7 +33,7 @@ type TakeScreenshotOptions = { timeout?: number } -type AutomationOptions = TakeScreenshotOptions & Omit & Partial +type AutomationOptions = TakeScreenshotOptions & Omit & Partial const getViewportHeight = (state: StateFunc) => { // TODO this doesn't seem correct @@ -310,7 +310,7 @@ const takeElementScreenshot = ($el: JQuery, state: StateFunc, autom } // "app only" means we're hiding the runner UI -const isAppOnly = ({ capture }: { capture: Cypress.ScreenshotOptions['capture']}) => { +const isAppOnly = ({ capture }: { capture: Cypress.ScreenshotOptions['capture'] }) => { return (capture === 'viewport') || (capture === 'fullPage') } diff --git a/packages/driver/src/cy/commands/sessions/index.ts b/packages/driver/src/cy/commands/sessions/index.ts index 8c116c8870ed..6943e30ab7fa 100644 --- a/packages/driver/src/cy/commands/sessions/index.ts +++ b/packages/driver/src/cy/commands/sessions/index.ts @@ -32,7 +32,7 @@ export default function (Commands, Cypress, cy) { } }) - Cypress.on('test:before:after:run:async', (test, Cypress, { nextTestHasTestIsolationOn }: {nextTestHasTestIsolationOn?: boolean} = {}) => { + Cypress.on('test:before:after:run:async', (test, Cypress, { nextTestHasTestIsolationOn }: { nextTestHasTestIsolationOn?: boolean } = {}) => { if (nextTestHasTestIsolationOn || nextTestHasTestIsolationOn === undefined) { return navigateAboutBlank({ inBetweenTestsAndNextTestHasTestIsolationOn: true }) } diff --git a/packages/driver/src/cy/focused.ts b/packages/driver/src/cy/focused.ts index 85edd76541eb..cf3a8637342c 100644 --- a/packages/driver/src/cy/focused.ts +++ b/packages/driver/src/cy/focused.ts @@ -49,7 +49,6 @@ const simulateFocusEvent = (el, win) => { return el.dispatchEvent(focusinEvt) } -// eslint-disable-next-line @cypress/dev/arrow-body-multiline-braces export const create = (state: StateFunc) => ({ documentHasFocus () { // hardcode document has focus as true diff --git a/packages/driver/src/cy/jquery.ts b/packages/driver/src/cy/jquery.ts index 7196ebe2190a..3e9a81e8f7f6 100644 --- a/packages/driver/src/cy/jquery.ts +++ b/packages/driver/src/cy/jquery.ts @@ -8,7 +8,6 @@ const remoteJQueryisNotSameAsGlobal = (remoteJQuery) => { return remoteJQuery && (remoteJQuery !== $) } -// eslint-disable-next-line @cypress/dev/arrow-body-multiline-braces export const create = (state: StateFunc) => ({ $$ (selector, context?) { if (context == null) { diff --git a/packages/driver/src/cy/keyboard.ts b/packages/driver/src/cy/keyboard.ts index fbeb454fe78d..2da05198d219 100644 --- a/packages/driver/src/cy/keyboard.ts +++ b/packages/driver/src/cy/keyboard.ts @@ -7,7 +7,7 @@ import { USKeyboard } from '../cypress/UsKeyboardLayout' import $dom from '../dom' import $document from '../dom/document' import $elements, { HTMLTextLikeInputElement } from '../dom/elements' -// eslint-disable-next-line no-duplicate-imports + import type { HTMLTextLikeElement } from '../dom/elements' import $selection from '../dom/selection' import $utils from '../cypress/utils' @@ -302,7 +302,7 @@ const parseCharsBetweenCurlyBraces = (chars: string) => { const shouldIgnoreEvent = < T extends KeyEventType, - K extends { [key in T]?: boolean } + K extends { [key in T]?: boolean }, >( eventName: T, options: K, diff --git a/packages/driver/src/cy/listeners.ts b/packages/driver/src/cy/listeners.ts index f12ced5e36f0..38de186ae3f7 100644 --- a/packages/driver/src/cy/listeners.ts +++ b/packages/driver/src/cy/listeners.ts @@ -13,7 +13,7 @@ type BoundEvent = [ win: Window, event: keyof WindowEventMap, fn: BoundEventHandler, - capture?: boolean + capture?: boolean, ] let events: BoundEvent[] = [] diff --git a/packages/driver/src/cy/location.ts b/packages/driver/src/cy/location.ts index 4e22bf57a021..7fee21cc3133 100644 --- a/packages/driver/src/cy/location.ts +++ b/packages/driver/src/cy/location.ts @@ -15,7 +15,6 @@ const getRemoteLocationFromCrossOriginWindow = (autWindow: Window): Promise ({ getRemoteLocation (key?: string | undefined, win?: Window) { try { diff --git a/packages/driver/src/cy/mouse.ts b/packages/driver/src/cy/mouse.ts index c87e4b110a4b..1a2701b6d896 100644 --- a/packages/driver/src/cy/mouse.ts +++ b/packages/driver/src/cy/mouse.ts @@ -14,7 +14,7 @@ const debug = debugFn('cypress:driver:mouse') export type ForceEl = false | HTMLElement -export type MouseCoords = { x?: number, y?: number} +export type MouseCoords = { x?: number, y?: number } /** * @typedef Coords diff --git a/packages/driver/src/cy/retries.ts b/packages/driver/src/cy/retries.ts index 2cfedf637dce..ad9092bd4f46 100644 --- a/packages/driver/src/cy/retries.ts +++ b/packages/driver/src/cy/retries.ts @@ -24,7 +24,6 @@ type retryOptions = { total?: number } -// eslint-disable-next-line @cypress/dev/arrow-body-multiline-braces export const create = (Cypress: ICypress, state: StateFunc, timeout: $Cy['timeout'], clearTimeout: $Cy['clearTimeout'], whenStable: $Cy['whenStable'], finishAssertions: (err?: Error) => void) => ({ retry (fn, options: retryOptions, log?) { // remove the runnables timeout because we are now in retry diff --git a/packages/driver/src/cy/stability.ts b/packages/driver/src/cy/stability.ts index 8b67b3214784..3102379d8b37 100644 --- a/packages/driver/src/cy/stability.ts +++ b/packages/driver/src/cy/stability.ts @@ -2,7 +2,6 @@ import Promise from 'bluebird' import type { ICypress } from '../cypress' import type { StateFunc } from '../cypress/state' -// eslint-disable-next-line @cypress/dev/arrow-body-multiline-braces export const create = (Cypress: ICypress, state: StateFunc) => ({ isStable: (stable: boolean = true, event: string) => { if (state('isStable') === stable) { diff --git a/packages/driver/src/cy/testConfigOverrides.ts b/packages/driver/src/cy/testConfigOverrides.ts index 92097243f2aa..56785dfbe65a 100644 --- a/packages/driver/src/cy/testConfigOverrides.ts +++ b/packages/driver/src/cy/testConfigOverrides.ts @@ -12,7 +12,7 @@ type ResolvedTestConfigOverride = { * The list of test config overrides and the invocation details used to add helpful * error messaging to consumers if a test override fails validation. */ - testConfigList: Array + testConfigList: Array /** * The test config overrides that will apply to the test if it passes validation. */ @@ -33,11 +33,11 @@ type TestConfig = { invocationDetails: { stack: Object } -}; +} type ConfigOverrides = { env: Object | undefined -}; +} function setConfig (testConfig: ResolvedTestConfigOverride, config, localConfigOverrides: ConfigOverrides = { env: undefined }) { const { testConfigList = [] } = testConfig diff --git a/packages/driver/src/cy/timeouts.ts b/packages/driver/src/cy/timeouts.ts index f076a62b0ec9..1cd4b536c5b8 100644 --- a/packages/driver/src/cy/timeouts.ts +++ b/packages/driver/src/cy/timeouts.ts @@ -2,7 +2,6 @@ import _ from 'lodash' import $errUtils from '../cypress/error_utils' import type { StateFunc } from '../cypress/state' -// eslint-disable-next-line @cypress/dev/arrow-body-multiline-braces export const create = (state: StateFunc) => ({ timeout (ms?: number, delta: boolean = false) { const runnable = state('runnable') diff --git a/packages/driver/src/cy/timers.ts b/packages/driver/src/cy/timers.ts index 9c55ad2ab7ee..c935dda2a42c 100644 --- a/packages/driver/src/cy/timers.ts +++ b/packages/driver/src/cy/timers.ts @@ -1,6 +1,5 @@ import type { ICypress } from '../cypress' -// eslint-disable-next-line @cypress/dev/arrow-body-multiline-braces export const create = (Cypress: ICypress) => ({ reset () { return Cypress.action('app:timers:reset') diff --git a/packages/driver/src/cy/top_attr_guards.ts b/packages/driver/src/cy/top_attr_guards.ts index cb98268d6c3a..5afc052574d5 100644 --- a/packages/driver/src/cy/top_attr_guards.ts +++ b/packages/driver/src/cy/top_attr_guards.ts @@ -2,7 +2,7 @@ import $elements from '../dom/elements' const invalidTargets = new Set(['_parent', '_top']) -export type GuardedEvent = Event & {target: HTMLFormElement | HTMLAnchorElement} +export type GuardedEvent = Event & { target: HTMLFormElement | HTMLAnchorElement } /** * Guard against target being set to something other than blank or self, while trying @@ -12,7 +12,7 @@ export function handleInvalidEventTarget (e: GuardedEvent) { handleInvalidTarget(e.target) } -export type GuardedAnchorEvent = Event & {target: HTMLAnchorElement} +export type GuardedAnchorEvent = Event & { target: HTMLAnchorElement } /** * We need to listen to all click events on the window, but only handle anchor elements, diff --git a/packages/driver/src/cy/xhrs.ts b/packages/driver/src/cy/xhrs.ts index 157ca472b2f9..5ee94174753a 100644 --- a/packages/driver/src/cy/xhrs.ts +++ b/packages/driver/src/cy/xhrs.ts @@ -23,7 +23,6 @@ const xhrNotWaitedOnByIndex = (state: StateFunc, alias: string, index: number, p } } -// eslint-disable-next-line @cypress/dev/arrow-body-multiline-braces export const create = (state: StateFunc) => ({ getIndexedXhrByAlias (alias: string, index: number) { let prop diff --git a/packages/driver/src/cypress/command_queue.ts b/packages/driver/src/cypress/command_queue.ts index 09ac6e460bf2..7d8db9ea4e96 100644 --- a/packages/driver/src/cypress/command_queue.ts +++ b/packages/driver/src/cypress/command_queue.ts @@ -295,8 +295,6 @@ export class CommandQueue extends Queue<$Command> { command.set('queryFn', ret) ret = retryQuery(command, ret, this.cy) } - } catch (err) { - throw err } finally { // always remove this listener Cypress.removeListener('command:enqueued', commandEnqueued) diff --git a/packages/driver/src/cypress/cy.ts b/packages/driver/src/cypress/cy.ts index 516e74436d8f..a3145fc1a515 100644 --- a/packages/driver/src/cypress/cy.ts +++ b/packages/driver/src/cypress/cy.ts @@ -1,4 +1,3 @@ -/* eslint-disable prefer-rest-params */ import _ from 'lodash' import Promise from 'bluebird' import debugFn from 'debug' @@ -81,7 +80,6 @@ const setTopOnError = function (Cypress, cy: $Cy) { return } - // eslint-disable-next-line @cypress/dev/arrow-body-multiline-braces const onTopError = (handlerType) => (event) => { const { originalErr, err, promise } = $errUtils.errorFromUncaughtEvent(handlerType, event) as ErrorFromProjectRejectionEvent @@ -151,6 +149,7 @@ export class $Cy extends EventEmitter2 implements ITimeouts, IStability, IAssert keyboard: Keyboard mouse: Mouse } + queue: CommandQueue timeout: ITimeouts['timeout'] @@ -1091,7 +1090,6 @@ export class $Cy extends EventEmitter2 implements ITimeouts, IStability, IAssert const cy = this bindToListeners(contentWindow, { - // eslint-disable-next-line @cypress/dev/arrow-body-multiline-braces onError: (handlerType) => (event) => { const { originalErr, err, promise } = $errUtils.errorFromUncaughtEvent(handlerType, event) as ErrorFromProjectRejectionEvent diff --git a/packages/driver/src/cypress/error_messages.ts b/packages/driver/src/cypress/error_messages.ts index 34e998fe8d6b..18ae4aae6a42 100644 --- a/packages/driver/src/cypress/error_messages.ts +++ b/packages/driver/src/cypress/error_messages.ts @@ -1373,7 +1373,7 @@ export default { If you're trying to send a \`x-www-form-urlencoded\` request then pass either a string or object literal to the \`body\` property.`, docsUrl: 'https://on.cypress.io/request', }, - /* eslint-disable indent */ + loading_failed (obj) { return { message: cyStripIndent(`\ @@ -1462,7 +1462,7 @@ export default { docsUrl: 'https://on.cypress.io/request', } }, - /* eslint-enable indent */ + url_missing: { message: `${cmd('request')} requires a \`url\`. You did not provide a \`url\`.`, docsUrl: 'https://on.cypress.io/request', diff --git a/packages/driver/src/cypress/log.ts b/packages/driver/src/cypress/log.ts index a5169d79746f..317b45a7158c 100644 --- a/packages/driver/src/cypress/log.ts +++ b/packages/driver/src/cypress/log.ts @@ -101,7 +101,7 @@ export const LogUtils = { return _ .chain(tests) .flatMap((test) => test.prevAttempts ? [test, ...test.prevAttempts] : [test]) - .flatMap<{id: string}>((tests) => [].concat(tests.agents, tests.routes, tests.commands)) + .flatMap<{ id: string }>((tests) => [].concat(tests.agents, tests.routes, tests.commands)) .compact() .union([{ id: '0' }]) // id is a string in the form of 'log-origin-#', grab the number off the end. diff --git a/packages/driver/src/cypress/mocha.ts b/packages/driver/src/cypress/mocha.ts index 125c36672bba..445b29533b20 100644 --- a/packages/driver/src/cypress/mocha.ts +++ b/packages/driver/src/cypress/mocha.ts @@ -1,4 +1,3 @@ -/* eslint-disable prefer-rest-params */ import _ from 'lodash' import $errUtils, { CypressError } from './error_utils' import $utils from './utils' @@ -450,7 +449,7 @@ function getNormalizedRetriesConfig (Cypress: Cypress.Cypress): NormalizedRetrie } } - const enablementKey: 'openMode'|'runMode' = isInOpenMode ? 'openMode' : 'runMode' + const enablementKey: 'openMode' | 'runMode' = isInOpenMode ? 'openMode' : 'runMode' const enablementValue = retriesConfig[enablementKey] // if retries are explicitly disabled, return an empty object diff --git a/packages/driver/src/cypress/runner.ts b/packages/driver/src/cypress/runner.ts index d4c1b77ff9f9..c72e94d7f6e0 100644 --- a/packages/driver/src/cypress/runner.ts +++ b/packages/driver/src/cypress/runner.ts @@ -1254,7 +1254,6 @@ export default { return foundTest } - // eslint-disable-next-line @cypress/dev/arrow-body-multiline-braces const onSpecError = (handlerType: HandlerType) => (event) => { let { originalErr, err } = $errUtils.errorFromUncaughtEvent(handlerType, event) diff --git a/packages/driver/src/dom/coordinates.ts b/packages/driver/src/dom/coordinates.ts index d4d4e558b249..9af397512439 100644 --- a/packages/driver/src/dom/coordinates.ts +++ b/packages/driver/src/dom/coordinates.ts @@ -189,7 +189,6 @@ const getCoordsByPosition = ( yPosition: 'top' | 'center' | 'bottom' = 'center', ) => { const getLeft = () => { - /* eslint-disable default-case */ switch (xPosition) { case 'left': return Math.ceil(left) case 'center': return Math.floor(left) @@ -205,8 +204,6 @@ const getCoordsByPosition = ( } } - /* eslint-disable default-case */ - // returning x/y here because this is // about the target position we want // to fire the event at based on what diff --git a/packages/driver/src/dom/elements/find.ts b/packages/driver/src/dom/elements/find.ts index e9366f3794b0..5215eaa080a3 100644 --- a/packages/driver/src/dom/elements/find.ts +++ b/packages/driver/src/dom/elements/find.ts @@ -303,7 +303,7 @@ export const getContainsSelector = (text, filter = '', options: { matchCase?: boolean } = {}) => { if (_.isRegExp(text) && options.matchCase === false && !text.flags.includes('i')) { - text = new RegExp(text.source, text.flags + 'i') // eslint-disable-line prefer-template + text = new RegExp(text.source, text.flags + 'i') } const escapedText = _.isString(text) ? JSON.stringify(text).slice(1, -1) : text.toString() diff --git a/packages/driver/src/util/serialization/log.ts b/packages/driver/src/util/serialization/log.ts index 7cb4d63bf8f5..17446b8d7017 100644 --- a/packages/driver/src/util/serialization/log.ts +++ b/packages/driver/src/util/serialization/log.ts @@ -413,7 +413,7 @@ export const preprocessLogForSerialization = (logAttrs) => { * @returns a reified version of what a log is supposed to look like in Cypress */ export const reifyLogFromSerialization = (logAttrs) => { - let { snapshots, ... logAttrsRest } = logAttrs + let { snapshots, ...logAttrsRest } = logAttrs // if the protocol is enabled, we don't need to reify the snapshot since the snapshot was serializable coming into the primary instance of Cypress. // also make sure numTestsKeptInMemory is 0, otherwise we will want to preprocess the snapshot diff --git a/packages/driver/test/tsconfig.json b/packages/driver/test/tsconfig.json new file mode 100644 index 000000000000..ec187a83ccb4 --- /dev/null +++ b/packages/driver/test/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../ts/tsconfig.json", + "compilerOptions": { + "noEmit": true, + "allowJs": true, + }, + "include": ["**/*"] +} \ No newline at end of file diff --git a/packages/driver/types/cypress/log.d.ts b/packages/driver/types/cypress/log.d.ts index 2a793a3b70db..b17a100a26d4 100644 --- a/packages/driver/types/cypress/log.d.ts +++ b/packages/driver/types/cypress/log.d.ts @@ -20,8 +20,8 @@ declare namespace Cypress { } type Snapshot = { - body?: {get: () => any} - htmlAttrs?: {[key: string]: any} + body?: { get: () => any } + htmlAttrs?: { [key: string]: any } name?: string } diff --git a/packages/electron/.eslintignore b/packages/electron/.eslintignore deleted file mode 100644 index 79afe972da7d..000000000000 --- a/packages/electron/.eslintignore +++ /dev/null @@ -1,5 +0,0 @@ -**/dist -**/*.d.ts -**/package-lock.json -**/tsconfig.json -**/cypress/fixtures \ No newline at end of file diff --git a/packages/electron/eslint.config.ts b/packages/electron/eslint.config.ts new file mode 100644 index 000000000000..538cdee3835f --- /dev/null +++ b/packages/electron/eslint.config.ts @@ -0,0 +1,12 @@ +import baseConfig from '../../eslint.config' +import globals from 'globals' + +export default [ + ...baseConfig, { + languageOptions: { + globals: { + ...globals.node, + }, + }, + }, +] diff --git a/packages/electron/package.json b/packages/electron/package.json index dc8d22b68f66..f77caa61663e 100644 --- a/packages/electron/package.json +++ b/packages/electron/package.json @@ -7,7 +7,7 @@ "build-binary": "node ./bin/cypress-electron --install", "clean-deps": "rimraf node_modules", "postinstall": "echo '@packages/electron needs: yarn build'", - "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .", + "lint": "eslint .", "start": "./bin/cypress-electron", "test": "yarn test-unit", "test-debug": "yarn test-unit --inspect-brk=5566", diff --git a/packages/electron/test/.eslintrc.json b/packages/electron/test/.eslintrc.json deleted file mode 100644 index b5ed5206d083..000000000000 --- a/packages/electron/test/.eslintrc.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": [ - "plugin:@cypress/dev/tests" - ] -} diff --git a/packages/electron/tsconfig.json b/packages/electron/tsconfig.json new file mode 100644 index 000000000000..e1aae408665a --- /dev/null +++ b/packages/electron/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../ts/tsconfig.json", + "compilerOptions": { + "allowJs": true, + "noEmit": true, + } +} \ No newline at end of file diff --git a/packages/errors/.eslintignore b/packages/errors/.eslintignore deleted file mode 100644 index d5857ea71fbd..000000000000 --- a/packages/errors/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -**/tsconfig.json diff --git a/packages/errors/eslint.config.ts b/packages/errors/eslint.config.ts new file mode 100644 index 000000000000..c0299b06dfa4 --- /dev/null +++ b/packages/errors/eslint.config.ts @@ -0,0 +1,23 @@ +import baseConfig from '../../eslint.config' + +export default [ + ...baseConfig, + { + ignores: ['__snapshot-html__/**/*'], + }, + { + languageOptions: { + parserOptions: { + projectService: { + allowDefaultProject: ['eslint.config.ts', 'index.js'], + }, + }, + }, + }, + { + rules: { + '@stylistic/block-spacing': 'warn', + '@stylistic/object-curly-spacing': 'warn', + }, + }, +] diff --git a/packages/errors/package.json b/packages/errors/package.json index ef28ab134a6c..7662e6c285c1 100644 --- a/packages/errors/package.json +++ b/packages/errors/package.json @@ -7,16 +7,15 @@ "scripts": { "build": "../../scripts/run-if-ci.sh tsc || echo 'type errors'", "build-prod": "tsc", - "check-ts": "tsc --noEmit && yarn -s tslint", + "check-ts": "tsc --noEmit", "clean": "rimraf ./src/*.js ./src/**/*.js ./src/**/**/*.js ./test/**/*.js || echo 'cleaned'", "clean-deps": "rimraf node_modules", "comparison": "node -r @packages/ts/register test/support/error-comparison-tool.ts", - "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .", + "lint": "eslint .", "test": "yarn test-unit", "test-electron": "HTML_IMAGE_CONVERSION=1 xvfb-maybe electron --no-sandbox ./node_modules/.bin/_mocha", "pretest-unit": "yarn clean", - "test-unit": "mocha", - "tslint": "tslint --config ../ts/tslint.json --project ." + "test-unit": "mocha" }, "dependencies": { "ansi_up": "5.0.0", diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts index cf1d82ec723a..fa999bccef98 100644 --- a/packages/errors/src/errors.ts +++ b/packages/errors/src/errors.ts @@ -1,6 +1,6 @@ import AU from 'ansi_up' import os from 'os' -/* eslint-disable no-console */ + import chalk from 'chalk' import _ from 'lodash' import path from 'path' @@ -172,7 +172,6 @@ export const AllCypressErrors = { We will retry ${fmt.off(arg1.tries)} more ${fmt.off(time)} in ${fmt.off(delay)}... ` /* Because of fmt.listFlags() and fmt.listItems() */ - /* eslint-disable indent */ }, CLOUD_CANNOT_PROCEED_IN_PARALLEL: (arg1: {flags: any, response: Error}) => { const message = normalizeNetworkErrorMessage(arg1.response) @@ -221,7 +220,7 @@ export const AllCypressErrors = { ciBuildId: '--ciBuildId', })}` }, - CLOUD_UNKNOWN_CREATE_RUN_WARNING: (arg1: {props?: any, message: string}) => { + CLOUD_UNKNOWN_CREATE_RUN_WARNING: (arg1: { props?: any, message: string }) => { if (!Object.keys(arg1.props).length) { return errTemplate`\ Warning from Cypress Cloud: ${fmt.highlight(arg1.message)} @@ -234,7 +233,7 @@ export const AllCypressErrors = { Details: ${fmt.meta(arg1.props)}` }, - CLOUD_STALE_RUN: (arg1: {runUrl: string, [key: string]: any}) => { + CLOUD_STALE_RUN: (arg1: { runUrl: string, [key: string]: any }) => { return errTemplate`\ You are attempting to pass the ${fmt.flag(`--parallel`)} flag to a run that was completed over 24 hours ago. @@ -251,7 +250,7 @@ export const AllCypressErrors = { https://on.cypress.io/stale-run` }, - CLOUD_ALREADY_COMPLETE: (props: {runUrl: string, tags: string, group: string, parallel: string, ciBuildId: string}) => { + CLOUD_ALREADY_COMPLETE: (props: {runUrl: string, tags: string, group: string, parallel: boolean, ciBuildId: string}) => { return errTemplate`\ The run you are attempting to access is already complete and will not accept new groups. @@ -259,12 +258,15 @@ export const AllCypressErrors = { When a run finishes all of its groups, it waits for a configurable set of time before finally completing. You must add more groups during that time period. - ${fmt.listFlags(props, { - tags: '--tag', - group: '--group', - parallel: '--parallel', - ciBuildId: '--ciBuildId', - })} + ${fmt.listFlags({ + ...props, + parallel: String(props.parallel), + }, { + tags: '--tag', + group: '--group', + parallel: '--parallel', + ciBuildId: '--ciBuildId', + })} https://on.cypress.io/already-complete` }, @@ -374,7 +376,7 @@ export const AllCypressErrors = { https://on.cypress.io/run-group-name-not-unique` }, - CLOUD_AUTO_CANCEL_NOT_AVAILABLE_IN_PLAN: (arg1: {link: string}) => { + CLOUD_AUTO_CANCEL_NOT_AVAILABLE_IN_PLAN: (arg1: { link: string }) => { return errTemplate`\ ${fmt.highlightSecondary(`Auto Cancellation`)} is not included under your current billing plan. @@ -382,19 +384,23 @@ export const AllCypressErrors = { ${fmt.off(arg1.link)}` }, - CLOUD_AUTO_CANCEL_MISMATCH: (arg1: {runUrl: string, tags: string, group: string, parallel: string, ciBuildId: string, autoCancelAfterFailures: string }) => { + CLOUD_AUTO_CANCEL_MISMATCH: (arg1: {runUrl: string, tags: string, group: string, parallel: boolean, ciBuildId: string, autoCancelAfterFailures: number }) => { return errTemplate`\ You passed the ${fmt.flag(`--auto-cancel-after-failures`)} flag, but this run originally started with a different value for the ${fmt.flag(`--auto-cancel-after-failures`)} flag. The existing run is: ${fmt.url(arg1.runUrl)} - ${fmt.listFlags(arg1, { - tags: '--tag', - group: '--group', - parallel: '--parallel', - ciBuildId: '--ciBuildId', - autoCancelAfterFailures: '--auto-cancel-after-failures', - })} + ${fmt.listFlags({ + ...arg1, + parallel: String(arg1.parallel), + autoCancelAfterFailures: String(arg1.autoCancelAfterFailures), + }, { + tags: '--tag', + group: '--group', + parallel: '--parallel', + ciBuildId: '--ciBuildId', + autoCancelAfterFailures: '--auto-cancel-after-failures', + })} The first setting of --auto-cancel-after-failures for any given run takes precedent. @@ -454,7 +460,6 @@ export const AllCypressErrors = { The --ci-build-id flag is used to either group or parallelize multiple runs together. https://on.cypress.io/incorrect-ci-build-id-usage` - /* eslint-enable indent */ }, RECORD_KEY_MISSING: () => { return errTemplate`\ @@ -503,7 +508,7 @@ export const AllCypressErrors = { https://on.cypress.io/recording-project-runs` }, - CLOUD_INVALID_RUN_REQUEST: (arg1: {message: string, errors: string[], object: object}) => { + CLOUD_INVALID_RUN_REQUEST: (arg1: { message: string, errors: string[], object: object }) => { return errTemplate`\ Recording this run failed. The request was invalid. @@ -642,7 +647,7 @@ export const AllCypressErrors = { return AllCypressErrors.CLOUD_PROTOCOL_UPLOAD_NETWORK_FAILURE(firstError as Error & { url: string }) } - return AllCypressErrors.CLOUD_PROTOCOL_UPLOAD_HTTP_FAILURE(error.errors[0] as Error & { url: string, status: number, statusText: string, responseBody: string}) + return AllCypressErrors.CLOUD_PROTOCOL_UPLOAD_HTTP_FAILURE(error.errors[0] as Error & { url: string, status: number, statusText: string, responseBody: string }) } let systemErr = error.errors.find((err) => { @@ -947,7 +952,7 @@ export const AllCypressErrors = { Instead the value was: ${fmt.stringify(value)}` }, - RENAMED_CONFIG_OPTION: (arg1: {name: string, newName: string}) => { + RENAMED_CONFIG_OPTION: (arg1: { name: string, newName: string }) => { return errTemplate`\ The ${fmt.highlight(arg1.name)} configuration option you have supplied has been renamed. @@ -968,7 +973,7 @@ export const AllCypressErrors = { This server has been configured as your ${fmt.highlight(`baseUrl`)}, and tests will likely fail if it is not running.` }, // TODO: test this - CANNOT_CONNECT_BASE_URL_RETRYING: (arg1: {attempt: number, baseUrl: string, remaining: number, delay: number}) => { + CANNOT_CONNECT_BASE_URL_RETRYING: (arg1: { attempt: number, baseUrl: string, remaining: number, delay: number }) => { switch (arg1.attempt) { case 1: return errTemplate`\ @@ -986,7 +991,7 @@ export const AllCypressErrors = { } }, // TODO: test this - INVALID_REPORTER_NAME: (arg1: {name: string, paths: string[], error: Error}) => { + INVALID_REPORTER_NAME: (arg1: { name: string, paths: string[], error: Error }) => { return errTemplate`\ Error loading the reporter: ${fmt.highlight(arg1.name)} @@ -1032,7 +1037,7 @@ export const AllCypressErrors = { https://on.cypress.io/installing-cypress` }, - FREE_PLAN_EXCEEDS_MONTHLY_PRIVATE_TESTS: (arg1: {link: string, usedTestsMessage: string, limit: number}) => { + FREE_PLAN_EXCEEDS_MONTHLY_PRIVATE_TESTS: (arg1: { link: string, usedTestsMessage: string, limit: number }) => { return errTemplate`\ You've exceeded the limit of private test results under your free plan this month. ${getUsedTestsMessage(arg1.limit, arg1.usedTestsMessage)} @@ -1040,7 +1045,7 @@ export const AllCypressErrors = { ${fmt.off(arg1.link)}` }, - FREE_PLAN_IN_GRACE_PERIOD_EXCEEDS_MONTHLY_PRIVATE_TESTS: (arg1: {link: string, usedTestsMessage: string, gracePeriodMessage: string, limit: number}) => { + FREE_PLAN_IN_GRACE_PERIOD_EXCEEDS_MONTHLY_PRIVATE_TESTS: (arg1: { link: string, usedTestsMessage: string, gracePeriodMessage: string, limit: number }) => { return errTemplate`\ You've exceeded the limit of private test results under your free plan this month. ${getUsedTestsMessage(arg1.limit, arg1.usedTestsMessage)} @@ -1048,7 +1053,7 @@ export const AllCypressErrors = { ${fmt.off(arg1.link)}` }, - PAID_PLAN_EXCEEDS_MONTHLY_PRIVATE_TESTS: (arg1: {link: string, usedTestsMessage: string, limit: number}) => { + PAID_PLAN_EXCEEDS_MONTHLY_PRIVATE_TESTS: (arg1: { link: string, usedTestsMessage: string, limit: number }) => { return errTemplate`\ You've exceeded the limit of private test results under your current billing plan this month. ${getUsedTestsMessage(arg1.limit, arg1.usedTestsMessage)} @@ -1056,7 +1061,7 @@ export const AllCypressErrors = { ${fmt.off(arg1.link)}` }, - FREE_PLAN_EXCEEDS_MONTHLY_TESTS: (arg1: {link: string, usedTestsMessage: string, limit: number}) => { + FREE_PLAN_EXCEEDS_MONTHLY_TESTS: (arg1: { link: string, usedTestsMessage: string, limit: number }) => { return errTemplate`\ You've exceeded the limit of test results under your free plan this month. ${getUsedTestsMessage(arg1.limit, arg1.usedTestsMessage)} @@ -1064,7 +1069,7 @@ export const AllCypressErrors = { ${fmt.off(arg1.link)}` }, - FREE_PLAN_IN_GRACE_PERIOD_EXCEEDS_MONTHLY_TESTS: (arg1: {link: string, usedTestsMessage: string, gracePeriodMessage: string, limit: number}) => { + FREE_PLAN_IN_GRACE_PERIOD_EXCEEDS_MONTHLY_TESTS: (arg1: { link: string, usedTestsMessage: string, gracePeriodMessage: string, limit: number }) => { return errTemplate`\ You've exceeded the limit of test results under your free plan this month. ${getUsedTestsMessage(arg1.limit, arg1.usedTestsMessage)} @@ -1074,7 +1079,7 @@ export const AllCypressErrors = { ${fmt.off(arg1.link)}` }, - PLAN_EXCEEDS_MONTHLY_TESTS: (arg1: {link: string, planType: string, usedTestsMessage: string, limit: number}) => { + PLAN_EXCEEDS_MONTHLY_TESTS: (arg1: { link: string, planType: string, usedTestsMessage: string, limit: number }) => { return errTemplate`\ You've exceeded the limit of test results under your ${fmt.highlight(arg1.planType)} billing plan this month. ${getUsedTestsMessage(arg1.limit, arg1.usedTestsMessage)} @@ -1082,7 +1087,7 @@ export const AllCypressErrors = { ${fmt.off(arg1.link)}` }, - FREE_PLAN_IN_GRACE_PERIOD_PARALLEL_FEATURE: (arg1: {link: string, gracePeriodMessage: string}) => { + FREE_PLAN_IN_GRACE_PERIOD_PARALLEL_FEATURE: (arg1: { link: string, gracePeriodMessage: string }) => { return errTemplate`\ ${fmt.highlightSecondary(`Parallelization`)} is not included under your free plan. @@ -1090,7 +1095,7 @@ export const AllCypressErrors = { ${fmt.off(arg1.link)}` }, - PARALLEL_FEATURE_NOT_AVAILABLE_IN_PLAN: (arg1: {link: string}) => { + PARALLEL_FEATURE_NOT_AVAILABLE_IN_PLAN: (arg1: { link: string }) => { return errTemplate`\ ${fmt.highlightSecondary(`Parallelization`)} is not included under your current billing plan. @@ -1098,7 +1103,7 @@ export const AllCypressErrors = { ${fmt.off(arg1.link)}` }, - PLAN_IN_GRACE_PERIOD_RUN_GROUPING_FEATURE_USED: (arg1: {link: string, gracePeriodMessage: string}) => { + PLAN_IN_GRACE_PERIOD_RUN_GROUPING_FEATURE_USED: (arg1: { link: string, gracePeriodMessage: string }) => { return errTemplate`\ ${fmt.highlightSecondary(`Grouping`)} is not included under your free plan. @@ -1106,7 +1111,7 @@ export const AllCypressErrors = { ${fmt.off(arg1.link)}` }, - RUN_GROUPING_FEATURE_NOT_AVAILABLE_IN_PLAN: (arg1: {link: string}) => { + RUN_GROUPING_FEATURE_NOT_AVAILABLE_IN_PLAN: (arg1: { link: string }) => { return errTemplate`\ ${fmt.highlightSecondary(`Grouping`)} is not included under your current billing plan. @@ -1153,7 +1158,7 @@ export const AllCypressErrors = { CYPRESS_INTERNAL_ENV is reserved for internal use and cannot be modified.` }, - CDP_VERSION_TOO_OLD: (minimumVersion: string, currentVersion: {major: number, minor: string | number}) => { + CDP_VERSION_TOO_OLD: (minimumVersion: string, currentVersion: { major: number, minor: string | number }) => { const phrase = currentVersion.major !== 0 ? fmt.highlight(`${currentVersion.major}.${currentVersion.minor}`) : fmt.off('an older version') @@ -1265,7 +1270,7 @@ export const AllCypressErrors = { }, // TODO: verify configFile is absolute path // TODO: make this relative path, not absolute - EXPERIMENTAL_COMPONENT_TESTING_REMOVED: (arg1: {configFile: string}) => { + EXPERIMENTAL_COMPONENT_TESTING_REMOVED: (arg1: { configFile: string }) => { return errTemplate`\ The ${fmt.highlight('experimentalComponentTesting')} configuration option was removed in ${fmt.cypressVersion(`7.0.0`)}. @@ -1894,7 +1899,6 @@ export const AllCypressErrors = { }, } as const -// eslint-disable-next-line @typescript-eslint/no-unused-vars const _typeCheck: Record ErrTemplateResult> = AllCypressErrors export type AllCypressErrorObj = typeof AllCypressErrors @@ -1981,7 +1985,7 @@ interface GenericError extends Error { [key: string]: any } -export const cloneErr = function (err: CypressError | GenericError, options: {html?: boolean} = {}) { +export const cloneErr = function (err: CypressError | GenericError, options: { html?: boolean } = {}) { _.defaults(options, { html: false, }) diff --git a/packages/errors/src/stackUtils.ts b/packages/errors/src/stackUtils.ts index e713d3cf442c..2015ab6aa23c 100644 --- a/packages/errors/src/stackUtils.ts +++ b/packages/errors/src/stackUtils.ts @@ -3,7 +3,7 @@ import type { ErrorLike } from './errorTypes' export const stackLineRegex = /^\s*(at )?.*@?(?:\(?.*(?::\d+:\d+||\[native code\])+\)?)$/ -type MessageLines = [string[], string[]] & {messageEnded?: boolean} +type MessageLines = [string[], string[]] & { messageEnded?: boolean } // returns tuple of [message, stack] export const splitStack = (stack: string) => { diff --git a/packages/errors/test/support/error-comparison-tool.ts b/packages/errors/test/support/error-comparison-tool.ts index 14a8062ec03d..dbd27509363a 100644 --- a/packages/errors/test/support/error-comparison-tool.ts +++ b/packages/errors/test/support/error-comparison-tool.ts @@ -140,13 +140,13 @@ app.get('/base-list', async (req, res) => { } }) -app.get<{offset: number}>('/load-more/:offset', async (req, res) => { +app.get<{ offset: number }>('/load-more/:offset', async (req, res) => { const rows = await getRows(req.params.offset) res.send(rows) }) -app.get<{offset: number}>('/load-more-base/:offset', async (req, res) => { +app.get<{ offset: number }>('/load-more-base/:offset', async (req, res) => { const rows = await getRows(req.params.offset, true) res.send(rows) @@ -166,7 +166,7 @@ app.get('/looks-good/:name', async (req, res) => { } }) -app.get<{name: string, type: string}>('/html/:name/:type', async (req, res) => { +app.get<{ name: string, type: string }>('/html/:name/:type', async (req, res) => { const pathToFile = path.join(ERRORS_DIR, req.params.type, `${req.params.name}.html`) try { diff --git a/packages/errors/test/unit/errors_spec.ts b/packages/errors/test/unit/errors_spec.ts index 609464bebeda..bad720439861 100644 --- a/packages/errors/test/unit/errors_spec.ts +++ b/packages/errors/test/unit/errors_spec.ts @@ -1,7 +1,7 @@ +/* eslint-disable no-console */ import 'sinon-chai' import style from 'ansi-styles' import chai, { expect } from 'chai' -/* eslint-disable no-console */ import chalk from 'chalk' import sinon, { SinonSpy } from 'sinon' import * as errors from '../../src' @@ -84,9 +84,11 @@ describe('lib/errors', () => { }) it('is not logged if a known Cypress error', () => { - const err = new Error('foo') + const err: Error & { + isCypressErr?: boolean + } = new Error('foo') - err['isCypressErr'] = true + err.isCypressErr = true const ret = errors.log(err) @@ -97,7 +99,10 @@ describe('lib/errors', () => { }) context('err.cause', () => { - let err + let err: Error & { + cause?: any + isCypressErr?: boolean + } beforeEach(() => { err = new Error('foo') diff --git a/packages/errors/test/unit/visualSnapshotErrors_spec.ts b/packages/errors/test/unit/visualSnapshotErrors_spec.ts index 5f9512adf1d7..104f58577294 100644 --- a/packages/errors/test/unit/visualSnapshotErrors_spec.ts +++ b/packages/errors/test/unit/visualSnapshotErrors_spec.ts @@ -185,7 +185,7 @@ const testVisualError = (errorGeneratorFn: () => Er } } -const testVisualErrors = (whichError: CypressErrorType | '*', errorsToTest: {[K in CypressErrorType]: () => ErrorGenerator}) => { +const testVisualErrors = (whichError: CypressErrorType | '*', errorsToTest: { [K in CypressErrorType]: () => ErrorGenerator }) => { // if we aren't testing all the errors if (whichError !== '*') { // then just test this individual error @@ -291,7 +291,7 @@ const makeErr = () => { err.stack = err.stack?.split('\n').slice(0, 3).join('\n') ?? '' - return err as Error & {stack: string} + return err as Error & { stack: string } } process.on('uncaughtException', (err) => { @@ -464,9 +464,10 @@ describe('visual error templates', () => { return { default: [{ runUrl: 'https://cloud.cypress.io/project/abcd/runs/1', - tag: '123', + tags: '123', group: 'foo', parallel: true, + ciBuildId: 'test-ciBuildId-123', }], } }, @@ -474,9 +475,10 @@ describe('visual error templates', () => { return { default: [{ runUrl: 'https://cloud.cypress.io/project/abcd/runs/1', - tag: '123', + tags: '123', group: 'foo', parallel: true, + ciBuildId: 'test-ciBuildId-123', }], } }, @@ -484,9 +486,9 @@ describe('visual error templates', () => { return { default: [{ runUrl: 'https://cloud.cypress.io/project/abcd/runs/1', - tag: '123', + tags: '123', group: 'foo', - parallel: true, + ciBuildId: 'test-ciBuildId-123', }], } }, @@ -563,9 +565,10 @@ describe('visual error templates', () => { return { default: [{ runUrl: 'https://cloud.cypress.io/project/abcd/runs/1', - tag: '123', + tags: '123', group: 'foo', parallel: true, + ciBuildId: 'test-ciBuildId-123', autoCancelAfterFailures: 3, }], } diff --git a/packages/errors/tsconfig.json b/packages/errors/tsconfig.json index 3959f1d1fc2b..cf58420f55a1 100644 --- a/packages/errors/tsconfig.json +++ b/packages/errors/tsconfig.json @@ -1,7 +1,9 @@ { "extends": "../ts/tsconfig.json", "include": [ + "index.js", "src", + "test" ], "compilerOptions": { "allowJs": false, diff --git a/packages/example/bin/convert.js b/packages/example/bin/convert.js index 8ba38500d38f..81fa0c6c5612 100755 --- a/packages/example/bin/convert.js +++ b/packages/example/bin/convert.js @@ -1,7 +1,5 @@ #!/usr/bin/env node -/* eslint-disable quotes */ - const fs = require('fs') const path = require('path') const glob = require('glob') @@ -17,12 +15,12 @@ function replaceStringsIn (file) { } replace('http://localhost:8080', 'https://example.cypress.io') - replace("to.eq('localhost:8080')", "to.eq('example.cypress.io')") - replace("to.eq('localhost')", "to.eq('example.cypress.io')") - replace("to.eq('8080')", "to.eq('')") - replace("to.eq('http:')", "to.eq('https:')") - replace(eslintRe, "") - replace("imgSrcToDataURL('/assets", "imgSrcToDataURL('https://example.cypress.io/assets") + replace('to.eq(\'localhost:8080\')', 'to.eq(\'example.cypress.io\')') + replace('to.eq(\'localhost\')', 'to.eq(\'example.cypress.io\')') + replace('to.eq(\'8080\')', 'to.eq(\'\')') + replace('to.eq(\'http:\')', 'to.eq(\'https:\')') + replace(eslintRe, '') + replace('imgSrcToDataURL(\'/assets', 'imgSrcToDataURL(\'https://example.cypress.io/assets') fs.writeFile(file, str, function (err) { if (err) throw err diff --git a/packages/example/eslint.config.ts b/packages/example/eslint.config.ts new file mode 100644 index 000000000000..7c776897d3cd --- /dev/null +++ b/packages/example/eslint.config.ts @@ -0,0 +1,18 @@ +import baseConfig from '../../eslint.config' + +export default [ + ...baseConfig, + { + ignores: ['app/**/*', 'build/**/*', 'cypress/**/*'], + }, + { + languageOptions: { + parserOptions: { + projectService: { + allowDefaultProject: ['bin/*.js', 'eslint.config.ts', 'cypress.config.js', 'gulpfile.js', 'index.d.ts', 'index.js', 'lib/*.{js,ts}'], + maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING: 10, + }, + }, + }, + }, +] diff --git a/packages/extension/.eslintignore b/packages/extension/.eslintignore deleted file mode 100644 index 3405de2acf70..000000000000 --- a/packages/extension/.eslintignore +++ /dev/null @@ -1,6 +0,0 @@ -**/dist -**/*.d.ts -**/package-lock.json -**/tsconfig.json -**/cypress/fixtures -/test/helpers/background.js \ No newline at end of file diff --git a/packages/extension/app/v3/content.js b/packages/extension/app/v3/content.js index 8c34f18b27d3..940edd70d4e2 100644 --- a/packages/extension/app/v3/content.js +++ b/packages/extension/app/v3/content.js @@ -1,4 +1,4 @@ -/* global chrome, window */ +/* global chrome */ // this content script has access to the DOM, but is otherwise isolated from // the page running Cypress, so we have to use postMessage to communicate. it diff --git a/packages/extension/eslint.config.ts b/packages/extension/eslint.config.ts new file mode 100644 index 000000000000..ba04036df98f --- /dev/null +++ b/packages/extension/eslint.config.ts @@ -0,0 +1,26 @@ +import baseConfig from '../../eslint.config' + +export default [ + ...baseConfig, + { + languageOptions: { + parserOptions: { + projectService: false, + project: './eslint.tsconfig.json', + }, + }, + }, + { + files: ['extension/lib/extension.js'], + }, + { + files: ['test/**/*.js'], + languageOptions: { + globals: { + sinon: 'readonly', + global: 'readonly', + process: 'readonly', + }, + }, + }, +] diff --git a/packages/extension/eslint.tsconfig.json b/packages/extension/eslint.tsconfig.json new file mode 100644 index 000000000000..5c815b9f0993 --- /dev/null +++ b/packages/extension/eslint.tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "allowJs" : true, + "outDir": "./dist" + } +} \ No newline at end of file diff --git a/packages/extension/index.d.ts b/packages/extension/index.d.ts index 902c9e199556..13c625030aa2 100644 --- a/packages/extension/index.d.ts +++ b/packages/extension/index.d.ts @@ -2,4 +2,4 @@ declare const lib: typeof import('./lib/extension') -export default lib \ No newline at end of file +export default lib diff --git a/packages/extension/lib/extension.js b/packages/extension/lib/extension.js index 75612fe7908f..370cc25e5516 100644 --- a/packages/extension/lib/extension.js +++ b/packages/extension/lib/extension.js @@ -1,3 +1,4 @@ +/* global __dirname */ const path = require('path') const Promise = require('bluebird') const { getCookieUrl } = require('./util') diff --git a/packages/extension/package.json b/packages/extension/package.json index 8c3241b1098a..bab44dcb72e0 100644 --- a/packages/extension/package.json +++ b/packages/extension/package.json @@ -5,16 +5,15 @@ "main": "index.js", "scripts": { "build": "gulp build", - "check-ts": "tsc --noEmit && yarn -s tslint", + "check-ts": "tsc --noEmit", "clean": "gulp clean", "clean-deps": "rimraf node_modules", "postinstall": "echo '@packages/extension needs: yarn build'", - "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .", + "lint": "eslint .", "test": "yarn test-unit", "test-debug": "yarn test-unit --inspect-brk=5566", "test-unit": "cross-env NODE_ENV=test mocha -r @packages/ts/register --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json", "test-watch": "yarn test-unit --watch", - "tslint": "tslint --config ../ts/tslint.json --project . --exclude ./dist/v2/background.js", "watch": "yarn build && chokidar 'app/**/*.*' 'app/*.*' -c 'yarn build'" }, "dependencies": { diff --git a/packages/extension/test/.eslintrc.json b/packages/extension/test/.eslintrc.json deleted file mode 100644 index 7e8e439b6d39..000000000000 --- a/packages/extension/test/.eslintrc.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": [ - "plugin:@cypress/dev/tests" - ], - "globals": { - "sinon": true - } -} diff --git a/packages/extension/test/helpers/background.js b/packages/extension/test/helpers/background.js index c883ffa9f0f3..1d3445657ef5 100644 --- a/packages/extension/test/helpers/background.js +++ b/packages/extension/test/helpers/background.js @@ -1,22 +1,24 @@ -(function() { +/* global chrome, io */ + +(function () { var HOST, PATH, automation, client, fail, invoke, - slice = [].slice; + slice = [].slice - HOST = "CHANGE_ME_HOST"; + HOST = 'CHANGE_ME_HOST' - PATH = "CHANGE_ME_PATH"; + PATH = 'CHANGE_ME_PATH' client = io.connect(HOST, { - path: PATH - }); + path: PATH, + }) automation = { - getAllCookies: function(filter, fn) { + getAllCookies: function (filter, fn) { if (filter == null) { - filter = {}; + filter = {} } - return chrome.cookies.getAll(filter, fn); - } - }; -}).call(this); + return chrome.cookies.getAll(filter, fn) + }, + } +}).call(this) diff --git a/packages/frontend-shared/.eslintignore b/packages/frontend-shared/.eslintignore deleted file mode 100644 index b491744f208d..000000000000 --- a/packages/frontend-shared/.eslintignore +++ /dev/null @@ -1,6 +0,0 @@ -**/dist -**/*.d.ts -**/package-lock.json -**/tsconfig.json -**/cypress/fixtures -**/generated \ No newline at end of file diff --git a/packages/frontend-shared/.eslintrc.json b/packages/frontend-shared/.eslintrc.json deleted file mode 100644 index c31464dcd46d..000000000000 --- a/packages/frontend-shared/.eslintrc.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "globals": { - "defineProps": "readonly", - "defineEmits": "readonly", - "defineExpose": "readonly", - "withDefaults": "readonly" - }, - "plugins": [ - "cypress", - "@cypress/dev" - ], - "extends": [ - "plugin:@cypress/dev/general", - "plugin:@cypress/dev/tests", - "plugin:vue/vue3-recommended" - ], - "parser": "vue-eslint-parser", - "parserOptions": { - "parser": "@typescript-eslint/parser" - }, - "env": { - "cypress/globals": true - }, - "overrides": [ - { - "files": "**/*.vue", - "rules": { - "vue/no-v-html": "off", - "no-spaced-func": "off", - "no-restricted-imports": [ - "error", - { - "patterns": [ - "@packages/graphql/*" - ] - } - ] - } - }, - { - "files": [ - "*.tsx", - "*.jsx" - ], - "rules": { - "react/jsx-no-bind": "off", - "react/react-in-jsx-scope": "off", - "react/no-unknown-property": [ - "error", - { - "ignore": [ - "class", - "for" - ] - } - ] - } - } - ] -} diff --git a/packages/frontend-shared/cypress/support/customPercyCommand.ts b/packages/frontend-shared/cypress/support/customPercyCommand.ts index ad714edf3ad8..eb3dfd7da0b9 100644 --- a/packages/frontend-shared/cypress/support/customPercyCommand.ts +++ b/packages/frontend-shared/cypress/support/customPercyCommand.ts @@ -3,7 +3,7 @@ import '@percy/cypress' import type { SnapshotOptions } from '@percy/core' -export interface CustomSnapshotOptions extends SnapshotOptions{ +export interface CustomSnapshotOptions extends SnapshotOptions { /** * width of the snapshot taken from the left edge of the viewport * @default - The test's viewportWidth @@ -28,7 +28,7 @@ export interface CustomSnapshotOptions extends SnapshotOptions{ elementOverrides?: Record void) | true> } -interface SnapshotMutationOptions{ +interface SnapshotMutationOptions { log?: string defaultWidth: number defaultHeight: number @@ -39,7 +39,7 @@ interface SnapshotMutationOptions{ declare global { namespace Cypress { - interface Chainable{ + interface Chainable { /** * A custom Percy command that allows for additional mutations prior to snapshot generation. Mutations will be * reset after snapshot generation so that the AUT is not polluted after the command executes. @@ -84,7 +84,6 @@ class ElementOverrideManager { }) Object.entries(overrides).forEach(([k, v]) => { - // eslint-disable-next-line cypress/no-assigning-return-values const $el = cy.$$(k) if (typeof v === 'function') { @@ -189,7 +188,7 @@ const applySnapshotMutations = ({ }) } -export const installCustomPercyCommand = ({ before, elementOverrides }: {before?: () => void, elementOverrides?: CustomSnapshotOptions['elementOverrides'], isComponentTesting?: boolean } = {}) => { +export const installCustomPercyCommand = ({ before, elementOverrides }: { before?: () => void, elementOverrides?: CustomSnapshotOptions['elementOverrides'], isComponentTesting?: boolean } = {}) => { /** * A custom Percy command that allows for additional mutations prior to snapshot generation. Mutations will be * reset after snapshot generation so that the AUT is not polluted after the command executes. @@ -254,7 +253,7 @@ export const installCustomPercyCommand = ({ before, elementOverrides }: {before? // Percy v3.1.0 will timeout waiting for response from server if screenshot // takes longer than defaultCommandTimeout, so we hack around it - // eslint-disable-next-line + const _backupTimeout = Cypress.config('defaultCommandTimeout') Cypress.config('defaultCommandTimeout', 10000) diff --git a/packages/frontend-shared/cypress/support/e2e.ts b/packages/frontend-shared/cypress/support/e2e.ts index 47d188c07625..2a613c6d5e49 100644 --- a/packages/frontend-shared/cypress/support/e2e.ts +++ b/packages/frontend-shared/cypress/support/e2e.ts @@ -62,7 +62,7 @@ export interface RemoteGraphQLBatchInterceptPayload { result: T } -export type RemoteGraphQLInterceptor = ( +export type RemoteGraphQLInterceptor = ( obj: RemoteGraphQLInterceptPayload, testState: Record, options: Record) => ExecutionResult | Promise> | Response export type RemoteGraphQLBatchInterceptor = (obj: RemoteGraphQLBatchInterceptPayload, testState: Record) => T | Promise @@ -244,7 +244,7 @@ function openGlobalMode (options: OpenGlobalModeOptions = {}) { }) } -type WithPrefix = `${T}${string}`; +type WithPrefix = `${T}${string}` function openProject (projectName: WithPrefix, argv: string[] = [], capabilities: InternalOpenProjectCapabilities = { cloudStudio: false }) { if (!fixtureDirs.some((dir) => projectName.startsWith(dir))) { @@ -287,7 +287,7 @@ function startAppServer (mode: 'component' | 'e2e' = 'e2e', options: { skipMocki // Used to format a Cypress error in a way that makes sense to the cy-in-cy // open mode reporter. Typically we'll see all the details we need in the // terminal or in the Cypress UI components, but in the reporter we need to format it a bit - function formatError (e: Error & {messageMarkdown?: string, originalError?: Error}) { + function formatError (e: Error & { messageMarkdown?: string, originalError?: Error }) { if (e.messageMarkdown) { e.message = e.messageMarkdown if (e.originalError) { @@ -431,8 +431,8 @@ function skipWelcome () { type UnwrapPromise = R extends PromiseLike ? U : R export type CyTaskResult = - {value?: never, error: {name: string, message: string, stack?: string}} | - {value: UnwrapPromise, error?: never} + { value?: never, error: { name: string, message: string, stack?: string } } | + { value: UnwrapPromise, error?: never } function withRetryableCtx, R> (fn: (ctx: DataContext, o: T & WithCtxInjected) => R | Promise, opts: T = {} as T): Cypress.Chainable> { return withCtx(fn, { ...opts, retry: true }) @@ -521,7 +521,7 @@ function findBrowsers (options: FindBrowsersOptions = {}) { }) } -function remoteGraphQLIntercept (fn: RemoteGraphQLInterceptor, remoteGraphQLOptions?: Record) { +function remoteGraphQLIntercept (fn: RemoteGraphQLInterceptor, remoteGraphQLOptions?: Record) { return logInternal('remoteGraphQLIntercept', () => { return taskInternal('__internal_remoteGraphQLIntercept', { fn: fn.toString(), @@ -530,7 +530,7 @@ function remoteGraphQLIntercept (fn: RemoteGraphQLInterceptor, remo }) } -function remoteGraphQLInterceptBatched (fn: RemoteGraphQLBatchInterceptor) { +function remoteGraphQLInterceptBatched (fn: RemoteGraphQLBatchInterceptor) { return logInternal('remoteGraphQLInterceptBatched', () => { return taskInternal('__internal_remoteGraphQLInterceptBatched', fn.toString()) }) diff --git a/packages/frontend-shared/cypress/support/mock-graphql/clientTestUtils.ts b/packages/frontend-shared/cypress/support/mock-graphql/clientTestUtils.ts index 113eee844d80..8e8957261ef6 100644 --- a/packages/frontend-shared/cypress/support/mock-graphql/clientTestUtils.ts +++ b/packages/frontend-shared/cypress/support/mock-graphql/clientTestUtils.ts @@ -36,7 +36,7 @@ export function resetTestNodeIdx () { nodeIdx = {} } -export function testNodeId (type: T, title?: string) { +export function testNodeId (type: T, title?: string) { nodeIdx[type] = (nodeIdx[type] ?? 0) + 1 const id = title ? `${type}:${nodeIdx[type]}:${title}` : `${type}:${nodeIdx[type]}` diff --git a/packages/frontend-shared/cypress/support/mock-graphql/fake-uuid.d.ts b/packages/frontend-shared/cypress/support/mock-graphql/fake-uuid.d.ts index b88f6a1cf20c..14a1ae9c0992 100644 --- a/packages/frontend-shared/cypress/support/mock-graphql/fake-uuid.d.ts +++ b/packages/frontend-shared/cypress/support/mock-graphql/fake-uuid.d.ts @@ -1,5 +1,5 @@ declare module 'fake-uuid' { - type A_to_F = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' + type A_to_F = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' const fakeUuid: (input?: A_to_F | number, fill?: number | A_to_F) => string export default fakeUuid -} \ No newline at end of file +} diff --git a/packages/frontend-shared/cypress/support/mock-graphql/mountFragment.ts b/packages/frontend-shared/cypress/support/mock-graphql/mountFragment.ts index 77f3a56d62cc..a9fcec9ec33b 100644 --- a/packages/frontend-shared/cypress/support/mock-graphql/mountFragment.ts +++ b/packages/frontend-shared/cypress/support/mock-graphql/mountFragment.ts @@ -162,7 +162,7 @@ export const registerMountFn = ({ plugins }: MountFnOptions = {}) => { subscriptionHooks.set(name, hook) } - function stubSubscriptionEvent > ( + function stubSubscriptionEvent> ( document: T, emitEvent: () => ResultOf, ) { diff --git a/packages/frontend-shared/cypress/support/mock-graphql/stubgql-ErrorWrapper.ts b/packages/frontend-shared/cypress/support/mock-graphql/stubgql-ErrorWrapper.ts index d84d25a9776f..b03beec1c78c 100644 --- a/packages/frontend-shared/cypress/support/mock-graphql/stubgql-ErrorWrapper.ts +++ b/packages/frontend-shared/cypress/support/mock-graphql/stubgql-ErrorWrapper.ts @@ -46,5 +46,5 @@ export const StubErrorWrapper = { } as const // For type checking -// eslint-disable-next-line @typescript-eslint/no-unused-vars + const _typeCheck: MaybeResolver = StubErrorWrapper diff --git a/packages/frontend-shared/cypress/support/mock-graphql/stubgql-Mutation.ts b/packages/frontend-shared/cypress/support/mock-graphql/stubgql-Mutation.ts index 8b2122cba26e..866ee5d757f4 100644 --- a/packages/frontend-shared/cypress/support/mock-graphql/stubgql-Mutation.ts +++ b/packages/frontend-shared/cypress/support/mock-graphql/stubgql-Mutation.ts @@ -148,7 +148,7 @@ export const stubMutation: MaybeResolver = { return args.ids.map((id) => { const [__typename, hash] = atob(id).split(':') - const rf: RemoteFetchable & {__typename: string} = { + const rf: RemoteFetchable & { __typename: string } = { id, fetchingStatus: 'FETCHING', operation: '', diff --git a/packages/frontend-shared/cypress/support/mock-graphql/stubgql-Registry.ts b/packages/frontend-shared/cypress/support/mock-graphql/stubgql-Registry.ts index 384862cb8687..e00bda9f39e8 100644 --- a/packages/frontend-shared/cypress/support/mock-graphql/stubgql-Registry.ts +++ b/packages/frontend-shared/cypress/support/mock-graphql/stubgql-Registry.ts @@ -8,7 +8,7 @@ import { stubMigration } from './stubgql-Migration' import type { CodegenTypeMap } from '../generated/test-graphql-types.gen' import { StubErrorWrapper } from './stubgql-ErrorWrapper' -type MaybeResolveMap = {[K in keyof CodegenTypeMap]: MaybeResolver} +type MaybeResolveMap = { [K in keyof CodegenTypeMap]: MaybeResolver } export const GQLStubRegistry = { Wizard: stubWizard, @@ -28,5 +28,5 @@ export const GQLStubRegistry = { } as const // For Type checking -// eslint-disable-next-line @typescript-eslint/no-unused-vars + const _x: Partial = GQLStubRegistry diff --git a/packages/frontend-shared/eslint.config.ts b/packages/frontend-shared/eslint.config.ts new file mode 100644 index 000000000000..a5d71f1d1708 --- /dev/null +++ b/packages/frontend-shared/eslint.config.ts @@ -0,0 +1,47 @@ +import baseConfig from '../../eslint.config' +import globals from 'globals' +import react from 'eslint-plugin-react' + +export default [ + ...baseConfig, + { + ignores: ['**/generated/**/*'], + }, + { + files: ['index.js'], + languageOptions: { + globals: { + process: 'readonly', + }, + }, + }, + { + files: ['script/**/*'], + languageOptions: { + globals: { + ...globals.node, + }, + }, + }, + // {cy,spec}.tsx files in the src/ dir are component tests, + // and since the components that are being rendered are vue + // components and not react components, react rules do not apply. + { + files: ['src/**/*.{spec,cy}.tsx'], + rules: { + ...Object.keys(react.configs.flat.recommended.rules).reduce((rules, rule) => { + return { + ...rules, + [rule]: 'off', + } + }, {}), + 'react/no-unknown-property': 'off', + }, + }, + { + rules: { + 'import-x/no-unresolved': 'warn', + 'vue/no-v-html': 'warn', + }, + }, +] diff --git a/packages/frontend-shared/package.json b/packages/frontend-shared/package.json index e8881af87d6d..637ca9a3c380 100644 --- a/packages/frontend-shared/package.json +++ b/packages/frontend-shared/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "build": "node ./script/build.js", - "check-ts": "vue-tsc --noEmit && yarn -s tslint", + "check-ts": "vue-tsc --noEmit", "clean": "rimraf dist ./node_modules/.vite src/*.js src/**/*.js && echo 'cleaned'", "clean-deps": "rimraf node_modules", "cypress:open": "cross-env TZ=America/New_York node ../../scripts/cypress open --component --project .", @@ -14,9 +14,8 @@ "generate-shiki-theme": "node ./script/generate-shiki-theme.js", "generate-stub-specs": "node ./script/generate-stub-specs.js", "postinstall": "patch-package", - "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json,.vue .", - "test": "yarn cypress:run && yarn types", - "tslint": "tslint --config ../ts/tslint.json --project ." + "lint": "eslint .", + "test": "yarn cypress:run && yarn types" }, "dependencies": { "@cypress-design/vue-icon": "^1.6.0", diff --git a/packages/frontend-shared/src/components/AlertHeader.vue b/packages/frontend-shared/src/components/AlertHeader.vue index 65cf9937ac6a..4111131e744f 100644 --- a/packages/frontend-shared/src/components/AlertHeader.vue +++ b/packages/frontend-shared/src/components/AlertHeader.vue @@ -51,7 +51,6 @@ const emit = defineEmits<{ (eventName: 'suffixIconClicked'): void }>() -/* eslint-disable vue/require-default-prop */ defineProps<{ title: string prefixIcon?: FunctionalComponent | null diff --git a/packages/frontend-shared/src/components/Badge.vue b/packages/frontend-shared/src/components/Badge.vue index aed7d9d36ff5..d5cfd956d6c4 100644 --- a/packages/frontend-shared/src/components/Badge.vue +++ b/packages/frontend-shared/src/components/Badge.vue @@ -1,5 +1,5 @@