Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .syncpackrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://json.schemastore.org/syncpack.json",
"source": [ "package.json", "packages/*/package.json" ],
"versionGroups": [
{
"label": "Peer ranges are intentionally wider than dev/prod ranges",
"dependencyTypes": [ "peer" ],
"dependencies": [ "**" ],
"isIgnored": true
}
]
}
20 changes: 7 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"packageManager": "pnpm@10.33.0+sha512.10568bb4a6afb58c9eb3630da90cc9516417abebd3fabbe6739f0ae795728da1491e9db5a544c76ad8eb7570f5c4bb3d6c637b2cb41bfdcdb47fa823c8649319",
"scripts": {
"test": "vitest run",
"lint:js": "yard-toolkit lint js -m custom ./packages/**/src/**/*.js",
"format:js": "yard-toolkit format js -m custom ./packages/**/*.js",
"lint:js": "yard-toolkit lint js -m custom './packages/*/src/**/*.js'",
"format:js": "yard-toolkit format js -m custom './packages/**/*.js'",
"dep:check": "syncpack lint",
"dep:fix": "syncpack fix",
"dep:outdated": "pnpm outdated --recursive",
Expand All @@ -25,20 +25,14 @@
},
"type": "commonjs",
"devDependencies": {
"@babel/core": "^7.29.7",
"@yardinternet/eslint-config": "workspace:*",
"@yardinternet/prettier-config": "workspace:*",
"@yardinternet/toolkit": "workspace:*",
"husky": "^9.1.7",
"lerna": "^9.0.7",
"lint-staged": "^17.0.8",
"prettier": "npm:wp-prettier@^3.0.3",
"syncpack": "^14.3.1",
"vitest": "^3.2.6"
},
"pnpm": {
"overrides": {
"stylelint-order": "^8.1.1"
}
"lerna": "^10.0.1",
"lint-staged": "^17.5.1",
"prettier": "npm:wp-prettier@^3.9.6",
"syncpack": "^15.3.3",
"vitest": "^5.0.1"
}
}
10 changes: 5 additions & 5 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
"author": "",
"license": "ISC",
"dependencies": {
"@wordpress/eslint-plugin": "^25.8.0",
"@wordpress/eslint-plugin": "^26.0.0",
"eslint-import-resolver-alias": "^1.1.2",
"globals": "^17.7.0",
"typescript-eslint": "^8.62.1"
"globals": "^17.12.0",
"typescript-eslint": "^8.70.0"
},
"devDependencies": {
"eslint": "^10.6.0",
"vitest": "^3.2.6"
"eslint": "^10.11.0",
"vitest": "^5.0.1"
}
}
2 changes: 1 addition & 1 deletion packages/eslint-config/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module.exports = [
},
},
// Register TS ourselves so it works regardless of whether the consumer has
// `typescript` installed. Scoped to TS files to keep the babel parser on JS.
// `typescript` installed. Scoped to TS files to keep the default parser on JS.
...tseslint.configs.recommended.map( ( config ) => ( {
...config,
files: [ '**/*.ts', '**/*.tsx' ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2506,8 +2506,8 @@ exports[`eslint config explicit rules match snapshot 1`] = `
exports[`eslint config files patterns match snapshot 1`] = `
[
[
"**/*.test.js",
"**/test/*.js",
"**/*.test.{js,jsx}",
"**/test/*.{js,jsx}",
],
[
"**/*.ts",
Expand Down
11 changes: 5 additions & 6 deletions packages/postcss-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
"author": "",
"license": "ISC",
"dependencies": {
"autoprefixer": "^10.5.0",
"cssnano": "^7.1.9",
"path": "^0.12.7",
"postcss": "^8.5.15",
"postcss-import": "^16.1.1",
"autoprefixer": "^10.6.1",
"cssnano": "^8.0.10",
"postcss": "^8.5.28",
"postcss-import": "^17.0.0",
"postcss-mixins": "^12.1.2",
"postcss-nested": "^7.0.2"
"postcss-nested": "^8.0.1"
}
}
8 changes: 4 additions & 4 deletions packages/prettier-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
"dependencies": {
"@shufo/prettier-plugin-blade": "^1.16.2",
"@shufo/tailwindcss-class-sorter": "^3.0.1",
"@wordpress/prettier-config": "^4.48.0",
"prettier": "npm:wp-prettier@^3.0.3",
"prettier-plugin-tailwindcss": "^0.7.4"
"@wordpress/prettier-config": "^4.55.0",
"prettier": "npm:wp-prettier@^3.9.6",
"prettier-plugin-tailwindcss": "^0.8.1"
},
"devDependencies": {
"vitest": "^3.2.6"
"vitest": "^5.0.1"
}
}
12 changes: 9 additions & 3 deletions packages/prettier-config/src/utils/find-tailwind-stylesheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ function findTailwindStylesheet() {

// 1. PWD / VSCODE_CWD env vars — set to the project root by the shell and
// VSCode, and unlike process.cwd() they survive being reset to '/'.
if ( process.env.VSCODE_CWD ) roots.push( process.env.VSCODE_CWD );
if ( process.env.PWD ) roots.push( process.env.PWD );
if ( process.env.VSCODE_CWD ) {
roots.push( process.env.VSCODE_CWD );
}
if ( process.env.PWD ) {
roots.push( process.env.PWD );
}

// 2. Installed normally (no symlink): strip at the first node_modules boundary.
const nmIndex = __dirname.indexOf( 'node_modules' );
Expand All @@ -29,7 +33,9 @@ function findTailwindStylesheet() {
for ( const root of roots ) {
for ( const relative of relatives ) {
const candidate = path.resolve( root, relative );
if ( fs.existsSync( candidate ) ) return candidate;
if ( fs.existsSync( candidate ) ) {
return candidate;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/stylelint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"stylelint": "^17.13.0",
"stylelint": "^17.15.0",
"stylelint-config-idiomatic-order": "^10.0.0",
"stylelint-config-recommended": "^18.0.0"
}
Expand Down
20 changes: 9 additions & 11 deletions packages/toolkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,22 @@
"author": "",
"license": "ISC",
"dependencies": {
"@babel/core": "^7.29.7",
"@shufo/prettier-plugin-blade": "^1.16.2",
"@shufo/tailwindcss-class-sorter": "^3.0.1",
"@wordpress/eslint-plugin": "^25.8.0",
"@wordpress/prettier-config": "^4.48.0",
"@wordpress/eslint-plugin": "^26.0.0",
"@wordpress/prettier-config": "^4.55.0",
"@yardinternet/shared-utils": "workspace:*",
"chalk": "^5.6.2",
"eslint": "^10.6.0",
"eslint": "^10.11.0",
"eslint-import-resolver-alias": "^1.1.2",
"globals": "^17.7.0",
"globby": "^16.2.0",
"globals": "^17.12.0",
"globby": "^16.2.4",
"meow": "^14.0.0",
"prettier": "npm:wp-prettier@^3.0.3",
"prettier-plugin-tailwindcss": "^0.7.4",
"stylelint": "^17.13.0",
"prettier": "npm:wp-prettier@^3.9.6",
"prettier-plugin-tailwindcss": "^0.8.1",
"stylelint": "^17.15.0",
"stylelint-config-idiomatic-order": "^10.0.0",
"stylelint-config-recommended": "^18.0.0",
"typescript-eslint": "^8.62.1"
"typescript-eslint": "^8.70.0"
},
"optionalDependencies": {
"@yardinternet/eslint-config": "workspace:^",
Expand Down
4 changes: 3 additions & 1 deletion packages/toolkit/src/utils/get-block-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ export const getBlockPaths = async () => {

const validBlockPaths = await Promise.all(
blockEntries.map( async ( entry ) => {
if ( ! entry.isDirectory() ) return null;
if ( ! entry.isDirectory() ) {
return null;
}

const blockPath = path.join( blocksDir, entry.name );
const blockJsonPath = path.join(
Expand Down
23 changes: 17 additions & 6 deletions packages/toolkit/src/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ export const resolveFiles = async ( globs ) => {
};

export const addQuotesToStrings = ( item ) => {
if ( item?.startsWith( "'" ) || item?.startsWith( '"' ) ) return item;
if ( item?.startsWith( "'" ) || item?.startsWith( '"' ) ) {
return item;
}
return "'" + item + "'";
};

Expand All @@ -54,12 +56,15 @@ const fromString = (
errorWhenNotFound,
errorSearchName
) => {
if ( ! nameString ) log.error( `${ errorSearchName } was not set!` );
if ( ! nameString ) {
log.error( `${ errorSearchName } was not set!` );
}

const result = filterObjectByName( nameString, configObject );

if ( errorWhenNotFound && result === null )
if ( errorWhenNotFound && result === null ) {
log.error( `${ errorSearchName } ${ nameString } was not found!` );
}

return result;
};
Expand Down Expand Up @@ -100,10 +105,14 @@ export const getPathByFormatModeAndFiletype = (

const paths = pathObj?.path ?? null;

if ( ! paths ) return [ defaultPath ];
if ( ! paths ) {
return [ defaultPath ];
}

// check if single value
if ( ! Array.isArray( paths ) ) return [ paths ];
if ( ! Array.isArray( paths ) ) {
return [ paths ];
}

return paths;
};
Expand Down Expand Up @@ -166,7 +175,9 @@ export const execWithEnv = async ( command, env = {}, options = {} ) => {
export const setupGracefulShutdown = ( children ) => {
process.on( 'SIGINT', () => {
children.forEach( ( child ) => {
if ( child && ! child.killed ) child.kill( 'SIGINT' );
if ( child && ! child.killed ) {
child.kill( 'SIGINT' );
}
} );
process.exit( 0 );
} );
Expand Down
10 changes: 6 additions & 4 deletions packages/toolkit/src/utils/logger.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import chalk from 'chalk';
import { exit } from 'node:process';
import { styleText } from 'node:util';

const baseLog = (
type = 'info',
msg = '',
{ bold = false, color = 'white' } = {}
) => {
const typeColor = chalk[ color ] || chalk.white;
const styledType = bold ? typeColor.bold( type ) : typeColor( type );
const prefix = chalk.gray( '[Yard toolkit]' );
const styledType = styleText(
color,
bold ? styleText( 'bold', type ) : type
);
const prefix = styleText( 'gray', '[Yard toolkit]' );
// eslint-disable-next-line no-console
console.log( `${ prefix } [${ styledType }] ${ msg }` );
};
Expand Down
13 changes: 8 additions & 5 deletions packages/toolkit/tests/helpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ describe( 'runCommand', () => {
[ 0, 0 ],
[ 1, 1 ],
[ null, 1 ],
] )( 'sets process.exitCode to %s when the child exits', ( code, expected ) => {
runCommand( 'eslint', [], [] );
exitHandler( code );
] )(
'sets process.exitCode to %s when the child exits',
( code, expected ) => {
runCommand( 'eslint', [], [] );
exitHandler( code );

expect( process.exitCode ).toBe( expected );
} );
expect( process.exitCode ).toBe( expected );
}
);
} );
6 changes: 4 additions & 2 deletions packages/ts-config-wordpress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,20 @@ The `@wordpress/*` types are only relevant in WordPress/Brave projects. npm libr

## Types included

Versions are pinned (`~`) to the `@wordpress/*` releases bundled with WordPress 7.1, so the types match the APIs sites actually run. Bump them together with the WordPress version.

| Package | Source |
|---|---|
| `@wordpress/blocks` | bundled types |
| `@wordpress/components` | bundled types |
| `@wordpress/data` | bundled types |
| `@wordpress/dom-ready` | bundled types |
| `@wordpress/editor` | bundled types |
| `@wordpress/element` | bundled types |
| `@wordpress/hooks` | bundled types |
| `@wordpress/i18n` | bundled types |
| `@wordpress/server-side-render` | bundled types |
| `@types/wordpress__block-editor` | DefinitelyTyped |
| `@types/wordpress__blocks` | DefinitelyTyped |
| `@types/wordpress__server-side-render` | DefinitelyTyped |

### Missing types

Expand Down
20 changes: 10 additions & 10 deletions packages/ts-config-wordpress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
"directory": "packages/ts-config-wordpress"
},
"dependencies": {
"@types/wordpress__block-editor": "^11.5.17",
"@types/wordpress__blocks": "^15.10.0",
"@types/wordpress__server-side-render": "^6.15.0",
"@wordpress/components": "^33.1.0",
"@wordpress/data": "^10.47.0",
"@wordpress/dom-ready": "^4.47.0",
"@wordpress/editor": "^14.47.0",
"@wordpress/element": "^6.40.0",
"@wordpress/hooks": "^4.40.0",
"@wordpress/i18n": "^6.13.0"
"@types/wordpress__block-editor": "^15.0.6",
"@wordpress/blocks": "~15.24.0",
"@wordpress/components": "~37.0.0",
"@wordpress/data": "~10.51.0",
"@wordpress/dom-ready": "~4.51.0",
"@wordpress/editor": "~14.51.0",
"@wordpress/element": "~8.3.0",
"@wordpress/hooks": "~4.51.0",
"@wordpress/i18n": "~6.24.0",
"@wordpress/server-side-render": "~6.27.0"
}
}
11 changes: 5 additions & 6 deletions packages/vite-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,20 @@
"description": "Vite configuration used by the WordPress team for sites and packages.",
"dependencies": {
"@roots/vite-plugin": "^2.2.0",
"@tailwindcss/vite": "^4.3.1",
"@vitejs/plugin-react": "^5.2.0",
"@tailwindcss/vite": "^4.3.3",
"@vitejs/plugin-react": "^6.1.1",
"@yardinternet/shared-utils": "workspace:*",
"@yardinternet/vite-plugin-gutenberg-blocks": "^2.7.1",
"chalk": "^5.6.2",
"laravel-vite-plugin": "^3.1.0",
"laravel-vite-plugin": "^3.2.0",
"postcss-prefixwrap": "^1.58.0",
"vite-plugin-checker": "^0.14.5",
"vite-plugin-dts": "^4.5.4",
"vite-plugin-dts": "^5.1.1",
"vite-plugin-externals": "^0.6.2"
},
"peerDependencies": {
"vite": "^8.0.0"
},
"optionalDependencies": {
"@rollup/rollup-linux-x64-gnu": "^4.62.2"
"@rollup/rollup-linux-x64-gnu": "^4.63.4"
}
}
2 changes: 1 addition & 1 deletion packages/vite-config/src/configs/brave-theme-blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const braveBlocksConfig = ( { blockPath } ) => {
'web/app/themes',
blockPath.split( path.sep ).at( 3 ),
'public'
);
);
const allThemes = getAllThemeNames();

return defineConfig( {
Expand Down
2 changes: 1 addition & 1 deletion packages/vite-config/src/configs/brave.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export const braveConfig = ( {
? [ 'resources/views/**/*.blade.php' ]
: [
'web/app/themes/**/resources/views/**/*.blade.php',
],
],
} ),
/**
* Externalizes React, ReactDOM and ReactJSXRuntime so they reference the global versions provided by WordPress' wp-element (window.React, window.ReactDOM).
Expand Down
Loading
Loading