@@ -2,9 +2,11 @@ import axeCore from 'axe-core'
22
33let cache = { }
44let style = { }
5- const deferred = { }
65let lastNotification = ''
76
7+ const deferred = { }
8+ const impacts = [ 'critical' , 'serious' , 'moderate' , 'minor' ]
9+
810export function checkAndReport ( options , node ) {
911 const deferred = createDeferred ( )
1012 style = { ...options . style }
@@ -40,8 +42,8 @@ const standardResultHandler = function (errorInfo, results) {
4042
4143 if ( results . violations . length ) {
4244 console . group ( '%cNew axe issues' , style . head )
43- console . log ( results . violations )
44- results . violations . forEach ( result => {
45+ const violations = sortViolations ( results . violations )
46+ violations . forEach ( result => {
4547 console . groupCollapsed ( '%c%s%c %s %s %c%s' , style [ result . impact || 'minor' ] , result . impact , style . title , result . help , '\n' , style . url , result . helpUrl )
4648 result . nodes . forEach ( function ( node ) {
4749 failureSummary ( node , 'any' )
@@ -61,6 +63,14 @@ export function resetLastNotification () {
6163 lastNotification = ''
6264}
6365
66+ function sortViolations ( violations ) {
67+ let sorted = [ ]
68+ impacts . forEach ( impact => {
69+ sorted = [ ...sorted , ...violations . filter ( violation => violation . impact === impact ) ]
70+ } )
71+ return sorted
72+ }
73+
6474function createDeferred ( ) {
6575 deferred . promise = new Promise ( ( resolve , reject ) => {
6676 deferred . resolve = resolve
0 commit comments