@@ -41,6 +41,15 @@ function ruleFunc(method, opts, context) {
4141 // validate or autofix 4 physical properties as logical shorthands
4242 physical4Prop . forEach ( ( [ props , prop ] ) => {
4343 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+
4453 const firstInlineDecl = blockStartDecl ;
4554
4655 if ( isAutofix ) {
@@ -81,6 +90,13 @@ function ruleFunc(method, opts, context) {
8190 // validate or autofix 2 physical properties as logical shorthands
8291 physical2Prop ( ) . forEach ( ( [ props , prop ] ) => {
8392 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+
84100 const firstInlineDecl = blockStartIndex < inlineStartIndex
85101 ? blockStartDecl
86102 : inlineStartDecl ;
@@ -107,33 +123,41 @@ function ruleFunc(method, opts, context) {
107123 // validate or autofix physical properties as logical
108124 physicalProp ( dir ) . forEach ( ( [ props , prop ] ) => {
109125 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+ }
115129
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 ) ;
118136 }
119137 } ) ;
120138 } ) ;
121139
122140 // validate or autofix physical values as logical
123141 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+ }
126145
127- if ( valuekey in props ) {
128- const value = props [ valuekey ] ;
146+ if ( isDeclAnException ( node , propExceptions ) ) {
147+ return ;
148+ }
129149
130- if ( isAutofix ) {
131- node . value = value ;
132- } else {
133- reportUnexpectedValue ( node , value ) ;
150+ const valuekey = node . value . toLowerCase ( ) ;
134151
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 ) ;
137161 }
138162 }
139163 } ) ;
@@ -149,7 +173,19 @@ const isMethodIndifferent = method => method === 'ignore' || method === false ||
149173const isMethodAlways = method => method === 'always' || method === true ;
150174const isContextAutofixing = context => Boolean ( Object ( context ) . fix ) ;
151175const 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+
155191const isDeclReported = decl => reportedDecls . has ( decl ) ;
0 commit comments