From ac778ce6533ddeb9a40ecb4f9764a50a9a9bad0e Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Wed, 24 Jul 2024 03:23:40 +0300 Subject: [PATCH] Fix ESLint --- package.json | 10 +++-- packages/presets/client/src/index.ts | 1 + patches/@rushstack+eslint-patch+1.10.2.patch | 30 +++++++++++++ yarn.lock | 45 +++++++++++--------- 4 files changed, 63 insertions(+), 23 deletions(-) create mode 100644 patches/@rushstack+eslint-patch+1.10.2.patch diff --git a/package.json b/package.json index b9aa3a6ab59..52b7bd2ce64 100644 --- a/package.json +++ b/package.json @@ -15,12 +15,12 @@ "watch-build": "npx tsc-watch --project tsconfig.json --onSuccess \"bob build\"", "rebuild": "bob build --incremental", "test": "jest --forceExit --no-watchman", - "lint": "eslint --cache --ignore-path .gitignore .", + "lint": "cross-env \"ESLINT_USE_FLAT_CONFIG=false\" eslint --cache --ignore-path .gitignore .", "prettier": "prettier --cache --write --list-different .", "prettier:check": "prettier --cache --check .", "types:check": "tsc --noEmit", "test-and-build": "yarn build && yarn test", - "ci:lint": "eslint --cache --ignore-path .gitignore --output-file eslint_report.json --format json .", + "ci:lint": "cross-env \"ESLINT_USE_FLAT_CONFIG=false\" eslint --cache --ignore-path .gitignore --output-file eslint_report.json --format json .", "prerelease": "yarn build", "release": "changeset publish", "generate:examples:esm": "node packages/graphql-codegen-cli/dist/esm/bin.js --require dotenv/config --config ./dev-test/codegen.ts dotenv_config_path=dev-test/.env", @@ -53,6 +53,7 @@ "@types/jest": "28.1.8", "babel-jest": "29.6.4", "bob-the-bundler": "6.0.0", + "cross-env": "7.0.3", "eslint": "9.6.0", "graphql": "16.8.0", "husky": "8.0.3", @@ -72,7 +73,7 @@ }, "lint-staged": { "packages/**/src/**/*.{ts,tsx}": [ - "eslint --fix" + "cross-env \"ESLINT_USE_FLAT_CONFIG=false\" eslint --fix" ], "**/*.{js,jsx,cjs,mjs,ts,tsx,graphql,gql,yml,yaml,json,md}": [ "prettier --write" @@ -91,6 +92,7 @@ "**/@types/graphql-upload/graphql": "^16.0.0", "ts-node": "10.9.1", "typescript": "5.2.2", - "cosmiconfig": "8.1.3" + "cosmiconfig": "8.1.3", + "eslint-plugin-promise": "6.6.0" } } diff --git a/packages/presets/client/src/index.ts b/packages/presets/client/src/index.ts index c2f302f3828..5b0804ad9fa 100644 --- a/packages/presets/client/src/index.ts +++ b/packages/presets/client/src/index.ts @@ -114,6 +114,7 @@ export const preset: Types.OutputPreset = { ); } + // eslint-disable-next-line no-constant-binary-expression const isPersistedOperations = !!options.presetConfig?.persistedDocuments ?? false; const reexports: Array = []; diff --git a/patches/@rushstack+eslint-patch+1.10.2.patch b/patches/@rushstack+eslint-patch+1.10.2.patch new file mode 100644 index 00000000000..458e7d4dcbd --- /dev/null +++ b/patches/@rushstack+eslint-patch+1.10.2.patch @@ -0,0 +1,30 @@ +diff --git a/node_modules/@rushstack/eslint-patch/lib/_patch-base.js b/node_modules/@rushstack/eslint-patch/lib/_patch-base.js +index df0b347..a4568b4 100644 +--- a/node_modules/@rushstack/eslint-patch/lib/_patch-base.js ++++ b/node_modules/@rushstack/eslint-patch/lib/_patch-base.js +@@ -181,10 +181,11 @@ if (isNaN(ESLINT_MAJOR_VERSION)) { + throw new Error(`Unable to parse ESLint version "${exports.eslintPackageVersion}" in file "${eslintPackageJsonPath}"`); + } + if (!(ESLINT_MAJOR_VERSION >= 6 && ESLINT_MAJOR_VERSION <= 8)) { +- throw new Error('The ESLint patch script has only been tested with ESLint version 6.x, 7.x, and 8.x.' + ++ console.warn('The ESLint patch script has only been tested with ESLint version 6.x, 7.x, and 8.x.' + + ` (Your version: ${exports.eslintPackageVersion})\n` + + 'Consider reporting a GitHub issue:\n' + + 'https://github.com/microsoft/rushstack/issues'); ++ return; + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let configArrayFactory; +diff --git a/node_modules/@rushstack/eslint-patch/lib/modern-module-resolution.js b/node_modules/@rushstack/eslint-patch/lib/modern-module-resolution.js +index 417a748..6abef9a 100644 +--- a/node_modules/@rushstack/eslint-patch/lib/modern-module-resolution.js ++++ b/node_modules/@rushstack/eslint-patch/lib/modern-module-resolution.js +@@ -11,7 +11,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); + const _patch_base_1 = require("./_patch-base"); + // error: "The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received ''" + const isInvalidImporterPath = (ex) => (ex === null || ex === void 0 ? void 0 : ex.code) === 'ERR_INVALID_ARG_VALUE'; +-if (!_patch_base_1.configArrayFactory.__loadPluginPatched) { ++if (_patch_base_1.configArrayFactory && !_patch_base_1.configArrayFactory.__loadPluginPatched) { + _patch_base_1.configArrayFactory.__loadPluginPatched = true; + // eslint-disable-next-line @typescript-eslint/typedef + const originalLoadPlugin = _patch_base_1.configArrayFactory.prototype._loadPlugin; diff --git a/yarn.lock b/yarn.lock index deac322e724..199973aef4c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4413,7 +4413,14 @@ dependencies: "@types/unist" "^2" -"@types/node@*", "@types/node@18.19.39", "@types/node@^18.11.18": +"@types/node@*", "@types/node@^20.0.0": + version "20.11.19" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.19.tgz#b466de054e9cb5b3831bee38938de64ac7f81195" + integrity sha512-7xMnVEcZFu0DikYjWOlRq7NTPETrm7teqUT2WkQjrTIkEgUyyGdWsj/Zg8bEJt5TNklzbPD1X3fqfsHw3SpapQ== + dependencies: + undici-types "~5.26.4" + +"@types/node@18.19.39", "@types/node@^18.11.18": version "18.19.39" resolved "https://registry.yarnpkg.com/@types/node/-/node-18.19.39.tgz#c316340a5b4adca3aee9dcbf05de385978590593" integrity sha512-nPwTRDKUctxw3di5b4TfT3I0sWDiWoPQCZjXhvdkINntwr8lcoVCKsTgnXeRubKIlfnV+eN/HYk6Jb40tbcEAQ== @@ -4430,13 +4437,6 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-16.18.45.tgz#a2b845b94faf76de3160c630ce8b07f957390ca5" integrity sha512-Eu7U6/0P086nyPzeS41o2NvPVr16vWJMS5RdTzPF8XQaCPtq07E5GbR4fbcv5AYjy+zd0FYSV4p0WBdDXfPZzw== -"@types/node@^20.0.0": - version "20.11.19" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.19.tgz#b466de054e9cb5b3831bee38938de64ac7f81195" - integrity sha512-7xMnVEcZFu0DikYjWOlRq7NTPETrm7teqUT2WkQjrTIkEgUyyGdWsj/Zg8bEJt5TNklzbPD1X3fqfsHw3SpapQ== - dependencies: - undici-types "~5.26.4" - "@types/normalize-package-data@^2.4.0": version "2.4.1" resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301" @@ -4521,16 +4521,16 @@ resolved "https://registry.yarnpkg.com/@types/trusted-types/-/trusted-types-2.0.2.tgz#fc25ad9943bcac11cceb8168db4f275e0e72e756" integrity sha512-F5DIZ36YVLE+PN+Zwws4kJogq47hNgX3Nx6WyDJ3kcplxyke3XIzB8uK5n/Lpm1HBsbGzd6nmGehL8cPekP+Tg== -"@types/unist@*", "@types/unist@^2", "@types/unist@^2.0.0", "@types/unist@^2.0.2": - version "2.0.10" - resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.10.tgz#04ffa7f406ab628f7f7e97ca23e290cd8ab15efc" - integrity sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA== - -"@types/unist@^3.0.0": +"@types/unist@*", "@types/unist@^3.0.0": version "3.0.0" resolved "https://registry.yarnpkg.com/@types/unist/-/unist-3.0.0.tgz#988ae8af1e5239e89f9fbb1ade4c935f4eeedf9a" integrity sha512-MFETx3tbTjE7Uk6vvnWINA/1iJ7LuMdO4fcq8UfF0pRbj01aGLduVvQcRyswuACJdpnHgg8E3rQLhaRdNEJS0w== +"@types/unist@^2", "@types/unist@^2.0.0", "@types/unist@^2.0.2": + version "2.0.10" + resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.10.tgz#04ffa7f406ab628f7f7e97ca23e290cd8ab15efc" + integrity sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA== + "@types/ws@^8.0.0": version "8.5.4" resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.4.tgz#bb10e36116d6e570dd943735f86c933c1587b8a5" @@ -6313,6 +6313,13 @@ create-require@^1.1.0: resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== +cross-env@7.0.3: + version "7.0.3" + resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf" + integrity sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw== + dependencies: + cross-spawn "^7.0.1" + cross-fetch@^3.1.5: version "3.1.5" resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.5.tgz#e1389f44d9e7ba767907f7af8454787952ab534f" @@ -6336,7 +6343,7 @@ cross-spawn@^5.0.1, cross-spawn@^5.1.0: shebang-command "^1.2.0" which "^1.2.9" -cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3: +cross-spawn@^7.0.0, cross-spawn@^7.0.1, cross-spawn@^7.0.2, cross-spawn@^7.0.3: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== @@ -7618,10 +7625,10 @@ eslint-plugin-n@^17.0.0: minimatch "^9.0.0" semver "^7.5.3" -eslint-plugin-promise@^6.1.1: - version "6.1.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-6.1.1.tgz#269a3e2772f62875661220631bd4dafcb4083816" - integrity sha512-tjqWDwVZQo7UIPMeDReOpUgHCmCiH+ePnVT+5zVapL0uuHnegBUs2smM13CzOs2Xb5+MHMRFTs9v24yjba4Oig== +eslint-plugin-promise@6.6.0, eslint-plugin-promise@^6.1.1: + version "6.6.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-6.6.0.tgz#acd3fd7d55cead7a10f92cf698f36c0aafcd717a" + integrity sha512-57Zzfw8G6+Gq7axm2Pdo3gW/Rx3h9Yywgn61uE/3elTCOePEHVrn2i5CdfBwA1BLK0Q0WqctICIUSqXZW/VprQ== "eslint-plugin-react-hooks@^4.5.0 || 5.0.0-canary-7118f5dd7-20230705", eslint-plugin-react-hooks@^4.6.0: version "4.6.0"