Skip to content

Commit

Permalink
Upgrade wp-prettier to 2.6.2 (#40542)
Browse files Browse the repository at this point in the history
* Upgrade wp-prettier dependency to 2.6.2

* Change the bracketSameLine option name

* Reformat files with new Prettier

* Fix regex explainer alignment

* Fixup eslint-disable-next-line usages where the next has moved

* Format markdown files

* Format files after merging changes with `trunk`

Co-authored-by: Greg Ziółkowski <grzegorz@gziolo.pl>
  • Loading branch information
jsnajdr and gziolo authored Jun 14, 2022
1 parent e021880 commit 33d84b0
Show file tree
Hide file tree
Showing 602 changed files with 6,823 additions and 7,561 deletions.
7 changes: 4 additions & 3 deletions bin/check-latest-npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,16 @@ async function getLatestNPMVersion() {
/** @type {NodeJS.ErrnoException} */ ( error ).code ===
'ENOTFOUND'
) {
error = new Error( `Could not contact the npm registry to determine latest version.
error =
new Error( `Could not contact the npm registry to determine latest version.
This could be due to an intermittent outage of the service, or because you are not connected to the internet.
Because it is important that \`package-lock.json\` files only be committed while running the latest version of npm, this commit has been blocked.
If you are certain of your changes and desire to commit anyways, you should either connect to the internet or bypass commit verification using ${ yellow(
'git commit --no-verify'
) } .` );
'git commit --no-verify'
) } .` );
}

reject( error );
Expand Down
12 changes: 6 additions & 6 deletions bin/packages/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ function isFileImportedInStyleEntry( file, importStatements ) {
function findStyleEntriesThatImportFile( file ) {
const entriesWithImport = stylesheetEntryPoints.reduce(
( acc, entryPoint ) => {
const styleEntryImportStatements = parseImportStatements(
entryPoint
);
const styleEntryImportStatements =
parseImportStatements( entryPoint );

if (
isFileImportedInStyleEntry( file, styleEntryImportStatements )
Expand Down Expand Up @@ -161,9 +160,10 @@ function createBlockJsonEntryTransform() {
return new Transform( {
objectMode: true,
async transform( file, encoding, callback ) {
const matches = /block-library[\/\\]src[\/\\](.*)[\/\\]block.json$/.exec(
file
);
const matches =
/block-library[\/\\]src[\/\\](.*)[\/\\]block.json$/.exec(
file
);
const blockName = matches ? matches[ 1 ] : undefined;

// Only block.json files in the block-library folder are subject to this transform.
Expand Down
4 changes: 2 additions & 2 deletions bin/packages/validate-typescript-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const tscDetectedVersion = require( 'typescript' ).version;
/**
* Internal dependencies
*/
const tscDependencyVersion = require( '../../package.json' ).devDependencies
.typescript;
const tscDependencyVersion =
require( '../../package.json' ).devDependencies.typescript;

if ( tscDependencyVersion !== tscDetectedVersion ) {
console.error(
Expand Down
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 @@ -207,7 +207,7 @@
"patch-package": "6.2.2",
"postcss": "8.4.5",
"postcss-loader": "6.2.1",
"prettier": "npm:wp-prettier@2.2.1-beta-1",
"prettier": "npm:wp-prettier@2.6.2",
"progress": "2.0.3",
"react": "17.0.2",
"react-dom": "17.0.2",
Expand Down
9 changes: 4 additions & 5 deletions packages/a11y/src/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,11 @@ describe( 'speak', () => {

describe( 'setup when the elements already exist', () => {
it( 'should not create the aria live regions again', () => {
const before = document.getElementsByClassName(
'a11y-speak-region'
).length;
const before =
document.getElementsByClassName( 'a11y-speak-region' ).length;
setup();
const after = document.getElementsByClassName( 'a11y-speak-region' )
.length;
const after =
document.getElementsByClassName( 'a11y-speak-region' ).length;

expect( before ).toBe( after );
} );
Expand Down
7 changes: 4 additions & 3 deletions packages/annotations/src/block/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ import { STORE_NAME } from '../store/constants';
*/
const addAnnotationClassName = ( OriginalComponent ) => {
return withSelect( ( select, { clientId, className } ) => {
const annotations = select(
STORE_NAME
).__experimentalGetAnnotationsForBlock( clientId );
const annotations =
select( STORE_NAME ).__experimentalGetAnnotationsForBlock(
clientId
);

return {
className: annotations
Expand Down
15 changes: 6 additions & 9 deletions packages/annotations/src/format/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,20 +168,17 @@ export const annotation = {
},
__experimentalGetPropsForEditableTreeChangeHandler( dispatch ) {
return {
removeAnnotation: dispatch( STORE_NAME )
.__experimentalRemoveAnnotation,
updateAnnotationRange: dispatch( STORE_NAME )
.__experimentalUpdateAnnotationRange,
removeAnnotation:
dispatch( STORE_NAME ).__experimentalRemoveAnnotation,
updateAnnotationRange:
dispatch( STORE_NAME ).__experimentalUpdateAnnotationRange,
};
},
__experimentalCreateOnChangeEditableValue( props ) {
return ( formats ) => {
const positions = retrieveAnnotationPositions( formats );
const {
removeAnnotation,
updateAnnotationRange,
annotations,
} = props;
const { removeAnnotation, updateAnnotationRange, annotations } =
props;

updateAnnotationsWithPositions( annotations, positions, {
removeAnnotation,
Expand Down
12 changes: 6 additions & 6 deletions packages/api-fetch/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,12 @@ function apiFetch( options ) {
// ```
// opts1 => m1( opts1, opts2 => m2( opts2, opts3 => m3( opts3, fetchHandler ) ) );
// ```
const enhancedHandler = middlewares.reduceRight( (
/** @type {FetchHandler} */ next,
middleware
) => {
return ( workingOptions ) => middleware( workingOptions, next );
}, fetchHandler );
const enhancedHandler = middlewares.reduceRight(
( /** @type {FetchHandler} */ next, middleware ) => {
return ( workingOptions ) => middleware( workingOptions, next );
},
fetchHandler
);

