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

Upgrade wp-prettier to 2.8.5 #49258

Merged
merged 4 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
"patch-package": "6.2.2",
"postcss": "8.4.16",
"postcss-loader": "6.2.1",
"prettier": "npm:wp-prettier@2.6.2",
"prettier": "npm:wp-prettier@2.8.5",
"progress": "2.0.3",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand Down
8 changes: 6 additions & 2 deletions packages/block-editor/src/hooks/content-lock-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,13 @@ export const withBlockControls = createHigherOrderComponent(
return <BlockEdit { ...props } />;
}

const showStopEditingAsBlocks = isEditingAsBlocks && ! isContentLocked;
const showStartEditingAsBlocks =
! isEditingAsBlocks && isContentLocked && props.isSelected;
Comment on lines +107 to +109
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious why those were needed as separate variables. Is the new version breaking these expressions somehow?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not breaking them, the formatting was just not pretty. The conditional JSX:

<>
  { isEditing && isLocked && isSelected && (
    <BlockSettings />
  ) }
</>

was already over 80 columns, but the old Prettier didn't break it. The new Prettier breaks it like:

<>
  { isEditing &&
    isLocked &&
    isSelected && (
      <BlockSettings />
    ) }
</>

which looks bad and also adds a new level of indentation for the inner markup. I decided to make it look good again by extracting the condition.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, thank you for clarifying 👍


return (
<>
{ isEditingAsBlocks && ! isContentLocked && (
{ showStopEditingAsBlocks && (
<>
<StopEditingAsBlocksOnOutsideSelect
clientId={ props.clientId }
Expand All @@ -123,7 +127,7 @@ export const withBlockControls = createHigherOrderComponent(
</BlockControls>
</>
) }
{ ! isEditingAsBlocks && isContentLocked && props.isSelected && (
{ showStartEditingAsBlocks && (
<BlockSettingsMenuControls>
{ ( { onClose } ) => (
<MenuItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const colors = [

const Template: ComponentStory< typeof BorderBoxControl > = ( props ) => {
const { onChange, ...otherProps } = props;
const [ borders, setBorders ] = useState< typeof props[ 'value' ] >();
const [ borders, setBorders ] = useState< ( typeof props )[ 'value' ] >();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does make sense IMO 👍


const onChangeMerged: ComponentProps<
typeof BorderBoxControl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Layout } from './styles/box-control-styles';
import type { BoxControlInputControlProps } from './types';

const groupedSides = [ 'vertical', 'horizontal' ] as const;
type GroupedSide = typeof groupedSides[ number ];
type GroupedSide = ( typeof groupedSides )[ number ];

export default function AxialInputControls( {
onChange,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const meta: ComponentMeta< typeof ComboboxControl > = {
};
export default meta;

const mapCountryOption = ( country: typeof countries[ number ] ) => ( {
const mapCountryOption = ( country: ( typeof countries )[ number ] ) => ( {
value: country.code,
label: country.name,
} );
Expand Down
6 changes: 3 additions & 3 deletions packages/components/src/palette-edit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ export function PaletteEdit( {
{ hasElements && (
<>
{ isEditing && (
<PaletteEditListView< typeof elements[ number ] >
<PaletteEditListView< ( typeof elements )[ number ] >
canOnlyChangeValues={ canOnlyChangeValues }
elements={ elements }
// @ts-expect-error TODO: Don't know how to resolve
Expand All @@ -548,13 +548,13 @@ export function PaletteEdit( {
isGradient={ isGradient }
onClose={ () => setEditingElement( null ) }
onChange={ (
newElement: typeof elements[ number ]
newElement: ( typeof elements )[ number ]
) => {
debounceOnChange(
// @ts-expect-error TODO: Don't know how to resolve
elements.map(
(
currentElement: typeof elements[ number ],
currentElement: ( typeof elements )[ number ],
currentIndex: number
) => {
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const POSITIONS = {
corner: 'corner',
} as const;

export type Position = typeof POSITIONS[ keyof typeof POSITIONS ];
export type Position = ( typeof POSITIONS )[ keyof typeof POSITIONS ];

interface UseResizeLabelProps {
/** The label value. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ const PAGE_STATUS = [

export type Page = {
id: number;
status: typeof PAGE_STATUS[ number ];
status: ( typeof PAGE_STATUS )[ number ];
};

export type CreatePagePayload = {
title?: string;
content?: string;
status: typeof PAGE_STATUS[ number ];
status: ( typeof PAGE_STATUS )[ number ];
date?: string;
date_gmt?: string;
};
Expand Down
5 changes: 3 additions & 2 deletions packages/e2e-test-utils-playwright/src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function observeConsoleLogging( message: ConsoleMessage ) {
const type = message.type();
if (
! OBSERVED_CONSOLE_MESSAGE_TYPES.includes(
type as typeof OBSERVED_CONSOLE_MESSAGE_TYPES[ number ]
type as ( typeof OBSERVED_CONSOLE_MESSAGE_TYPES )[ number ]
)
) {
return;
Expand Down Expand Up @@ -85,7 +85,8 @@ function observeConsoleLogging( message: ConsoleMessage ) {
return;
}

const logFunction = type as typeof OBSERVED_CONSOLE_MESSAGE_TYPES[ number ];
const logFunction =
type as ( typeof OBSERVED_CONSOLE_MESSAGE_TYPES )[ number ];

// Disable reason: We intentionally bubble up the console message
// which, unless the test explicitly anticipates the logging via
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-post/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ export const showBlockTypes =
( type ) =>
! (
Array.isArray( blockNames ) ? blockNames : [ blockNames ]
).includes( type )
).includes( type )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I love this. I hated how it added that extra space!

);

registry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function PostTypeSupportCheck( { postType, children, supportKeys } ) {
if ( postType ) {
isSupported = (
Array.isArray( supportKeys ) ? supportKeys : [ supportKeys ]
).some( ( key ) => !! postType.supports[ key ] );
).some( ( key ) => !! postType.supports[ key ] );
}

if ( ! isSupported ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function ThemeSupportCheck( {
} ) {
const isSupported = (
Array.isArray( supportKeys ) ? supportKeys : [ supportKeys ]
).some( ( key ) => {
).some( ( key ) => {
const supported = themeSupports?.[ key ] ?? false;
// 'post-thumbnails' can be boolean or an array of post types.
// In the latter case, we need to verify `postType` exists
Expand Down
3 changes: 0 additions & 3 deletions packages/private-apis/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,3 @@
},
"include": [ "src/**/*" ]
}



4 changes: 4 additions & 0 deletions packages/scripts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Enhancements

- The bundled `wp-prettier` dependency has been upgraded from `2.6.2` to `2.8.5`.

## 26.0.0 (2023-03-15)

### Breaking Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"npm-packlist": "^3.0.0",
"postcss": "^8.4.5",
"postcss-loader": "^6.2.1",
"prettier": "npm:wp-prettier@2.6.2",
"prettier": "npm:wp-prettier@2.8.5",
"puppeteer-core": "^13.2.0",
"react-refresh": "^0.10.0",
"read-pkg-up": "^7.0.1",
Expand Down
Loading