Skip to content

Commit 2a91850

Browse files
committed
Autorun and raise js errors always
1 parent 48c3baf commit 2a91850

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

src/auditor.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { axe } from "axe-core/axe.min.js";
2-
import logger from "./logger";
2+
import report from "./reporter";
33

4-
export default function (url, raiseError) {
4+
export default function () {
55
window.axe.a11yCheck(document, {}, (results) => {
6-
logger(results, url, raiseError);
6+
report(results);
77
});
88
}

src/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import auditor from "./auditor.js";
22

3-
const DEFAULT_URL = "https://accesslint-service-staging.herokuapp.com/api/v1/reports";
3+
(function() {
4+
var load = function() {
5+
window.removeEventListener("load", load, false);
6+
auditor();
7+
};
48

5-
window.AccessLint = {
6-
audit({ url = DEFAULT_URL, raiseError = false }) {
7-
auditor(url, raiseError);
8-
},
9-
};
9+
window.addEventListener("load", load);
10+
})();
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import request from "browser-request";
22

3-
export default function (message, url, raiseError) {
3+
const url = "https://accesslint-service-staging.herokuapp.com/api/v1/reports";
4+
5+
export default function (message) {
46
let violations = message.violations;
57

6-
if (raiseError && violations.length > 0) {
7-
console.error(message);
8-
throw new Error(`AccessLintError: ${violations.length} violations.`);
9-
} else {
8+
if (violations.length > 0) {
109
request({
1110
method: "POST",
1211
url: url,
1312
json: message,
1413
}, function() {});
14+
15+
console.error(message);
16+
throw new Error(`AccessLintError: ${violations.length} violations.`);
1517
}
1618
}

0 commit comments

Comments
 (0)