Skip to content

Commit

Permalink
Add ESLint rule to prevent usage of the verb 'toggle' in translatable…
Browse files Browse the repository at this point in the history
… strings (#67741)


Co-authored-by: im3dabasia <[email protected]>
Co-authored-by: swissspidy <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: afercia <[email protected]>
  • Loading branch information
5 people authored Dec 19, 2024
1 parent d55319c commit 8a10988
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ const restrictedSyntax = [
message:
'Avoid truthy checks on length property rendering, as zero length is rendered verbatim.',
},
{
selector:
'CallExpression[callee.name=/^(__|_x|_n|_nx)$/] > Literal[value=/^toggle\\b/i]',
message: "Avoid using the verb 'Toggle' in translatable strings",
},
];

/** `no-restricted-syntax` rules for components. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function ResponsiveBlockControl( props ) {
);

const toggleHelpText = __(
'Toggle between using the same value for all screen sizes or using a unique value per screen size.'
'Choose whether to use the same value for all screen sizes or a unique value for each screen size.'
);

const defaultControl = renderDefaultControl(
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/table-of-contents/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default function TableOfContentsEdit( {
'Only including headings from the current page (if the post is paginated).'
)
: __(
'Toggle to only include headings from the current page (if the post is paginated).'
'Include headings from all pages (if the post is paginated).'
)
}
/>
Expand Down

1 comment on commit 8a10988

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 8a10988.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12411852221
📝 Reported issues:

Please sign in to comment.