import request from "browser-request";

const url = "https://beta.accesslint.com/api/v1/reports";

export default function (message) {
  const violations = message.violations;

  if (violations.length > 0) {
    let descriptions = [];

    violations.map((violation) => {
      descriptions.push(violation.help);
    });

    request({
      method: "POST",
      url: url,
      json: message,
    }, function() {});

    throw new Error(
      `AccessLintError: ${violations.length} violations:` + "\n" +
      descriptions.join(",\n")
    );
  }
}

import request from "browser-request";

const url = "https://beta.accesslint.com/api/v1/reports";

export default function (message) {
  const violations = message.violations;

  if (violations.length > 0) {
    request({
      method: "POST",
      url: url,
      json: message,
    }, function() {});

    console.error(
      `AccessLint - ${violations.length} accessibility violations:`,
      violations
    );
  }
}

Use console.error instead of throw
Use console.error instead of throw

- We want the script to continue.
- Console.error supports logging objects.
- Poltergeist will still fail with this implementation.
