# html-tag-audit

> html tag auditing tool

Latest version **1.0.2** (published 2022-08-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install html-tag-audit
pnpm add html-tag-audit
yarn add html-tag-audit
bun add html-tag-audit
```

Provides the command `html-tag-audit`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2022-08-19 |
| First published | 2021-04-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 16.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Kyle Wilichowski |
| Maintainers | kdwilich |

## Links

- npm: https://www.npmjs.com/package/html-tag-audit
- Repository: https://github.com/kdwilich/html-tag-audit
- Homepage: https://github.com/kdwilich/html-tag-audit#readme
- Issues: https://github.com/kdwilich/html-tag-audit/issues
- npm.io page: https://npm.io/package/html-tag-audit

## Dependencies (3)

- [glob](https://npm.io/package/glob.md) ^7.1.6
- [commander](https://npm.io/package/commander.md) ^7.2.0
- [htmlparser2](https://npm.io/package/htmlparser2.md) ^6.1.0

## Recent versions

- 1.0.2 (latest) — 2022-08-19
- 1.0.1 — 2021-04-26
- 1.0.0 — 2021-04-24

## README

# html-tag-audit

A tool to audit all html files in a given directory and output their tags and attributes.

## Usage

Run this command from the directory you want to start the audit on:

```bash
npx html-tag-audit
```

Or define the directory to start in (`-sd`/`--start-dir`):

```bash
npx html-tag-audit -sd ./dir/to/start
```

The default behavior is to ignore html tags and obvious angular tags as this project was built to audit angular apps. Change the blacklist if an alternative output is desired (`-B`/`--blacklist`):

```bash
# accepted values: all, ng, html, none
# skip over html tags and attributes:
npx html-tag-audit --blacklist html
```

View [tag blacklist](https://github.com/kdwilich/html-tag-audit/blob/master/src/blacklists/tag-blacklist.js) and [attributes blacklist](https://github.com/kdwilich/html-tag-audit/blob/master/src/blacklists/attribute-blacklist.js)

## Available Flags

Flags are also viewable with the `--help` flag

- `-sd, --start-dir <dir>` - change starting directory (default: `./`)
- `-nf, --no-file-output` - disable file output
- `-fd, --file-output-dir <dir>` - change output file directory (default: `./`)
- `-fn, --filename <filename>` - change output file name (default: `html-tag-audit`)
- `-ft, --filetype <filetype>` - change output file type [`json`, `md`, `csv`, `txt`] (default: `json`)
- `-s, --sort <type>` - sort results [`tag`, `count`] (default: `tag`)
- `-lr, --log-results` - log audit results
- `-lp, --log-path` - log current path
- `-B, --blacklist <list>` - change audit blacklist [`all`, `none`, `ng`, `html`] (default: `all`)
- `-lt, --log-tags <list>` - log blacklisted tags without running audit [`all`, `ng`, `html`]
- `-la, --log-attributes <list>` - log blacklisted attributes without running audit [`all`, `ng`, `html`]

## Output

Running the command with no flags will output the audit results to a file named `html-tag-audit.json`. The file type can be changed by passing an accepted type to the `-ft` flag.

### Example

A file exists as `./html-files/test.html` and contains:
```html
<app-html-tag (onclick)="clickme()" [disabled]="false"></app-html-tag>
<app-html-tag styleclass="example-class" randAttribute="someValue"></app-html-tag>
```

Executing `npx html-tag-audit -sd ./html-files` results in this output:

```json
# html-tag-audit.json
{
  "app-html-tag": {
    "count": 2,
    "attributes": [
      "(onclick)",
      "[disabled]",
      "styleclass",
      "randattribute"
    ]
  }
}
```

Or to output as a markdown file instead, run `npx html-tag-audit -sd ./html-files -ft md`:

```md
# html-tag-audit.md
|Tag|Count|Attributes|
|---|---:|---|
|app-html-tag|2|(onclick),[disabled],styleclass,randattribute|
```

Preview:
|Tag|Count|Attributes|
|---|---:|---|
|app-html-tag|2|(onclick),[disabled],styleclass,randattribute|

---
_Source: https://npm.io/package/html-tag-audit · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