return enhancedHandler( options ).catch( ( error ) => {
if ( error.code !== 'rest_cookie_invalid_nonce' ) {
Expand Down
40 changes: 16 additions & 24 deletions packages/api-fetch/src/middlewares/test/preloading.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ describe( 'Preloading Middleware', () => {
body,
},
};
const preloadingMiddleware = createPreloadingMiddleware(
preloadedData
);
const preloadingMiddleware =
createPreloadingMiddleware( preloadedData );
const requestOptions = {
method: 'GET',
path: 'wp/v2/posts',
Expand All @@ -41,9 +40,8 @@ describe( 'Preloading Middleware', () => {
body,
},
};
const preloadingMiddleware = createPreloadingMiddleware(
preloadedData
);
const preloadingMiddleware =
createPreloadingMiddleware( preloadedData );
const requestOptions = {
method: 'GET',
path: 'wp/v2/posts',
Expand Down Expand Up @@ -85,9 +83,8 @@ describe( 'Preloading Middleware', () => {
},
};

const preloadingMiddleware = createPreloadingMiddleware(
preloadedData
);
const preloadingMiddleware =
createPreloadingMiddleware( preloadedData );

const requestOptions = {
method: 'OPTIONS',
Expand Down Expand Up @@ -120,9 +117,8 @@ describe( 'Preloading Middleware', () => {
},
};

const preloadingMiddleware = createPreloadingMiddleware(
preloadedData
);
const preloadingMiddleware =
createPreloadingMiddleware( preloadedData );

const requestOptions = {
method: 'OPTIONS',
Expand All @@ -148,9 +144,8 @@ describe( 'Preloading Middleware', () => {
body,
},
};
const preloadingMiddleware = createPreloadingMiddleware(
preloadedData
);
const preloadingMiddleware =
createPreloadingMiddleware( preloadedData );
const requestOptions = {
method: 'GET',
path: 'wp/v2/fake_resource',
Expand All @@ -169,9 +164,8 @@ describe( 'Preloading Middleware', () => {
'wp/v2/demo-reverse-alphabetical?foo=bar&baz=quux': { body },
'wp/v2/demo-alphabetical?baz=quux&foo=bar': { body },
};
const preloadingMiddleware = createPreloadingMiddleware(
preloadedData
);
const preloadingMiddleware =
createPreloadingMiddleware( preloadedData );

let requestOptions = {
method: 'GET',
Expand Down Expand Up @@ -252,9 +246,8 @@ describe( 'Preloading Middleware', () => {
},
};

const preloadingMiddleware = createPreloadingMiddleware(
preloadedData
);
const preloadingMiddleware =
createPreloadingMiddleware( preloadedData );

const requestOptions = {
method: 'OPTIONS',
Expand All @@ -278,9 +271,8 @@ describe( 'Preloading Middleware', () => {
[ 'method empty', { [ method ]: {} } ],
] )( '%s', ( label, preloadedData ) => {
it( 'should move to the next middleware if no preloaded data', () => {
const preloadingMiddleware = createPreloadingMiddleware(
preloadedData
);
const preloadingMiddleware =
createPreloadingMiddleware( preloadedData );
const requestOptions = {
method,
path: 'wp/v2/posts',
Expand Down
10 changes: 4 additions & 6 deletions packages/babel-plugin-import-jsx-pragma/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ module.exports = ( babel ) => {
}

const { scopeVariable } = getOptions( state );
state.hasUndeclaredScopeVariable = ! path.scope.hasBinding(
scopeVariable
);
state.hasUndeclaredScopeVariable =
! path.scope.hasBinding( scopeVariable );
},
JSXFragment( path, state ) {
if ( state.hasUndeclaredScopeVariableFrag ) {
Expand All @@ -62,9 +61,8 @@ module.exports = ( babel ) => {
return;
}

state.hasUndeclaredScopeVariableFrag = ! path.scope.hasBinding(
scopeVariableFrag
);
state.hasUndeclaredScopeVariableFrag =
! path.scope.hasBinding( scopeVariableFrag );
},
Program: {
exit( path, state ) {
Expand Down
27 changes: 13 additions & 14 deletions packages/babel-plugin-makepot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,8 @@ module.exports = () => {
forEach(
sortedTranslations,
( translation ) => {
const {
msgctxt = '',
msgid,
} = translation;
const { msgctxt = '', msgid } =
translation;
if (
! memo.hasOwnProperty( msgctxt )
) {
Expand All @@ -349,16 +347,17 @@ module.exports = () => {
memo[ msgctxt ][ msgid ]
)
) {
translation.comments.reference = uniq(
[
memo[ msgctxt ][ msgid ]
.comments.reference,
translation.comments
.reference,
]
.join( '\n' )
.split( '\n' )
).join( '\n' );
translation.comments.reference =
uniq(
[
memo[ msgctxt ][ msgid ]
.comments.reference,
translation.comments
.reference,
]
.join( '\n' )
.split( '\n' )
).join( '\n' );
}

memo[ msgctxt ][ msgid ] = translation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,8 @@ function DownloadableBlockListItem( { composite, item, onClick } ) {

const { hasNotice, isInstalling, isInstallable } = useSelect(
( select ) => {
const {
getErrorNoticeForBlock,
isInstalling: isBlockInstalling,
} = select( blockDirectoryStore );
const { getErrorNoticeForBlock, isInstalling: isBlockInstalling } =
select( blockDirectoryStore );
const notice = getErrorNoticeForBlock( item.id );
const hasFatal = notice && notice.isFatal;
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,8 @@ function DownloadableBlocksPanel( {

export default compose( [
withSelect( ( select, { filterValue, rootClientId = null } ) => {
const {
getDownloadableBlocks,
isRequestingDownloadableBlocks,
} = select( blockDirectoryStore );
const { getDownloadableBlocks, isRequestingDownloadableBlocks } =
select( blockDirectoryStore );
const { canInsertBlockType } = select( blockEditorStore );

const hasPermission = select( coreStore ).canUser(
Expand Down
Loading

0 comments on commit 33d84b0

Please sign in to comment.