react/scripts/eslint-rules
Andrew Clark af219cc6e6
Lint rule to forbid access of cross-fork fields (#19679)
* Lint rule to forbid access of cross-fork fields

We use a shared Fiber type for both reconciler forks (old and new). It
is a superset of all the fields used by both forks. However, there are
some fields that should only be used in the new fork, and others that
should only be used in the old fork.

Ideally we would enforce this with separate Flow types for each fork.
The problem is that the Fiber type is accessed by some packages outside
the reconciler (like React DOM), and get passed into the reconciler as
arguments. So there's no way to fork the Fiber type without also forking
the packages where they are used. FiberRoot has the same issue.

Instead, I've added a lint rule that forbids cross-fork access of
fork-specific fields. Fields that end in `_old` or `_new` are forbidden
from being used inside the new or old fork respectively. Or you can
specific custom fields using the ESLint plugin options.

I used this plugin to find and remove references to the effect list
in d2e914a.

* Mark effect list fields as old

And `subtreeTag` as new.

I didn't mark `lastEffect` because that name is also used by the
Hook type. Not super important; could rename to `lastEffect_old` but
idk if it's worth the effort.
2020-08-24 10:07:11 -07:00
..
__tests__ Lint rule to forbid access of cross-fork fields (#19679) 2020-08-24 10:07:11 -07:00
README.md Simplify Jest config a little bit (#11242) 2017-10-16 23:17:00 +01:00
index.js Lint rule to forbid access of cross-fork fields (#19679) 2020-08-24 10:07:11 -07:00
invariant-args.js Remove the condition argument from warning() (#17568) 2019-12-11 03:28:14 +00:00
no-cross-fork-imports.js Land Lanes implementation in old fork (#19108) 2020-06-11 20:05:15 -07:00
no-cross-fork-types.js Lint rule to forbid access of cross-fork fields (#19679) 2020-08-24 10:07:11 -07:00
no-primitive-constructors.js Drop the year from Facebook copyright headers and the LICENSE file. (#13593) 2018-09-07 15:11:23 -07:00
no-production-logging.js Use console directly instead of warning() modules (#17599) 2019-12-14 18:09:25 +00:00
no-to-warn-dev-within-to-throw.js Additional test infra changes for toErrorDev rename (#17632) 2019-12-17 13:31:47 +00:00
package.json Simplify Jest config a little bit (#11242) 2017-10-16 23:17:00 +01:00
warning-args.js Use console directly instead of warning() modules (#17599) 2019-12-14 18:09:25 +00:00

README.md

Custom ESLint Rules

This is a dummy npm package that allows us to treat it as an eslint-plugin. It's not actually published, nor are the rules here useful for users of React. If you want to lint your React code, try https://github.com/yannickcr/eslint-plugin-react.

If you modify this rule, you must re-run npm install ./eslint-rules for it to take effect.