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
|
12 | language.
|
13 |
|
14 | ## Install
|
15 |
|
16 | This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
|
17 | Node 12+ is needed to use it and it must be `import`ed instead of `require`d.
|
18 |
|
19 | [npm][]:
|
20 |
|
21 | ```sh
|
22 | npm install retext-equality
|
23 | ```
|
24 |
|
25 | ## Use
|
26 |
|
27 | Say we have the following file, `example.txt`:
|
28 |
|
29 | ```txt
|
30 | He’s pretty set on beating your butt for sheriff.
|
31 | ```
|
32 |
|
33 | …and our script, `example.js`, looks like this:
|
34 |
|
35 | ```js
|
36 | import {readSync} from 'to-vfile'
|
37 | import {reporter} from 'vfile-reporter'
|
38 | import {unified} from 'unified'
|
39 | import retextEnglish from 'retext-english'
|
40 | import retextEquality from 'retext-equality'
|
41 | import retextStringify from 'retext-stringify'
|
42 |
|
43 | const file = readSync('example.txt')
|
44 |
|
45 | unified()
|
46 | .use(retextEnglish)
|
47 | .use(retextEquality)
|
48 | .use(retextStringify)
|
49 | .process(file)
|
50 | .then((file) => {
|
51 | console.error(reporter(file))
|
52 | })
|
53 | ```
|
54 |
|
55 | Now, running `node example` yields:
|
56 |
|
57 | ```txt
|
58 | example.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 |
|
66 | This package exports no identifiers.
|
67 | The default export is `retextEquality`.
|
68 |
|
69 | ### `unified().use(retextEquality[, options])`
|
70 |
|
71 | Check for possible insensitive, inconsiderate language.
|
72 |
|
73 | ###### `options.ignore`
|
74 |
|
75 | List of phrases *not* to warn about (`Array.<string>`).
|
76 |
|
77 | ###### `options.noBinary`
|
78 |
|
79 | Do not allow binary references (`boolean`, default: `false`).
|
80 | By default `he` is warned about unless it’s followed by something like `or she`
|
81 | or `and she`.
|
82 | When `noBinary` is `true`, both cases would be warned about.
|
83 |
|
84 | ### Messages
|
85 |
|
86 | See [`rules.md`][rules] for a list of rules and how rules work.
|
87 |
|
88 | Each message is emitted as a [`VFileMessage`][message] on `file`, with the
|
89 | following fields:
|
90 |
|
91 | ###### `message.source`
|
92 |
|
93 | Name of this plugin (`'retext-equality'`).
|
94 |
|
95 | ###### `message.ruleId`
|
96 |
|
97 | See `id` in [`rules.md`][rules].
|
98 |
|
99 | ###### `message.actual`
|
100 |
|
101 | Current not ok phrase (`string`).
|
102 |
|
103 | ###### `message.expected`
|
104 |
|
105 | Suggest ok phrase (`Array.<string>`).
|
106 |
|
107 | ###### `message.note`
|
108 |
|
109 | Extra 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 |
|
124 | See [`contributing.md`][contributing] in [`retextjs/.github`][health] for ways
|
125 | to get started.
|
126 | See [`support.md`][support] for ways to get help.
|
127 |
|
128 | To create new patterns, add them in the YAML files in the [`data/`][script]
|
129 | directory, and run `npm install` and then `npm test` to build everything.
|
130 | Please see the current patterns for inspiration.
|
131 | New English rules will be automatically added to `rules.md`.
|
132 |
|
133 | Once you are happy with the new rule, add a test for it in [`test.js`][test] and
|
134 | open a pull request.
|
135 |
|
136 | This project has a [code of conduct][coc].
|
137 | By interacting with this repository, organization, or community you agree to
|
138 | abide by its terms.
|
139 |
|
140 | ## License
|
141 |
|
142 | [MIT][license] © [Titus Wormer][author]
|
143 |
|
144 |
|
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
|