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.2.1 #27441

Merged
merged 2 commits into from
Dec 3, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 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
Expand Up @@ -179,7 +179,7 @@
"patch-package": "6.2.2",
"postcss": "7.0.32",
"postcss-loader": "3.0.0",
"prettier": "npm:wp-prettier@2.0.5",
"prettier": "npm:wp-prettier@2.2.1-beta-1",
"progress": "2.0.3",
"puppeteer": "npm:puppeteer-core@3.0.0",
"react": "16.13.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/query/test/utils.js
Expand Up @@ -13,8 +13,8 @@ describe( 'Query block utils', () => {
expect( getTermsInfo( terms ) ).toEqual(
expect.objectContaining( {
mapById: expect.objectContaining( {
'4': expect.objectContaining( { name: 'nba' } ),
'11': expect.objectContaining( {
4: expect.objectContaining( { name: 'nba' } ),
11: expect.objectContaining( {
name: 'featured',
} ),
} ),
Expand Down
4 changes: 2 additions & 2 deletions packages/core-data/src/locks/test/selectors.js
Expand Up @@ -124,7 +124,7 @@ describe( '__unstableIsLockAvailable', () => {
post: {
locks: [],
children: {
'16': {
16: {
locks: [
{
store: 'core',
Expand All @@ -145,7 +145,7 @@ describe( '__unstableIsLockAvailable', () => {
wp_template_part: {
locks: [],
children: {
'17': {
17: {
locks: [],
children: {},
},
Expand Down
40 changes: 20 additions & 20 deletions packages/data/src/types.d.ts
Expand Up @@ -2,31 +2,31 @@ export type WPDataFunctionOrGeneratorArray = Array< Function | Generator >;
export type WPDataFunctionArray = Array< Function >;

export interface WPDataAttachedStore {
Copy link
Member

Choose a reason for hiding this comment

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

Is it using now different indentation than JS? Can we align?

Copy link
Member

Choose a reason for hiding this comment

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

This looks correct to me @gziolo, the indentation is changes spaces to tabs, I suspect this had been missed by ESLint/Prettier at some point previously:

image

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this file previously used spaced and was merely reformatted to tabs. There's been no radical change to how TS files are formatted and there are no differences between JS an TS formatting.

Copy link
Member Author

Choose a reason for hiding this comment

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

Now I noticed that tsc uses 4 spaces indentation when generating the *.d.ts files in build-types. That's probably where this formatting originated. And Babel apparently indents with 2 spaces.

Copy link
Member

@gziolo gziolo Dec 3, 2020

Choose a reason for hiding this comment

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

I was browsing this file in the mobile app. I couldn't verify whether it's tabs or spaces, it looked like 2 spaces. Ignore this comment One tab is correct.

getSelectors: () => WPDataFunctionArray,
getActions: () => WPDataFunctionArray,
subscribe: (listener: () => void) => (() => void)
};
getSelectors: () => WPDataFunctionArray;
getActions: () => WPDataFunctionArray;
subscribe: ( listener: () => void ) => () => void;
}

export interface WPDataStore {
/**
* Store Name
*/
name: string,
/**
* Store Name
*/
name: string;

/**
* Store configuration object.
*/
instantiate: (registry: WPDataRegistry) => WPDataAttachedStore,
};
/**
* Store configuration object.
*/
instantiate: ( registry: WPDataRegistry ) => WPDataAttachedStore;
}

export interface WPDataReduxStoreConfig {
reducer: ( state: any, action: any ) => any,
actions?: WPDataFunctionOrGeneratorArray,
resolvers?: WPDataFunctionOrGeneratorArray,
selectors?: WPDataFunctionArray,
controls?: WPDataFunctionArray,
reducer: ( state: any, action: any ) => any;
actions?: WPDataFunctionOrGeneratorArray;
resolvers?: WPDataFunctionOrGeneratorArray;
selectors?: WPDataFunctionArray;
controls?: WPDataFunctionArray;
}

export interface WPDataRegistry {
register: ( store: WPDataStore ) => void,
}
register: ( store: WPDataStore ) => void;
}
4 changes: 4 additions & 0 deletions packages/eslint-plugin/CHANGELOG.md
Expand Up @@ -6,6 +6,10 @@

- Add `no-unsafe-wp-apis` rule to discourage usage of unsafe APIs ([#27301](https://github.com/WordPress/gutenberg/pull/27301)).

### Enhancements

- The bundled `wp-prettier` dependency has been upgraded from `2.0.5` to `2.2.1`.

### Documentation

- Include a note about the minimum version required for `node` (10.0.0) and `npm` (6.9.0).
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/package.json
Expand Up @@ -42,7 +42,7 @@
"eslint-plugin-react": "^7.20.0",
"eslint-plugin-react-hooks": "^4.0.4",
"globals": "^12.0.0",
"prettier": "npm:wp-prettier@2.0.5",
"prettier": "npm:wp-prettier@2.2.1-beta-1",
"requireindex": "^1.2.0"
},
"peerDependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/scripts/CHANGELOG.md
Expand Up @@ -5,6 +5,7 @@
### Enhancements

- Autoformat TypeScript files (`*.ts` and `*.tsx`) in `format-js` script (#27138)[https://github.com/WordPress/gutenberg/pull/27138].
- The bundled `wp-prettier` dependency has been upgraded from `2.0.5` to `2.2.1`.

### Internal

Expand Down
2 changes: 1 addition & 1 deletion packages/scripts/package.json
Expand Up @@ -59,7 +59,7 @@
"minimist": "^1.2.0",
"npm-package-json-lint": "^5.0.0",
"postcss-loader": "^3.0.0",
"prettier": "npm:wp-prettier@2.0.5",
"prettier": "npm:wp-prettier@2.2.1-beta-1",
"puppeteer": "npm:puppeteer-core@3.0.0",
"read-pkg-up": "^1.0.1",
"resolve-bin": "^0.4.0",
Expand Down
36 changes: 15 additions & 21 deletions packages/shortcode/src/index.js
Expand Up @@ -90,29 +90,23 @@ export function next( tag, text, index = 0 ) {
* @return {string} Text with shortcodes replaced.
*/
export function replace( tag, text, callback ) {
return text.replace( regexp( tag ), function (
match,
left,
$3,
attrs,
slash,
content,
closing,
right
) {
// If both extra brackets exist, the shortcode has been properly
// escaped.
if ( left === '[' && right === ']' ) {
return match;
}
return text.replace(
regexp( tag ),
function ( match, left, $3, attrs, slash, content, closing, right ) {
// If both extra brackets exist, the shortcode has been properly
// escaped.
if ( left === '[' && right === ']' ) {
return match;
}

// Create the match object and pass it through the callback.
const result = callback( fromMatch( arguments ) );
// Create the match object and pass it through the callback.
const result = callback( fromMatch( arguments ) );

// Make sure to return any of the extra brackets if they weren't used to
// escape the shortcode.
return result ? left + result + right : match;
} );
// Make sure to return any of the extra brackets if they weren't used to
// escape the shortcode.
return result ? left + result + right : match;
}
);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/url/src/test/index.test.js
Expand Up @@ -626,7 +626,7 @@ describe( 'getQueryArgs', () => {

expect( getQueryArgs( url ) ).toEqual( {
foo: {
'0': '0',
0: '0',
one: '1',
},
} );
Expand Down