Skip to content

Commit

Permalink
Merge branch 'trunk' into fix/php-warnings-for-post-id
Browse files Browse the repository at this point in the history
  • Loading branch information
bor0 authored Dec 19, 2024
2 parents 513b0cd + 129f0de commit 2d476f5
Show file tree
Hide file tree
Showing 1,008 changed files with 15,523 additions and 9,296 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

6 changes: 2 additions & 4 deletions .eslintignore.root
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# Named ".eslintignore.root" rather than ".eslintignore" because there's no way to stop eslint from reading this after processing ignorePatterns in .eslintrc.js. Sigh.
# Our standard eslint config reads .gitignore and .eslintignore to determine what to ignore.
# This file is named ".eslintignore.root" rather than ".eslintignore" because eslint, despite not using it, still complains if it exists.

# Stuff not to lint in general.
*.min.js
**/changelog/

# Storybook files
**/@(storybook|stories)/**/*.js

# Ignored by default, but we should check it
!.github/
!.prettierrc.js
Expand Down
11 changes: 0 additions & 11 deletions .eslintrc.js

This file was deleted.

9 changes: 5 additions & 4 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
.gitkeep production-exclude

# We don't need these files in any production mirror.
.eslintrc.js production-exclude
jsconfig.json production-exclude
tsconfig.json production-exclude
**/.phan/** production-exclude
eslint.config.mjs production-exclude
.eslintignore production-exclude
jsconfig.json production-exclude
tsconfig.json production-exclude
**/.phan/** production-exclude
**/.w.org-assets/** production-exclude
9 changes: 0 additions & 9 deletions .github/.eslintrc.js

This file was deleted.

11 changes: 11 additions & 0 deletions .github/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import makeBaseConfig from 'jetpack-js-tools/eslintrc/base.mjs';

export default [
...makeBaseConfig( import.meta.url, { envs: [ 'node' ] } ),
{
rules: {
'no-console': 'off',
'n/no-process-exit': 'off',
},
},
];
62 changes: 24 additions & 38 deletions .github/files/lint-project-structure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,6 @@ for PROJECT in projects/*/*; do
fi
fi

# - If a project uses react, it should include the react linting rules too.
if [[ -e "$PROJECT/package.json" ]] && jq -e '.dependencies.react // .devDependencies.react' "$PROJECT/package.json" >/dev/null && ! git grep eslintrc/react "$PROJECT"/.eslintrc.* &>/dev/null; then
EXIT=1
TMP=$( git ls-files "$PROJECT"/.eslintrc.* | head -n 1 ) || true
[[ -n "$TMP" ]] && TMP=" file=$TMP"
echo "::error${TMP}::Project $SLUG appears to use React but does not extend jetpack-js-tools/eslintrc/react in its eslint config. Please add that."
fi

# - composer.json must exist.
if [[ ! -e "$PROJECT/composer.json" ]]; then
EXIT=1
Expand Down Expand Up @@ -520,54 +512,35 @@ done

