File tree Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -125,17 +125,22 @@ module.exports = {
125
125
Object . keys ( cssVars ) . forEach ( cssVar => {
126
126
if ( Array . isArray ( cssVars [ cssVar ] ) ) {
127
127
cssVars [ cssVar ] . forEach ( cssVarObject => {
128
- const regex = new RegExp ( `var\\(${ cssVar } \\)` , 'g' )
129
- if ( cssVarObject . props . some ( prop => rawText . includes ( prop ) ) && regex . test ( rawText ) ) {
130
- const fixedString = rawText . replace ( regex , `var(${ cssVarObject . replacement } , var(${ cssVar } ))` )
131
- context . report ( {
132
- node,
133
- message : `Replace var(${ cssVar } ) with var(${ cssVarObject . replacement } , var(${ cssVar } ))` ,
134
- fix : function ( fixer ) {
135
- return fixer . replaceText ( node , node . type === 'Literal' ? `"${ fixedString } "` : fixedString )
128
+ cssVarObject . props . forEach ( prop => {
129
+ const regex = new RegExp ( `var\\(${ cssVar } \\)` , 'g' )
130
+ if ( rawText . includes ( prop ) && regex . test ( rawText ) ) {
131
+ const fixedString = rawText . replace ( regex , `var(${ cssVarObject . replacement } , var(${ cssVar } ))` )
132
+ if ( ! rawText . includes ( fixedString ) ) {
133
+ // Check if the autofix has already been applied
134
+ context . report ( {
135
+ node,
136
+ message : `Replace var(${ cssVar } ) with var(${ cssVarObject . replacement } , var(${ cssVar } ))` ,
137
+ fix : function ( fixer ) {
138
+ return fixer . replaceText ( node , node . type === 'Literal' ? `"${ fixedString } "` : fixedString )
139
+ }
140
+ } )
136
141
}
137
- } )
138
- }
142
+ }
143
+ } )
139
144
} )
140
145
}
141
146
} )
You can’t perform that action at this time.
0 commit comments