Remove no-fallthrough lint suppressions (#26553)

The lint rule already understands a normal comment. Also a bunch of
these were unnecessary.
This commit is contained in:
Sophie Alpert
2023-04-04 20:08:33 -07:00
committed by GitHub
parent c15579631f
commit 790ebc962d
12 changed files with 29 additions and 57 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
/* eslint-disable no-fallthrough, react/react-in-jsx-scope, react/jsx-no-undef */
/* eslint-disable react/react-in-jsx-scope, react/jsx-no-undef */
/* global React ReactCache ReactDOM SchedulerTracing ScheduleTracing */
const apps = [];
@@ -350,7 +350,6 @@ 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 ||
@@ -663,7 +662,7 @@ function setProp(
if (enableCustomElementPropertySupport) {
break;
}
// eslint-disable-next-line no-fallthrough
// Fall through
default: {
if (
key.length > 2 &&
@@ -761,7 +760,7 @@ function setPropOnCustomElement(
if (enableCustomElementPropertySupport) {
break;
}
// eslint-disable-next-line no-fallthrough
// Fall through
default: {
if (registrationNameDependencies.hasOwnProperty(key)) {
if (__DEV__ && value != null && typeof value !== 'function') {
@@ -1010,7 +1009,6 @@ 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':
@@ -1174,7 +1172,7 @@ export function diffProperties(
'Cannot update the "is" prop after it has been initialized.',
);
}
// eslint-disable-next-line no-fallthrough
// Fall through
default: {
(updatePayload = updatePayload || []).push(propKey, nextProp);
}
@@ -1790,7 +1788,7 @@ function diffHydratedCustomComponent(
}
continue;
}
// eslint-disable-next-line no-fallthrough
// Fall through
case 'className':
if (enableCustomElementPropertySupport) {
// className is a special cased property on the server to render as an attribute.
@@ -1803,7 +1801,7 @@ function diffHydratedCustomComponent(
warnForPropDifference('className', serverValue, value);
continue;
}
// eslint-disable-next-line no-fallthrough
// Fall through
default: {
let ownNamespaceDev = parentNamespaceDev;
if (ownNamespaceDev === HTML_NAMESPACE) {
@@ -319,20 +319,17 @@ export function getEventPriority(domEventName: DOMEventName): EventPriority {
case 'touchend':
case 'touchstart':
case 'volumechange':
// Used by polyfills:
// eslint-disable-next-line no-fallthrough
// Used by polyfills: (fall through)
case 'change':
case 'selectionchange':
case 'textInput':
case 'compositionstart':
case 'compositionend':
case 'compositionupdate':
// Only enableCreateEventHandleAPI:
// eslint-disable-next-line no-fallthrough
// Only enableCreateEventHandleAPI: (fall through)
case 'beforeblur':
case 'afterblur':
// Not used by React but could be by user code:
// eslint-disable-next-line no-fallthrough
// Not used by React but could be by user code: (fall through)
case 'beforeinput':
case 'blur':
case 'fullscreenchange':
@@ -357,8 +354,7 @@ export function getEventPriority(domEventName: DOMEventName): EventPriority {
case 'toggle':
case 'touchmove':
case 'wheel':
// Not used by React but could be by user code:
// eslint-disable-next-line no-fallthrough
// Not used by React but could be by user code: (fall through)
case 'mouseenter':
case 'mouseleave':
case 'pointerenter':
@@ -693,7 +693,6 @@ 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 ||
@@ -1123,11 +1122,9 @@ 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;
@@ -1248,7 +1245,6 @@ 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;
@@ -1330,7 +1326,6 @@ function pushStartTextArea(
throw new Error(
'`dangerouslySetInnerHTML` does not make sense on <textarea>.',
);
// eslint-disable-next-line-no-fallthrough
default:
pushAttribute(target, propKey, propValue);
break;
@@ -1677,7 +1672,6 @@ 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;
@@ -1906,7 +1900,6 @@ 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;
@@ -1936,7 +1929,6 @@ function pushStartMenuItem(
throw new Error(
'menuitems cannot have `children` nor `dangerouslySetInnerHTML`.',
);
// eslint-disable-next-line-no-fallthrough
default:
pushAttribute(target, propKey, propValue);
break;
@@ -2088,7 +2080,6 @@ function pushStartTitle(
throw new Error(
'`dangerouslySetInnerHTML` does not make sense on <title>.',
);
// eslint-disable-next-line-no-fallthrough
default:
pushAttribute(target, propKey, propValue);
break;
@@ -2787,11 +2778,12 @@ 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':
@@ -4044,7 +4036,6 @@ 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;
@@ -4240,7 +4231,6 @@ 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;
+5 -5
View File
@@ -550,29 +550,29 @@ export function createFiberFromTypeAndProps(
if (enableLegacyHidden) {
return createFiberFromLegacyHidden(pendingProps, mode, lanes, key);
}
// eslint-disable-next-line no-fallthrough
// Fall through
case REACT_SCOPE_TYPE:
if (enableScopeAPI) {
return createFiberFromScope(type, pendingProps, mode, lanes, key);
}
// eslint-disable-next-line no-fallthrough
// Fall through
case REACT_CACHE_TYPE:
if (enableCache) {
return createFiberFromCache(pendingProps, mode, lanes, key);
}
// eslint-disable-next-line no-fallthrough
// Fall through
case REACT_TRACING_MARKER_TYPE:
if (enableTransitionTracing) {
return createFiberFromTracingMarker(pendingProps, mode, lanes, key);
}
// eslint-disable-next-line no-fallthrough
// Fall through
case REACT_DEBUG_TRACING_MODE_TYPE:
if (enableDebugTracing) {
fiberTag = Mode;
mode |= DebugTracingMode;
break;
}
// eslint-disable-next-line no-fallthrough
// Fall through
default: {
if (typeof type === 'object' && type !== null) {
switch (type.$$typeof) {
+2 -2
View File
@@ -4096,12 +4096,12 @@ function beginWork(
if (enableFloat && supportsResources) {
return updateHostHoistable(current, workInProgress, renderLanes);
}
// eslint-disable-next-line no-fallthrough
// Fall through
case HostSingleton:
if (enableHostSingletons && supportsSingletons) {
return updateHostSingleton(current, workInProgress, renderLanes);
}
// eslint-disable-next-line no-fallthrough
// Fall through
case HostComponent:
return updateHostComponent(current, workInProgress, renderLanes);
case HostText:
+6 -11
View File
@@ -1129,8 +1129,8 @@ function commitLayoutEffectOnFiber(
}
break;
}
// Fall through
}
// eslint-disable-next-line-no-fallthrough
case HostSingleton:
case HostComponent: {
recursivelyTraverseLayoutEffects(
@@ -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) {
@@ -1851,7 +1851,6 @@ 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 ' +
@@ -2042,8 +2041,8 @@ function commitDeletionEffectsOnFiber(
}
return;
}
// Fall through
}
// eslint-disable-next-line no-fallthrough
case HostSingleton: {
if (enableHostSingletons && supportsSingletons) {
if (!offscreenSubtreeWasHidden) {
@@ -2071,15 +2070,14 @@ 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
@@ -2707,8 +2705,8 @@ function commitMutationEffectsOnFiber(
}
return;
}
// Fall through
}
// eslint-disable-next-line-no-fallthrough
case HostSingleton: {
if (enableHostSingletons && supportsSingletons) {
if (flags & Update) {
@@ -2727,8 +2725,8 @@ function commitMutationEffectsOnFiber(
}
}
}
// Fall through
}
// eslint-disable-next-line-no-fallthrough
case HostComponent: {
recursivelyTraverseMutationEffects(root, finishedWork, lanes);
commitReconciliationEffects(finishedWork);
@@ -3772,7 +3770,6 @@ function commitPassiveMountOnFiber(
}
// Intentional fallthrough to next branch
}
// eslint-disable-next-line-no-fallthrough
default: {
recursivelyTraversePassiveMountEffects(
finishedRoot,
@@ -3966,7 +3963,6 @@ export function reconnectPassiveEffects(
}
// Intentional fallthrough to next branch
}
// eslint-disable-next-line-no-fallthrough
default: {
recursivelyTraverseReconnectPassiveEffects(
finishedRoot,
@@ -4047,7 +4043,6 @@ function commitAtomicPassiveEffects(
}
break;
}
// eslint-disable-next-line-no-fallthrough
default: {
recursivelyTraverseAtomicPassiveEffects(
finishedRoot,
+2 -2
View File
@@ -1172,8 +1172,8 @@ function completeWork(
}
}
}
// Fall through
}
// eslint-disable-next-line-no-fallthrough
case HostSingleton: {
if (enableHostSingletons && supportsSingletons) {
popHostContext(workInProgress);
@@ -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;
+1 -1
View File
@@ -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 ` +
-4
View File
@@ -1122,9 +1122,6 @@ 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.
@@ -2381,7 +2378,6 @@ 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`.
-2
View File
@@ -1224,7 +1224,6 @@ function renderElement(
}
throw new Error('ReactDOMServer does not yet support scope components.');
}
// eslint-disable-next-line-no-fallthrough
case REACT_SUSPENSE_TYPE: {
if (
enableSuspenseAvoidThisFallbackFizz &&
@@ -1379,7 +1378,6 @@ function renderNodeDestructiveImpl(
'Portals are not currently supported by the server renderer. ' +
'Render them conditionally so that they only appear on the client render.',
);
// eslint-disable-next-line-no-fallthrough
case REACT_LAZY_TYPE: {
const lazyNode: LazyComponentType<any, any> = (node: any);
const payload = lazyNode._payload;
+1 -2
View File
@@ -89,7 +89,7 @@ export default function getComponentNameFromType(type: mixed): string | null {
if (enableCache) {
return 'Cache';
}
// eslint-disable-next-line no-fallthrough
// Fall through
case REACT_TRACING_MARKER_TYPE:
if (enableTransitionTracing) {
return 'TracingMarker';
@@ -126,7 +126,6 @@ export default function getComponentNameFromType(type: mixed): string | null {
const context2 = ((type: any): ReactContext<any>);
return (context2.displayName || context2._globalName) + '.Provider';
}
// eslint-disable-next-line no-fallthrough
}
}
return null;