retext plugin to check for possible insensitive, inconsiderate language.
- What is this?
- When should I use this?
- Install
- Use
- API
- Messages
- Types
- Compatibility
- Related
- Contributing
- License
This package is a unified (retext) plugin to check for certain words that could be considered insensitive, or otherwise inconsiderate, in certain contexts.
You can opt-into this plugin when you’re dealing with your own text and want to check for potential mistakes.
This package is ESM only. In Node.js (version 12.20+, 14.14+, 16.0+, or 18.0+), install with npm:
npm install retext-equality
In Deno with esm.sh
:
import retextEquality from 'https://esm.sh/retext-equality@6'
In browsers with esm.sh
:
<script type="module">
import retextEquality from 'https://esm.sh/retext-equality@6?bundle'
</script>
Say our document example.txt
contains:
He’s pretty set on beating your butt for sheriff.
…and our module example.js
looks as follows:
import {read} from 'to-vfile'
import {reporter} from 'vfile-reporter'
import {unified} from 'unified'
import retextEnglish from 'retext-english'
import retextEquality from 'retext-equality'
import retextStringify from 'retext-stringify'
const file = await unified()
.use(retextEnglish)
.use(retextEquality)
.use(retextStringify)
.process(await read('example.txt'))
console.error(reporter(file))
…now running node example.js
yields:
example.txt
1:1-1:5 warning `He’s` may be insensitive, use `They`, `It` instead he-she retext-equality
⚠ 1 warning
This package exports no identifiers.
The default export is retextEquality
.
Check for possible insensitive, inconsiderate language.
Configuration (optional).
List of phrases not to warn about (Array<string>
).
Do not allow binary references (boolean
, default: false
).
By default he
is warned about unless it’s followed by something like or she
or and she
.
When noBinary
is true
, both cases will be warned about.
See rules.md
for a list of rules and how rules work.
Each message is emitted as a VFileMessage
on file
, with the
following fields:
Name of this plugin ('retext-equality'
).
See id
in rules.md
.
Current not ok phrase (string
).
Suggest ok phrase (Array<string>
).
Extra info, when available (string?
).
This package is fully typed with TypeScript.
It exports the additional type Options
.
Projects maintained by the unified collective are compatible with all maintained versions of Node.js. As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+. Our projects sometimes work with older versions, but this is not guaranteed.
alex
— Catch insensitive, inconsiderate writingretext-passive
— Check passive voiceretext-profanities
— Check for profane and vulgar wordingretext-simplify
— Check phrases for simpler alternatives
See contributing.md
in retextjs/.github
for ways
to get started.
See support.md
for ways to get help.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.
To create new patterns, add them in the YAML files in the data/
directory, and run npm install
and then npm test
to build everything.
Please see the current patterns for inspiration.
New English rules will automatically be added to rules.md
.
When you are happy with the new rule, add a test for it in test.js
,
and open a pull request.