Skip to content

Commit

Permalink
Merge changes published in the Gutenberg plugin "release/18.6" branch
Browse files Browse the repository at this point in the history
  • Loading branch information
gutenbergplugin committed Jun 15, 2024
1 parent 2f30cdd commit 0ef18d3
Show file tree
Hide file tree
Showing 405 changed files with 5,998 additions and 4,260 deletions.
139 changes: 82 additions & 57 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,72 @@ const restrictedImports = [
},
];

const restrictedSyntax = [
// NOTE: We can't include the forward slash in our regex or
// we'll get a `SyntaxError` (Invalid regular expression: \ at end of pattern)
// here. That's why we use \\u002F in the regexes below.
{
selector:
'ImportDeclaration[source.value=/^@wordpress\\u002F.+\\u002F/]',
message: 'Path access on WordPress dependencies is not allowed.',
},
{
selector:
'CallExpression[callee.name="deprecated"] Property[key.name="version"][value.value=/' +
majorMinorRegExp +
'/]',
message:
'Deprecated functions must be removed before releasing this version.',
},
{
selector:
'CallExpression[callee.object.name="page"][callee.property.name="waitFor"]',
message:
'This method is deprecated. You should use the more explicit API methods available.',
},
{
selector:
'CallExpression[callee.object.name="page"][callee.property.name="waitForTimeout"]',
message: 'Prefer page.waitForSelector instead.',
},
{
selector: 'JSXAttribute[name.name="id"][value.type="Literal"]',
message:
'Do not use string literals for IDs; use withInstanceId instead.',
},
{
// Discourage the usage of `Math.random()` as it's a code smell
// for UUID generation, for which we already have a higher-order
// component: `withInstanceId`.
selector:
'CallExpression[callee.object.name="Math"][callee.property.name="random"]',
message:
'Do not use Math.random() to generate unique IDs; use withInstanceId instead. (If you’re not generating unique IDs: ignore this message.)',
},
{
selector:
'CallExpression[callee.name="withDispatch"] > :function > BlockStatement > :not(VariableDeclaration,ReturnStatement)',
message:
'withDispatch must return an object with consistent keys. Avoid performing logic in `mapDispatchToProps`.',
},
{
selector:
'LogicalExpression[operator="&&"][left.property.name="length"][right.type="JSXElement"]',
message:
'Avoid truthy checks on length property rendering, as zero length is rendered verbatim.',
},
];

/** `no-restricted-syntax` rules for components. */
const restrictedSyntaxComponents = [
{
selector:
'JSXOpeningElement[name.name="Button"]:not(:has(JSXAttribute[name.name="__experimentalIsFocusable"])) JSXAttribute[name.name="disabled"]',
message:
'`disabled` used without the `__experimentalIsFocusable` prop. Disabling a control without maintaining focusability can cause accessibility issues, by hiding their presence from screen reader users, or preventing focus from returning to a trigger element. (Ignore this error if you truly mean to disable.)',
},
];

