UNPKG

4.99 kBMarkdownView Raw
1# retext-equality
2
3[![Build][build-badge]][build]
4[![Coverage][coverage-badge]][coverage]
5[![Downloads][downloads-badge]][downloads]
6[![Size][size-badge]][size]
7[![Sponsors][sponsors-badge]][collective]
8[![Backers][backers-badge]][collective]
9[![Chat][chat-badge]][chat]
10
11[**retext**][retext] plugin to check for possible insensitive, inconsiderate
12language.
13
14## Install
15
16This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
17Node 12+ is needed to use it and it must be `import`ed instead of `require`d.
18
19[npm][]:
20
21```sh
22npm install retext-equality
23```
24
25## Use
26
27Say we have the following file, `example.txt`:
28
29```txt
30He’s pretty set on beating your butt for sheriff.
31```
32
33…and our script, `example.js`, looks like this:
34
35```js
36import {readSync} from 'to-vfile'
37import {reporter} from 'vfile-reporter'
38import {unified} from 'unified'
39import retextEnglish from 'retext-english'
40import retextEquality from 'retext-equality'
41import retextStringify from 'retext-stringify'
42
43const file = readSync('example.txt')
44
45unified()
46 .use(retextEnglish)
47 .use(retextEquality)
48 .use(retextStringify)
49 .process(file)
50 .then((file) => {
51 console.error(reporter(file))
52 })
53```
54
55Now, running `node example` yields:
56
57```txt
58example.txt
59 1:1-1:5 warning `He’s` may be insensitive, use `They`, `It` instead he-she retext-equality
60
61⚠ 1 warning
62```
63
64## API
65
66This package exports no identifiers.
67The default export is `retextEquality`.
68
69### `unified().use(retextEquality[, options])`
70
71Check for possible insensitive, inconsiderate language.
72
73###### `options.ignore`
74
75List of phrases *not* to warn about (`Array.<string>`).
76
77###### `options.noBinary`
78
79Do not allow binary references (`boolean`, default: `false`).
80By default `he` is warned about unless it’s followed by something like `or she`
81or `and she`.
82When `noBinary` is `true`, both cases would be warned about.
83
84### Messages
85
86See [`rules.md`][rules] for a list of rules and how rules work.
87
88Each message is emitted as a [`VFileMessage`][message] on `file`, with the
89following fields:
90
91###### `message.source`
92
93Name of this plugin (`'retext-equality'`).
94
95###### `message.ruleId`
96
97See `id` in [`rules.md`][rules].
98
99###### `message.actual`
100
101Current not ok phrase (`string`).
102
103###### `message.expected`
104
105Suggest ok phrase (`Array.<string>`).
106
107###### `message.note`
108
109Extra information, when available (`string?`).
110
111## Related
112
113* [`alex`](https://github.com/get-alex/alex)
114 — Catch insensitive, inconsiderate writing
115* [`retext-passive`](https://github.com/retextjs/retext-passive)
116 — Check passive voice
117* [`retext-profanities`](https://github.com/retextjs/retext-profanities)
118 — Check for profane and vulgar wording
119* [`retext-simplify`](https://github.com/retextjs/retext-simplify)
120 — Check phrases for simpler alternatives
121
122## Contributing
123
124See [`contributing.md`][contributing] in [`retextjs/.github`][health] for ways
125to get started.
126See [`support.md`][support] for ways to get help.
127
128To create new patterns, add them in the YAML files in the [`data/`][script]
129directory, and run `npm install` and then `npm test` to build everything.
130Please see the current patterns for inspiration.
131New English rules will be automatically added to `rules.md`.
132
133Once you are happy with the new rule, add a test for it in [`test.js`][test] and
134open a pull request.
135
136This project has a [code of conduct][coc].
137By interacting with this repository, organization, or community you agree to
138abide by its terms.
139
140## License
141
142[MIT][license] © [Titus Wormer][author]
143
144<!-- Definitions -->
145
146[build-badge]: https://github.com/retextjs/retext-equality/workflows/main/badge.svg
147
148[build]: https://github.com/retextjs/retext-equality/actions
149
150[coverage-badge]: https://img.shields.io/codecov/c/github/retextjs/retext-equality.svg
151
152[coverage]: https://codecov.io/github/retextjs/retext-equality
153
154[downloads-badge]: https://img.shields.io/npm/dm/retext-equality.svg
155
156[downloads]: https://www.npmjs.com/package/retext-equality
157
158[size-badge]: https://img.shields.io/bundlephobia/minzip/retext-equality.svg
159
160[size]: https://bundlephobia.com/result?p=retext-equality
161
162[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
163
164[backers-badge]: https://opencollective.com/unified/backers/badge.svg
165
166[collective]: https://opencollective.com/unified
167
168[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
169
170[chat]: https://github.com/retextjs/retext/discussions
171
172[npm]: https://docs.npmjs.com/cli/install
173
174[health]: https://github.com/retextjs/.github
175
176[contributing]: https://github.com/retextjs/.github/blob/HEAD/contributing.md
177
178[support]: https://github.com/retextjs/.github/blob/HEAD/support.md
179
180[coc]: https://github.com/retextjs/.github/blob/HEAD/code-of-conduct.md
181
182[license]: license
183
184[author]: https://wooorm.com
185
186[retext]: https://github.com/retextjs/retext
187
188[message]: https://github.com/vfile/vfile-message
189
190[script]: script
191
192[test]: test.js
193
194[rules]: rules.md