npm package: @ta11y/reporter
Description: Output reporters for ta11y audit results.
Author: Saasify
Latest version: 1.3.1

<p align="center">
  <a href="https://ta11y.saasify.sh" title="ta11y">
    <img src="https://raw.githubusercontent.com/saasify-sh/ta11y/master/media/logo.svg?sanitize=true" alt="ta11y Logo" width="256" />
  </a>
</p>

# @ta11y/reporter

> Output reporters for ta11y audit results.

[![NPM](https://img.shields.io/npm/v/@ta11y/reporter.svg)](https://www.npmjs.com/package/@ta11y/reporter) [![Build Status](https://travis-ci.com/saasify-sh/ta11y.svg?branch=master)](https://travis-ci.com/saasify-sh/ta11y) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Install

```bash
npm install --save @ta11y/reporter
```

## Usage

The easiest way to use this package is to use the [CLI](https://github.com/saasify-sh/ta11y/tree/master/packages/ta11y).

```js
const { audit } = require('@ta11y/core')
const { formatAuditResults } = require('@ta11y/reporter')

audit('https://en.wikipedia.org')
  .then((auditResults) => {
    // overview of results (number of urls visited, success, error)
    console.log(auditResults.summary)

    // save the results to an excel spreadsheet
    return formatAuditResults(auditResults, 'out.xls')
  })
```

## Formats

We support all output formats supported by [SheetJS](https://docs.sheetjs.com/#supported-output-formats).

| file type | file ext | container | sheets | Description                     |
| :-------- | -------: | :-------: | :----- | :------------------------------ |
| `xlsx`    |  `.xlsx` |    ZIP    | multi  | Excel 2007+ XML Format          |
| `xlsm`    |  `.xlsm` |    ZIP    | multi  | Excel 2007+ Macro XML Format    |
| `xlsb`    |  `.xlsb` |    ZIP    | multi  | Excel 2007+ Binary Format       |
| `biff8`   |   `.xls` |    CFB    | multi  | Excel 97-2004 Workbook Format   |
| `biff5`   |   `.xls` |    CFB    | multi  | Excel 5.0/95 Workbook Format    |
| `biff2`   |   `.xls` |    none   | single | Excel 2.0 Worksheet Format      |
| `xlml`    |   `.xls` |    none   | multi  | Excel 2003-2004 (SpreadsheetML) |
| `ods`     |   `.ods` |    ZIP    | multi  | OpenDocument Spreadsheet        |
| `fods`    |  `.fods` |    none   | multi  | Flat OpenDocument Spreadsheet   |
| `csv`     |   `.csv` |    none   | single | Comma Separated Values          |
| `txt`     |   `.txt` |    none   | single | UTF-16 Unicode Text (TXT)       |
| `sylk`    |  `.sylk` |    none   | single | Symbolic Link (SYLK)            |
| `html`    |  `.html` |    none   | single | HTML Document                   |
| `dif`     |   `.dif` |    none   | single | Data Interchange Format (DIF)   |
| `dbf`     |   `.dbf` |    none   | single | dBASE II + VFP Extensions (DBF) |
| `rtf`     |   `.rtf` |    none   | single | Rich Text Format (RTF)          |
| `prn`     |   `.prn` |    none   | single | Lotus Formatted Text            |
| `eth`     |   `.eth` |    none   | single | Ethercalc Record Format (ETH)   |

## API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### [formatAuditResults](https://git@github.com/:saasify-sh/ta11y/blob/51ac1c6224fbc0c0515846fbe960ea21e93e5feb/packages/ta11y-reporter/lib/index.js#L22-L71)

Formats and outputs the given audit results from `@ta11y/core`, optionally writing
them to a `file`.

If no options / filename is passed, the input will be returned untransformed.

Type: `function (auditResults, opts): Promise`

-   `auditResults` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** JSON audit results to format.
-   `opts` **([object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) \| [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))?** Filename to write or config options.
    -   `opts.file` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Filename to write.
    -   `opts.format` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** File format to use (by default this is inferred from the filename).
    -   `opts.encoding` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** File encoding to use (by default this is inferred from the file format).

### [formatExtractResults](https://git@github.com/:saasify-sh/ta11y/blob/51ac1c6224fbc0c0515846fbe960ea21e93e5feb/packages/ta11y-reporter/lib/index.js#L87-L117)

Formats and outputs the given extraction results from `@ta11y/extract`, optionally writing
them to a `file`.

If no options / filename is passed, the input will be returned untransformed.

Type: `function (extractResults, opts, auditResults): Promise`

-   `extractResults`  
-   `opts` **([object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) \| [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))?** Filename to write or config options.
    -   `opts.file` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Filename to write.
    -   `opts.format` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** File format to use (by default this is inferred from the filename).
    -   `opts.encoding` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** File encoding to use (by default this is inferred from the file format).
-   `auditResults` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** JSON audit results to format.

## License

MIT © [Saasify](https://saasify.sh)