Skip to content

Commit b7e7f1a

Browse files
authored
[BE] upgrade prettier to 3.3.3 (#30420)
Mostly just changes in ternary formatting.
1 parent d7c4334 commit b7e7f1a

File tree

50 files changed

+206
-234
lines changed

Some content is hidden

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

50 files changed

+206
-234
lines changed

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hook-noAlias.expect.md

+3-7
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,9 @@ import {useNoAlias} from 'shared-runtime';
66

77
function Component(props) {
88
const item = {a: props.a};
9-
const x = useNoAlias(
10-
item,
11-
() => {
12-
console.log(props);
13-
},
14-
[props.a]
15-
);
9+
const x = useNoAlias(item, () => {
10+
console.log(props);
11+
}, [props.a]);
1612
return [x, item];
1713
}
1814

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hook-noAlias.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ import {useNoAlias} from 'shared-runtime';
22

33
function Component(props) {
44
const item = {a: props.a};
5-
const x = useNoAlias(
6-
item,
7-
() => {
8-
console.log(props);
9-
},
10-
[props.a]
11-
);
5+
const x = useNoAlias(item, () => {
6+
console.log(props);
7+
}, [props.a]);
128
return [x, item];
139
}
1410

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/useMemo-constant-prop.expect.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ function useFoo(cond) {
1111
const derived1 = useMemo(() => {
1212
return identity(sourceDep);
1313
}, [sourceDep]);
14-
const derived2 = cond ?? Math.min(sourceDep, 1) ? 1 : 2;
14+
const derived2 = (cond ?? Math.min(sourceDep, 1)) ? 1 : 2;
1515
const derived3 = useMemo(() => {
1616
return identity(sourceDep);
1717
}, [sourceDep]);
18-
const derived4 = Math.min(sourceDep, -1) ?? cond ? 1 : 2;
18+
const derived4 = (Math.min(sourceDep, -1) ?? cond) ? 1 : 2;
1919
return [derived1, derived2, derived3, derived4];
2020
}
2121

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/useMemo-constant-prop.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ function useFoo(cond) {
77
const derived1 = useMemo(() => {
88
return identity(sourceDep);
99
}, [sourceDep]);
10-
const derived2 = cond ?? Math.min(sourceDep, 1) ? 1 : 2;
10+
const derived2 = (cond ?? Math.min(sourceDep, 1)) ? 1 : 2;
1111
const derived3 = useMemo(() => {
1212
return identity(sourceDep);
1313
}, [sourceDep]);
14-
const derived4 = Math.min(sourceDep, -1) ?? cond ? 1 : 2;
14+
const derived4 = (Math.min(sourceDep, -1) ?? cond) ? 1 : 2;
1515
return [derived1, derived2, derived3, derived4];
1616
}
1717

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ternary-expression.expect.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
```javascript
55
function ternary(props) {
6-
const a = props.a && props.b ? props.c || props.d : props.e ?? props.f;
6+
const a = props.a && props.b ? props.c || props.d : (props.e ?? props.f);
77
const b = props.a ? (props.b && props.c ? props.d : props.e) : props.f;
88
return a ? b : null;
99
}

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/ternary-expression.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function ternary(props) {
2-
const a = props.a && props.b ? props.c || props.d : props.e ?? props.f;
2+
const a = props.a && props.b ? props.c || props.d : (props.e ?? props.f);
33
const b = props.a ? (props.b && props.c ? props.d : props.e) : props.f;
44
return a ? b : null;
55
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
"minimist": "^1.2.3",
8181
"mkdirp": "^0.5.1",
8282
"ncp": "^2.0.0",
83-
"prettier": "3.0.3",
83+
"prettier": "^3.3.3",
8484
"prettier-2": "npm:prettier@^2",
8585
"pretty-format": "^29.4.1",
8686
"prop-types": "^15.6.2",

packages/react-debug-tools/src/ReactDebugHooks.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,9 @@ function useState<S>(
284284
hook !== null
285285
? hook.memoizedState
286286
: typeof initialState === 'function'
287-
? // $FlowFixMe[incompatible-use]: Flow doesn't like mixed types
288-
initialState()
289-
: initialState;
287+
? // $FlowFixMe[incompatible-use]: Flow doesn't like mixed types
288+
initialState()
289+
: initialState;
290290
hookLog.push({
291291
displayName: null,
292292
primitive: 'State',

packages/react-debug-tools/src/__tests__/ReactHooksInspectionIntegration-test.js

+8-16
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,10 @@ describe('ReactHooksInspectionIntegration', () => {
182182
React.useLayoutEffect(effect);
183183
React.useEffect(effect);
184184

185-
React.useImperativeHandle(
186-
outsideRef,
187-
() => {
188-
// Return a function so that jest treats them as non-equal.
189-
return function Instance() {};
190-
},
191-
[],
192-
);
185+
React.useImperativeHandle(outsideRef, () => {
186+
// Return a function so that jest treats them as non-equal.
187+
return function Instance() {};
188+
}, []);
193189

194190
React.useMemo(() => state1 + state2, [state1]);
195191

@@ -472,14 +468,10 @@ describe('ReactHooksInspectionIntegration', () => {
472468
React.useLayoutEffect(effect);
473469
React.useEffect(effect);
474470

475-
React.useImperativeHandle(
476-
outsideRef,
477-
() => {
478-
// Return a function so that jest treats them as non-equal.
479-
return function Instance() {};
480-
},
481-
[],
482-
);
471+
React.useImperativeHandle(outsideRef, () => {
472+
// Return a function so that jest treats them as non-equal.
473+
return function Instance() {};
474+
}, []);
483475

484476
React.useMemo(() => state1 + state2, [state1]);
485477

packages/react-devtools-shared/src/devtools/views/Settings/ComponentsSettings.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,8 @@ export default function ComponentsSettings(_: {}): React.Node {
349349
componentFilter.isValid === false
350350
? 'Filter invalid'
351351
: componentFilter.isEnabled
352-
? 'Filter enabled'
353-
: 'Filter disabled'
352+
? 'Filter enabled'
353+
: 'Filter disabled'
354354
}>
355355
<ToggleIcon
356356
isEnabled={componentFilter.isEnabled}

packages/react-devtools-shared/src/hooks/astUtils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ function getHookVariableName(
289289
const nodeType = hook.node.id.type;
290290
switch (nodeType) {
291291
case AST_NODE_TYPES.ARRAY_PATTERN:
292-
return !isCustomHook ? hook.node.id.elements[0]?.name ?? null : null;
292+
return !isCustomHook ? (hook.node.id.elements[0]?.name ?? null) : null;
293293

294294
case AST_NODE_TYPES.IDENTIFIER:
295295
return hook.node.id.name;

packages/react-devtools-timeline/src/content-views/ReactMeasuresView.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ export class ReactMeasuresView extends View {
186186
context.fillStyle = showHoverHighlight
187187
? hoveredFillStyle
188188
: showGroupHighlight
189-
? groupSelectedFillStyle
190-
: fillStyle;
189+
? groupSelectedFillStyle
190+
: fillStyle;
191191
context.fillRect(
192192
drawableRect.origin.x,
193193
drawableRect.origin.y,

packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -650,9 +650,9 @@ export const scheduleMicrotask: any =
650650
typeof queueMicrotask === 'function'
651651
? queueMicrotask
652652
: typeof localPromise !== 'undefined'
653-
? callback =>
654-
localPromise.resolve(null).then(callback).catch(handleErrorInNextTick)
655-
: scheduleTimeout; // TODO: Determine the best fallback here.
653+
? callback =>
654+
localPromise.resolve(null).then(callback).catch(handleErrorInNextTick)
655+
: scheduleTimeout; // TODO: Determine the best fallback here.
656656

657657
function handleErrorInNextTick(error: any) {
658658
setTimeout(() => {

packages/react-dom-bindings/src/events/SyntheticEvent.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -564,23 +564,23 @@ const WheelEventInterface = {
564564
return 'deltaX' in event
565565
? event.deltaX
566566
: // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive).
567-
'wheelDeltaX' in event
568-
? // $FlowFixMe[unsafe-arithmetic] assuming this is a number
569-
-event.wheelDeltaX
570-
: 0;
567+
'wheelDeltaX' in event
568+
? // $FlowFixMe[unsafe-arithmetic] assuming this is a number
569+
-event.wheelDeltaX
570+
: 0;
571571
},
572572
deltaY(event: {[propName: string]: mixed}) {
573573
return 'deltaY' in event
574574
? event.deltaY
575575
: // Fallback to `wheelDeltaY` for Webkit and normalize (down is positive).
576-
'wheelDeltaY' in event
577-
? // $FlowFixMe[unsafe-arithmetic] assuming this is a number
578-
-event.wheelDeltaY
579-
: // Fallback to `wheelDelta` for IE<9 and normalize (down is positive).
580-
'wheelDelta' in event
581-
? // $FlowFixMe[unsafe-arithmetic] assuming this is a number
582-
-event.wheelDelta
583-
: 0;
576+
'wheelDeltaY' in event
577+
? // $FlowFixMe[unsafe-arithmetic] assuming this is a number
578+
-event.wheelDeltaY
579+
: // Fallback to `wheelDelta` for IE<9 and normalize (down is positive).
580+
'wheelDelta' in event
581+
? // $FlowFixMe[unsafe-arithmetic] assuming this is a number
582+
-event.wheelDelta
583+
: 0;
584584
},
585585
deltaZ: 0,
586586

packages/react-dom-bindings/src/events/plugins/SelectEventPlugin.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ function getEventTargetDocument(eventTarget: any) {
8080
return eventTarget.window === eventTarget
8181
? eventTarget.document
8282
: eventTarget.nodeType === DOCUMENT_NODE
83-
? eventTarget
84-
: eventTarget.ownerDocument;
83+
? eventTarget
84+
: eventTarget.ownerDocument;
8585
}
8686

8787
/**

packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,8 @@ export function createRenderState(
515515
typeof scriptConfig === 'string' || scriptConfig.crossOrigin == null
516516
? undefined
517517
: scriptConfig.crossOrigin === 'use-credentials'
518-
? 'use-credentials'
519-
: '';
518+
? 'use-credentials'
519+
: '';
520520
}
521521

522522
preloadBootstrapScriptOrModule(resumableState, renderState, src, props);
@@ -567,8 +567,8 @@ export function createRenderState(
567567
typeof scriptConfig === 'string' || scriptConfig.crossOrigin == null
568568
? undefined
569569
: scriptConfig.crossOrigin === 'use-credentials'
570-
? 'use-credentials'
571-
: '';
570+
? 'use-credentials'
571+
: '';
572572
}
573573

574574
preloadBootstrapScriptOrModule(resumableState, renderState, src, props);
@@ -736,8 +736,8 @@ export function createRootFormatContext(namespaceURI?: string): FormatContext {
736736
namespaceURI === 'http://www.w3.org/2000/svg'
737737
? SVG_MODE
738738
: namespaceURI === 'http://www.w3.org/1998/Math/MathML'
739-
? MATHML_MODE
740-
: ROOT_HTML_MODE;
739+
? MATHML_MODE
740+
: ROOT_HTML_MODE;
741741
return createFormatContext(insertionMode, null, NO_SCOPE);
742742
}
743743

@@ -2493,8 +2493,8 @@ function pushLink(
24932493
props.onLoad && props.onError
24942494
? '`onLoad` and `onError` props'
24952495
: props.onLoad
2496-
? '`onLoad` prop'
2497-
: '`onError` prop';
2496+
? '`onLoad` prop'
2497+
: '`onError` prop';
24982498
console.error(
24992499
'React encountered a `<link rel="stylesheet" .../>` with a `precedence` prop and %s. The presence of loading and error handlers indicates an intent to manage the stylesheet loading state from your from your Component code and React will not hoist or deduplicate this stylesheet. If your intent was to have React hoist and deduplciate this stylesheet using the `precedence` prop remove the %s, otherwise remove the `precedence` prop.',
25002500
propDescription,
@@ -2669,8 +2669,8 @@ function pushStyle(
26692669
typeof child === 'function'
26702670
? 'a Function'
26712671
: typeof child === 'symbol'
2672-
? 'a Sybmol'
2673-
: 'an Array';
2672+
? 'a Sybmol'
2673+
: 'an Array';
26742674
console.error(
26752675
'React expect children of <style> tags to be a string, number, or object with a `toString` method but found %s instead. ' +
26762676
'In browsers style Elements can only have `Text` Nodes as children.',
@@ -3337,8 +3337,8 @@ function pushScriptImpl(
33373337
typeof children === 'number'
33383338
? 'a number for children'
33393339
: Array.isArray(children)
3340-
? 'an array for children'
3341-
: 'something unexpected for children';
3340+
? 'an array for children'
3341+
: 'something unexpected for children';
33423342
console.error(
33433343
'A script element was rendered with %s. If script element has children it must be a single string.' +
33443344
' Consider using dangerouslySetInnerHTML or passing a plain string as children.',
@@ -5436,8 +5436,8 @@ function preconnect(href: string, crossOrigin: ?CrossOriginEnum) {
54365436
crossOrigin === 'use-credentials'
54375437
? 'credentials'
54385438
: typeof crossOrigin === 'string'
5439-
? 'anonymous'
5440-
: 'default';
5439+
? 'anonymous'
5440+
: 'default';
54415441
const key = getResourceKey(href);
54425442
if (!resumableState.connectResources[bucket].hasOwnProperty(key)) {
54435443
resumableState.connectResources[bucket][key] = EXISTS;

packages/react-dom-bindings/src/shared/ReactDOMResourceValidation.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,20 @@ export function getValueDescriptorExpectingObjectForWarning(
6868
return thing === null
6969
? '`null`'
7070
: thing === undefined
71-
? '`undefined`'
72-
: thing === ''
73-
? 'an empty string'
74-
: `something with type "${typeof thing}"`;
71+
? '`undefined`'
72+
: thing === ''
73+
? 'an empty string'
74+
: `something with type "${typeof thing}"`;
7575
}
7676

7777
export function getValueDescriptorExpectingEnumForWarning(thing: any): string {
7878
return thing === null
7979
? '`null`'
8080
: thing === undefined
81-
? '`undefined`'
82-
: thing === ''
83-
? 'an empty string'
84-
: typeof thing === 'string'
85-
? JSON.stringify(thing)
86-
: `something with type "${typeof thing}"`;
81+
? '`undefined`'
82+
: thing === ''
83+
? 'an empty string'
84+
: typeof thing === 'string'
85+
? JSON.stringify(thing)
86+
: `something with type "${typeof thing}"`;
8787
}

packages/react-dom/src/__tests__/ReactDOMFizzStatic-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ describe('ReactDOMFizzStatic', () => {
133133
return children.length === 0
134134
? undefined
135135
: children.length === 1
136-
? children[0]
137-
: children;
136+
? children[0]
137+
: children;
138138
}
139139

140140
function resolveText(text) {

packages/react-dom/src/__tests__/ReactDOMFizzSuppressHydrationWarning-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
135135
return children.length === 0
136136
? undefined
137137
: children.length === 1
138-
? children[0]
139-
: children;
138+
? children[0]
139+
: children;
140140
}
141141

142142
it('suppresses but does not fix text mismatches with suppressHydrationWarning', async () => {

packages/react-dom/src/__tests__/ReactDOMFloat-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@ describe('ReactDOMFloat', () => {
282282
return children.length === 0
283283
? undefined
284284
: children.length === 1
285-
? children[0]
286-
: children;
285+
? children[0]
286+
: children;
287287
}
288288

289289
function BlockedOn({value, children}) {

packages/react-dom/src/__tests__/ReactDOMServerSuspense-test.internal.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ describe('ReactDOMServerSuspense', () => {
7272
return children.length === 0
7373
? undefined
7474
: children.length === 1
75-
? children[0]
76-
: children;
75+
? children[0]
76+
: children;
7777
}
7878

7979
it('should render the children when no promise is thrown', async () => {

packages/react-dom/src/__tests__/ReactDOMSingletonComponents-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ describe('ReactDOM HostSingleton', () => {
128128
return children.length === 0
129129
? undefined
130130
: children.length === 1
131-
? children[0]
132-
: children;
131+
? children[0]
132+
: children;
133133
}
134134

135135
it('warns if you render the same singleton twice at the same time', async () => {

0 commit comments

Comments
 (0)