Skip to content

Commit

Permalink
Revert "Remove no-fallthrough lint suppressions (#26553)"
Browse files Browse the repository at this point in the history
This reverts commit 790ebc9.
  • Loading branch information
kassens committed Apr 17, 2023
1 parent cc958d2 commit 5f06848
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 29 deletions.
2 changes: 1 addition & 1 deletion fixtures/devtools/regression/shared.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable react/react-in-jsx-scope, react/jsx-no-undef */
/* eslint-disable no-fallthrough, react/react-in-jsx-scope, react/jsx-no-undef */
/* global React ReactCache ReactDOM SchedulerTracing ScheduleTracing */

const apps = [];
Expand Down
12 changes: 7 additions & 5 deletions packages/react-dom-bindings/src/client/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ function setProp(
}
}
// Fall through to the last case which shouldn't remove empty strings.
// eslint-disable-next-line no-fallthrough
case 'formAction': {
if (
value == null ||
Expand Down Expand Up @@ -662,7 +663,7 @@ function setProp(
if (enableCustomElementPropertySupport) {
break;
}
// Fall through
// eslint-disable-next-line no-fallthrough
default: {
if (
key.length > 2 &&
Expand Down Expand Up @@ -760,7 +761,7 @@ function setPropOnCustomElement(
if (enableCustomElementPropertySupport) {
break;
}
// Fall through
// eslint-disable-next-line no-fallthrough
default: {
if (registrationNameDependencies.hasOwnProperty(key)) {
if (__DEV__ && value != null && typeof value !== 'function') {
Expand Down Expand Up @@ -1009,6 +1010,7 @@ export function setInitialProperties(
listenToNonDelegatedEvent('load', domElement);
// We fallthrough to the return of the void elements
}
// eslint-disable-next-line no-fallthrough
case 'area':
case 'base':
case 'br':
Expand Down Expand Up @@ -1172,7 +1174,7 @@ export function diffProperties(
'Cannot update the "is" prop after it has been initialized.',
);
}
// Fall through
// eslint-disable-next-line no-fallthrough
default: {
(updatePayload = updatePayload || []).push(propKey, nextProp);
}
Expand Down Expand Up @@ -1788,7 +1790,7 @@ function diffHydratedCustomComponent(
}
continue;
}
// Fall through
// eslint-disable-next-line no-fallthrough
case 'className':
if (enableCustomElementPropertySupport) {
// className is a special cased property on the server to render as an attribute.
Expand All @@ -1801,7 +1803,7 @@ function diffHydratedCustomComponent(
warnForPropDifference('className', serverValue, value);
continue;
}
// Fall through
// eslint-disable-next-line no-fallthrough
default: {
let ownNamespaceDev = parentNamespaceDev;
if (ownNamespaceDev === HTML_NAMESPACE) {
Expand Down
12 changes: 8 additions & 4 deletions packages/react-dom-bindings/src/events/ReactDOMEventListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,17 +319,20 @@ export function getEventPriority(domEventName: DOMEventName): EventPriority {
case 'touchend':
case 'touchstart':
case 'volumechange':
// Used by polyfills: (fall through)
// Used by polyfills:
// eslint-disable-next-line no-fallthrough
case 'change':
case 'selectionchange':
case 'textInput':
case 'compositionstart':
case 'compositionend':
case 'compositionupdate':
// Only enableCreateEventHandleAPI: (fall through)
// Only enableCreateEventHandleAPI:
// eslint-disable-next-line no-fallthrough
case 'beforeblur':
case 'afterblur':
// Not used by React but could be by user code: (fall through)
// Not used by React but could be by user code:
// eslint-disable-next-line no-fallthrough
case 'beforeinput':
case 'blur':
case 'fullscreenchange':
Expand All @@ -354,7 +357,8 @@ export function getEventPriority(domEventName: DOMEventName): EventPriority {
case 'toggle':
case 'touchmove':
case 'wheel':
// Not used by React but could be by user code: (fall through)
// Not used by React but could be by user code:
// eslint-disable-next-line no-fallthrough
case 'mouseenter':
case 'mouseleave':
case 'pointerenter':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ function pushAttribute(
}
}
// Fall through to the last case which shouldn't remove empty strings.
// eslint-disable-next-line no-fallthrough
case 'formAction': {
if (
value == null ||
Expand Down Expand Up @@ -1122,9 +1123,11 @@ function pushStartOption(
case 'dangerouslySetInnerHTML':
innerHTML = propValue;
break;
// eslint-disable-next-line-no-fallthrough
case 'value':
value = propValue;
// We intentionally fallthrough to also set the attribute on the node.
// eslint-disable-next-line-no-fallthrough
default:
pushAttribute(target, propKey, propValue);
break;
Expand Down Expand Up @@ -1245,6 +1248,7 @@ function pushInput(
`${'input'} is a self-closing tag and must neither have \`children\` nor ` +
'use `dangerouslySetInnerHTML`.',
);
// eslint-disable-next-line-no-fallthrough
case 'defaultChecked':
defaultChecked = propValue;
break;
Expand Down Expand Up @@ -1326,6 +1330,7 @@ function pushStartTextArea(
throw new Error(
'`dangerouslySetInnerHTML` does not make sense on <textarea>.',
);
// eslint-disable-next-line-no-fallthrough
default:
pushAttribute(target, propKey, propValue);
break;
Expand Down Expand Up @@ -1672,6 +1677,7 @@ function pushLinkImpl(
`${'link'} is a self-closing tag and must neither have \`children\` nor ` +
'use `dangerouslySetInnerHTML`.',
);
// eslint-disable-next-line-no-fallthrough
default:
pushAttribute(target, propKey, propValue);
break;
Expand Down Expand Up @@ -1900,6 +1906,7 @@ function pushSelfClosing(
`${tag} is a self-closing tag and must neither have \`children\` nor ` +
'use `dangerouslySetInnerHTML`.',
);
// eslint-disable-next-line-no-fallthrough
default:
pushAttribute(target, propKey, propValue);
break;
Expand Down Expand Up @@ -1929,6 +1936,7 @@ function pushStartMenuItem(
throw new Error(
'menuitems cannot have `children` nor `dangerouslySetInnerHTML`.',
);
// eslint-disable-next-line-no-fallthrough
default:
pushAttribute(target, propKey, propValue);
break;
Expand Down Expand Up @@ -2080,6 +2088,7 @@ function pushStartTitle(
throw new Error(
'`dangerouslySetInnerHTML` does not make sense on <title>.',
);
// eslint-disable-next-line-no-fallthrough
default:
pushAttribute(target, propKey, propValue);
break;
Expand Down Expand Up @@ -2778,12 +2787,11 @@ export function pushEndInstance(
if (!enableFloat) {
break;
}
// Fall through
}

// Omitted close tags
// TODO: Instead of repeating this switch we could try to pass a flag from above.
// That would require returning a tuple. Which might be ok if it gets inlined.
// eslint-disable-next-line-no-fallthrough
case 'area':
case 'base':
case 'br':
Expand Down Expand Up @@ -4036,6 +4044,7 @@ function writeStyleResourceDependencyInJS(
`${'link'} is a self-closing tag and must neither have \`children\` nor ` +
'use `dangerouslySetInnerHTML`.',
);
// eslint-disable-next-line-no-fallthrough
default:
writeStyleResourceAttributeInJS(destination, propKey, propValue);
break;
Expand Down Expand Up @@ -4231,6 +4240,7 @@ function writeStyleResourceDependencyInAttr(
`${'link'} is a self-closing tag and must neither have \`children\` nor ` +
'use `dangerouslySetInnerHTML`.',
);
// eslint-disable-next-line-no-fallthrough
default:
writeStyleResourceAttributeInAttr(destination, propKey, propValue);
break;
Expand Down
10 changes: 5 additions & 5 deletions packages/react-reconciler/src/ReactFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,29 +550,29 @@ export function createFiberFromTypeAndProps(
if (enableLegacyHidden) {
return createFiberFromLegacyHidden(pendingProps, mode, lanes, key);
}
// Fall through
// eslint-disable-next-line no-fallthrough
case REACT_SCOPE_TYPE:
if (enableScopeAPI) {
return createFiberFromScope(type, pendingProps, mode, lanes, key);
}
// Fall through
// eslint-disable-next-line no-fallthrough
case REACT_CACHE_TYPE:
if (enableCache) {
return createFiberFromCache(pendingProps, mode, lanes, key);
}
// Fall through
// eslint-disable-next-line no-fallthrough
case REACT_TRACING_MARKER_TYPE:
if (enableTransitionTracing) {
return createFiberFromTracingMarker(pendingProps, mode, lanes, key);
}
// Fall through
// eslint-disable-next-line no-fallthrough
case REACT_DEBUG_TRACING_MODE_TYPE:
if (enableDebugTracing) {
fiberTag = Mode;
mode |= DebugTracingMode;
break;
}
// Fall through
// eslint-disable-next-line no-fallthrough
default: {
if (typeof type === 'object' && type !== null) {
switch (type.$$typeof) {
Expand Down
4 changes: 2 additions & 2 deletions packages/react-reconciler/src/ReactFiberBeginWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -4096,12 +4096,12 @@ function beginWork(
if (enableFloat && supportsResources) {
return updateHostHoistable(current, workInProgress, renderLanes);
}
// Fall through
// eslint-disable-next-line no-fallthrough
case HostSingleton:
if (enableHostSingletons && supportsSingletons) {
return updateHostSingleton(current, workInProgress, renderLanes);
}
// Fall through
// eslint-disable-next-line no-fallthrough
case HostComponent:
return updateHostComponent(current, workInProgress, renderLanes);
case HostText:
Expand Down
17 changes: 11 additions & 6 deletions packages/react-reconciler/src/ReactFiberCommitWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -1129,8 +1129,8 @@ function commitLayoutEffectOnFiber(
}
break;
}
// Fall through
}
// eslint-disable-next-line-no-fallthrough
case HostSingleton:
case HostComponent: {
recursivelyTraverseLayoutEffects(
Expand Down Expand Up @@ -1827,8 +1827,8 @@ function commitPlacement(finishedWork: Fiber): void {
insertOrAppendPlacementNode(finishedWork, before, parent);
break;
}
// Fall through
}
// eslint-disable-next-line no-fallthrough
case HostComponent: {
const parent: Instance = parentFiber.stateNode;
if (parentFiber.flags & ContentReset) {
Expand All @@ -1851,6 +1851,7 @@ function commitPlacement(finishedWork: Fiber): void {
insertOrAppendPlacementNodeIntoContainer(finishedWork, before, parent);
break;
}
// eslint-disable-next-line-no-fallthrough
default:
throw new Error(
'Invalid host parent fiber. This error is likely caused by a bug ' +
Expand Down Expand Up @@ -2041,8 +2042,8 @@ function commitDeletionEffectsOnFiber(
}
return;
}
// Fall through
}
// eslint-disable-next-line no-fallthrough
case HostSingleton: {
if (enableHostSingletons && supportsSingletons) {
if (!offscreenSubtreeWasHidden) {
Expand Down Expand Up @@ -2070,14 +2071,15 @@ function commitDeletionEffectsOnFiber(

return;
}
// Fall through
}
// eslint-disable-next-line no-fallthrough
case HostComponent: {
if (!offscreenSubtreeWasHidden) {
safelyDetachRef(deletedFiber, nearestMountedAncestor);
}
// Intentional fallthrough to next branch
}
// eslint-disable-next-line-no-fallthrough
case HostText: {
// We only need to remove the nearest host child. Set the host parent
// to `null` on the stack to indicate that nested children don't
Expand Down Expand Up @@ -2705,8 +2707,8 @@ function commitMutationEffectsOnFiber(
}
return;
}
// Fall through
}
// eslint-disable-next-line-no-fallthrough
case HostSingleton: {
if (enableHostSingletons && supportsSingletons) {
if (flags & Update) {
Expand All @@ -2725,8 +2727,8 @@ function commitMutationEffectsOnFiber(
}
}
}
// Fall through
}
// eslint-disable-next-line-no-fallthrough
case HostComponent: {
recursivelyTraverseMutationEffects(root, finishedWork, lanes);
commitReconciliationEffects(finishedWork);
Expand Down Expand Up @@ -3770,6 +3772,7 @@ function commitPassiveMountOnFiber(
}
// Intentional fallthrough to next branch
}
// eslint-disable-next-line-no-fallthrough
default: {
recursivelyTraversePassiveMountEffects(
finishedRoot,
Expand Down Expand Up @@ -3963,6 +3966,7 @@ export function reconnectPassiveEffects(
}
// Intentional fallthrough to next branch
}
// eslint-disable-next-line-no-fallthrough
default: {
recursivelyTraverseReconnectPassiveEffects(
finishedRoot,
Expand Down Expand Up @@ -4043,6 +4047,7 @@ function commitAtomicPassiveEffects(
}
break;
}
// eslint-disable-next-line-no-fallthrough
default: {
recursivelyTraverseAtomicPassiveEffects(
finishedRoot,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-reconciler/src/ReactFiberCompleteWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -1172,8 +1172,8 @@ function completeWork(
}
}
}
// Fall through
}
// eslint-disable-next-line-no-fallthrough
case HostSingleton: {
if (enableHostSingletons && supportsSingletons) {
popHostContext(workInProgress);
Expand Down Expand Up @@ -1234,8 +1234,8 @@ function completeWork(
bubbleProperties(workInProgress);
return null;
}
// Fall through
}
// eslint-disable-next-line-no-fallthrough
case HostComponent: {
popHostContext(workInProgress);
const type = workInProgress.type;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberThrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ function throwException(
}
break;
}
// Fall through
}
// eslint-disable-next-line no-fallthrough
default: {
throw new Error(
`Unexpected Suspense handler tag (${suspenseBoundary.tag}). This ` +
Expand Down
4 changes: 4 additions & 0 deletions packages/react-reconciler/src/ReactFiberWorkLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,9 @@ function finishConcurrentRender(
case RootFatalErrored: {
throw new Error('Root did not complete. This is a bug in React.');
}
// Flow knows about invariant, so it complains if I add a break
// statement, but eslint doesn't know about invariant, so it complains
// if I do. eslint-disable-next-line no-fallthrough
case RootErrored: {
// We should have already attempted to retry this tree. If we reached
// this point, it errored again. Commit it.
Expand Down Expand Up @@ -2378,6 +2381,7 @@ function replaySuspendedUnitOfWork(unitOfWork: Fiber): void {
unitOfWork.tag = FunctionComponent;
// Fallthrough to the next branch.
}
// eslint-disable-next-line no-fallthrough
case SimpleMemoComponent:
case FunctionComponent: {
// Resolve `defaultProps`. This logic is copied from `beginWork`.
Expand Down
Loading

0 comments on commit 5f06848

Please sign in to comment.