Remove no-fallthrough lint suppressions (#26553)
The lint rule already understands a normal comment. Also a bunch of these were unnecessary.
Sophie Alpert committed
Apr 4, 2023 at 20:08 UTC
790ebc962de573a37e4755207eba91b07a0fa172
12 files changed
+29
-57
fixtures/devtools/regression/shared.js
+1
-1
@@ -1,4 +1,4 @@
1
-/* eslint-disable no-fallthrough, react/react-in-jsx-scope, react/jsx-no-undef */
1
+/* eslint-disable react/react-in-jsx-scope, react/jsx-no-undef */
2
/* global React ReactCache ReactDOM SchedulerTracing ScheduleTracing */
3
4
const apps = [];
packages/react-dom-bindings/src/client/ReactDOMComponent.js
+5
-7
@@ -350,7 +350,6 @@ function setProp(
350
}
351
}
352
// Fall through to the last case which shouldn't remove empty strings.
353
- // eslint-disable-next-line no-fallthrough
353
case 'formAction': {
354
if (
355
value == null ||
@@ -663,7 +662,7 @@ function setProp(
662
if (enableCustomElementPropertySupport) {
663
break;
664
}
666
- // eslint-disable-next-line no-fallthrough
665
+ // Fall through
666
default: {
667
if (
668
key.length > 2 &&
@@ -761,7 +760,7 @@ function setPropOnCustomElement(
760
if (enableCustomElementPropertySupport) {
761
break;
762
}
764
- // eslint-disable-next-line no-fallthrough
763
+ // Fall through
764
default: {
765
if (registrationNameDependencies.hasOwnProperty(key)) {
766
if (__DEV__ && value != null && typeof value !== 'function') {
@@ -1010,7 +1009,6 @@ export function setInitialProperties(
1009
listenToNonDelegatedEvent('load', domElement);
1010
// We fallthrough to the return of the void elements
1011
}
1013
- // eslint-disable-next-line no-fallthrough
1012
case 'area':
1013
case 'base':
1014
case 'br':
@@ -1174,7 +1172,7 @@ export function diffProperties(
1172
'Cannot update the "is" prop after it has been initialized.',
1173
);
1174
}
1177
- // eslint-disable-next-line no-fallthrough
1175
+ // Fall through
1176
default: {
1177
(updatePayload = updatePayload || []).push(propKey, nextProp);
1178
}
@@ -1790,7 +1788,7 @@ function diffHydratedCustomComponent(
1788
}
1789
continue;
1790
}
1793
- // eslint-disable-next-line no-fallthrough
1791
+ // Fall through
1792
case 'className':
1793
if (enableCustomElementPropertySupport) {
1794
// className is a special cased property on the server to render as an attribute.
@@ -1803,7 +1801,7 @@ function diffHydratedCustomComponent(
1801
warnForPropDifference('className', serverValue, value);
1802
continue;
1803
}
1806
- // eslint-disable-next-line no-fallthrough
1804
+ // Fall through
1805
default: {
1806
let ownNamespaceDev = parentNamespaceDev;
1807
if (ownNamespaceDev === HTML_NAMESPACE) {
packages/react-dom-bindings/src/events/ReactDOMEventListener.js
+4
-8
@@ -319,20 +319,17 @@ export function getEventPriority(domEventName: DOMEventName): EventPriority {
319
case 'touchend':
320
case 'touchstart':
321
case 'volumechange':
322
- // Used by polyfills:
323
- // eslint-disable-next-line no-fallthrough
322
+ // Used by polyfills: (fall through)
323
case 'change':
324
case 'selectionchange':
325
case 'textInput':
326
case 'compositionstart':
327
case 'compositionend':
328
case 'compositionupdate':
330
- // Only enableCreateEventHandleAPI:
331
- // eslint-disable-next-line no-fallthrough
329
+ // Only enableCreateEventHandleAPI: (fall through)
330
case 'beforeblur':
331
case 'afterblur':
334
- // Not used by React but could be by user code:
335
- // eslint-disable-next-line no-fallthrough
332
+ // Not used by React but could be by user code: (fall through)
333
case 'beforeinput':
334
case 'blur':
335
case 'fullscreenchange':
@@ -357,8 +354,7 @@ export function getEventPriority(domEventName: DOMEventName): EventPriority {
354
case 'toggle':
355
case 'touchmove':
356
case 'wheel':
360
- // Not used by React but could be by user code:
361
- // eslint-disable-next-line no-fallthrough
357
+ // Not used by React but could be by user code: (fall through)
358
case 'mouseenter':
359
case 'mouseleave':
360
case 'pointerenter':
packages/react-dom-bindings/src/server/ReactDOMServerFormatConfig.js
+2
-12
@@ -693,7 +693,6 @@ function pushAttribute(
693
}
694
}
695
// Fall through to the last case which shouldn't remove empty strings.
696
- // eslint-disable-next-line no-fallthrough
696
case 'formAction': {
697
if (
698
value == null ||
@@ -1123,11 +1122,9 @@ function pushStartOption(
1122
case 'dangerouslySetInnerHTML':
1123
innerHTML = propValue;
1124
break;
1126
- // eslint-disable-next-line-no-fallthrough
1125
case 'value':
1126
value = propValue;
1127
// We intentionally fallthrough to also set the attribute on the node.
1130
- // eslint-disable-next-line-no-fallthrough
1128
default:
1129
pushAttribute(target, propKey, propValue);
1130
break;
@@ -1248,7 +1245,6 @@ function pushInput(
1245
`${'input'} is a self-closing tag and must neither have \`children\` nor ` +
1246
'use `dangerouslySetInnerHTML`.',
1247
);
1251
- // eslint-disable-next-line-no-fallthrough
1248
case 'defaultChecked':
1249
defaultChecked = propValue;
1250
break;
@@ -1330,7 +1326,6 @@ function pushStartTextArea(
1326
throw new Error(
1327
'`dangerouslySetInnerHTML` does not make sense on <textarea>.',
1328
);
1333
- // eslint-disable-next-line-no-fallthrough
1329
default:
1330
pushAttribute(target, propKey, propValue);
1331
break;
@@ -1677,7 +1672,6 @@ function pushLinkImpl(
1672
`${'link'} is a self-closing tag and must neither have \`children\` nor ` +
1673
'use `dangerouslySetInnerHTML`.',
1674
);
1680
- // eslint-disable-next-line-no-fallthrough
1675
default:
1676
pushAttribute(target, propKey, propValue);
1677
break;
@@ -1906,7 +1900,6 @@ function pushSelfClosing(
1900
`${tag} is a self-closing tag and must neither have \`children\` nor ` +
1901
'use `dangerouslySetInnerHTML`.',
1902
);
1909
- // eslint-disable-next-line-no-fallthrough
1903
default:
1904
pushAttribute(target, propKey, propValue);
1905
break;
@@ -1936,7 +1929,6 @@ function pushStartMenuItem(
1929
throw new Error(
1930
'menuitems cannot have `children` nor `dangerouslySetInnerHTML`.',
1931
);
1939
- // eslint-disable-next-line-no-fallthrough
1932
default:
1933
pushAttribute(target, propKey, propValue);
1934
break;
@@ -2088,7 +2080,6 @@ function pushStartTitle(
2080
throw new Error(
2081
'`dangerouslySetInnerHTML` does not make sense on <title>.',
2082
);
2091
- // eslint-disable-next-line-no-fallthrough
2083
default:
2084
pushAttribute(target, propKey, propValue);
2085
break;
@@ -2787,11 +2778,12 @@ export function pushEndInstance(
2778
if (!enableFloat) {
2779
break;
2780
}
2781
+ // Fall through
2782
}
2783
+
2784
// Omitted close tags
2785
// TODO: Instead of repeating this switch we could try to pass a flag from above.
2786
// That would require returning a tuple. Which might be ok if it gets inlined.
2794
- // eslint-disable-next-line-no-fallthrough
2787
case 'area':
2788
case 'base':
2789
case 'br':
@@ -4044,7 +4036,6 @@ function writeStyleResourceDependencyInJS(
4036
`${'link'} is a self-closing tag and must neither have \`children\` nor ` +
4037
'use `dangerouslySetInnerHTML`.',
4038
);
4047
- // eslint-disable-next-line-no-fallthrough
4039
default:
4040
writeStyleResourceAttributeInJS(destination, propKey, propValue);
4041
break;
@@ -4240,7 +4231,6 @@ function writeStyleResourceDependencyInAttr(
4231
`${'link'} is a self-closing tag and must neither have \`children\` nor ` +
4232
'use `dangerouslySetInnerHTML`.',
4233
);
4243
- // eslint-disable-next-line-no-fallthrough
4234
default:
4235
writeStyleResourceAttributeInAttr(destination, propKey, propValue);
4236
break;
packages/react-reconciler/src/ReactFiber.js
+5
-5
@@ -550,29 +550,29 @@ export function createFiberFromTypeAndProps(
550
if (enableLegacyHidden) {
551
return createFiberFromLegacyHidden(pendingProps, mode, lanes, key);
552
}
553
- // eslint-disable-next-line no-fallthrough
553
+ // Fall through
554
case REACT_SCOPE_TYPE:
555
if (enableScopeAPI) {
556
return createFiberFromScope(type, pendingProps, mode, lanes, key);
557
}
558
- // eslint-disable-next-line no-fallthrough
558
+ // Fall through
559
case REACT_CACHE_TYPE:
560
if (enableCache) {
561
return createFiberFromCache(pendingProps, mode, lanes, key);
562
}
563
- // eslint-disable-next-line no-fallthrough
563
+ // Fall through
564
case REACT_TRACING_MARKER_TYPE:
565
if (enableTransitionTracing) {
566
return createFiberFromTracingMarker(pendingProps, mode, lanes, key);
567
}
568
- // eslint-disable-next-line no-fallthrough
568
+ // Fall through
569
case REACT_DEBUG_TRACING_MODE_TYPE:
570
if (enableDebugTracing) {
571
fiberTag = Mode;
572
mode |= DebugTracingMode;
573
break;
574
}
575
- // eslint-disable-next-line no-fallthrough
575
+ // Fall through
576
default: {
577
if (typeof type === 'object' && type !== null) {
578
switch (type.$$typeof) {
packages/react-reconciler/src/ReactFiberBeginWork.js
+2
-2
@@ -4096,12 +4096,12 @@ function beginWork(
4096
if (enableFloat && supportsResources) {
4097
return updateHostHoistable(current, workInProgress, renderLanes);
4098
}
4099
- // eslint-disable-next-line no-fallthrough
4099
+ // Fall through
4100
case HostSingleton:
4101
if (enableHostSingletons && supportsSingletons) {
4102
return updateHostSingleton(current, workInProgress, renderLanes);
4103
}
4104
- // eslint-disable-next-line no-fallthrough
4104
+ // Fall through
4105
case HostComponent:
4106
return updateHostComponent(current, workInProgress, renderLanes);
4107
case HostText:
packages/react-reconciler/src/ReactFiberCommitWork.js
+6
-11
@@ -1129,8 +1129,8 @@ function commitLayoutEffectOnFiber(
1129
}
1130
break;
1131
}
1132
+ // Fall through
1133
}
1133
- // eslint-disable-next-line-no-fallthrough
1134
case HostSingleton:
1135
case HostComponent: {
1136
recursivelyTraverseLayoutEffects(
@@ -1827,8 +1827,8 @@ function commitPlacement(finishedWork: Fiber): void {
1827
insertOrAppendPlacementNode(finishedWork, before, parent);
1828
break;
1829
}
1830
+ // Fall through
1831
}
1831
- // eslint-disable-next-line no-fallthrough
1832
case HostComponent: {
1833
const parent: Instance = parentFiber.stateNode;
1834
if (parentFiber.flags & ContentReset) {
@@ -1851,7 +1851,6 @@ function commitPlacement(finishedWork: Fiber): void {
1851
insertOrAppendPlacementNodeIntoContainer(finishedWork, before, parent);
1852
break;
1853
}
1854
- // eslint-disable-next-line-no-fallthrough
1854
default:
1855
throw new Error(
1856
'Invalid host parent fiber. This error is likely caused by a bug ' +
@@ -2042,8 +2041,8 @@ function commitDeletionEffectsOnFiber(
2041
}
2042
return;
2043
}
2044
+ // Fall through
2045
}
2046
- // eslint-disable-next-line no-fallthrough
2046
case HostSingleton: {
2047
if (enableHostSingletons && supportsSingletons) {
2048
if (!offscreenSubtreeWasHidden) {
@@ -2071,15 +2070,14 @@ function commitDeletionEffectsOnFiber(
2070
2071
return;
2072
}
2073
+ // Fall through
2074
}
2075
- // eslint-disable-next-line no-fallthrough
2075
case HostComponent: {
2076
if (!offscreenSubtreeWasHidden) {
2077
safelyDetachRef(deletedFiber, nearestMountedAncestor);
2078
}
2079
// Intentional fallthrough to next branch
2080
}
2082
- // eslint-disable-next-line-no-fallthrough
2081
case HostText: {
2082
// We only need to remove the nearest host child. Set the host parent
2083
// to `null` on the stack to indicate that nested children don't
@@ -2707,8 +2705,8 @@ function commitMutationEffectsOnFiber(
2705
}
2706
return;
2707
}
2708
+ // Fall through
2709
}
2711
- // eslint-disable-next-line-no-fallthrough
2710
case HostSingleton: {
2711
if (enableHostSingletons && supportsSingletons) {
2712
if (flags & Update) {
@@ -2727,8 +2725,8 @@ function commitMutationEffectsOnFiber(
2725
}
2726
}
2727
}
2728
+ // Fall through
2729
}
2731
- // eslint-disable-next-line-no-fallthrough
2730
case HostComponent: {
2731
recursivelyTraverseMutationEffects(root, finishedWork, lanes);
2732
commitReconciliationEffects(finishedWork);
@@ -3772,7 +3770,6 @@ function commitPassiveMountOnFiber(
3770
}
3771
// Intentional fallthrough to next branch
3772
}
3775
- // eslint-disable-next-line-no-fallthrough
3773
default: {
3774
recursivelyTraversePassiveMountEffects(
3775
finishedRoot,
@@ -3966,7 +3963,6 @@ export function reconnectPassiveEffects(
3963
}
3964
// Intentional fallthrough to next branch
3965
}
3969
- // eslint-disable-next-line-no-fallthrough
3966
default: {
3967
recursivelyTraverseReconnectPassiveEffects(
3968
finishedRoot,
@@ -4047,7 +4043,6 @@ function commitAtomicPassiveEffects(
4043
}
4044
break;
4045
}
4050
- // eslint-disable-next-line-no-fallthrough
4046
default: {
4047
recursivelyTraverseAtomicPassiveEffects(
4048
finishedRoot,
packages/react-reconciler/src/ReactFiberCompleteWork.js
+2
-2
@@ -1172,8 +1172,8 @@ function completeWork(
1172
}
1173
}
1174
}
1175
+ // Fall through
1176
}
1176
- // eslint-disable-next-line-no-fallthrough
1177
case HostSingleton: {
1178
if (enableHostSingletons && supportsSingletons) {
1179
popHostContext(workInProgress);
@@ -1234,8 +1234,8 @@ function completeWork(
1234
bubbleProperties(workInProgress);
1235
return null;
1236
}
1237
+ // Fall through
1238
}
1238
- // eslint-disable-next-line-no-fallthrough
1239
case HostComponent: {
1240
popHostContext(workInProgress);
1241
const type = workInProgress.type;
packages/react-reconciler/src/ReactFiberThrow.js
+1
-1
@@ -465,8 +465,8 @@ function throwException(
465
}
466
break;
467
}
468
+ // Fall through
469
}
469
- // eslint-disable-next-line no-fallthrough
470
default: {
471
throw new Error(
472
`Unexpected Suspense handler tag (${suspenseBoundary.tag}). This ` +
packages/react-reconciler/src/ReactFiberWorkLoop.js
-4
@@ -1122,9 +1122,6 @@ function finishConcurrentRender(
1122
case RootFatalErrored: {
1123
throw new Error('Root did not complete. This is a bug in React.');
1124
}
1125
- // Flow knows about invariant, so it complains if I add a break
1126
- // statement, but eslint doesn't know about invariant, so it complains
1127
- // if I do. eslint-disable-next-line no-fallthrough
1125
case RootErrored: {
1126
// We should have already attempted to retry this tree. If we reached
1127
// this point, it errored again. Commit it.
@@ -2381,7 +2378,6 @@ function replaySuspendedUnitOfWork(unitOfWork: Fiber): void {
2378
unitOfWork.tag = FunctionComponent;
2379
// Fallthrough to the next branch.
2380
}
2384
- // eslint-disable-next-line no-fallthrough
2381
case SimpleMemoComponent:
2382
case FunctionComponent: {
2383
// Resolve `defaultProps`. This logic is copied from `beginWork`.
packages/react-server/src/ReactFizzServer.js
-2
@@ -1224,7 +1224,6 @@ function renderElement(
1224
}
1225
throw new Error('ReactDOMServer does not yet support scope components.');
1226
}
1227
- // eslint-disable-next-line-no-fallthrough
1227
case REACT_SUSPENSE_TYPE: {
1228
if (
1229
enableSuspenseAvoidThisFallbackFizz &&
@@ -1379,7 +1378,6 @@ function renderNodeDestructiveImpl(
1378
'Portals are not currently supported by the server renderer. ' +
1379
'Render them conditionally so that they only appear on the client render.',
1380
);
1382
- // eslint-disable-next-line-no-fallthrough
1381
case REACT_LAZY_TYPE: {
1382
const lazyNode: LazyComponentType<any, any> = (node: any);
1383
const payload = lazyNode._payload;
packages/shared/getComponentNameFromType.js
+1
-2
@@ -89,7 +89,7 @@ export default function getComponentNameFromType(type: mixed): string | null {
89
if (enableCache) {
90
return 'Cache';
91
}
92
- // eslint-disable-next-line no-fallthrough
92
+ // Fall through
93
case REACT_TRACING_MARKER_TYPE:
94
if (enableTransitionTracing) {
95
return 'TracingMarker';
@@ -126,7 +126,6 @@ export default function getComponentNameFromType(type: mixed): string | null {
126
const context2 = ((type: any): ReactContext<any>);
127
return (context2.displayName || context2._globalName) + '.Provider';
128
}
129
- // eslint-disable-next-line no-fallthrough
129
}
130
}
131
return null;