File tree Expand file tree Collapse file tree 1 file changed +12
-15
lines changed Expand file tree Collapse file tree 1 file changed +12
-15
lines changed Original file line number Diff line number Diff line change @@ -125,22 +125,19 @@ module.exports = {
125
125
Object . keys ( cssVars ) . forEach ( cssVar => {
126
126
if ( Array . isArray ( cssVars [ cssVar ] ) ) {
127
127
cssVars [ cssVar ] . forEach ( cssVarObject => {
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
- } )
141
- }
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
+ if ( ! rawText . includes ( fixedString ) ) {
132
+ context . report ( {
133
+ node,
134
+ message : `Replace var(${ cssVar } ) with var(${ cssVarObject . replacement } , var(${ cssVar } ))` ,
135
+ fix : function ( fixer ) {
136
+ return fixer . replaceText ( node , node . type === 'Literal' ? `"${ fixedString } "` : fixedString )
137
+ }
138
+ } )
142
139
}
143
- } )
140
+ }
144
141
} )
145
142
}
146
143
} )
You can’t perform that action at this time.
0 commit comments