From 9089563c7366bc371bbfeefe5dbb3236971c82d7 Mon Sep 17 00:00:00 2001 From: Kai Spencer Date: Sat, 20 Jul 2024 19:47:38 +0100 Subject: [PATCH 1/2] chore: migrate eslint to flat config --- .eslintrc.js | 39 ---- eslint.config.mjs | 59 ++++++ package.json | 10 +- pnpm-lock.yaml | 198 ++++++++++++------ src/core/utils/internal/getCallFrame.ts | 4 +- .../utils/internal/parseGraphQLRequest.ts | 1 + src/core/utils/matching/matchRequestUrl.ts | 4 +- src/core/utils/url/cleanUrl.ts | 2 +- src/core/utils/url/isAbsoluteUrl.ts | 2 +- .../iframe-isolated-response.mocks.ts | 2 +- test/browser/playwright.extend.ts | 6 +- .../rest-api/query-params-warning.test.ts | 4 +- .../response/body/body-stream.test.ts | 1 + 13 files changed, 219 insertions(+), 113 deletions(-) delete mode 100644 .eslintrc.js create mode 100644 eslint.config.mjs diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index c65bce779..000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,39 +0,0 @@ -module.exports = { - parser: '@typescript-eslint/parser', - parserOptions: { - ecmaVersion: 2020, - sourceType: 'module', - }, - extends: [ - 'plugin:@typescript-eslint/recommended', - 'plugin:prettier/recommended', - ], - rules: { - // Forbid "console.debug()" statements. - 'no-console': [ - 'error', - { - allow: ['log', 'warn', 'error', 'group', 'groupCollapsed', 'groupEnd'], - }, - ], - '@typescript-eslint/prefer-ts-expect-error': 2, - '@typescript-eslint/no-explicit-any': 0, - '@typescript-eslint/explicit-module-boundary-types': 0, - '@typescript-eslint/ban-ts-comment': 0, - '@typescript-eslint/no-namespace': [ - 2, - { - allowDeclarations: true, - }, - ], - '@typescript-eslint/no-namespace': 0, - '@typescript-eslint/no-var-requires': 0, - '@typescript-eslint/no-unused-vars': [ - 2, - { - varsIgnorePattern: '^_', - argsIgnorePattern: '^_', - }, - ], - }, -} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 000000000..193ef528a --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,59 @@ +// @ts-check + +import eslint from '@eslint/js' +import tseslint from 'typescript-eslint' +import eslintConfigPrettier from 'eslint-config-prettier' +import eslintPluginPrettier from 'eslint-plugin-prettier/recommended' + +export default tseslint.config( + eslint.configs.recommended, + eslintConfigPrettier, + ...tseslint.configs.recommended, + { + languageOptions: { + parserOptions: { ecmaVersion: 2020, sourceType: 'module' }, + }, + rules: { + 'no-console': [ + 'error', + { + allow: [ + 'log', + 'warn', + 'error', + 'group', + 'groupCollapsed', + 'groupEnd', + ], + }, + ], + '@typescript-eslint/prefer-ts-expect-error': 'error', + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/explicit-module-boundary-types': 'off', + '@typescript-eslint/ban-ts-comment': 'off', + '@typescript-eslint/no-namespace': [ + 'error', + { + allowDeclarations: true, + }, + ], + '@typescript-eslint/no-var-requires': 'off', + '@typescript-eslint/no-unused-vars': [ + 'error', + { + varsIgnorePattern: '^_', + argsIgnorePattern: '^_', + }, + ], + }, + }, + // Unused variables are useful in test files, and type test files + { + files: ['**/*.test.ts', '**/*.test-d.ts'], + rules: { + '@typescript-eslint/no-unused-vars': 'off', + }, + }, + // @ts-expect-error tseslint adds strict typing to this configuration, eslint-plugin-prettier has an incompatible type + eslintPluginPrettier, +) diff --git a/package.json b/package.json index 390881bf2..40d6181ca 100644 --- a/package.json +++ b/package.json @@ -154,17 +154,20 @@ "devDependencies": { "@commitlint/cli": "^18.4.4", "@commitlint/config-conventional": "^18.4.4", + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "^9.7.0", "@open-draft/test-server": "^0.4.2", "@ossjs/release": "^0.8.1", "@playwright/test": "^1.40.1", "@swc/core": "^1.3.102", + "@types/eslint__js": "^8.42.3", "@types/express": "^4.17.21", "@types/fs-extra": "^11.0.4", "@types/glob": "^8.1.0", "@types/json-bigint": "^1.0.4", "@types/node": "18.x", - "@typescript-eslint/eslint-plugin": "^7.2.0", - "@typescript-eslint/parser": "^7.2.0", + "@typescript-eslint/eslint-plugin": "^7.16.1", + "@typescript-eslint/parser": "^7.16.1", "@web/dev-server": "^0.1.38", "axios": "^1.6.5", "babel-minify": "^0.5.1", @@ -176,7 +179,7 @@ "esbuild-loader": "^4.0.2", "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", - "eslint-plugin-prettier": "^5.1.3", + "eslint-plugin-prettier": "^5.2.1", "express": "^4.18.2", "fs-extra": "^11.2.0", "fs-teardown": "^0.3.0", @@ -192,6 +195,7 @@ "ts-node": "^10.9.2", "tsup": "^8.0.1", "typescript": "^5.5.2", + "typescript-eslint": "^7.16.1", "undici": "^5.20.0", "url-loader": "^4.1.1", "vitest": "^1.2.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3be902c71..68b94adc4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -64,6 +64,12 @@ devDependencies: '@commitlint/config-conventional': specifier: ^18.4.4 version: 18.6.3 + '@eslint/eslintrc': + specifier: ^3.1.0 + version: 3.1.0 + '@eslint/js': + specifier: ^9.7.0 + version: 9.7.0 '@open-draft/test-server': specifier: ^0.4.2 version: 0.4.2 @@ -76,6 +82,9 @@ devDependencies: '@swc/core': specifier: ^1.3.102 version: 1.4.11 + '@types/eslint__js': + specifier: ^8.42.3 + version: 8.42.3 '@types/express': specifier: ^4.17.21 version: 4.17.21 @@ -92,11 +101,11 @@ devDependencies: specifier: 18.x version: 18.19.28 '@typescript-eslint/eslint-plugin': - specifier: ^7.2.0 - version: 7.5.0(@typescript-eslint/parser@7.5.0)(eslint@8.57.0)(typescript@5.5.2) + specifier: ^7.16.1 + version: 7.16.1(@typescript-eslint/parser@7.16.1)(eslint@8.57.0)(typescript@5.5.2) '@typescript-eslint/parser': - specifier: ^7.2.0 - version: 7.5.0(eslint@8.57.0)(typescript@5.5.2) + specifier: ^7.16.1 + version: 7.16.1(eslint@8.57.0)(typescript@5.5.2) '@web/dev-server': specifier: ^0.1.38 version: 0.1.38 @@ -131,8 +140,8 @@ devDependencies: specifier: ^9.1.0 version: 9.1.0(eslint@8.57.0) eslint-plugin-prettier: - specifier: ^5.1.3 - version: 5.1.3(eslint-config-prettier@9.1.0)(eslint@8.57.0)(prettier@3.2.5) + specifier: ^5.2.1 + version: 5.2.1(eslint-config-prettier@9.1.0)(eslint@8.57.0)(prettier@3.2.5) express: specifier: ^4.18.2 version: 4.19.2 @@ -178,6 +187,9 @@ devDependencies: typescript: specifier: ^5.5.2 version: 5.5.2 + typescript-eslint: + specifier: ^7.16.1 + version: 7.16.1(eslint@8.57.0)(typescript@5.5.2) undici: specifier: ^5.20.0 version: 5.28.3 @@ -1116,11 +1128,33 @@ packages: - supports-color dev: true + /@eslint/eslintrc@3.1.0: + resolution: {integrity: sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + dependencies: + ajv: 6.12.6 + debug: 4.3.4 + espree: 10.1.0 + globals: 14.0.0 + ignore: 5.3.1 + import-fresh: 3.3.0 + js-yaml: 4.1.0 + minimatch: 3.1.2 + strip-json-comments: 3.1.1 + transitivePeerDependencies: + - supports-color + dev: true + /@eslint/js@8.57.0: resolution: {integrity: sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true + /@eslint/js@9.7.0: + resolution: {integrity: sha512-ChuWDQenef8OSFnvuxv0TCVxEwmu3+hPNKvM9B34qpM0rDRbjL8t5QkQeHHeAfsKQjuH9wS82WeCi1J/owatng==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + dev: true + /@fastify/busboy@2.1.1: resolution: {integrity: sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==} engines: {node: '>=14'} @@ -1908,6 +1942,12 @@ packages: '@types/json-schema': 7.0.15 dev: true + /@types/eslint__js@8.42.3: + resolution: {integrity: sha512-alfG737uhmPdnvkrLdZLcEKJ/B8s9Y4hrZ+YAdzUeoArBlSUERA2E87ROfOaS4jd/C45fzOoZzidLc1IPwLqOw==} + dependencies: + '@types/eslint': 8.56.7 + dev: true + /@types/estree@0.0.39: resolution: {integrity: sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==} dev: true @@ -2131,8 +2171,8 @@ packages: '@types/yargs-parser': 21.0.3 dev: true - /@typescript-eslint/eslint-plugin@7.5.0(@typescript-eslint/parser@7.5.0)(eslint@8.57.0)(typescript@5.5.2): - resolution: {integrity: sha512-HpqNTH8Du34nLxbKgVMGljZMG0rJd2O9ecvr2QLYp+7512ty1j42KnsFwspPXg1Vh8an9YImf6CokUBltisZFQ==} + /@typescript-eslint/eslint-plugin@7.16.1(@typescript-eslint/parser@7.16.1)(eslint@8.57.0)(typescript@5.5.2): + resolution: {integrity: sha512-SxdPak/5bO0EnGktV05+Hq8oatjAYVY3Zh2bye9pGZy6+jwyR3LG3YKkV4YatlsgqXP28BTeVm9pqwJM96vf2A==} engines: {node: ^18.18.0 || >=20.0.0} peerDependencies: '@typescript-eslint/parser': ^7.0.0 @@ -2143,25 +2183,23 @@ packages: optional: true dependencies: '@eslint-community/regexpp': 4.10.0 - '@typescript-eslint/parser': 7.5.0(eslint@8.57.0)(typescript@5.5.2) - '@typescript-eslint/scope-manager': 7.5.0 - '@typescript-eslint/type-utils': 7.5.0(eslint@8.57.0)(typescript@5.5.2) - '@typescript-eslint/utils': 7.5.0(eslint@8.57.0)(typescript@5.5.2) - '@typescript-eslint/visitor-keys': 7.5.0 - debug: 4.3.4 + '@typescript-eslint/parser': 7.16.1(eslint@8.57.0)(typescript@5.5.2) + '@typescript-eslint/scope-manager': 7.16.1 + '@typescript-eslint/type-utils': 7.16.1(eslint@8.57.0)(typescript@5.5.2) + '@typescript-eslint/utils': 7.16.1(eslint@8.57.0)(typescript@5.5.2) + '@typescript-eslint/visitor-keys': 7.16.1 eslint: 8.57.0 graphemer: 1.4.0 ignore: 5.3.1 natural-compare: 1.4.0 - semver: 7.6.0 ts-api-utils: 1.3.0(typescript@5.5.2) typescript: 5.5.2 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/parser@7.5.0(eslint@8.57.0)(typescript@5.5.2): - resolution: {integrity: sha512-cj+XGhNujfD2/wzR1tabNsidnYRaFfEkcULdcIyVBYcXjBvBKOes+mpMBP7hMpOyk+gBcfXsrg4NBGAStQyxjQ==} + /@typescript-eslint/parser@7.16.1(eslint@8.57.0)(typescript@5.5.2): + resolution: {integrity: sha512-u+1Qx86jfGQ5i4JjK33/FnawZRpsLxRnKzGE6EABZ40KxVT/vWsiZFEBBHjFOljmmV3MBYOHEKi0Jm9hbAOClA==} engines: {node: ^18.18.0 || >=20.0.0} peerDependencies: eslint: ^8.56.0 @@ -2170,10 +2208,10 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/scope-manager': 7.5.0 - '@typescript-eslint/types': 7.5.0 - '@typescript-eslint/typescript-estree': 7.5.0(typescript@5.5.2) - '@typescript-eslint/visitor-keys': 7.5.0 + '@typescript-eslint/scope-manager': 7.16.1 + '@typescript-eslint/types': 7.16.1 + '@typescript-eslint/typescript-estree': 7.16.1(typescript@5.5.2) + '@typescript-eslint/visitor-keys': 7.16.1 debug: 4.3.4 eslint: 8.57.0 typescript: 5.5.2 @@ -2181,16 +2219,16 @@ packages: - supports-color dev: true - /@typescript-eslint/scope-manager@7.5.0: - resolution: {integrity: sha512-Z1r7uJY0MDeUlql9XJ6kRVgk/sP11sr3HKXn268HZyqL7i4cEfrdFuSSY/0tUqT37l5zT0tJOsuDP16kio85iA==} + /@typescript-eslint/scope-manager@7.16.1: + resolution: {integrity: sha512-nYpyv6ALte18gbMz323RM+vpFpTjfNdyakbf3nsLvF43uF9KeNC289SUEW3QLZ1xPtyINJ1dIsZOuWuSRIWygw==} engines: {node: ^18.18.0 || >=20.0.0} dependencies: - '@typescript-eslint/types': 7.5.0 - '@typescript-eslint/visitor-keys': 7.5.0 + '@typescript-eslint/types': 7.16.1 + '@typescript-eslint/visitor-keys': 7.16.1 dev: true - /@typescript-eslint/type-utils@7.5.0(eslint@8.57.0)(typescript@5.5.2): - resolution: {integrity: sha512-A021Rj33+G8mx2Dqh0nMO9GyjjIBK3MqgVgZ2qlKf6CJy51wY/lkkFqq3TqqnH34XyAHUkq27IjlUkWlQRpLHw==} + /@typescript-eslint/type-utils@7.16.1(eslint@8.57.0)(typescript@5.5.2): + resolution: {integrity: sha512-rbu/H2MWXN4SkjIIyWcmYBjlp55VT+1G3duFOIukTNFxr9PI35pLc2ydwAfejCEitCv4uztA07q0QWanOHC7dA==} engines: {node: ^18.18.0 || >=20.0.0} peerDependencies: eslint: ^8.56.0 @@ -2199,8 +2237,8 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/typescript-estree': 7.5.0(typescript@5.5.2) - '@typescript-eslint/utils': 7.5.0(eslint@8.57.0)(typescript@5.5.2) + '@typescript-eslint/typescript-estree': 7.16.1(typescript@5.5.2) + '@typescript-eslint/utils': 7.16.1(eslint@8.57.0)(typescript@5.5.2) debug: 4.3.4 eslint: 8.57.0 ts-api-utils: 1.3.0(typescript@5.5.2) @@ -2209,13 +2247,13 @@ packages: - supports-color dev: true - /@typescript-eslint/types@7.5.0: - resolution: {integrity: sha512-tv5B4IHeAdhR7uS4+bf8Ov3k793VEVHd45viRRkehIUZxm0WF82VPiLgHzA/Xl4TGPg1ZD49vfxBKFPecD5/mg==} + /@typescript-eslint/types@7.16.1: + resolution: {integrity: sha512-AQn9XqCzUXd4bAVEsAXM/Izk11Wx2u4H3BAfQVhSfzfDOm/wAON9nP7J5rpkCxts7E5TELmN845xTUCQrD1xIQ==} engines: {node: ^18.18.0 || >=20.0.0} dev: true - /@typescript-eslint/typescript-estree@7.5.0(typescript@5.5.2): - resolution: {integrity: sha512-YklQQfe0Rv2PZEueLTUffiQGKQneiIEKKnfIqPIOxgM9lKSZFCjT5Ad4VqRKj/U4+kQE3fa8YQpskViL7WjdPQ==} + /@typescript-eslint/typescript-estree@7.16.1(typescript@5.5.2): + resolution: {integrity: sha512-0vFPk8tMjj6apaAZ1HlwM8w7jbghC8jc1aRNJG5vN8Ym5miyhTQGMqU++kuBFDNKe9NcPeZ6x0zfSzV8xC1UlQ==} engines: {node: ^18.18.0 || >=20.0.0} peerDependencies: typescript: '*' @@ -2223,12 +2261,12 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/types': 7.5.0 - '@typescript-eslint/visitor-keys': 7.5.0 + '@typescript-eslint/types': 7.16.1 + '@typescript-eslint/visitor-keys': 7.16.1 debug: 4.3.4 globby: 11.1.0 is-glob: 4.0.3 - minimatch: 9.0.3 + minimatch: 9.0.4 semver: 7.6.0 ts-api-utils: 1.3.0(typescript@5.5.2) typescript: 5.5.2 @@ -2236,30 +2274,27 @@ packages: - supports-color dev: true - /@typescript-eslint/utils@7.5.0(eslint@8.57.0)(typescript@5.5.2): - resolution: {integrity: sha512-3vZl9u0R+/FLQcpy2EHyRGNqAS/ofJ3Ji8aebilfJe+fobK8+LbIFmrHciLVDxjDoONmufDcnVSF38KwMEOjzw==} + /@typescript-eslint/utils@7.16.1(eslint@8.57.0)(typescript@5.5.2): + resolution: {integrity: sha512-WrFM8nzCowV0he0RlkotGDujx78xudsxnGMBHI88l5J8wEhED6yBwaSLP99ygfrzAjsQvcYQ94quDwI0d7E1fA==} engines: {node: ^18.18.0 || >=20.0.0} peerDependencies: eslint: ^8.56.0 dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0) - '@types/json-schema': 7.0.15 - '@types/semver': 7.5.8 - '@typescript-eslint/scope-manager': 7.5.0 - '@typescript-eslint/types': 7.5.0 - '@typescript-eslint/typescript-estree': 7.5.0(typescript@5.5.2) + '@typescript-eslint/scope-manager': 7.16.1 + '@typescript-eslint/types': 7.16.1 + '@typescript-eslint/typescript-estree': 7.16.1(typescript@5.5.2) eslint: 8.57.0 - semver: 7.6.0 transitivePeerDependencies: - supports-color - typescript dev: true - /@typescript-eslint/visitor-keys@7.5.0: - resolution: {integrity: sha512-mcuHM/QircmA6O7fy6nn2w/3ditQkj+SgtOc8DW3uQ10Yfj42amm2i+6F2K4YAOPNNTmE6iM1ynM6lrSwdendA==} + /@typescript-eslint/visitor-keys@7.16.1: + resolution: {integrity: sha512-Qlzzx4sE4u3FsHTPQAAQFJFNOuqtuY0LFrZHwQ8IHK705XxBiWOFkfKRWu6niB7hwfgnwIpO4jTC75ozW1PHWg==} engines: {node: ^18.18.0 || >=20.0.0} dependencies: - '@typescript-eslint/types': 7.5.0 + '@typescript-eslint/types': 7.16.1 eslint-visitor-keys: 3.4.3 dev: true @@ -2536,6 +2571,14 @@ packages: acorn: 8.11.3 dev: true + /acorn-jsx@5.3.2(acorn@8.12.1): + resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} + peerDependencies: + acorn: ^6.0.0 || ^7.0.0 || ^8.0.0 + dependencies: + acorn: 8.12.1 + dev: true + /acorn-walk@8.3.2: resolution: {integrity: sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==} engines: {node: '>=0.4.0'} @@ -2547,6 +2590,12 @@ packages: hasBin: true dev: true + /acorn@8.12.1: + resolution: {integrity: sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==} + engines: {node: '>=0.4.0'} + hasBin: true + dev: true + /agent-base@7.1.1: resolution: {integrity: sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA==} engines: {node: '>= 14'} @@ -4124,8 +4173,8 @@ packages: eslint: 8.57.0 dev: true - /eslint-plugin-prettier@5.1.3(eslint-config-prettier@9.1.0)(eslint@8.57.0)(prettier@3.2.5): - resolution: {integrity: sha512-C9GCVAs4Eq7ZC/XFQHITLiHJxQngdtraXaM+LoUFoFp/lHNl2Zn8f3WQbe9HvTBBQ9YnKFB0/2Ajdqwo5D1EAw==} + /eslint-plugin-prettier@5.2.1(eslint-config-prettier@9.1.0)(eslint@8.57.0)(prettier@3.2.5): + resolution: {integrity: sha512-gH3iR3g4JfF+yYPaJYkN7jEl9QbweL/YfkoRlNnuIEHEz1vHVlCmWOS+eGGiRuzHQXdJFCOTxRgvju9b8VUmrw==} engines: {node: ^14.18.0 || >=16.0.0} peerDependencies: '@types/eslint': '>=8.0.0' @@ -4142,7 +4191,7 @@ packages: eslint-config-prettier: 9.1.0(eslint@8.57.0) prettier: 3.2.5 prettier-linter-helpers: 1.0.0 - synckit: 0.8.8 + synckit: 0.9.1 dev: true /eslint-scope@5.1.1: @@ -4166,6 +4215,11 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true + /eslint-visitor-keys@4.0.0: + resolution: {integrity: sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + dev: true + /eslint@8.57.0: resolution: {integrity: sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -4213,6 +4267,15 @@ packages: - supports-color dev: true + /espree@10.1.0: + resolution: {integrity: sha512-M1M6CpiE6ffoigIOWYO9UDP8TMUw9kqb21tf+08IgDYjCsOvCuDt4jQcZmoYxx+w7zlKw9/N0KXfto+I8/FrXA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + dependencies: + acorn: 8.12.1 + acorn-jsx: 5.3.2(acorn@8.12.1) + eslint-visitor-keys: 4.0.0 + dev: true + /espree@9.6.1: resolution: {integrity: sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -4804,6 +4867,11 @@ packages: type-fest: 0.20.2 dev: true + /globals@14.0.0: + resolution: {integrity: sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==} + engines: {node: '>=18'} + dev: true + /globalthis@1.0.3: resolution: {integrity: sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA==} engines: {node: '>= 0.4'} @@ -5973,13 +6041,6 @@ packages: brace-expansion: 1.1.11 dev: true - /minimatch@9.0.3: - resolution: {integrity: sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==} - engines: {node: '>=16 || 14 >=14.17'} - dependencies: - brace-expansion: 2.0.1 - dev: true - /minimatch@9.0.4: resolution: {integrity: sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==} engines: {node: '>=16 || 14 >=14.17'} @@ -7462,8 +7523,8 @@ packages: resolution: {integrity: sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==} dev: true - /synckit@0.8.8: - resolution: {integrity: sha512-HwOKAP7Wc5aRGYdKH+dw0PRRpbO841v2DENBtjnR5HFWoiNByAl7vrx3p0G/rCyYXQsrxqtX48TImFtPcIHSpQ==} + /synckit@0.9.1: + resolution: {integrity: sha512-7gr8p9TQP6RAHusBOSLs46F4564ZrjV8xFmw5zCmgmhGUcw2hxsShhJ6CEiHQMgPDwAQ1fWHPM0ypc4RMAig4A==} engines: {node: ^14.18.0 || >=16.0.0} dependencies: '@pkgr/core': 0.1.1 @@ -7845,6 +7906,25 @@ packages: possible-typed-array-names: 1.0.0 dev: true + /typescript-eslint@7.16.1(eslint@8.57.0)(typescript@5.5.2): + resolution: {integrity: sha512-889oE5qELj65q/tGeOSvlreNKhimitFwZqQ0o7PcWC7/lgRkAMknznsCsV8J8mZGTP/Z+cIbX8accf2DE33hrA==} + engines: {node: ^18.18.0 || >=20.0.0} + peerDependencies: + eslint: ^8.56.0 + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@typescript-eslint/eslint-plugin': 7.16.1(@typescript-eslint/parser@7.16.1)(eslint@8.57.0)(typescript@5.5.2) + '@typescript-eslint/parser': 7.16.1(eslint@8.57.0)(typescript@5.5.2) + '@typescript-eslint/utils': 7.16.1(eslint@8.57.0)(typescript@5.5.2) + eslint: 8.57.0 + typescript: 5.5.2 + transitivePeerDependencies: + - supports-color + dev: true + /typescript@5.5.2: resolution: {integrity: sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==} engines: {node: '>=14.17'} diff --git a/src/core/utils/internal/getCallFrame.ts b/src/core/utils/internal/getCallFrame.ts index bee9e70f4..a0a372215 100644 --- a/src/core/utils/internal/getCallFrame.ts +++ b/src/core/utils/internal/getCallFrame.ts @@ -1,8 +1,8 @@ // Ignore the source files traces for local testing. -const SOURCE_FRAME = /[\/\\]msw[\/\\]src[\/\\](.+)/ +const SOURCE_FRAME = /[/\\]msw[/\\]src[/\\](.+)/ const BUILD_FRAME = - /(node_modules)?[\/\\]lib[\/\\](core|browser|node|native|iife)[\/\\]|^[^\/\\]*$/ + /(node_modules)?[/\\]lib[/\\](core|browser|node|native|iife)[/\\]|^[^/\\]*$/ /** * Return the stack trace frame of a function's invocation. diff --git a/src/core/utils/internal/parseGraphQLRequest.ts b/src/core/utils/internal/parseGraphQLRequest.ts index 62fa55379..6f042c945 100644 --- a/src/core/utils/internal/parseGraphQLRequest.ts +++ b/src/core/utils/internal/parseGraphQLRequest.ts @@ -160,6 +160,7 @@ async function getGraphQLInput(request: Request): Promise { variables, } } + return null } default: diff --git a/src/core/utils/matching/matchRequestUrl.ts b/src/core/utils/matching/matchRequestUrl.ts index 3b9ce6ebf..434e984d6 100644 --- a/src/core/utils/matching/matchRequestUrl.ts +++ b/src/core/utils/matching/matchRequestUrl.ts @@ -42,13 +42,13 @@ export function coercePath(path: string): string { * Escape the port so that "path-to-regexp" can match * absolute URLs including port numbers. */ - .replace(/([^\/])(:)(?=\d+)/, '$1\\$2') + .replace(/([^/])(:)(?=\d+)/, '$1\\$2') /** * Escape the protocol so that "path-to-regexp" could match * absolute URL. * @see https://github.com/pillarjs/path-to-regexp/issues/259 */ - .replace(/^([^\/]+)(:)(?=\/\/)/, '$1\\$2') + .replace(/^([^/]+)(:)(?=\/\/)/, '$1\\$2') ) } diff --git a/src/core/utils/url/cleanUrl.ts b/src/core/utils/url/cleanUrl.ts index f226b3c0c..89a3dd23f 100644 --- a/src/core/utils/url/cleanUrl.ts +++ b/src/core/utils/url/cleanUrl.ts @@ -1,4 +1,4 @@ -const REDUNDANT_CHARACTERS_EXP = /[\?|#].*$/g +const REDUNDANT_CHARACTERS_EXP = /[?|#].*$/g export function getSearchParams(path: string) { return new URL(`/${path}`, 'http://localhost').searchParams diff --git a/src/core/utils/url/isAbsoluteUrl.ts b/src/core/utils/url/isAbsoluteUrl.ts index a91dbde43..a4fd9d054 100644 --- a/src/core/utils/url/isAbsoluteUrl.ts +++ b/src/core/utils/url/isAbsoluteUrl.ts @@ -2,5 +2,5 @@ * Determines if the given URL string is an absolute URL. */ export function isAbsoluteUrl(url: string): boolean { - return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url) + return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url) } diff --git a/test/browser/msw-api/setup-worker/scenarios/iframe-isolated-response/iframe-isolated-response.mocks.ts b/test/browser/msw-api/setup-worker/scenarios/iframe-isolated-response/iframe-isolated-response.mocks.ts index 8204158dc..e4fdb7b89 100644 --- a/test/browser/msw-api/setup-worker/scenarios/iframe-isolated-response/iframe-isolated-response.mocks.ts +++ b/test/browser/msw-api/setup-worker/scenarios/iframe-isolated-response/iframe-isolated-response.mocks.ts @@ -4,7 +4,7 @@ import { setupWorker } from 'msw/browser' const worker = setupWorker() worker.start() -// @ts-ignore +// @ts-expect-error window.msw = { worker, http, diff --git a/test/browser/playwright.extend.ts b/test/browser/playwright.extend.ts index 1e9aa092e..db1df9b85 100644 --- a/test/browser/playwright.extend.ts +++ b/test/browser/playwright.extend.ts @@ -66,7 +66,7 @@ interface GraphQLMultipartDataOptions { } export const test = base.extend({ - async createServer({}, use) { + async createServer(_, use) { let server: HttpServer | undefined await use(async (...middleware) => { @@ -77,7 +77,7 @@ export const test = base.extend({ await server?.close() }, - async webpackServer({}, use) { + async webpackServer(_, use) { use(await getWebpackServer()) }, async loadExample({ page, webpackServer, waitForMswActivation }, use) { @@ -126,7 +126,7 @@ export const test = base.extend({ workerConsole.removeAllListeners() await compilation?.dispose() }, - async waitFor({}, use) { + async waitFor(_, use) { await use(waitFor) }, async waitForMswActivation({ spyOnConsole }, use) { diff --git a/test/browser/rest-api/query-params-warning.test.ts b/test/browser/rest-api/query-params-warning.test.ts index d7358a731..ab47b0c7f 100644 --- a/test/browser/rest-api/query-params-warning.test.ts +++ b/test/browser/rest-api/query-params-warning.test.ts @@ -9,8 +9,8 @@ test('warns when a request handler URL contains query parameters', async ({ await loadExample(require.resolve('./query-params-warning.mocks.ts')) expect(consoleSpy.get('warning')).toEqual([ - `[MSW] Found a redundant usage of query parameters in the request handler URL for "GET /user?name=admin". Please match against a path instead and access query parameters using \"new URL(request.url).searchParams\" instead. Learn more: https://mswjs.io/docs/recipes/query-parameters`, - `[MSW] Found a redundant usage of query parameters in the request handler URL for "POST /login?id=123&type=auth". Please match against a path instead and access query parameters using \"new URL(request.url).searchParams\" instead. Learn more: https://mswjs.io/docs/recipes/query-parameters`, + `[MSW] Found a redundant usage of query parameters in the request handler URL for "GET /user?name=admin". Please match against a path instead and access query parameters using "new URL(request.url).searchParams" instead. Learn more: https://mswjs.io/docs/recipes/query-parameters`, + `[MSW] Found a redundant usage of query parameters in the request handler URL for "POST /login?id=123&type=auth". Please match against a path instead and access query parameters using "new URL(request.url).searchParams" instead. Learn more: https://mswjs.io/docs/recipes/query-parameters`, ]) await fetch('/user?name=admin').then(async (res) => { diff --git a/test/browser/rest-api/response/body/body-stream.test.ts b/test/browser/rest-api/response/body/body-stream.test.ts index 43b76d5a1..ac5dd9ad6 100644 --- a/test/browser/rest-api/response/body/body-stream.test.ts +++ b/test/browser/rest-api/response/body/body-stream.test.ts @@ -16,6 +16,7 @@ test('responds with a mocked ReadableStream response', async ({ const chunks: Array<{ text: string; timestamp: number }> = [] const reader = res.body.getReader() + // eslint-disable-next-line no-constant-condition while (true) { const { value, done } = await reader.read() From f846f620b1c18019177e513424cfcb1c06763434 Mon Sep 17 00:00:00 2001 From: Kai Spencer Date: Sat, 20 Jul 2024 19:55:15 +0100 Subject: [PATCH 2/2] chore: fix playwright test setup to use destructuring pattern --- test/browser/playwright.extend.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/browser/playwright.extend.ts b/test/browser/playwright.extend.ts index db1df9b85..fd0de4497 100644 --- a/test/browser/playwright.extend.ts +++ b/test/browser/playwright.extend.ts @@ -66,7 +66,8 @@ interface GraphQLMultipartDataOptions { } export const test = base.extend({ - async createServer(_, use) { + // eslint-disable-next-line no-empty-pattern -- First argument must use the destructuring pattern. + async createServer({}, use) { let server: HttpServer | undefined await use(async (...middleware) => { @@ -77,7 +78,8 @@ export const test = base.extend({ await server?.close() }, - async webpackServer(_, use) { + // eslint-disable-next-line no-empty-pattern -- First argument must use the destructuring pattern. + async webpackServer({}, use) { use(await getWebpackServer()) }, async loadExample({ page, webpackServer, waitForMswActivation }, use) { @@ -126,7 +128,8 @@ export const test = base.extend({ workerConsole.removeAllListeners() await compilation?.dispose() }, - async waitFor(_, use) { + // eslint-disable-next-line no-empty-pattern -- First argument must use the destructuring pattern. + async waitFor({}, use) { await use(waitFor) }, async waitForMswActivation({ spyOnConsole }, use) {