Skip to content

Commit cdec694

Browse files
committedMar 25, 2022
Add improved docs
1 parent c4a3d10 commit cdec694

File tree

2 files changed

+96
-41
lines changed

2 files changed

+96
-41
lines changed
 

‎lib/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* @property {VFile} file
2323
* @property {Statistics} stats
2424
*
25-
* @typedef {{[x: string]: number}} Sizes
25+
* @typedef {Record<string, number>} Sizes
2626
*
2727
* @typedef Info
2828
* @property {Array<FileRow|Row>} rows

‎readme.md

+95-40
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,60 @@
77
[![Backers][backers-badge]][collective]
88
[![Chat][chat-badge]][chat]
99

10-
Create a report for a **[vfile][]**.
10+
[vfile][] utility to create a report from a file.
1111

1212
![Example screenshot of vfile-reporter][screenshot]
1313

14-
## Features
14+
## Contents
1515

16-
* [x] Ranges (`3:2` and `3:2-3:6`)
17-
* [x] Stack-traces to show where awful stuff occurs
18-
* [x] Successful files (configurable)
19-
* [x] All of [**VFile**][vfile]’s awesomeness
16+
* [What is this?](#what-is-this)
17+
* [When should I use this?](#when-should-i-use-this)
18+
* [Install](#install)
19+
* [Use](#use)
20+
* [API](#api)
21+
* [`reporter(files[, options])`](#reporterfiles-options)
22+
* [Types](#types)
23+
* [Compatibility](#compatibility)
24+
* [Security](#security)
25+
* [Related](#related)
26+
* [Contribute](#contribute)
27+
* [License](#license)
2028

21-
## Install
29+
## What is this?
30+
31+
This package create a textual report from a file showing the warnings that
32+
occurred while processing.
33+
Many CLIs of tools that process files, whether linters (such as ESLint) or
34+
bundlers (such as esbuild), have similar functionality.
35+
36+
## When should I use this?
37+
38+
You can use this package whenever you want to display a report about what
39+
occurred while processing to a human.
2240

23-
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
24-
Node 12+ is needed to use it and it must be `import`ed instead of `require`d.
41+
## Install
2542

26-
[npm][]:
43+
This package is [ESM only][esm].
44+
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
2745

2846
```sh
2947
npm install vfile-reporter
3048
```
3149

50+
In Deno with [`esm.sh`][esmsh]:
51+
52+
```js
53+
import {reporter} from 'https://esm.sh/vfile-reporter@7'
54+
```
55+
56+
In browsers with [`esm.sh`][esmsh]:
57+
58+
```html
59+
<script type="module">
60+
import {reporter} from 'https://esm.sh/vfile-reporter@7?bundle'
61+
</script>
62+
```
63+
3264
## Use
3365

3466
Say `example.js` contains:
@@ -58,55 +90,72 @@ test/fixture/2.js: no issues found
5890

5991
## API
6092

61-
This package exports the following identifiers: `reporter`.
62-
That identifier is also the default export.
93+
This package exports the identifier `reporter`.
94+
That value is also the default export.
6395

6496
### `reporter(files[, options])`
6597

66-
Generate a stylish report from the given [`vfile`][vfile], `Array<VFile>`,
67-
or `Error`.
98+
Create a report from an error, on file, or multiple files.
6899

69100
##### `options`
70101

102+
Configuration (optional).
103+
104+
###### `options.color`
105+
106+
Use ANSI colors in report (`boolean`, default: depends).
107+
The default behavior is the check if [color is supported][supports-color].
108+
71109
###### `options.verbose`
72110

73-
Output long form descriptions of messages, if applicable (`boolean`, default:
74-
`false`).
111+
Show message [`note`][message-note]s (`boolean`, default: `false`).
112+
Notes are optional, additional, long descriptions.
75113

76114
###### `options.quiet`
77115

78-
Do not output anything for a file which has no warnings or errors (`boolean`,
79-
default: `false`).
80-
The default behavior is to show a success message.
116+
Do not show files without messages (`boolean`, default: `false`).
81117

82118
###### `options.silent`
83119

84-
Do not output messages without `fatal` set to true (`boolean`, default:
85-
`false`).
120+
Show errors only (`boolean`, default: `false`).
121+
This does not show info and warning messages.
86122
Also sets `quiet` to `true`.
87123

88-
###### `options.color`
89-
90-
Whether to use color (`boolean`, default: depends).
91-
The default behavior is the check if [color is supported][supports-color].
92-
93124
###### `options.defaultName`
94125

95-
Label to use for files without file-path (`string`, default: `'<stdin>'`).
126+
Label to use for files without file path (`string`, default: `'<stdin>'`).
96127
If one file and no `defaultName` is given, no name will show up in the report.
97128

129+
##### Returns
130+
131+
`string`.
132+
133+
## Types
134+
135+
This package is fully typed with [TypeScript][].
136+
It exports the additional type `Options`.
137+
138+
## Compatibility
139+
140+
Projects maintained by the unified collective are compatible with all maintained
141+
versions of Node.js.
142+
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
143+
Our projects sometimes work with older versions, but this is not guaranteed.
144+
145+
## Security
146+
147+
Use of `vfile-reporter` is safe.
148+
98149
## Related
99150

100151
* [`vfile-reporter-json`](https://github.com/vfile/vfile-reporter-json)
101-
— JSON reporter
152+
create a JSON report
102153
* [`vfile-reporter-pretty`](https://github.com/vfile/vfile-reporter-pretty)
103-
— Pretty reporter
104-
* [`convert-vinyl-to-vfile`](https://github.com/dustinspecker/convert-vinyl-to-vfile)
105-
— Convert from [Vinyl][]
106-
* [`vfile-statistics`](https://github.com/vfile/vfile-statistics)
107-
— Count messages per category
108-
* [`vfile-sort`](https://github.com/vfile/vfile-sort)
109-
— Sort messages by line/column
154+
— create a pretty report
155+
* [`vfile-reporter-junit`](https://github.com/kellyselden/vfile-reporter-junit)
156+
— create a jUnit report
157+
* [`vfile-reporter-position`](https://github.com/Hocdoc/vfile-reporter-position)
158+
— create a report with content excerpts
110159

111160
## Contribute
112161

@@ -115,7 +164,7 @@ get started.
115164
See [`support.md`][support] for ways to get help.
116165

117166
This project has a [code of conduct][coc].
118-
By interacting with this repository, organization, or community you agree to
167+
By interacting with this repository, organisation, or community you agree to
119168
abide by its terms.
120169

121170
## License
@@ -152,13 +201,19 @@ Nicholas C. Zakas, and licensed under MIT.
152201

153202
[npm]: https://docs.npmjs.com/cli/install
154203

155-
[contributing]: https://github.com/vfile/.github/blob/HEAD/contributing.md
204+
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
205+
206+
[esmsh]: https://esm.sh
207+
208+
[typescript]: https://www.typescriptlang.org
209+
210+
[contributing]: https://github.com/vfile/.github/blob/main/contributing.md
156211

157-
[support]: https://github.com/vfile/.github/blob/HEAD/support.md
212+
[support]: https://github.com/vfile/.github/blob/main/support.md
158213

159214
[health]: https://github.com/vfile/.github
160215

161-
[coc]: https://github.com/vfile/.github/blob/HEAD/code-of-conduct.md
216+
[coc]: https://github.com/vfile/.github/blob/main/code-of-conduct.md
162217

163218
[license]: license
164219

@@ -172,4 +227,4 @@ Nicholas C. Zakas, and licensed under MIT.
172227

173228
[supports-color]: https://github.com/chalk/supports-color
174229

175-
[vinyl]: https://github.com/gulpjs/vinyl
230+
[message-note]: https://github.com/vfile/vfile-message#note

0 commit comments

Comments
 (0)
Please sign in to comment.