Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] upgrade prettier to 3.3.3 #30420

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@ import {useNoAlias} from 'shared-runtime';

function Component(props) {
const item = {a: props.a};
const x = useNoAlias(
item,
() => {
console.log(props);
},
[props.a]
);
const x = useNoAlias(item, () => {
console.log(props);
}, [props.a]);
return [x, item];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@ import {useNoAlias} from 'shared-runtime';

function Component(props) {
const item = {a: props.a};
const x = useNoAlias(
item,
() => {
console.log(props);
},
[props.a]
);
const x = useNoAlias(item, () => {
console.log(props);
}, [props.a]);
return [x, item];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ function useFoo(cond) {
const derived1 = useMemo(() => {
return identity(sourceDep);
}, [sourceDep]);
const derived2 = cond ?? Math.min(sourceDep, 1) ? 1 : 2;
const derived2 = (cond ?? Math.min(sourceDep, 1)) ? 1 : 2;
const derived3 = useMemo(() => {
return identity(sourceDep);
}, [sourceDep]);
const derived4 = Math.min(sourceDep, -1) ?? cond ? 1 : 2;
const derived4 = (Math.min(sourceDep, -1) ?? cond) ? 1 : 2;
return [derived1, derived2, derived3, derived4];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ function useFoo(cond) {
const derived1 = useMemo(() => {
return identity(sourceDep);
}, [sourceDep]);
const derived2 = cond ?? Math.min(sourceDep, 1) ? 1 : 2;
const derived2 = (cond ?? Math.min(sourceDep, 1)) ? 1 : 2;
const derived3 = useMemo(() => {
return identity(sourceDep);
}, [sourceDep]);
const derived4 = Math.min(sourceDep, -1) ?? cond ? 1 : 2;
const derived4 = (Math.min(sourceDep, -1) ?? cond) ? 1 : 2;
return [derived1, derived2, derived3, derived4];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

```javascript
function ternary(props) {
const a = props.a && props.b ? props.c || props.d : props.e ?? props.f;
const a = props.a && props.b ? props.c || props.d : (props.e ?? props.f);
const b = props.a ? (props.b && props.c ? props.d : props.e) : props.f;
return a ? b : null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function ternary(props) {
const a = props.a && props.b ? props.c || props.d : props.e ?? props.f;
const a = props.a && props.b ? props.c || props.d : (props.e ?? props.f);
const b = props.a ? (props.b && props.c ? props.d : props.e) : props.f;
return a ? b : null;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"minimist": "^1.2.3",
"mkdirp": "^0.5.1",
"ncp": "^2.0.0",
"prettier": "3.0.3",
"prettier": "^3.3.3",
"prettier-2": "npm:prettier@^2",
"pretty-format": "^29.4.1",
"prop-types": "^15.6.2",
Expand Down
6 changes: 3 additions & 3 deletions packages/react-debug-tools/src/ReactDebugHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ function useState<S>(
hook !== null
? hook.memoizedState
: typeof initialState === 'function'
? // $FlowFixMe[incompatible-use]: Flow doesn't like mixed types
initialState()
: initialState;
? // $FlowFixMe[incompatible-use]: Flow doesn't like mixed types
initialState()
: initialState;
hookLog.push({
displayName: null,
primitive: 'State',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,10 @@ describe('ReactHooksInspectionIntegration', () => {
React.useLayoutEffect(effect);
React.useEffect(effect);

React.useImperativeHandle(
outsideRef,
() => {
// Return a function so that jest treats them as non-equal.
return function Instance() {};
},
[],
);
React.useImperativeHandle(outsideRef, () => {
// Return a function so that jest treats them as non-equal.
return function Instance() {};
}, []);

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

Expand Down Expand Up @@ -472,14 +468,10 @@ describe('ReactHooksInspectionIntegration', () => {
React.useLayoutEffect(effect);
React.useEffect(effect);

React.useImperativeHandle(
outsideRef,
() => {
// Return a function so that jest treats them as non-equal.
return function Instance() {};
},
[],
);
React.useImperativeHandle(outsideRef, () => {
// Return a function so that jest treats them as non-equal.
return function Instance() {};
}, []);

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ export default function ComponentsSettings(_: {}): React.Node {
componentFilter.isValid === false
? 'Filter invalid'
: componentFilter.isEnabled
? 'Filter enabled'
: 'Filter disabled'
? 'Filter enabled'
: 'Filter disabled'
}>
<ToggleIcon
isEnabled={componentFilter.isEnabled}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-devtools-shared/src/hooks/astUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ function getHookVariableName(
const nodeType = hook.node.id.type;
switch (nodeType) {
case AST_NODE_TYPES.ARRAY_PATTERN:
return !isCustomHook ? hook.node.id.elements[0]?.name ?? null : null;
return !isCustomHook ? (hook.node.id.elements[0]?.name ?? null) : null;

case AST_NODE_TYPES.IDENTIFIER:
return hook.node.id.name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ export class ReactMeasuresView extends View {
context.fillStyle = showHoverHighlight
? hoveredFillStyle
: showGroupHighlight
? groupSelectedFillStyle
: fillStyle;
? groupSelectedFillStyle
: fillStyle;
context.fillRect(
drawableRect.origin.x,
drawableRect.origin.y,
Expand Down
6 changes: 3 additions & 3 deletions packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,9 +650,9 @@ export const scheduleMicrotask: any =
typeof queueMicrotask === 'function'
? queueMicrotask
: typeof localPromise !== 'undefined'
? callback =>
localPromise.resolve(null).then(callback).catch(handleErrorInNextTick)
: scheduleTimeout; // TODO: Determine the best fallback here.
? callback =>
localPromise.resolve(null).then(callback).catch(handleErrorInNextTick)
: scheduleTimeout; // TODO: Determine the best fallback here.

function handleErrorInNextTick(error: any) {
setTimeout(() => {
Expand Down
24 changes: 12 additions & 12 deletions packages/react-dom-bindings/src/events/SyntheticEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,23 +564,23 @@ const WheelEventInterface = {
return 'deltaX' in event
? event.deltaX
: // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive).
'wheelDeltaX' in event
? // $FlowFixMe[unsafe-arithmetic] assuming this is a number
-event.wheelDeltaX
: 0;
'wheelDeltaX' in event
? // $FlowFixMe[unsafe-arithmetic] assuming this is a number
-event.wheelDeltaX
: 0;
},
deltaY(event: {[propName: string]: mixed}) {
return 'deltaY' in event
? event.deltaY
: // Fallback to `wheelDeltaY` for Webkit and normalize (down is positive).
'wheelDeltaY' in event
? // $FlowFixMe[unsafe-arithmetic] assuming this is a number
-event.wheelDeltaY
: // Fallback to `wheelDelta` for IE<9 and normalize (down is positive).
'wheelDelta' in event
? // $FlowFixMe[unsafe-arithmetic] assuming this is a number
-event.wheelDelta
: 0;
'wheelDeltaY' in event
? // $FlowFixMe[unsafe-arithmetic] assuming this is a number
-event.wheelDeltaY
: // Fallback to `wheelDelta` for IE<9 and normalize (down is positive).
'wheelDelta' in event
? // $FlowFixMe[unsafe-arithmetic] assuming this is a number
-event.wheelDelta
: 0;
},
deltaZ: 0,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ function getEventTargetDocument(eventTarget: any) {
return eventTarget.window === eventTarget
? eventTarget.document
: eventTarget.nodeType === DOCUMENT_NODE
? eventTarget
: eventTarget.ownerDocument;
? eventTarget
: eventTarget.ownerDocument;
}

/**
Expand Down
28 changes: 14 additions & 14 deletions packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,8 @@ export function createRenderState(
typeof scriptConfig === 'string' || scriptConfig.crossOrigin == null
? undefined
: scriptConfig.crossOrigin === 'use-credentials'
? 'use-credentials'
: '';
? 'use-credentials'
: '';
}

preloadBootstrapScriptOrModule(resumableState, renderState, src, props);
Expand Down Expand Up @@ -567,8 +567,8 @@ export function createRenderState(
typeof scriptConfig === 'string' || scriptConfig.crossOrigin == null
? undefined
: scriptConfig.crossOrigin === 'use-credentials'
? 'use-credentials'
: '';
? 'use-credentials'
: '';
}

preloadBootstrapScriptOrModule(resumableState, renderState, src, props);
Expand Down Expand Up @@ -736,8 +736,8 @@ export function createRootFormatContext(namespaceURI?: string): FormatContext {
namespaceURI === 'http://www.w3.org/2000/svg'
? SVG_MODE
: namespaceURI === 'http://www.w3.org/1998/Math/MathML'
? MATHML_MODE
: ROOT_HTML_MODE;
? MATHML_MODE
: ROOT_HTML_MODE;
return createFormatContext(insertionMode, null, NO_SCOPE);
}

Expand Down Expand Up @@ -2493,8 +2493,8 @@ function pushLink(
props.onLoad && props.onError
? '`onLoad` and `onError` props'
: props.onLoad
? '`onLoad` prop'
: '`onError` prop';
? '`onLoad` prop'
: '`onError` prop';
console.error(
'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.',
propDescription,
Expand Down Expand Up @@ -2669,8 +2669,8 @@ function pushStyle(
typeof child === 'function'
? 'a Function'
: typeof child === 'symbol'
? 'a Sybmol'
: 'an Array';
? 'a Sybmol'
: 'an Array';
console.error(
'React expect children of <style> tags to be a string, number, or object with a `toString` method but found %s instead. ' +
'In browsers style Elements can only have `Text` Nodes as children.',
Expand Down Expand Up @@ -3337,8 +3337,8 @@ function pushScriptImpl(
typeof children === 'number'
? 'a number for children'
: Array.isArray(children)
? 'an array for children'
: 'something unexpected for children';
? 'an array for children'
: 'something unexpected for children';
console.error(
'A script element was rendered with %s. If script element has children it must be a single string.' +
' Consider using dangerouslySetInnerHTML or passing a plain string as children.',
Expand Down Expand Up @@ -5436,8 +5436,8 @@ function preconnect(href: string, crossOrigin: ?CrossOriginEnum) {
crossOrigin === 'use-credentials'
? 'credentials'
: typeof crossOrigin === 'string'
? 'anonymous'
: 'default';
? 'anonymous'
: 'default';
const key = getResourceKey(href);
if (!resumableState.connectResources[bucket].hasOwnProperty(key)) {
resumableState.connectResources[bucket][key] = EXISTS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,20 @@ export function getValueDescriptorExpectingObjectForWarning(
return thing === null
? '`null`'
: thing === undefined
? '`undefined`'
: thing === ''
? 'an empty string'
: `something with type "${typeof thing}"`;
? '`undefined`'
: thing === ''
? 'an empty string'
: `something with type "${typeof thing}"`;
}

export function getValueDescriptorExpectingEnumForWarning(thing: any): string {
return thing === null
? '`null`'
: thing === undefined
? '`undefined`'
: thing === ''
? 'an empty string'
: typeof thing === 'string'
? JSON.stringify(thing)
: `something with type "${typeof thing}"`;
? '`undefined`'
: thing === ''
? 'an empty string'
: typeof thing === 'string'
? JSON.stringify(thing)
: `something with type "${typeof thing}"`;
}
4 changes: 2 additions & 2 deletions packages/react-dom/src/__tests__/ReactDOMFizzStatic-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ describe('ReactDOMFizzStatic', () => {
return children.length === 0
? undefined
: children.length === 1
? children[0]
: children;
? children[0]
: children;
}

function resolveText(text) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
return children.length === 0
? undefined
: children.length === 1
? children[0]
: children;
? children[0]
: children;
}

it('suppresses but does not fix text mismatches with suppressHydrationWarning', async () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/__tests__/ReactDOMFloat-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ describe('ReactDOMFloat', () => {
return children.length === 0
? undefined
: children.length === 1
? children[0]
: children;
? children[0]
: children;
}

function BlockedOn({value, children}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ describe('ReactDOMServerSuspense', () => {
return children.length === 0
? undefined
: children.length === 1
? children[0]
: children;
? children[0]
: children;
}

it('should render the children when no promise is thrown', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ describe('ReactDOM HostSingleton', () => {
return children.length === 0
? undefined
: children.length === 1
? children[0]
: children;
? children[0]
: children;
}

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