mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 12:20:20 +01:00
* Add autofix to cross-fork lint rule * replace-fork: Replaces old fork contents with new For each file in the new fork, copies the contents into the corresponding file of the old fork, replacing what was already there. In contrast to merge-fork, which performs a three-way merge. * Replace old fork contents with new fork First I ran `yarn replace-fork`. Then I ran `yarn lint` with autofix enabled. There's currently no way to do that from the command line (we should fix that), so I had to edit the lint script file. * Manual fix-ups Removes dead branches, removes prefixes from internal fields. Stuff like that. * Fix DevTools tests DevTools tests only run against the old fork, which is why I didn't catch these earlier. There is one test that is still failing. I'm fairly certain it's related to the layout of the Suspense fiber: we no longer conditionally wrap the primary children. They are always wrapped in an extra fiber. Since this has been running in www for weeks without major issues, I'll defer fixing the remaining test to a follow up.
98 lines
2.8 KiB
JavaScript
98 lines
2.8 KiB
JavaScript
'use strict';
|
|
|
|
// These flags can be in a @gate pragma to declare that a test depends on
|
|
// certain conditions. They're like GKs.
|
|
//
|
|
// Examples:
|
|
// // @gate enableBlocksAPI
|
|
// test('uses an unstable API', () => {/*...*/})
|
|
//
|
|
// // @gate __DEV__
|
|
// test('only passes in development', () => {/*...*/})
|
|
//
|
|
// Most flags are defined in ReactFeatureFlags. If it's defined there, you don't
|
|
// have to do anything extra here.
|
|
//
|
|
// There are also flags based on the environment, like __DEV__. Feel free to
|
|
// add new flags and aliases below.
|
|
//
|
|
// You can also combine flags using multiple gates:
|
|
//
|
|
// // @gate enableBlocksAPI
|
|
// // @gate __DEV__
|
|
// test('both conditions must pass', () => {/*...*/})
|
|
//
|
|
// Or using logical operators
|
|
// // @gate enableBlocksAPI && __DEV__
|
|
// test('both conditions must pass', () => {/*...*/})
|
|
//
|
|
// Negation also works:
|
|
// // @gate !deprecateLegacyContext
|
|
// test('uses a deprecated feature', () => {/*...*/})
|
|
|
|
// These flags are based on the environment and don't change for the entire
|
|
// test run.
|
|
const environmentFlags = {
|
|
__DEV__,
|
|
build: __DEV__ ? 'development' : 'production',
|
|
|
|
// TODO: Should "experimental" also imply "modern"? Maybe we should
|
|
// always compare to the channel?
|
|
experimental: __EXPERIMENTAL__,
|
|
// Similarly, should stable imply "classic"?
|
|
stable: !__EXPERIMENTAL__,
|
|
|
|
// Use this for tests that are known to be broken.
|
|
FIXME: false,
|
|
};
|
|
|
|
function getTestFlags() {
|
|
// These are required on demand because some of our tests mutate them. We try
|
|
// not to but there are exceptions.
|
|
const featureFlags = require('shared/ReactFeatureFlags');
|
|
|
|
// TODO: This is a heuristic to detect the release channel by checking a flag
|
|
// that is known to only be enabled in www. What we should do instead is set
|
|
// the release channel explicitly in the each test config file.
|
|
const www = featureFlags.enableSuspenseCallback === true;
|
|
const releaseChannel = www
|
|
? __EXPERIMENTAL__
|
|
? 'modern'
|
|
: 'classic'
|
|
: __EXPERIMENTAL__
|
|
? 'experimental'
|
|
: 'stable';
|
|
|
|
// Return a proxy so we can throw if you attempt to access a flag that
|
|
// doesn't exist.
|
|
return new Proxy(
|
|
{
|
|
// Feature flag aliases
|
|
old: featureFlags.enableNewReconciler === false,
|
|
new: featureFlags.enableNewReconciler === true,
|
|
|
|
channel: releaseChannel,
|
|
modern: releaseChannel === 'modern',
|
|
classic: releaseChannel === 'classic',
|
|
www,
|
|
|
|
...featureFlags,
|
|
...environmentFlags,
|
|
},
|
|
{
|
|
get(flags, flagName) {
|
|
const flagValue = flags[flagName];
|
|
if (flagValue === undefined && typeof flagName === 'string') {
|
|
throw Error(
|
|
`Feature flag "${flagName}" does not exist. See TestFlags.js ` +
|
|
'for more details.'
|
|
);
|
|
}
|
|
return flagValue;
|
|
},
|
|
}
|
|
);
|
|
}
|
|
|
|
exports.getTestFlags = getTestFlags;
|