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