@@ -65,17 +65,18 @@ export const guards = [
6565 /** @param {ReturnType<import('@projectwallace/css-analyzer').analyze> } result */
6666 result => {
6767 const MAX_SELECTORS_PER_RULESET = 10
68+ let max = result . rules . selectors . max || 0
6869
6970 const outcome = {
7071 id : 'MaxSelectorsPerRule' ,
7172 score : 0 ,
72- value : result . rules . selectors . max ,
73+ value : max ,
7374 actuals : result . rules . selectors . items ,
7475 }
7576
7677 // Deduct 0.5 points per selectors over 10
77- if ( result . rules . selectors . max > MAX_SELECTORS_PER_RULESET ) {
78- const score = Math . ceil ( ( result . rules . selectors . max - MAX_SELECTORS_PER_RULESET ) * 0.5 )
78+ if ( max > MAX_SELECTORS_PER_RULESET ) {
79+ const score = Math . ceil ( ( max - MAX_SELECTORS_PER_RULESET ) * 0.5 )
7980 outcome . score = Math . min ( score , 15 )
8081 }
8182
@@ -86,17 +87,18 @@ export const guards = [
8687 /** @param {ReturnType<import('@projectwallace/css-analyzer').analyze> } result */
8788 result => {
8889 const MAX_DECLARATIONS_PER_RULESET = 10
90+ const max = result . rules . declarations . max || 0
8991
9092 const outcome = {
9193 id : 'MaxDeclarationsPerRule' ,
9294 score : 0 ,
93- value : result . rules . declarations . max ,
95+ value : max ,
9496 actuals : result . rules . declarations . items ,
9597 }
9698
9799 // Deduct 0.5 points per declarations over 10
98- if ( result . rules . declarations . max > MAX_DECLARATIONS_PER_RULESET ) {
99- const score = Math . ceil ( ( result . rules . declarations . max - MAX_DECLARATIONS_PER_RULESET ) * 0.5 )
100+ if ( max > MAX_DECLARATIONS_PER_RULESET ) {
101+ const score = Math . ceil ( ( max - MAX_DECLARATIONS_PER_RULESET ) * 0.5 )
100102 outcome . score = Math . min ( 15 , score )
101103 }
102104
0 commit comments