Skip to content

Commit 430eff5

Browse files
committed
cypress: Migrate to eslint v9
1 parent 3c80e1b commit 430eff5

File tree

8 files changed

+742
-460
lines changed

8 files changed

+742
-460
lines changed

workbench-cypress/.eslintignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

workbench-cypress/.eslintrc.json

Lines changed: 0 additions & 78 deletions
This file was deleted.

workbench-cypress/cypress/e2e/utils/sharedTests/excerpt.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ function truncate(str: string, len: number): string {
55
let truncated = "";
66
let width = 0;
77

8-
// eslint-disable-next-line no-restricted-syntax
98
for (const char of str) {
109
width += fullWidthRegex.test(char) ? 2 : 1;
1110

workbench-cypress/cypress/e2e/utils/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export type ScrollTo = ScrollToPosition | ScrollToXY | ScrollIntoView;
2929

3030
export type ClickFlow = {
3131
toClickBefore?: Selector;
32-
// eslint-disable-next-line no-use-before-define
3332
expectations: Expectation[];
3433
toClickAfter?: Selector;
3534
force?: boolean;

workbench-cypress/cypress/support/commands.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,21 @@ Cypress.Commands.add("visitAndWait", (path: string) => {
4040
function spyOnAddEventListener(win: any) {
4141
// win = window object in our application
4242
const addListener = win.EventTarget.prototype.addEventListener;
43-
// eslint-disable-next-line no-param-reassign
4443
win.EventTarget.prototype.addEventListener = function (name: string) {
4544
if (name === "change") {
4645
// web app added an event listener to the input box -
4746
// that means the web application has started
4847
appHasStarted = true;
4948
// restore the original event listener
50-
// eslint-disable-next-line no-param-reassign
5149
win.EventTarget.prototype.addEventListener = addListener;
5250
}
53-
// eslint-disable-next-line prefer-rest-params
5451
return addListener.apply(this, arguments);
5552
};
5653
}
5754

5855
function waitForAppStart() {
5956
// keeps rechecking "appHasStarted" variable
6057
return new Cypress.Promise((resolve, _) => {
61-
// eslint-disable-next-line consistent-return
6258
const isReady = () => {
6359
if (appHasStarted) {
6460
return resolve();
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
import js from '@eslint/js';
2+
import tseslint from '@typescript-eslint/eslint-plugin';
3+
import tsparser from '@typescript-eslint/parser';
4+
import cypress from 'eslint-plugin-cypress';
5+
import importPlugin from 'eslint-plugin-import';
6+
import eslintConfigPrettier from 'eslint-config-prettier';
7+
8+
export default [
9+
// Global ignores
10+
{
11+
ignores: ['node_modules/**', 'dist/**', 'cypress.config.ts', 'eslint.config.mjs'],
12+
},
13+
js.configs.recommended,
14+
{
15+
files: ['cypress/**/*.{js,ts}'],
16+
languageOptions: {
17+
parser: tsparser,
18+
parserOptions: {
19+
project: './tsconfig.json',
20+
ecmaVersion: 'latest',
21+
sourceType: 'module',
22+
},
23+
globals: {
24+
cy: 'readonly',
25+
Cypress: 'readonly',
26+
describe: 'readonly',
27+
it: 'readonly',
28+
before: 'readonly',
29+
after: 'readonly',
30+
beforeEach: 'readonly',
31+
afterEach: 'readonly',
32+
expect: 'readonly',
33+
context: 'readonly',
34+
setTimeout: 'readonly',
35+
},
36+
},
37+
plugins: {
38+
'@typescript-eslint': tseslint,
39+
'import': importPlugin,
40+
'cypress': cypress,
41+
},
42+
rules: {
43+
// Base JavaScript recommended rules
44+
...js.configs.recommended.rules,
45+
46+
// TypeScript ESLint recommended rules
47+
...tseslint.configs.recommended.rules,
48+
49+
// Import plugin rules (mimicking airbnb-base behavior)
50+
'import/no-unresolved': 'error',
51+
'import/named': 'error',
52+
'import/default': 'error',
53+
'import/namespace': 'error',
54+
'import/no-absolute-path': 'error',
55+
'import/no-self-import': 'error',
56+
'import/no-cycle': 'error',
57+
'import/no-useless-path-segments': 'error',
58+
'import/newline-after-import': 'error',
59+
'import/no-duplicates': 'error',
60+
61+
// Custom rules from the original config
62+
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
63+
'@typescript-eslint/await-thenable': 'error',
64+
'@typescript-eslint/explicit-function-return-type': 'off',
65+
'@typescript-eslint/explicit-module-boundary-types': 'off',
66+
'@typescript-eslint/naming-convention': [
67+
'error',
68+
{
69+
selector: 'default',
70+
format: ['camelCase'],
71+
leadingUnderscore: 'allow',
72+
},
73+
{
74+
selector: 'variable',
75+
format: ['camelCase', 'UPPER_CASE'],
76+
},
77+
{
78+
selector: ['typeLike', 'enumMember'],
79+
format: ['PascalCase'],
80+
},
81+
{
82+
selector: ['objectLiteralProperty'],
83+
format: null,
84+
},
85+
],
86+
'@typescript-eslint/no-base-to-string': 'error',
87+
'@typescript-eslint/no-extra-non-null-assertion': 'error',
88+
'@typescript-eslint/no-floating-promises': 'error',
89+
'@typescript-eslint/no-namespace': 'error',
90+
'@typescript-eslint/no-non-null-assertion': 'error',
91+
'@typescript-eslint/no-unused-vars': [
92+
'error',
93+
{
94+
argsIgnorePattern: '^_',
95+
varsIgnorePattern: '^_',
96+
},
97+
],
98+
'@typescript-eslint/no-use-before-define': [
99+
'error',
100+
{
101+
classes: false,
102+
functions: false,
103+
},
104+
],
105+
'@typescript-eslint/prefer-interface': 'off',
106+
'@typescript-eslint/prefer-nullish-coalescing': ['warn'],
107+
'@typescript-eslint/prefer-optional-chain': 'error',
108+
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
109+
'@typescript-eslint/promise-function-async': 'error',
110+
111+
// Import rules
112+
'import/prefer-default-export': 'off',
113+
114+
// Base JavaScript rules
115+
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
116+
'no-sequences': 'error',
117+
'no-underscore-dangle': 'off',
118+
'no-use-before-define': ['error', { classes: false, functions: false }],
119+
120+
// Cypress rules
121+
'cypress/no-unnecessary-waiting': 'warn',
122+
123+
},
124+
settings: {
125+
'import/resolver': {
126+
typescript: {
127+
project: './tsconfig.json',
128+
},
129+
node: {
130+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
131+
paths: ['cypress'],
132+
},
133+
},
134+
},
135+
},
136+
// Prettier config to disable formatting rules
137+
eslintConfigPrettier,
138+
];

workbench-cypress/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
"@babel/preset-env": "^7.28.3",
2626
"@babel/preset-typescript": "^7.27.1",
2727
"@cypress/github-action": "^6.10.2",
28-
"@typescript-eslint/eslint-plugin": "^7.14.1",
29-
"@typescript-eslint/parser": "^8.34.1",
30-
"eslint": "^8.57.0",
31-
"eslint-config-airbnb-base": "^15.0.0",
32-
"eslint-config-airbnb-typescript": "^18.0.0",
33-
"eslint-config-prettier": "^10.1.8",
28+
"@eslint/js": "^9.16.0",
29+
"@typescript-eslint/eslint-plugin": "^8.18.0",
30+
"@typescript-eslint/parser": "^8.18.0",
31+
"eslint": "^9.16.0",
32+
"eslint-config-prettier": "^9.1.0",
33+
"eslint-import-resolver-typescript": "^3.6.3",
3434
"eslint-plugin-cypress": "^4.3.0",
3535
"eslint-plugin-import": "^2.32.0",
3636
"npm-run-all2": "^8.0.4",

0 commit comments

Comments
 (0)