@@ -41,6 +41,15 @@ function ruleFunc(method, opts, context) {
41
41
// validate or autofix 4 physical properties as logical shorthands
42
42
physical4Prop . forEach ( ( [ props , prop ] ) => {
43
43
validateRuleWithProps ( node , props , ( blockStartDecl , blockStartIndex , inlineStartDecl , inlineStartIndex , blockEndDecl , blockEndIndex , inlineEndDecl , inlineEndIndex ) => { // eslint-disable-line
44
+ if (
45
+ isDeclAnException ( blockStartDecl , propExceptions ) ||
46
+ isDeclAnException ( inlineStartDecl , propExceptions ) ||
47
+ isDeclAnException ( blockEndDecl , propExceptions ) ||
48
+ isDeclAnException ( inlineEndDecl , propExceptions )
49
+ ) {
50
+ return ;
51
+ }
52
+
44
53
const firstInlineDecl = blockStartDecl ;
45
54
46
55
if ( isAutofix ) {
@@ -81,6 +90,13 @@ function ruleFunc(method, opts, context) {
81
90
// validate or autofix 2 physical properties as logical shorthands
82
91
physical2Prop ( ) . forEach ( ( [ props , prop ] ) => {
83
92
validateRuleWithProps ( node , props , ( blockStartDecl , blockStartIndex , inlineStartDecl , inlineStartIndex ) => { // eslint-disable-line
93
+ if (
94
+ isDeclAnException ( blockStartDecl , propExceptions ) ||
95
+ isDeclAnException ( inlineStartDecl , propExceptions )
96
+ ) {
97
+ return ;
98
+ }
99
+
84
100
const firstInlineDecl = blockStartIndex < inlineStartIndex
85
101
? blockStartDecl
86
102
: inlineStartDecl ;
@@ -107,33 +123,41 @@ function ruleFunc(method, opts, context) {
107
123
// validate or autofix physical properties as logical
108
124
physicalProp ( dir ) . forEach ( ( [ props , prop ] ) => {
109
125
validateRuleWithProps ( node , props , physicalDecl => {
110
- if ( ! isDeclAnException ( physicalDecl , propExceptions ) ) {
111
- if ( isAutofix ) {
112
- physicalDecl . prop = prop ;
113
- } else if ( ! isDeclReported ( physicalDecl ) ) {
114
- reportUnexpectedProperty ( physicalDecl , prop ) ;
126
+ if ( isDeclAnException ( physicalDecl , propExceptions ) ) {
127
+ return ;
128
+ }
115
129
116
- reportedDecls . set ( physicalDecl ) ;
117
- }
130
+ if ( isAutofix ) {
131
+ physicalDecl . prop = prop ;
132
+ } else if ( ! isDeclReported ( physicalDecl ) ) {
133
+ reportUnexpectedProperty ( physicalDecl , prop ) ;
134
+
135
+ reportedDecls . set ( physicalDecl ) ;
118
136
}
119
137
} ) ;
120
138
} ) ;
121
139
122
140
// validate or autofix physical values as logical
123
141
physicalValue ( dir ) . forEach ( ( [ regexp , props ] ) => {
124
- if ( isNodeMatchingDecl ( node , regexp ) && ! isDeclAnException ( node , propExceptions ) ) {
125
- const valuekey = node . value . toLowerCase ( ) ;
142
+ if ( ! isNodeMatchingDecl ( node , regexp ) ) {
143
+ return ;
144
+ }
126
145
127
- if ( valuekey in props ) {
128
- const value = props [ valuekey ] ;
146
+ if ( isDeclAnException ( node , propExceptions ) ) {
147
+ return ;
148
+ }
129
149
130
- if ( isAutofix ) {
131
- node . value = value ;
132
- } else {
133
- reportUnexpectedValue ( node , value ) ;
150
+ const valuekey = node . value . toLowerCase ( ) ;
134
151
135
- reportedDecls . set ( node ) ;
136
- }
152
+ if ( valuekey in props ) {
153
+ const value = props [ valuekey ] ;
154
+
155
+ if ( isAutofix ) {
156
+ node . value = value ;
157
+ } else {
158
+ reportUnexpectedValue ( node , value ) ;
159
+
160
+ reportedDecls . set ( node ) ;
137
161
}
138
162
}
139
163
} ) ;
@@ -149,7 +173,19 @@ const isMethodIndifferent = method => method === 'ignore' || method === false ||
149
173
const isMethodAlways = method => method === 'always' || method === true ;
150
174
const isContextAutofixing = context => Boolean ( Object ( context ) . fix ) ;
151
175
const isNodeMatchingDecl = ( decl , regexp ) => decl . type === 'decl' && regexp . test ( decl . prop ) ;
152
- const isDeclAnException = ( decl , propExceptions ) => propExceptions . some ( match => match instanceof RegExp
153
- ? match . test ( decl . prop )
154
- : String ( match || '' ) . toLowerCase ( ) === String ( decl . prop || '' ) . toLowerCase ( ) ) ;
176
+
177
+ const isDeclAnException = ( decl , propExceptions ) => {
178
+ if ( ! decl || decl . type !== 'decl' ) {
179
+ return false ;
180
+ }
181
+
182
+ return propExceptions . some ( ( match ) => {
183
+ if ( match instanceof RegExp ) {
184
+ return match . test ( decl . prop ) ;
185
+ }
186
+
187
+ return String ( match || '' ) . toLowerCase ( ) === String ( decl . prop || '' ) . toLowerCase ( ) ;
188
+ } ) ;
189
+ }
190
+
155
191
const isDeclReported = decl => reportedDecls . has ( decl ) ;
0 commit comments