Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Unify eslint config, convert to flat configs and update plugins (WIP) #30892

Open
wants to merge 115 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
228246c
remove eslint-plugin-dev
cacieprins Jan 14, 2025
7f3c67e
more fully remove eslint dev pkg
cacieprins Jan 14, 2025
920e1c7
use updated eslint for ./scripts
cacieprins Jan 14, 2025
00f1243
use new eslint for cli
cacieprins Jan 14, 2025
7c30ac8
npm/angular linting
cacieprins Jan 14, 2025
0a7039b
cypress-schematic eslint
cacieprins Jan 14, 2025
3f44b01
eslint for npm/grep
cacieprins Jan 14, 2025
6d821ab
npm/mount-utils
cacieprins Jan 14, 2025
57a038d
npm/puppeteer
cacieprins Jan 14, 2025
32ebb37
some global cfg
cacieprins Jan 14, 2025
ed49878
npm/react
cacieprins Jan 14, 2025
0749dbe
npm/svelte
cacieprins Jan 14, 2025
4c15d08
npm/vite-dev-server
cacieprins Jan 14, 2025
9433e5d
npm/vite-plugin-cypress-esm
cacieprins Jan 14, 2025
fe99b9f
adds react linting to npm/react
cacieprins Jan 14, 2025
d9c2439
npm/vue
cacieprins Jan 14, 2025
5205963
npm/webpack-batteries-included-preprocessor
cacieprins Jan 14, 2025
5be93e7
npm/webpack-dev-server
cacieprins Jan 14, 2025
1b1862a
npm/webpack-preprocessor
cacieprins Jan 14, 2025
7ce76db
use stylistic for ./scripts
cacieprins Jan 14, 2025
2ac9889
npm/angular with styles
cacieprins Jan 14, 2025
53d7cab
npm/cypress-schematic stylistic
cacieprins Jan 14, 2025
8c866c1
npm/grep stylistic
cacieprins Jan 14, 2025
d4d0637
npm/mount-utils stylistic
cacieprins Jan 14, 2025
77f38fc
npm/puppeteer stylistic
cacieprins Jan 14, 2025
c62768e
npm/react stylistic
cacieprins Jan 14, 2025
fb74c93
npm/svelte stylistic
cacieprins Jan 14, 2025
a0ea82b
adds back some restricted properties and syntax
cacieprins Jan 14, 2025
c34babc
npm/vite-dev-server stylistic
cacieprins Jan 14, 2025
58a38ac
npm/vite-plugin-cypress-esm stylistic
cacieprins Jan 14, 2025
816ba0d
npm/vue stylistic
cacieprins Jan 14, 2025
124ad49
npm/webpack-batteries-included stylistic
cacieprins Jan 14, 2025
3cb0c44
npm/webpack-dev-server stylistic
cacieprins Jan 14, 2025
9d84f3d
npm/webpack-preprocessor stylistic
cacieprins Jan 14, 2025
27797d0
cli stylistic
cacieprins Jan 14, 2025
d7bac78
new linting for packages/app
cacieprins Jan 14, 2025
6434772
remove conflicting old eslintrc from app
cacieprins Jan 15, 2025
eed56c0
lint fix for packages/config
cacieprins Jan 15, 2025
d035fa9
redundant rules in puppeteer
cacieprins Jan 15, 2025
8ba5ccb
eslint for packages/data-context
cacieprins Jan 15, 2025
b664d1b
eslint for packages/driver
cacieprins Jan 15, 2025
007aae2
eslint cleanup general
cacieprins Jan 15, 2025
85be136
packages/electron
cacieprins Jan 15, 2025
e2ed779
packages/errors
cacieprins Jan 15, 2025
abf276f
packages/example
cacieprins Jan 15, 2025
45184c0
rm
cacieprins Jan 15, 2025
93fb014
packages/extension
cacieprins Jan 15, 2025
2869f9a
basic linting for packages/frontend-shared
cacieprins Jan 15, 2025
df20017
basic graphql schema linting
cacieprins Jan 15, 2025
77b113e
eslint for packages/graphql
cacieprins Jan 15, 2025
7b7fb97
some cleanup
cacieprins Jan 15, 2025
1228a72
packages/https-proxy
cacieprins Jan 15, 2025
b79bf01
packages/icons
cacieprins Jan 15, 2025
bcbb78b
packages/launcher
cacieprins Jan 15, 2025
8529b72
packages/launchpad
cacieprins Jan 15, 2025
1c577fc
further restrict launchpad eslint to reduce impact of slow vue linting
cacieprins Jan 15, 2025
cbb673b
packages/net-stubbing
cacieprins Jan 15, 2025
3cb0ba1
packages/network
cacieprins Jan 15, 2025
8c1f83f
packages/packherd-require
cacieprins Jan 15, 2025
ad4bb60
packages/proxy
cacieprins Jan 15, 2025
92e192b
packages/reporter
cacieprins Jan 15, 2025
5c06e17
packages/resolve-dist
cacieprins Jan 15, 2025
d70180b
packages/rewriter
cacieprins Jan 15, 2025
a98c2bd
packages/runner
cacieprins Jan 15, 2025
ddbe9a9
packages/scaffold-config
cacieprins Jan 15, 2025
925955f
packages/server
cacieprins Jan 15, 2025
9b12088
packages/socket
cacieprins Jan 15, 2025
ecbe1f0
packages/telemetry
cacieprins Jan 15, 2025
32d1009
rm old eslintrc
cacieprins Jan 15, 2025
02f9730
packages/ts
cacieprins Jan 15, 2025
23dff45
packages/types
cacieprins Jan 15, 2025
08e1227
packages/v8-snapshot-require
cacieprins Jan 15, 2025
0d450bd
packages/web-config
cacieprins Jan 15, 2025
f174d7c
system-tests
cacieprins Jan 15, 2025
10bdd9f
tooling/electron-mksnapshot
cacieprins Jan 15, 2025
7d48750
rm old eslintrc
cacieprins Jan 15, 2025
643e17c
tooling/packherd
cacieprins Jan 15, 2025
ca7441a
tooling/v8-snapshot
cacieprins Jan 15, 2025
add6226
delete unnecessary eslintrc.json
cacieprins Jan 15, 2025
3e35bce
fix mount-utils eslint config
cacieprins Jan 15, 2025
7b44b56
fix webpack-preprocessor eslint.config.ts
cacieprins Jan 15, 2025
63a0d72
fix puppeteer eslint
cacieprins Jan 15, 2025
2e14154
fix svelte eslint config
cacieprins Jan 15, 2025
9462fc5
fix vite-plugin-cypress-esm eslint config
cacieprins Jan 15, 2025
b264d90
grep eslint fix
cacieprins Jan 15, 2025
1d1d61c
fix webpack-batteries eslint config
cacieprins Jan 15, 2025
9ec71b5
fix schematic
cacieprins Jan 15, 2025
ce4bbc8
fix vue eslint config
cacieprins Jan 15, 2025
515fb78
fix vite-dev-server eslint
cacieprins Jan 15, 2025
3d141fb
fix padding in cli
cacieprins Jan 15, 2025
3115ed7
fix npm/react
cacieprins Jan 15, 2025
2fdc396
fix lint in packages/config
cacieprins Jan 16, 2025
be425ab
fix lint for npm/webpack-dev-server
cacieprins Jan 16, 2025
09582b4
fix packages/electron
cacieprins Jan 16, 2025
0845c5c
fix extension
cacieprins Jan 16, 2025
ef293d4
eslint fixes for runner
cacieprins Jan 16, 2025
1dc3f65
set some react rules to warn
cacieprins Jan 16, 2025
2748955
fixes packages/driver
cacieprins Jan 16, 2025
f03c6ae
disable inapplicable react rules
cacieprins Jan 16, 2025
6f5340c
fix frontend-shared
cacieprins Jan 16, 2025
f4f5148
add class= back in
cacieprins Jan 16, 2025
f968f74
react rules do not apply to vue component tests
cacieprins Jan 16, 2025
4d1a034
fix whitespace in tooling/packherd
cacieprins Jan 16, 2025
69e6d51
data-context and internal scripts
cacieprins Jan 16, 2025
c965691
app eslint fixes
cacieprins Jan 16, 2025
1206812
final pass fixes for check-ts and lint
cacieprins Jan 16, 2025
4afc395
Merge branch 'develop' into eslint-stylistic
cacieprins Jan 16, 2025
4f6d36f
fix sorting in root package json, add (?does it work?) json eslint pl…
cacieprins Jan 16, 2025
6be9cd0
remove unused `path` identifier in root eslint.config.ts
cacieprins Jan 16, 2025
36b8655
expound on eslint methodology in CONTRIBUTING.md
cacieprins Jan 16, 2025
b2a7e3e
use prettier for json files, use prettier-package-json for package.js…
cacieprins Jan 21, 2025
09e07a4
Merge branch 'develop' into eslint-stylistic
cacieprins Jan 21, 2025
66b69a2
Update package.json
cacieprins Jan 21, 2025
3a27427
ignore .d.ts files in system-tests
cacieprins Jan 21, 2025
9f30b85
ignore validations in system tests
cacieprins Jan 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
16 changes: 0 additions & 16 deletions .circleci/workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2322,14 +2322,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:
Expand Down Expand Up @@ -3016,9 +3008,6 @@ linux-x64-workflow: &linux-x64-workflow
- npm-mount-utils:
requires:
- build
- npm-eslint-plugin-dev:
requires:
- build
- npm-cypress-schematic:
requires:
- build
Expand All @@ -3031,7 +3020,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
Expand Down Expand Up @@ -3387,9 +3375,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
Expand All @@ -3401,7 +3386,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
Expand Down
109 changes: 0 additions & 109 deletions .eslintrc.js

This file was deleted.

6 changes: 5 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
**/*

/.nx/cache
/.nx/workspace-data
/.nx/workspace-data

!**/*.json
**/package.json
**/package-lock.json
10 changes: 1 addition & 9 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these options are no longer valid in vscode

"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"json"
],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
Expand Down
9 changes: 6 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
Expand Down Expand Up @@ -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.
Expand Down
7 changes: 2 additions & 5 deletions autobarrel.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
16 changes: 0 additions & 16 deletions cli/.eslintignore

This file was deleted.

19 changes: 0 additions & 19 deletions cli/.eslintrc.json

This file was deleted.

62 changes: 62 additions & 0 deletions cli/eslint.config.ts
Original file line number Diff line number Diff line change
@@ -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',
},
},
},
]
3 changes: 1 addition & 2 deletions cli/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand All @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions cli/scripts/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
//
Expand Down
Loading
Loading