File tree Expand file tree Collapse file tree 3 files changed +309
-299
lines changed
Expand file tree Collapse file tree 3 files changed +309
-299
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,8 @@ If you enjoy my work you can:
3333
3434## Latest changelog
3535
36+ - FIX: [ FIX: ` enforces-shorthand ` false positive] ( https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/91 )
37+
3638- FIX: [ ` snap-x ` and ` snap-mandatory ` are conflicting classes] ( https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/90 )
3739
3840- New rule: [ ` enforces-shorthand ` ] ( docs/rules/enforces-shorthand.md ) merging multiple classnames when possible
Original file line number Diff line number Diff line change @@ -305,22 +305,27 @@ module.exports = {
305305 }
306306 let validatedClassNamesValue = union . join ( isSingleLine ? ' ' : '\n' ) ;
307307 const originalPatched = isSingleLine ? originalClassNamesValue . trim ( ) : originalClassNamesValue ;
308- troubles . forEach ( ( issue ) => {
309- if ( originalPatched !== validatedClassNamesValue ) {
310- validatedClassNamesValue = prefix + validatedClassNamesValue + suffix ;
311- context . report ( {
312- node : node ,
313- messageId : 'shorthandCandidateDetected' ,
314- data : {
315- classnames : issue [ 0 ] . join ( ', ' ) ,
316- shorthand : issue [ 1 ] ,
317- } ,
318- fix : function ( fixer ) {
319- return fixer . replaceTextRange ( [ start , end ] , validatedClassNamesValue ) ;
320- } ,
321- } ) ;
322- }
323- } ) ;
308+ troubles
309+ . filter ( ( trouble ) => {
310+ // Only valid issue if there are classes to replace
311+ return trouble [ 0 ] . length ;
312+ } )
313+ . forEach ( ( issue ) => {
314+ if ( originalPatched !== validatedClassNamesValue ) {
315+ validatedClassNamesValue = prefix + validatedClassNamesValue + suffix ;
316+ context . report ( {
317+ node : node ,
318+ messageId : 'shorthandCandidateDetected' ,
319+ data : {
320+ classnames : issue [ 0 ] . join ( ', ' ) ,
321+ shorthand : issue [ 1 ] ,
322+ } ,
323+ fix : function ( fixer ) {
324+ return fixer . replaceTextRange ( [ start , end ] , validatedClassNamesValue ) ;
325+ } ,
326+ } ) ;
327+ }
328+ } ) ;
324329 } ;
325330
326331 //----------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments