@samitouri / QOS-React / commits / babde5d182

[lint] Add no-optional-chaining (#31003)

## Overview Adds a lint rule to prevent optional chaining to catch issues like https://github.com/facebook/react/pull/30982 until we support optional chaining without a bundle impact.

Ricky committed Sep 19, 2024 at 13:42 UTC babde5d1826365bfb794abdb7de4bd21f7b02356
4 files changed +16 -4
.eslintrc.js
+3 -1
@@ -23,6 +23,7 @@ module.exports = {
23 'babel',
24 'ft-flow',
25 'jest',
26 + 'es',
27 'no-for-of-loops',
28 'no-function-declare-after-return',
29 'react',
@@ -47,7 +48,7 @@ module.exports = {
48 'ft-flow/no-unused-expressions': ERROR,
49 // 'ft-flow/no-weak-types': WARNING,
50 // 'ft-flow/require-valid-file-annotation': ERROR,
50 -
51 + 'es/no-optional-chaining': ERROR,
52 'no-cond-assign': OFF,
53 'no-constant-condition': OFF,
54 'no-control-regex': OFF,
@@ -435,6 +436,7 @@ module.exports = {
436 'packages/react-dom/src/test-utils/*.js',
437 ],
438 rules: {
439 + 'es/no-optional-chaining': OFF,
440 'react-internal/no-production-logging': OFF,
441 'react-internal/warning-args': OFF,
442 'react-internal/safe-string-coercion': [
package.json
+1
@@ -54,6 +54,7 @@
54 "eslint": "^7.7.0",
55 "eslint-config-prettier": "^6.9.0",
56 "eslint-plugin-babel": "^5.3.0",
57 + "eslint-plugin-es": "^4.1.0",
58 "eslint-plugin-eslint-plugin": "^3.5.3",
59 "eslint-plugin-ft-flow": "^2.0.3",
60 "eslint-plugin-jest": "28.4.0",
packages/react-debug-tools/src/ReactDebugHooks.js
+3 -2
@@ -567,8 +567,9 @@ function useMemoCache(size: number): Array<any> {
567 return [];
568 }
569
570 - // $FlowFixMe[incompatible-use]: updateQueue is mixed
571 - const memoCache = fiber.updateQueue?.memoCache;
570 + const memoCache =
571 + // $FlowFixMe[incompatible-use]: updateQueue is mixed
572 + fiber.updateQueue != null ? fiber.updateQueue.memoCache : null;
573 if (memoCache == null) {
574 return [];
575 }
yarn.lock
+9 -1
@@ -7262,6 +7262,14 @@ eslint-plugin-babel@^5.3.0:
7262 dependencies:
7263 eslint-rule-composer "^0.3.0"
7264
7265 +eslint-plugin-es@^4.1.0:
7266 + version "4.1.0"
7267 + resolved "https://registry.yarnpkg.com/eslint-plugin-es/-/eslint-plugin-es-4.1.0.tgz#f0822f0c18a535a97c3e714e89f88586a7641ec9"
7268 + integrity sha512-GILhQTnjYE2WorX5Jyi5i4dz5ALWxBIdQECVQavL6s7cI76IZTDWleTHkxz/QT3kvcs2QlGHvKLYsSlPOlPXnQ==
7269 + dependencies:
7270 + eslint-utils "^2.0.0"
7271 + regexpp "^3.0.0"
7272 +
7273 eslint-plugin-eslint-plugin@^3.5.3:
7274 version "3.5.3"
7275 resolved "https://registry.yarnpkg.com/eslint-plugin-eslint-plugin/-/eslint-plugin-eslint-plugin-3.5.3.tgz#6cac958e944b820962a4cf9e65cc32a2e0415eaf"
@@ -13971,7 +13979,7 @@ regex-not@^1.0.0, regex-not@^1.0.2:
13979 extend-shallow "^3.0.2"
13980 safe-regex "^1.1.0"
13981
13974 -regexpp@^3.1.0:
13982 +regexpp@^3.0.0, regexpp@^3.1.0:
13983 version "3.2.0"
13984 resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2"
13985 integrity sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==