# - Text domains in phpcs config should match composer.json.
debug "Checking package textdomain usage in phpcs config"
for FILE in $(git -c core.quotepath=off ls-files 'projects/packages/**/.phpcs.dir.xml'); do
for FILE in $(git -c core.quotepath=off ls-files 'projects/*/**/.phpcs.dir.xml'); do
DOM="$(php -r '$doc = new DOMDocument(); $doc->load( $argv[1] ); $xpath = new DOMXPath( $doc ); echo $xpath->evaluate( "string(//rule[@ref=\"WordPress.WP.I18n\"]/properties/property[@name=\"text_domain\"]/element/@value)" );' "$FILE")"
[[ -z "$DOM" ]] && continue
DIR="$FILE"
while ! [[ "$DIR" =~ ^projects/[^/]*/[^/]*$ ]]; do
DIR="${DIR%/*}"
done
SLUG="${DIR#projects/}"
DOM2="$(jq -r '.extra.textdomain // ""' "$DIR/composer.json")"
if [[ "$SLUG" == plugins/* ]]; then
WHAT='`.extra.wp-plugin-slug` or `.extra.beta-plugin-slug`'
DOM2="$(jq -r '.extra["wp-plugin-slug"] // .extra["beta-plugin-slug"] // ""' "$DIR/composer.json")"
else
WHAT='`.extra.textdomain`'
DOM2="$(jq -r '.extra.textdomain // ""' "$DIR/composer.json")"
fi
if [[ "$DOM" != "$DOM2" ]]; then
EXIT=1
LINE=$(grep --line-number --max-count=1 'name="text_domain"' "$FILE" || true)
if [[ -n "$LINE" ]]; then
LINE=",line=${LINE%%:*}"
fi
if [[ -z "$DOM2" ]]; then
echo "::error file=$FILE$LINE::PHPCS config sets textdomain \"$DOM\", but $SLUG's composer.json does not set \`.extra.textdomain\`."
echo "::error file=$FILE$LINE::PHPCS config sets textdomain \"$DOM\", but $SLUG's composer.json does not set $WHAT."
else
echo "::error file=$FILE$LINE::PHPCS config sets textdomain \"$DOM\", but $SLUG's composer.json sets domain \"$DOM2\"."
fi
fi
done

# - Text domains in eslint config should match composer.json.
debug "Checking package textdomain usage in eslint config"
for FILE in $(git -c core.quotepath=off ls-files 'projects/packages/**/.eslintrc.js' 'projects/packages/**/.eslintrc.cjs'); do
DOM="$(node -e 'const x = require( `./${ process.argv[1] }` ); console.log( x.rules?.["@wordpress/i18n-text-domain"]?.[1]?.allowedTextDomain ?? "" );' "$FILE")"
[[ -z "$DOM" ]] && continue
DIR="$FILE"
while ! [[ "$DIR" =~ ^projects/[^/]*/[^/]*$ ]]; do
DIR="${DIR%/*}"
done
SLUG="${DIR#projects/}"
DOM2="$(jq -r '.extra.textdomain // ""' "$DIR/composer.json")"
if [[ "$DOM" != "$DOM2" ]]; then
EXIT=1
LINE=$(grep --line-number --max-count=1 'allowedTextDomain' "$FILE" || true)
if [[ -n "$LINE" ]]; then
LINE=",line=${LINE%%:*}"
fi
if [[ -z "$DOM2" ]]; then
echo "::error file=$FILE$LINE::Eslint config sets textdomain \"$DOM\", but $SLUG's composer.json does not set \`.extra.textdomain\`."
else
echo "::error file=$FILE$LINE::Eslint config sets textdomain \"$DOM\", but $SLUG's composer.json sets domain \"$DOM2\"."
fi
fi
done

# - Text domains in block.json should match composer.json.
debug "Checking textdomain usage in block.json"
for FILE in $(git -c core.quotepath=off ls-files 'projects/packages/**/block.json' 'projects/plugins/**/block.json'); do
Expand All @@ -580,8 +553,10 @@ for FILE in $(git -c core.quotepath=off ls-files 'projects/packages/**/block.jso
done
SLUG="${DIR#projects/}"
if [[ "$SLUG" == plugins/* ]]; then
DOM2="$(jq -r '.extra["wp-plugin-slug"] // .extra["wp-theme-slug"] // ""' "$DIR/composer.json")"
WHAT='`.extra.wp-plugin-slug` or `.extra.beta-plugin-slug`'
DOM2="$(jq -r '.extra["wp-plugin-slug"] // .extra["beta-plugin-slug"] // ""' "$DIR/composer.json")"
else
WHAT='`.extra.textdomain`'
DOM2="$(jq -r '.extra.textdomain // ""' "$DIR/composer.json")"
fi
if [[ "$DOM" != "$DOM2" ]]; then
Expand All @@ -591,7 +566,7 @@ for FILE in $(git -c core.quotepath=off ls-files 'projects/packages/**/block.jso
LINE=",line=${LINE%%:*}"
fi
if [[ -z "$DOM2" ]]; then
echo "::error file=$FILE$LINE::block.json sets textdomain \"$DOM\", but $SLUG's composer.json does not set \`.extra.textdomain\`."
echo "::error file=$FILE$LINE::block.json sets textdomain \"$DOM\", but $SLUG's composer.json does not set $WHAT."
else
echo "::error file=$FILE$LINE::block.json sets textdomain \"$DOM\", but $SLUG's composer.json sets domain \"$DOM2\"."
fi
Expand Down Expand Up @@ -660,4 +635,15 @@ while IFS= read -r FILE; do
done < <( git grep -h --line-number --column -o "$RE" "$FILE" )
done < <( git -c core.quotepath=off grep -l "$RE" )

# - Check for `random(` in scss files.
debug "Checking for SCSS random."
while IFS= read -r FILE; do
EXIT=1
while IFS=: read -r LINE COL X; do
X=${X%(}
echo "::error file=$FILE,line=$LINE,col=$COL::Do not use SCSS \`$X()\`. It means that every build will have different CSS, dirtying the diffs (and making for redudant Simple deploys if this gets into a relevant plugin)."
done < <( git grep -h --line-number --column -o '\(random\|unique-id\)\s*(' "$FILE" )
done < <( git -c core.quotepath=off grep -l '\(random\|unique-id\)\s*(' '*.sass' '*.scss' )


exit $EXIT
39 changes: 0 additions & 39 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ jobs:
- 'pnpm-lock.yaml'
- '.eslintignore'
- '.eslintignore.root'
- '.eslintrc.*'
- 'eslint.config.*'
- '**/.eslintignore'
- '**/.eslintrc.*'
- '**/eslint.config.*'
# If the excludelist changed, run to ensure newly non-excluded files pass.
- 'tools/eslint-excludelist.json'
misc_excludelist:
Expand Down
2 changes: 1 addition & 1 deletion .phan/stubs/phpunit-stubs.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Stubs automatically generated from PHPUnit 9.6.21
* Stubs automatically generated from PHPUnit 9.6.22
* using the definition file `tools/stubs/phpunit-stub-defs.php` in the Jetpack monorepo.
*
* Do not edit this directly! Run tools/stubs/update-stubs.sh to regenerate it.
Expand Down
3 changes: 2 additions & 1 deletion .phan/stubs/woocommerce-internal-stubs.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Stubs automatically generated from WooCommerce 9.4.3
* Stubs automatically generated from WooCommerce 9.5.1
* using the definition file `tools/stubs/woocommerce-internal-stub-defs.php` in the Jetpack monorepo.
*
* Do not edit this directly! Run tools/stubs/update-stubs.sh to regenerate it.
Expand Down Expand Up @@ -50,6 +50,7 @@ class CustomOrdersTableController
*/
class OrdersTableDataStore extends \Abstract_WC_Order_Data_Store_CPT implements \WC_Object_Data_Store_Interface, \WC_Order_Data_Store_Interface
{
use \Automattic\WooCommerce\Internal\CostOfGoodsSold\CogsAwareTrait;
/**
* Get the custom orders table name.
*
Expand Down
2 changes: 1 addition & 1 deletion .phan/stubs/woocommerce-payments-stubs.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Stubs automatically generated from WooPayments 8.6.0
* Stubs automatically generated from WooPayments 8.6.1
* using the definition file `tools/stubs/woocommerce-payments-stub-defs.php` in the Jetpack monorepo.
*
* Do not edit this directly! Run tools/stubs/update-stubs.sh to regenerate it.
Expand Down
15 changes: 15 additions & 0 deletions .pnpm-patches/@[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Hack for https://github.com/WordPress/gutenberg/issues/67897

diff --git a/package.json b/package.json
index d7af17fea3f59f807a9d7234cf9ce79131538383..c862b012af312c9fc5cf1d2d884ec332ee079d0b 100644
--- a/package.json
+++ b/package.json
@@ -27,7 +27,7 @@
"exports": {
".": {
"types": "./build-types/index.d.ts",
- "import": "./build-module/index.js"
+ "default": "./build/index.js"
},
"./wp": {
"types": "./build-types/index.d.ts",
15 changes: 15 additions & 0 deletions .pnpmfile.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ function fixDeps( pkg ) {
pkg.peerDependencies[ dep ] = ver.replace( /^\^?/, '>=' );
}
}

// Doesn't really need these at all with eslint 9 and our config.
pkg.peerDependenciesMeta ??= {};
pkg.peerDependenciesMeta[ '@typescript-eslint/eslint-plugin' ] = { optional: true };
pkg.peerDependenciesMeta[ '@typescript-eslint/parser' ] = { optional: true };
}

// Unnecessarily explicit deps. I don't think we really even need @wordpress/babel-preset-default at all.
Expand Down Expand Up @@ -82,6 +87,16 @@ function fixDeps( pkg ) {
}
}

// Seemingly unmaintained upstream, and has strict deps that are outdated.
// https://github.com/mbalabash/estimo/issues/50
if ( pkg.name === 'estimo' ) {
for ( const [ dep, ver ] of Object.entries( pkg.dependencies ) ) {
if ( ver.match( /^\d+(\.\d+)+$/ ) ) {
pkg.dependencies[ dep ] = '^' + ver;
}
}
}

// Outdated dependency.
// No upstream bug link yet.
if ( pkg.name === 'rollup-plugin-postcss' && pkg.dependencies.cssnano === '^5.0.1' ) {
Expand Down
Loading

0 comments on commit 2d476f5

Please sign in to comment.