Skip to content

Commit

Permalink
Update @wordpress/eslint-plugin (#39305)
Browse files Browse the repository at this point in the history
This brings two new rules that needed fixing:

* `@wordpress/i18n-no-flanking-whitespace` complains about leading or
  trailing whitespace in JS i18n messages. Fix depends on context:
  * Sometimes it makes no difference, the browser (or React) strips it
	out. Removed these.
  * Sometimes it does, or it's unclear. In these cases I added it back
	outside the i18n call.
* `@wordpress/i18n-hyphenated-range` wants en-dashes (or em-dashes) for
  numeric ranges. Switched them to en-dashes.
  • Loading branch information
anomiex authored Sep 11, 2024
1 parent a76a351 commit 3a06084
Show file tree
Hide file tree
Showing 24 changed files with 59 additions and 31 deletions.
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Remove unnecessary leading space from i18n message.
2 changes: 1 addition & 1 deletion projects/packages/backup/src/js/components/Backups.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const NoGoodBackups = () => {
<p>
{ createInterpolateElement(
__(
' <a>Get in touch with us</a> to get your site backups going again.',
'<a>Get in touch with us</a> to get your site backups going again.',
'jetpack-backup-pkg'
),
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Use en-dash in numeric range in i18n message to conform to guidelines.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export default ( { salesforceData, setAttributes, instanceId } ) => {
{ organizationIdError && (
<HelpMessage isError id={ `contact-form-${ instanceId }-email-error` }>
{ __(
'Invalid Organization ID. Should be a 15 - 18 characters long alphanumeric string.',
'Invalid Organization ID. Should be a 15 18 characters long alphanumeric string.',
'jetpack-forms'
) }
</HelpMessage>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Move trailing spaces out of i18n messages.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ export default function InstantSearchUpsellNudge( props = { upgrade: true } ) {
<a className="jp-instant-search-upsell-nudge jp-search-dashboard-cut" href={ props.href }>
<span>
{ __(
'Offer instant search results to your visitors as soon as they start typing. ',
'Offer instant search results to your visitors as soon as they start typing.',
'jetpack-search-pkg'
) }
</span>
</span>{ ' ' }
<span>
<b>{ __( 'Try Jetpack Instant Search for free now', 'jetpack-search-pkg' ) }</b>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default class SearchSort extends Component {
aria-controls="jetpack-instant-search__search-results-content"
className="jetpack-instant-search__search-sort jetpack-instant-search__search-sort-with-links"
>
<div className="screen-reader-text">{ __( 'Sort by: ', 'jetpack-search-pkg' ) }</div>
<div className="screen-reader-text">{ __( 'Sort by:', 'jetpack-search-pkg' ) } </div>
{ [ ...sortOptions.entries() ].map( ( [ sortKey, label ] ) => (
<>
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ const ConversionLossPopover = () => {
screenReaderText={ __( 'Learn more about how slow sites lose visitors', 'jetpack' ) }
>
<p className="boost-conversion-loss-info__source">
{ __( 'Source: ', 'jetpack' ) }
{ __( 'Source:', 'jetpack' ) }{ ' ' }
<ExternalLink
href="https://web.dev/why-speed-matters/"
target="_blank"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const SEARCH_DESCRIPTION = __(
'jetpack'
);
const SEARCH_CUSTOMIZE_CTA = __( 'Customize your Search experience.', 'jetpack' );
const SEARCH_SUPPORT = __( 'Search supports many customizations. ', 'jetpack' );
const SEARCH_SUPPORT = __( 'Search supports many customizations.', 'jetpack' );

/**
* Displays a card for Search based on the props given.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class MyPlanBody extends React.Component {
<h3 className="jp-landing__plan-features-title">
{ __( 'Site security', 'jetpack' ) }
</h3>
<p>{ description + __( ' (powered by VaultPress).', 'jetpack' ) }</p>
<p>{ description + ' ' + __( '(powered by VaultPress).', 'jetpack' ) }</p>
{ this.props.isPluginInstalled( 'vaultpress/vaultpress.php' ) &&
this.props.isPluginActive( 'vaultpress/vaultpress.php' ) ? (
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const SEARCH_DESCRIPTION = __(
'jetpack'
);
const SEARCH_CUSTOMIZE_CTA = __( 'Customize your Search experience.', 'jetpack' );
const SEARCH_SUPPORT = __( 'Search supports many customizations. ', 'jetpack' );
const SEARCH_SUPPORT = __( 'Search supports many customizations.', 'jetpack' );

/**
* Search settings component to be used within the Performance section.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Move leading and trailing spaces out of i18n messages. Use en-dash for numeric ranges in i18n messages.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const defaultPromptTemplate = {
label: __( 'Post about…', 'jetpack' ),
description: {
original: 'Write a post about ',
translated: __( 'Write a post about ', 'jetpack' ),
translated: __( 'Write a post about', 'jetpack' ) + ' ',
},
};

Expand All @@ -37,21 +37,21 @@ export const promptTemplates = [
label: __( 'Informative article on…', 'jetpack' ),
description: {
original: 'Craft an informative article explaining ',
translated: __( 'Craft an informative article explaining ', 'jetpack' ),
translated: __( 'Craft an informative article explaining', 'jetpack' ) + ' ',
},
},
{
label: __( 'Step-by-step tutorial on…', 'jetpack' ),
description: {
original: 'Write a step-by-step tutorial on ',
translated: __( 'Write a step-by-step tutorial on ', 'jetpack' ),
translated: __( 'Write a step-by-step tutorial on', 'jetpack' ) + ' ',
},
},
{
label: __( 'Motivational post on…', 'jetpack' ),
description: {
original: 'Create a motivational post on ',
translated: __( 'Create a motivational post on ', 'jetpack' ),
translated: __( 'Create a motivational post on', 'jetpack' ) + ' ',
},
},
];
Expand All @@ -61,21 +61,21 @@ export const promptTemplatesForGeneratedContent = [
label: __( 'Say it differently…', 'jetpack' ),
description: {
original: 'Rewrite it in a way that ',
translated: __( 'Rewrite it in a way that ', 'jetpack' ),
translated: __( 'Rewrite it in a way that', 'jetpack' ) + ' ',
},
},
{
label: __( 'Add…', 'jetpack' ),
description: {
original: 'Add more details about ',
translated: __( 'Add more details about ', 'jetpack' ),
translated: __( 'Add more details about', 'jetpack' ) + ' ',
},
},
{
label: __( 'Remove…', 'jetpack' ),
description: {
original: 'Remove unnecessary details about ',
translated: __( 'Remove unnecessary details about ', 'jetpack' ),
translated: __( 'Remove unnecessary details about', 'jetpack' ) + ' ',
},
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { __, sprintf } from '@wordpress/i18n';

const TrackError = memo( ( { link, title, colors } ) => (
<div className="jetpack-podcast-player__track-error">
{ __( 'Episode unavailable. ', 'jetpack' ) }
{ __( 'Episode unavailable.', 'jetpack' ) }{ ' ' }
{ link && (
<span className={ colors.secondary.classes } style={ { color: colors.secondary.custom } }>
<a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const Controls = ( { blocks, disabledFeatures } ) => {
{ __( 'Write to see your grade level.', 'jetpack' ) }
</p>
) : (
<Tooltip text={ __( 'To make it easy to read, aim for level 8-12', 'jetpack' ) }>
<Tooltip text={ __( 'To make it easy to read, aim for level 812', 'jetpack' ) }>
<p>
{ gradeLevel }
<span className="jetpack-ai-proofread__grade-label">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Remove unnecessary trailing space from i18n message.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function Migration( props: Props ) {
<p>
{ __(
"You're a few steps away from upgrading your site to the speed and power of WordPress.com. " +
"Here's how it works: ",
"Here's how it works:",
'wpcom-migration'
) }
</p>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Move leading and trailing spaces out of i18n messages.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const ShareDebugData = () => {

return (
<div className={ styles[ 'share-data-section' ] }>
<Title mb={ 2 }>{ __( ' Share detailed data with Jetpack', 'jetpack-protect' ) }</Title>
<Title mb={ 2 }>{ __( 'Share detailed data with Jetpack', 'jetpack-protect' ) }</Title>
<div className={ styles[ 'footer-checkbox' ] }>
<CheckboxControl
checked={ Boolean( settings.jetpack_waf_share_debug_data ) }
Expand Down Expand Up @@ -114,7 +114,7 @@ const ShareData = () => {

return (
<div className={ styles[ 'share-data-section' ] }>
<Title mb={ 2 }>{ __( ' Share basic data with Jetpack', 'jetpack-protect' ) }</Title>
<Title mb={ 2 }>{ __( 'Share basic data with Jetpack', 'jetpack-protect' ) }</Title>
<div className={ styles[ 'footer-checkbox' ] }>
<CheckboxControl
checked={ Boolean( settings.jetpack_waf_share_data ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const ProductPromotion = () => {
<Title>{ __( 'Get access to our Cloud', 'jetpack-protect' ) }</Title>
<Text mb={ 3 }>
{ __(
'With your Protect upgrade, you have free access to scan your site on our Cloud, so you can be aware and fix your threats even if your site goes down. ',
'With your Protect upgrade, you have free access to scan your site on our Cloud, so you can be aware and fix your threats even if your site goes down.',
'jetpack-protect'
) }
</Text>
Expand Down Expand Up @@ -83,9 +83,9 @@ const FooterInfo = () => {
<Title>{ __( 'Line-by-line scanning', 'jetpack-protect' ) }</Title>
<Text mb={ 2 }>
{ __(
'We actively review line-by-line of your site files to identify threats and vulnerabilities. Jetpack monitors millions of websites to keep your site secure all the time. ',
'We actively review line-by-line of your site files to identify threats and vulnerabilities. Jetpack monitors millions of websites to keep your site secure all the time.',
'jetpack-protect'
) }
) }{ ' ' }
<Button variant="link" target="_blank" weight="regular" href={ learnMoreScanUrl }>
{ __( 'Learn more', 'jetpack-protect' ) }
</Button>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Move trailing space out of i18n message.
2 changes: 1 addition & 1 deletion projects/plugins/super-cache/js/preload-notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jQuery( document ).ready( function () {

if ( data.previous ) {
const p = jQuery( '<p>' );
p.append( jQuery( '<b>' ).text( __( 'Last preload finished: ', 'wp-super-cache' ) ) );
p.append( jQuery( '<b>' ).text( __( 'Last preload finished:', 'wp-super-cache' ) + ' ' ) );
p.append( jQuery( '<span>' ).text( new Date( data.previous * 1000 ).toLocaleString() ) );
panel.append( p );
}
Expand Down
2 changes: 1 addition & 1 deletion tools/js-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@testing-library/jest-dom": "6.5.0",
"@typescript-eslint/eslint-plugin": "6.21.0",
"@typescript-eslint/parser": "6.21.0",
"@wordpress/eslint-plugin": "20.3.0",
"@wordpress/eslint-plugin": "21.0.0",
"@wordpress/jest-console": "8.7.0",
"babel-jest": "29.4.3",
"chalk": "4.1.2",
Expand Down

0 comments on commit 3a06084

Please sign in to comment.