Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions packages/eslint-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Remove `fixable` option from `i18n-no-flanking-whitespace` rule.
Comment thread
ramonjd marked this conversation as resolved.
Resolved

## 22.11.0 (2025-06-04)

## 22.10.0 (2025-05-22)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,42 +29,34 @@ ruleTester.run( 'i18n-no-flanking-whitespace', rule, {
invalid: [
{
code: '__( "Double quoted string with a trailing newline\\n" );',
output: `__( 'Double quoted string with a trailing newline' );`,
errors: [ { messageId: 'noFlankingWhitespace' } ],
},
{
code: `__( ' Leading whitespace.' );`,
output: `__( 'Leading whitespace.' );`,
errors: [ { messageId: 'noFlankingWhitespace' } ],
},
{
code: `__( 'Trailing whitespace. ' );`,
output: `__( 'Trailing whitespace.' );`,
errors: [ { messageId: 'noFlankingWhitespace' } ],
},
{
code: `__( ' Flanking whitespace. ' );`,
output: `__( 'Flanking whitespace.' );`,
errors: [ { messageId: 'noFlankingWhitespace' } ],
},
{
code: '__( "\tLeading tab." );',
output: `__( 'Leading tab.' );`,
errors: [ { messageId: 'noFlankingWhitespace' } ],
},
{
code: '__( "\u0009Leading unicode tab." );',
output: `__( 'Leading unicode tab.' );`,
errors: [ { messageId: 'noFlankingWhitespace' } ],
},
{
code: `__( "Trailing tab.\t" );`,
output: `__( 'Trailing tab.' );`,
errors: [ { messageId: 'noFlankingWhitespace' } ],
},
{
code: `__( "\tFlanking tab.\t" );`,
output: `__( 'Flanking tab.' );`,
errors: [ { messageId: 'noFlankingWhitespace' } ],
},

Expand Down
17 changes: 0 additions & 17 deletions packages/eslint-plugin/rules/i18n-no-flanking-whitespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,6 @@ const PROBLEMS_BY_CHAR_CODE = {
32: 'whitespace',
};

function makeFixerFunction( arg ) {
return ( fixer ) => {
switch ( arg.type ) {
case 'Literal':
return [ fixer.replaceText( arg, `'${ arg.value.trim() }'` ) ];

case 'BinaryExpression':
return [
...makeFixerFunction( arg.left )( fixer ),
...makeFixerFunction( arg.right )( fixer ),
];
}
};
}

module.exports = {
meta: {
type: 'problem',
Expand All @@ -38,7 +23,6 @@ module.exports = {
noFlankingWhitespace:
'Translations should not contain flanking whitespace{{problem}}',
},
fixable: 'code',
},
create( context ) {
return {
Expand Down Expand Up @@ -81,7 +65,6 @@ module.exports = {
data: {
problem: problemString,
},
fix: makeFixerFunction( arg ),
} );
}
},
Expand Down