Skip to content

Commit fe5ec93

Browse files
committed
chore: Get style by options and remove constant file
1 parent b5d90f7 commit fe5ec93

File tree

2 files changed

+7
-33
lines changed

2 files changed

+7
-33
lines changed

Diff for: src/constants.js

-27
This file was deleted.

Diff for: src/utils.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import axeCore from 'axe-core'
2-
import { IMPACT, STYLE } from './constants'
32

43
let cache = {}
4+
let style = {}
55
const nodes = []
66
const deferred = {}
77
let lastNotification = ''
88

99
export function checkAndReport (options, node) {
1010
nodes.push(node)
1111
const deferred = createDeferred()
12+
style = { ...options.style }
1213

1314
axeCore.run(document, options.runOptions, (error, results) => {
1415
if (error) deferred.reject(error)
@@ -40,10 +41,10 @@ const standardResultHandler = function (errorInfo, results) {
4041
})
4142

4243
if (results.violations.length) {
43-
console.group('%cNew aXe issues', STYLE.head)
44+
console.group('%cNew axe issues', style.head)
45+
console.log(results.violations)
4446
results.violations.forEach(result => {
45-
const styl = IMPACT[result.impact] || IMPACT.minor
46-
console.groupCollapsed('%c%s: %c%s %s', STYLE[styl], result.impact, STYLE.defaultReset, result.help, result.helpUrl)
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)
4748
result.nodes.forEach(function (node) {
4849
failureSummary(node, 'any')
4950
failureSummary(node, 'none')
@@ -97,14 +98,14 @@ function failureSummary (node, key) {
9798
function logElement (node, logFn) {
9899
var el = document.querySelector(node.target.toString())
99100
if (!el) {
100-
logFn('Selector: %c%s', STYLE.boldCourier, node.target.toString())
101+
logFn('Selector: %c%s', style.boldCourier, node.target.toString())
101102
} else {
102103
logFn('Element: %o', el)
103104
}
104105
}
105106

106107
function logHtml (node) {
107-
console.log('HTML: %c%s', STYLE.boldCourier, node.html)
108+
console.log('HTML: %c%s', style.boldCourier, node.html)
108109
}
109110

110111
function logFailureMessage (node, key) {

0 commit comments

Comments
 (0)