Skip to content

Commit 393738b

Browse files
committed
Run the codemod
1 parent 74e1a0d commit 393738b

File tree

81 files changed

+711
-831
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+711
-831
lines changed

packages/create-subscription/src/createSubscription.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ export function createSubscription<Property, Value>(
3737
const {getCurrentValue, subscribe} = config;
3838

3939
if (__DEV__) {
40-
warningWithoutStack(
41-
typeof getCurrentValue === 'function',
42-
'Subscription must specify a getCurrentValue function',
43-
);
44-
warningWithoutStack(
45-
typeof subscribe === 'function',
46-
'Subscription must specify a subscribe function',
47-
);
40+
if (typeof getCurrentValue !== 'function') {
41+
warningWithoutStack(
42+
'Subscription must specify a getCurrentValue function',
43+
);
44+
}
45+
if (typeof subscribe !== 'function') {
46+
warningWithoutStack('Subscription must specify a subscribe function');
47+
}
4848
}
4949

5050
type Props = {

packages/legacy-events/EventPluginUtils.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ export function setComponentTree(
2222
getInstanceFromNode = getInstanceFromNodeImpl;
2323
getNodeFromInstance = getNodeFromInstanceImpl;
2424
if (__DEV__) {
25-
warningWithoutStack(
26-
getNodeFromInstance && getInstanceFromNode,
27-
'EventPluginUtils.setComponentTree(...): Injected ' +
28-
'module is missing getNodeFromInstance or getInstanceFromNode.',
29-
);
25+
if (!getNodeFromInstance || !getInstanceFromNode) {
26+
warningWithoutStack(
27+
'EventPluginUtils.setComponentTree(...): Injected ' +
28+
'module is missing getNodeFromInstance or getInstanceFromNode.',
29+
);
30+
}
3031
}
3132
}
3233

@@ -50,10 +51,9 @@ if (__DEV__) {
5051
? 1
5152
: 0;
5253

53-
warningWithoutStack(
54-
instancesIsArr === listenersIsArr && instancesLen === listenersLen,
55-
'EventPluginUtils: Invalid `event`.',
56-
);
54+
if (instancesIsArr !== listenersIsArr || instancesLen !== listenersLen) {
55+
warningWithoutStack('EventPluginUtils: Invalid `event`.');
56+
}
5757
};
5858
}
5959

packages/legacy-events/EventPropagators.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ function listenerAtPhase(inst, event, propagationPhase: PropagationPhases) {
4646
*/
4747
function accumulateDirectionalDispatches(inst, phase, event) {
4848
if (__DEV__) {
49-
warningWithoutStack(inst, 'Dispatching inst must not be null');
49+
if (!inst) {
50+
warningWithoutStack('Dispatching inst must not be null');
51+
}
5052
}
5153
const listener = listenerAtPhase(inst, event, phase);
5254
if (listener) {

packages/legacy-events/ResponderTouchHistoryStore.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,14 @@ function resetTouchRecord(touchRecord: TouchRecord, touch: Touch): void {
9595
function getTouchIdentifier({identifier}: Touch): number {
9696
invariant(identifier != null, 'Touch object is missing identifier.');
9797
if (__DEV__) {
98-
warningWithoutStack(
99-
identifier <= MAX_TOUCH_BANK,
100-
'Touch identifier %s is greater than maximum supported %s which causes ' +
101-
'performance issues backfilling array locations for all of the indices.',
102-
identifier,
103-
MAX_TOUCH_BANK,
104-
);
98+
if (identifier > MAX_TOUCH_BANK) {
99+
warningWithoutStack(
100+
'Touch identifier %s is greater than maximum supported %s which causes ' +
101+
'performance issues backfilling array locations for all of the indices.',
102+
identifier,
103+
MAX_TOUCH_BANK,
104+
);
105+
}
105106
}
106107
return identifier;
107108
}
@@ -200,10 +201,9 @@ const ResponderTouchHistoryStore = {
200201
}
201202
if (__DEV__) {
202203
const activeRecord = touchBank[touchHistory.indexOfSingleActiveTouch];
203-
warningWithoutStack(
204-
activeRecord != null && activeRecord.touchActive,
205-
'Cannot find single active touch.',
206-
);
204+
if (activeRecord == null || !activeRecord.touchActive) {
205+
warningWithoutStack('Cannot find single active touch.');
206+
}
207207
}
208208
}
209209
}

packages/legacy-events/SyntheticEvent.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ function getPooledWarningPropertyDefinition(propName, getVal) {
285285
function warn(action, result) {
286286
if (__DEV__) {
287287
warningWithoutStack(
288-
false,
289288
"This synthetic event is reused for performance reasons. If you're seeing this, " +
290289
"you're %s `%s` on a released/nullified synthetic event. %s. " +
291290
'If you must keep the original synthetic event around, use event.persist(). ' +

packages/react-cache/src/ReactCache.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,23 @@ function readContext(Context, observedBits) {
6464

6565
function identityHashFn(input) {
6666
if (__DEV__) {
67-
warningWithoutStack(
68-
typeof input === 'string' ||
67+
if (
68+
!(
69+
typeof input === 'string' ||
6970
typeof input === 'number' ||
7071
typeof input === 'boolean' ||
7172
input === undefined ||
72-
input === null,
73-
'Invalid key type. Expected a string, number, symbol, or boolean, ' +
74-
'but instead received: %s' +
75-
'\n\nTo use non-primitive values as keys, you must pass a hash ' +
76-
'function as the second argument to createResource().',
77-
input,
78-
);
73+
input === null
74+
)
75+
) {
76+
warningWithoutStack(
77+
'Invalid key type. Expected a string, number, symbol, or boolean, ' +
78+
'but instead received: %s' +
79+
'\n\nTo use non-primitive values as keys, you must pass a hash ' +
80+
'function as the second argument to createResource().',
81+
input,
82+
);
83+
}
7984
}
8085
return input;
8186
}

packages/react-dom/src/client/ReactDOM.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ if (__DEV__) {
9393
typeof Set.prototype.forEach !== 'function'
9494
) {
9595
warningWithoutStack(
96-
false,
9796
'React depends on Map and Set built-in types. Make sure that you load a ' +
9897
'polyfill in older browsers. https://fb.me/react-polyfills',
9998
);
@@ -146,7 +145,6 @@ const ReactDOM: Object = {
146145
if (!didWarnAboutUnstableCreatePortal) {
147146
didWarnAboutUnstableCreatePortal = true;
148147
lowPriorityWarningWithoutStack(
149-
false,
150148
'The ReactDOM.unstable_createPortal() alias has been deprecated, ' +
151149
'and will be removed in React 17+. Update your code to use ' +
152150
'ReactDOM.createPortal() instead. It has the exact same API, ' +

packages/react-dom/src/client/ReactDOMComponent.js

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ if (__DEV__) {
185185
}
186186
didWarnInvalidHydration = true;
187187
warningWithoutStack(
188-
false,
189188
'Text content did not match. Server: "%s" Client: "%s"',
190189
normalizedServerText,
191190
normalizedClientText,
@@ -211,7 +210,6 @@ if (__DEV__) {
211210
}
212211
didWarnInvalidHydration = true;
213212
warningWithoutStack(
214-
false,
215213
'Prop `%s` did not match. Server: %s Client: %s',
216214
propName,
217215
JSON.stringify(normalizedServerValue),
@@ -228,13 +226,12 @@ if (__DEV__) {
228226
attributeNames.forEach(function(name) {
229227
names.push(name);
230228
});
231-
warningWithoutStack(false, 'Extra attributes from the server: %s', names);
229+
warningWithoutStack('Extra attributes from the server: %s', names);
232230
};
233231

234232
warnForInvalidEventListener = function(registrationName, listener) {
235233
if (listener === false) {
236234
warning(
237-
false,
238235
'Expected `%s` listener to be a function, instead got `false`.\n\n' +
239236
'If you used to conditionally omit it with %s={condition && value}, ' +
240237
'pass %s={condition ? value : undefined} instead.',
@@ -244,7 +241,6 @@ if (__DEV__) {
244241
);
245242
} else {
246243
warning(
247-
false,
248244
'Expected `%s` listener to be a function, instead got a value of `%s` type.',
249245
registrationName,
250246
typeof listener,
@@ -416,13 +412,14 @@ export function createElement(
416412
isCustomComponentTag = isCustomComponent(type, props);
417413
// Should this check be gated by parent namespace? Not sure we want to
418414
// allow <SVG> or <mATH>.
419-
warning(
420-
isCustomComponentTag || type === type.toLowerCase(),
421-
'<%s /> is using incorrect casing. ' +
422-
'Use PascalCase for React components, ' +
423-
'or lowercase for HTML elements.',
424-
type,
425-
);
415+
if (!isCustomComponentTag && type !== type.toLowerCase()) {
416+
warning(
417+
'<%s /> is using incorrect casing. ' +
418+
'Use PascalCase for React components, ' +
419+
'or lowercase for HTML elements.',
420+
type,
421+
);
422+
}
426423
}
427424

428425
if (type === 'script') {
@@ -432,7 +429,6 @@ export function createElement(
432429
if (__DEV__) {
433430
if (enableTrustedTypesIntegration && !didWarnScriptTags) {
434431
warning(
435-
false,
436432
'Encountered a script tag while rendering React component. ' +
437433
'Scripts inside React components are never executed when rendering ' +
438434
'on the client. Consider using template tag instead ' +
@@ -488,7 +484,6 @@ export function createElement(
488484
) {
489485
warnedUnknownTags[type] = true;
490486
warning(
491-
false,
492487
'The tag <%s> is unrecognized in this browser. ' +
493488
'If you meant to render a React component, start its name with ' +
494489
'an uppercase letter.',
@@ -525,7 +520,6 @@ export function setInitialProperties(
525520
(domElement: any).shadyRoot
526521
) {
527522
warning(
528-
false,
529523
'%s is using shady DOM. Using shady DOM with React can ' +
530524
'cause things to break subtly.',
531525
getCurrentFiberOwnerNameInDevOrNull() || 'A component',
@@ -926,7 +920,6 @@ export function diffHydratedProperties(
926920
(domElement: any).shadyRoot
927921
) {
928922
warning(
929-
false,
930923
'%s is using shady DOM. Using shady DOM with React can ' +
931924
'cause things to break subtly.',
932925
getCurrentFiberOwnerNameInDevOrNull() || 'A component',
@@ -1219,7 +1212,6 @@ export function warnForDeletedHydratableElement(
12191212
}
12201213
didWarnInvalidHydration = true;
12211214
warningWithoutStack(
1222-
false,
12231215
'Did not expect server HTML to contain a <%s> in <%s>.',
12241216
child.nodeName.toLowerCase(),
12251217
parentNode.nodeName.toLowerCase(),
@@ -1237,7 +1229,6 @@ export function warnForDeletedHydratableText(
12371229
}
12381230
didWarnInvalidHydration = true;
12391231
warningWithoutStack(
1240-
false,
12411232
'Did not expect server HTML to contain the text node "%s" in <%s>.',
12421233
child.nodeValue,
12431234
parentNode.nodeName.toLowerCase(),
@@ -1256,7 +1247,6 @@ export function warnForInsertedHydratedElement(
12561247
}
12571248
didWarnInvalidHydration = true;
12581249
warningWithoutStack(
1259-
false,
12601250
'Expected server HTML to contain a matching <%s> in <%s>.',
12611251
tag,
12621252
parentNode.nodeName.toLowerCase(),
@@ -1281,7 +1271,6 @@ export function warnForInsertedHydratedText(
12811271
}
12821272
didWarnInvalidHydration = true;
12831273
warningWithoutStack(
1284-
false,
12851274
'Expected server HTML to contain a matching text node for "%s" in <%s>.',
12861275
text,
12871276
parentNode.nodeName.toLowerCase(),

packages/react-dom/src/client/ReactDOMInput.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ export function initWrapperState(element: Element, props: Object) {
8080
!didWarnCheckedDefaultChecked
8181
) {
8282
warning(
83-
false,
8483
'%s contains an input of type %s with both checked and defaultChecked props. ' +
8584
'Input elements must be either controlled or uncontrolled ' +
8685
'(specify either the checked prop, or the defaultChecked prop, but not ' +
@@ -98,7 +97,6 @@ export function initWrapperState(element: Element, props: Object) {
9897
!didWarnValueDefaultValue
9998
) {
10099
warning(
101-
false,
102100
'%s contains an input of type %s with both value and defaultValue props. ' +
103101
'Input elements must be either controlled or uncontrolled ' +
104102
'(specify either the value prop, or the defaultValue prop, but not ' +
@@ -144,7 +142,6 @@ export function updateWrapper(element: Element, props: Object) {
144142
!didWarnUncontrolledToControlled
145143
) {
146144
warning(
147-
false,
148145
'A component is changing an uncontrolled input of type %s to be controlled. ' +
149146
'Input elements should not switch from uncontrolled to controlled (or vice versa). ' +
150147
'Decide between using a controlled or uncontrolled input ' +
@@ -159,7 +156,6 @@ export function updateWrapper(element: Element, props: Object) {
159156
!didWarnControlledToUncontrolled
160157
) {
161158
warning(
162-
false,
163159
'A component is changing a controlled input of type %s to be uncontrolled. ' +
164160
'Input elements should not switch from controlled to uncontrolled (or vice versa). ' +
165161
'Decide between using a controlled or uncontrolled input ' +

0 commit comments

Comments
 (0)