module.exports = {
root: true,
extends: [
Expand Down Expand Up @@ -147,63 +213,7 @@ module.exports = {
disallowTypeAnnotations: false,
},
],
'no-restricted-syntax': [
'error',
// NOTE: We can't include the forward slash in our regex or
// we'll get a `SyntaxError` (Invalid regular expression: \ at end of pattern)
// here. That's why we use \\u002F in the regexes below.
{
selector:
'ImportDeclaration[source.value=/^@wordpress\\u002F.+\\u002F/]',
message:
'Path access on WordPress dependencies is not allowed.',
},
{
selector:
'CallExpression[callee.name="deprecated"] Property[key.name="version"][value.value=/' +
majorMinorRegExp +
'/]',
message:
'Deprecated functions must be removed before releasing this version.',
},
{
selector:
'CallExpression[callee.object.name="page"][callee.property.name="waitFor"]',
message:
'This method is deprecated. You should use the more explicit API methods available.',
},
{
selector:
'CallExpression[callee.object.name="page"][callee.property.name="waitForTimeout"]',
message: 'Prefer page.waitForSelector instead.',
},
{
selector: 'JSXAttribute[name.name="id"][value.type="Literal"]',
message:
'Do not use string literals for IDs; use withInstanceId instead.',
},
{
// Discourage the usage of `Math.random()` as it's a code smell
// for UUID generation, for which we already have a higher-order
// component: `withInstanceId`.
selector:
'CallExpression[callee.object.name="Math"][callee.property.name="random"]',
message:
'Do not use Math.random() to generate unique IDs; use withInstanceId instead. (If you’re not generating unique IDs: ignore this message.)',
},
{
selector:
'CallExpression[callee.name="withDispatch"] > :function > BlockStatement > :not(VariableDeclaration,ReturnStatement)',
message:
'withDispatch must return an object with consistent keys. Avoid performing logic in `mapDispatchToProps`.',
},
{
selector:
'LogicalExpression[operator="&&"][left.property.name="length"][right.type="JSXElement"]',
message:
'Avoid truthy checks on length property rendering, as zero length is rendered verbatim.',
},
],
'no-restricted-syntax': [ 'error', ...restrictedSyntax ],
},
overrides: [
{
Expand Down Expand Up @@ -253,6 +263,20 @@ module.exports = {
],
},
},
{
files: [
'packages/*/src/**/*.[tj]s?(x)',
'storybook/stories/**/*.[tj]s?(x)',
],
excludedFiles: [ '**/*.native.js' ],
rules: {
'no-restricted-syntax': [
'error',
...restrictedSyntax,
...restrictedSyntaxComponents,
],
},
},
{
files: [
// Components package.
Expand Down Expand Up @@ -372,6 +396,7 @@ module.exports = {
rules: {
'no-restricted-syntax': [
'error',
...restrictedSyntax,
{
selector:
':matches(Literal[value=/--wp-admin-theme-/],TemplateElement[value.cooked=/--wp-admin-theme-/])',
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create-block.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node: ['20', '21']
node: ['20', '22']
os: ['macos-latest', 'ubuntu-latest', 'windows-latest']

steps:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/php-changes-detection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- name: Get changed PHP files
id: changed-files-php
uses: tj-actions/changed-files@03334d095e2739fa9ac4034ec16f66d5d01e9eba # v44.5.1
uses: tj-actions/changed-files@d6babd6899969df1a11d14c368283ea4436bca78 # v44.5.2
with:
files: |
lib/**
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
<!-- pr-contains-php-changes -->
This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress.
If so, it is recommended to create a [new Trac ticket](https://core.trac.wordpress.org/newticket) and submit a pull request to the [WordPress Core Github repository](https://github.com/WordPress/wordpress-develop) soon after this pull request is merged.
If so, it is recommended to create a [new Trac ticket](https://core.trac.wordpress.org/newticket) and submit a pull request to the [WordPress Core GitHub repository](https://github.com/WordPress/wordpress-develop) soon after this pull request is merged.
If you're unsure, you can always ask for help in the #core-editor channel in [WordPress Slack](https://make.wordpress.org/chat/).
Expand All @@ -76,7 +76,7 @@ jobs:
<!-- pr-contains-php-changes -->
This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress.
If so, it is recommended to create a [new Trac ticket](https://core.trac.wordpress.org/newticket) and submit a pull request to the [WordPress Core Github repository](https://github.com/WordPress/wordpress-develop) soon after this pull request is merged.
If so, it is recommended to create a [new Trac ticket](https://core.trac.wordpress.org/newticket) and submit a pull request to the [WordPress Core GitHub repository](https://github.com/WordPress/wordpress-develop) soon after this pull request is merged.
If you're unsure, you can always ask for help in the #core-editor channel in [WordPress Slack](https://make.wordpress.org/chat/).
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rnmobile-ios-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- uses: ruby/setup-ruby@943103cae7d3f1bb1e4951d5fcc7928b40e4b742 # v1.177.1
- uses: ruby/setup-ruby@d5fb7a202fc07872cb44f00ba8e6197b70cb0c55 # v1.179.0
with:
# `.ruby-version` file location
working-directory: packages/react-native-editor/ios
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node: ['20', '21']
node: ['20', '22']
shard: ['1/4', '2/4', '3/4', '4/4']

steps:
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node: ['20', '21']
node: ['20', '22']

steps:
- name: Checkout repository
Expand Down Expand Up @@ -185,7 +185,7 @@ jobs:
# dependency versions are installed and cached.
##
- name: Set up PHP
uses: shivammathur/setup-php@c665c7a15b5295c2488ac8a87af9cb806cd72198 # v2.30.4
uses: shivammathur/setup-php@fc14643b0a99ee9db10a3c025a33d76544fa3761 # v2.30.5
with:
php-version: '${{ matrix.php }}'
ini-file: development
Expand Down Expand Up @@ -286,7 +286,7 @@ jobs:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- name: Set up PHP
uses: shivammathur/setup-php@c665c7a15b5295c2488ac8a87af9cb806cd72198 # v2.30.4
uses: shivammathur/setup-php@fc14643b0a99ee9db10a3c025a33d76544fa3761 # v2.30.5
with:
php-version: '7.4'
coverage: none
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upload-release-to-plugin-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
return $?
}
# Only update trunk *if* the published release's version in Github is GREATER
# Only update trunk *if* the published release's version in GitHub is GREATER
# than the version currently published in the WP plugins repo. If not, then it
# will upload it as a new tag.
shouldUpdateTrunk=false
Expand Down
4 changes: 3 additions & 1 deletion backport-changelog/6.6/6616.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ https://github.com/WordPress/wordpress-develop/pull/6616

* https://github.com/WordPress/gutenberg/pull/58409
* https://github.com/WordPress/gutenberg/pull/61328
* https://github.com/WordPress/gutenberg/pull/61842
* https://github.com/WordPress/gutenberg/pull/61842
* https://github.com/WordPress/gutenberg/pull/62199
* https://github.com/WordPress/gutenberg/pull/62252
3 changes: 3 additions & 0 deletions backport-changelog/6.6/6731.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/6731

* https://github.com/WordPress/gutenberg/pull/62299
3 changes: 3 additions & 0 deletions backport-changelog/6.6/6737.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/6737

* https://github.com/WordPress/gutenberg/pull/62305
3 changes: 3 additions & 0 deletions backport-changelog/6.6/6744.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/6744

* https://github.com/WordPress/gutenberg/pull/62355
4 changes: 4 additions & 0 deletions backport-changelog/6.6/6756.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
https://github.com/WordPress/wordpress-develop/pull/6756

* https://github.com/WordPress/gutenberg/pull/62461
* https://github.com/WordPress/gutenberg/pull/62495
3 changes: 3 additions & 0 deletions backport-changelog/6.6/6785.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/6785

* https://github.com/WordPress/gutenberg/pull/62459
3 changes: 3 additions & 0 deletions backport-changelog/6.6/6797.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/6797

* https://github.com/WordPress/gutenberg/pull/62526
3 changes: 3 additions & 0 deletions backport-changelog/6.6/6824.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/6824

* https://github.com/WordPress/gutenberg/pull/62550
3 changes: 3 additions & 0 deletions backport-changelog/6.6/6825.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/6825

* https://github.com/WordPress/gutenberg/pull/62552
3 changes: 3 additions & 0 deletions backport-changelog/6.7/6750.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/6750

* https://github.com/WordPress/gutenberg/pull/62357
2 changes: 1 addition & 1 deletion bin/cherry-pick.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ function getCurrentBranch() {
*/
async function reportGhUnavailable() {
console.log(
'Github CLI is not setup. This script will not be able to automatically'
'GitHub CLI is not setup. This script will not be able to automatically'
);
console.log(
'comment on the processed PRs and remove the backport label from them.'
Expand Down
19 changes: 12 additions & 7 deletions bin/packages/build-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const postcss = require( 'postcss' );
*/
const getBabelConfig = require( './get-babel-config' );

const isDev = process.env.NODE_ENV === 'development';

/**
* Path to packages directory.
*
Expand All @@ -27,10 +29,12 @@ const PACKAGES_DIR = path
*
* @type {Object}
*/
const JS_ENVIRONMENTS = {
main: 'build',
module: 'build-module',
};
const JS_ENVIRONMENTS = isDev
? { module: 'build-module' }
: {
main: 'build',
module: 'build-module',
};

/**
* Promisified fs.readFile.
Expand Down Expand Up @@ -122,9 +126,10 @@ async function buildCSS( file ) {
data: ''.concat( '@use "sass:math";', importLists, contents ),
} );

const result = await postcss(
require( '@wordpress/postcss-plugins-preset' )
).process( builtSass.css, {
const result = await postcss( [
require( 'postcss-local-keyframes' ),
...require( '@wordpress/postcss-plugins-preset' ),
] ).process( builtSass.css, {
from: 'src/app.css',
to: 'dest/app.css',
} );
Expand Down
2 changes: 1 addition & 1 deletion bin/packages/check-build-type-declaration-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async function getDecFile( packagePath ) {
async function typecheckDeclarations( file ) {
return new Promise( ( resolve, reject ) => {
exec(
`npx tsc --target esnext --moduleResolution node --noEmit ${ file }`,
`npx tsc --target esnext --moduleResolution node --noEmit --skipLibCheck "${ file }"`,
( error, stdout, stderr ) => {
if ( error ) {
reject( { file, error, stderr, stdout } );
Expand Down
6 changes: 3 additions & 3 deletions bin/plugin/commands/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,11 +606,11 @@ function getEntry( issue ) {

/**
* Builds a formatted string of the Issue/PR title with a link
* to the Github URL for that item.
* to the GitHub URL for that item.
*
* @param {string} title the title of the Issue/PR.
* @param {number} number the ID/number of the Issue/PR.
* @param {string} url the URL of the Github Issue/PR.
* @param {string} url the URL of the GitHub Issue/PR.
* @return {string} the formatted item
*/
function getFormattedItemDescription( title, number, url ) {
Expand Down Expand Up @@ -856,7 +856,7 @@ function sortFeatureGroups( featureGroups ) {
}

/**
* Returns a list of PRs created by first time contributors based on the Github
* Returns a list of PRs created by first time contributors based on the GitHub
* label associated with the PR. Also filters out any "bots".
*
* @param {IssuesListForRepoResponseItem[]} pullRequests List of pull requests.
Expand Down
2 changes: 1 addition & 1 deletion bin/plugin/commands/test/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import _pullRequests from './fixtures/pull-requests.json';
import botPullRequestFixture from './fixtures/bot-pull-requests.json';

/**
* pull-requests.json is a static snapshot of real data from the Github API.
* pull-requests.json is a static snapshot of real data from the GitHub API.
* We merge this with dummy fixture data for a "bot" pull request so as to
* ensure future updates to the pull-requests.json doesn't reduce test coverage
* of filtering out of bot PRs.
Expand Down
Loading

0 comments on commit 0ef18d3

Please sign in to comment.