textlint filter rule that filters any word by allowing lists.
Install with npm:
npm install textlint-filter-rule-allowlist
Via .textlintrc(Recommended)
{
"filters": {
"allowlist": {
"allow": [
"ignored-word",
"/\\d{4}-\\d{2}-\\d{2}/",
"/===IGNORE===[\\s\\S]*?===\/IGNORE===/m"
]
}
}
}allow:string[]- allowing list String or RegExp-like String
allowlistConfigPaths:string[]- File path list that includes allow words.
- The File path is relative path from your
.textlintrc. - Support file format: JSON, yml
- Cannot use when using @textlint/editor
For example, you can specify allowlistConfigPaths to .textlintrc.
{
"filters": {
"allowlist": {
"allowlistConfigPaths": [
"./allow.json",
"./allow.yml"
]
}
}
}These files should be following formats.
allow.json:
[
"ignore-word",
"/yes/i"
]
allow.yml:
- "ignore-word",
- /yes/i
This filter rule support RegExp-like String.
RegExp-like String is that started with / and ended with / or /flag.
\d in string literal.
/\d/ should be "\\d".
For example, you want to ignore /\d{4}-\d{2}-\d{2}/ pattern, you can write allow as follows:
[
"/\\d{4}-\\d{2}-\\d{2}/"
]Some textlint rule has false-positive about unique noun. You want to ignore the error about unique noun.
For example, you want to ignore error about /github/i, you can write allow as follows:
allow.json:
[
"/github/i"
]
This rule treat RegExp-like string as /github/ig..
g(global) flag is added by default.
You want to ignore error between ===IGNORE=== mark.
allow.json:
[
"/===IGNORE===[\\s\\S]*?===/IGNORE===/m"
]
text:
ERROR Text => actual error
===IGNORE===
ERROR Text => it is ignored!
===/IGNORE===
ERROR Text => actual error
You want to ignore math expression($$ math expression $$) in Markdown.
allow.json:
[
"/\\$\\$[\\s\\S]*?\\$\\$/m"
]text:
$$
\begin{pmatrix}
1 & 0 & 0 \\\
0 & 1 & 0 \\\
0 & 0 & 1
\end{pmatrix}
$$
For more information, see textlint/regexp-string-matcher – Example
See Releases page.
The original name of this filter rule is textlint-filter-rule-whitelist.
We have migrated to use textlint-filter-rule-allowlist.
For more details, see following issue.
Install devDependencies and Run npm test:
npm i -d && npm test
Pull requests and stars are always welcome.
For bugs and feature requests, please create an issue.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature - Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin my-new-feature - Submit a pull request :D
MIT © azu