Replace classnames with clsx#61138
Conversation
|
It looks like this PR is the first one making a change to the I tried rolling that back the update to actions/setup-node, and and it worked for me (#61289). I also moved the debugging steps we added above to that PR to keep this one specific to the task at hand. |
|
Thanks @desrosj, I'm gonna remove the unrelated CI debug changes in order to merge the PR. |
…gnore/clsx-size-test
|
Noting that this replaced at least five instances of |
At least this change introduces an unintentional side effect: diff --git a/packages/block-library/src/cover/edit.native.js b/packages/block-library/src/cover/edit.native.js
index 1fc1519f47f94..c5fe140e8fe23 100644
--- a/packages/block-library/src/cover/edit.native.js
+++ b/packages/block-library/src/cover/edit.native.js
@@ -10,7 +10,7 @@ import {
Platform,
} from 'react-native';
import Video from 'react-native-video';
-import classnames from 'classnames/dedupe';
+import clsx from 'clsx';
/**
* WordPress dependencies
@@ -298,7 +298,7 @@ const Cover = ( {
// Ensure that "is-light" is removed from "className" attribute if cover background is dark.
if ( isCoverDark && attributes.className?.includes( 'is-light' ) ) {
- const className = classnames( attributes.className, {
+ const className = clsx( attributes.className, {
'is-light': false,
} );
setAttributes( {Assuming
|
|
Good catch, thanks. Will fix. |
Gutenberg standardised on `clsx` in 2024 ([#61138]) and removed every `classnames` declaration across the monorepo. There is currently no guardrail preventing it from being re-added later — an `npm install classnames` in any workspace would land silently. Add a `Banned` version group to `syncpack.config.mjs` that fails `lint:deps` (and CI) on any declaration of `classnames` in any package.json. The rule is preventive: no current declarations are affected. Picked up as the follow-up suggested in #77950's review. [#61138]: #61138 Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Gutenberg standardised on `clsx` in 2024 ([#61138]) and removed every `classnames` declaration across the monorepo. There is currently no guardrail preventing it from being re-added later — an `npm install classnames` in any workspace would land silently. Add a `Banned` version group to `syncpack.config.mjs` that fails `lint:deps` (and CI) on any declaration of `classnames` in any package.json. The rule is preventive: no current declarations are affected. Picked up as the follow-up suggested in #77950's review. [#61138]: WordPress/gutenberg#61138 Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Source: WordPress/gutenberg@d651a81
PR originally started as a test, see: #61091 (comment)
Then it replaced #61091, see: #61091 (comment)
There are no significant changes in this PR that weren't already part of the previous PR, I only synced with trunk and ensured that all usage of classnames was still consistently replaced with cslx.