@@ -2,9 +2,11 @@ import axeCore from 'axe-core'
2
2
3
3
let cache = { }
4
4
let style = { }
5
- const deferred = { }
6
5
let lastNotification = ''
7
6
7
+ const deferred = { }
8
+ const impacts = [ 'critical' , 'serious' , 'moderate' , 'minor' ]
9
+
8
10
export function checkAndReport ( options , node ) {
9
11
const deferred = createDeferred ( )
10
12
style = { ...options . style }
@@ -40,8 +42,8 @@ const standardResultHandler = function (errorInfo, results) {
40
42
41
43
if ( results . violations . length ) {
42
44
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 => {
45
47
console . groupCollapsed ( '%c%s%c %s %s %c%s' , style [ result . impact || 'minor' ] , result . impact , style . title , result . help , '\n' , style . url , result . helpUrl )
46
48
result . nodes . forEach ( function ( node ) {
47
49
failureSummary ( node , 'any' )
@@ -61,6 +63,14 @@ export function resetLastNotification () {
61
63
lastNotification = ''
62
64
}
63
65
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
+
64
74
function createDeferred ( ) {
65
75
deferred . promise = new Promise ( ( resolve , reject ) => {
66
76
deferred . resolve = resolve
0 commit comments