Skip to content

Commit 40a8492

Browse files
authored
Resolves #37695 - Use clsx instead of classnames (#37708)
* Add rule to disallow `classnames` * Initial pass * `classnames/dedupe` → `@wordpress/token-list` * Add changelog * Use valid changelog types * Remove file from eslint exclusions * Change post-rebase use of classnames * More changelog format compliance fixes * Bump versions
1 parent b98fa45 commit 40a8492

File tree

379 files changed

+1042
-1003
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

379 files changed

+1042
-1003
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const loadIgnorePatterns = require( './tools/js-tools/load-eslint-ignore.js' );
33
/**
44
* @type {import("eslint").Linter.Config}
55
*/
6+
67
module.exports = {
78
root: true,
89
extends: [ './tools/js-tools/eslintrc/base.js' ],

pnpm-lock.yaml

Lines changed: 51 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: changed
3+
4+
Change codebase to use clsx instead of classnames.

projects/js-packages/ai-client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"@wordpress/element": "6.0.0",
5757
"@wordpress/i18n": "5.0.0",
5858
"@wordpress/icons": "10.0.0",
59-
"classnames": "2.3.2",
59+
"clsx": "2.1.1",
6060
"debug": "4.3.4",
6161
"markdown-it": "14.0.0",
6262
"react": "18.3.1",

projects/js-packages/ai-client/src/components/ai-control/ai-control.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* External dependencies
33
*/
44
import { PlainText } from '@wordpress/block-editor';
5-
import classNames from 'classnames';
5+
import clsx from 'clsx';
66
import React from 'react';
77
/**
88
* Internal dependencies
@@ -54,14 +54,14 @@ export default function AIControl( {
5454
}: AIControlProps ): ReactElement {
5555
return (
5656
<div
57-
className={ classNames( 'jetpack-components-ai-control__container-wrapper', className ) }
57+
className={ clsx( 'jetpack-components-ai-control__container-wrapper', className ) }
5858
ref={ wrapperRef }
5959
>
6060
{ error }
6161
<div className="jetpack-components-ai-control__container">
6262
{ banner }
6363
<div
64-
className={ classNames( 'jetpack-components-ai-control__wrapper', {
64+
className={ clsx( 'jetpack-components-ai-control__wrapper', {
6565
'is-transparent': isTransparent,
6666
} ) }
6767
>

projects/js-packages/ai-client/src/components/ai-status-indicator/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* External dependencies
33
*/
44
import { Spinner } from '@wordpress/components';
5-
import classNames from 'classnames';
5+
import clsx from 'clsx';
66
/*
77
* Types
88
*/
@@ -26,7 +26,7 @@ export type AiStatusIndicatorProps = {
2626
export default function AiStatusIndicator( { state }: AiStatusIndicatorProps ): React.ReactElement {
2727
return (
2828
<div
29-
className={ classNames( 'jetpack-ai-status-indicator__icon-wrapper', {
29+
className={ clsx( 'jetpack-ai-status-indicator__icon-wrapper', {
3030
[ `is-${ state }` ]: true,
3131
} ) }
3232
>

projects/js-packages/ai-client/src/components/message/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { ExternalLink, Button } from '@wordpress/components';
55
import { __, sprintf } from '@wordpress/i18n';
66
import { Icon, check, arrowRight } from '@wordpress/icons';
7-
import classNames from 'classnames';
7+
import clsx from 'clsx';
88
/**
99
* Internal dependencies
1010
*/
@@ -78,7 +78,7 @@ export default function Message( {
7878
}: MessageProps ): React.ReactElement {
7979
return (
8080
<div
81-
className={ classNames(
81+
className={ clsx(
8282
'jetpack-ai-assistant__message',
8383
`jetpack-ai-assistant__message-severity-${ severity }`
8484
) }
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: changed
3+
4+
Change codebase to use clsx instead of classnames.

projects/js-packages/components/components/action-button/index.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
import { Spinner } from '@wordpress/components';
55
import { __ } from '@wordpress/i18n';
6-
import classNames from 'classnames';
6+
import clsx from 'clsx';
77
import PropTypes from 'prop-types';
88
/**
99
* Internal dependencies
@@ -40,7 +40,7 @@ const ActionButton = props => {
4040
<>
4141
{
4242
<Button
43-
className={ classNames( styles.button, 'jp-action-button--button', customClass ) }
43+
className={ clsx( styles.button, 'jp-action-button--button', customClass ) }
4444
label={ label }
4545
onClick={ onClick }
4646
variant="primary"
@@ -51,7 +51,7 @@ const ActionButton = props => {
5151
}
5252

5353
{ displayError && (
54-
<p className={ classNames( styles.error, 'jp-action-button__error' ) }>{ errorMessage }</p>
54+
<p className={ clsx( styles.error, 'jp-action-button__error' ) }>{ errorMessage }</p>
5555
) }
5656
</>
5757
);

projects/js-packages/components/components/admin-page/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { __ } from '@wordpress/i18n';
2-
import classNames from 'classnames';
2+
import clsx from 'clsx';
33
import JetpackFooter from '../jetpack-footer';
44
import JetpackLogo from '../jetpack-logo';
55
import Col from '../layout/col';
@@ -25,7 +25,7 @@ const AdminPage: React.FC< AdminPageProps > = ( {
2525
showBackground = true,
2626
header,
2727
} ) => {
28-
const rootClassName = classNames( styles[ 'admin-page' ], {
28+
const rootClassName = clsx( styles[ 'admin-page' ], {
2929
[ styles.background ]: showBackground,
3030
} );
3131

projects/js-packages/components/components/alert/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Icon, warning, info, check } from '@wordpress/icons';
2-
import classNames from 'classnames';
2+
import clsx from 'clsx';
33
import React from 'react';
44
import styles from './style.module.scss';
55

@@ -39,7 +39,7 @@ const getIconByLevel = ( level: AlertProps[ 'level' ] ) => {
3939
* @returns {React.ReactElement} The `Alert` component.
4040
*/
4141
const Alert: React.FC< AlertProps > = ( { level = 'warning', children, showIcon = true } ) => {
42-
const classes = classNames( styles.container, styles[ `is-${ level }` ] );
42+
const classes = clsx( styles.container, styles[ `is-${ level }` ] );
4343

4444
return (
4545
<div className={ classes }>

projects/js-packages/components/components/automattic-byline-logo/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { __ } from '@wordpress/i18n';
2-
import classnames from 'classnames';
2+
import clsx from 'clsx';
33
import React from 'react';
44
import { AutomatticBylineLogoProps } from './types';
55

@@ -24,7 +24,7 @@ const AutomatticBylineLogo: React.FC< AutomatticBylineLogoProps > = ( {
2424
enableBackground="new 0 0 935 38.2"
2525
aria-labelledby="jp-automattic-byline-logo-title"
2626
height={ height }
27-
className={ classnames( 'jp-automattic-byline-logo', className ) }
27+
className={ clsx( 'jp-automattic-byline-logo', className ) }
2828
{ ...otherProps }
2929
>
3030
<desc id="jp-automattic-byline-logo-title">{ title }</desc>

0 commit comments

Comments
 (0)