Skip to content

Commit 5f82d00

Browse files
authored
feat: Add support for all alex config options. (#7)
1 parent 4eccb02 commit 5f82d00

File tree

2 files changed

+45
-5
lines changed

2 files changed

+45
-5
lines changed

README.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ $ textlint --rule alex README.md
3131

3232
## Options
3333

34-
### `allow`
34+
See [Alex's configuration documentation](https://github.com/get-alex/alex#configuration).
3535

36-
See Alex's document: [Ignoring messages](https://github.com/wooorm/alex#ignoring-messages "Ignoring messages")
36+
### `allow`
3737

3838
```json
3939
{
@@ -45,6 +45,42 @@ See Alex's document: [Ignoring messages](https://github.com/wooorm/alex#ignoring
4545
}
4646
```
4747

48+
### `deny`
49+
50+
```json
51+
{
52+
"rules": {
53+
"alex": {
54+
"deny": ["boogeyman-boogeywoman"]
55+
}
56+
}
57+
}
58+
```
59+
60+
### `noBinary`
61+
62+
```json
63+
{
64+
"rules": {
65+
"alex": {
66+
"noBinary": true
67+
}
68+
}
69+
}
70+
```
71+
72+
### `profanitySureness`
73+
74+
```json
75+
{
76+
"rules": {
77+
"alex": {
78+
"profanitySureness": 2
79+
}
80+
}
81+
}
82+
```
83+
4884
## Tests
4985

5086
npm test

src/textlint-rule-alex.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
import {RuleHelper} from "textlint-rule-helper";
44
import alex from "alex";
55
const defaultOptions = {
6-
allow: []
6+
allow: undefined,
7+
deny: undefined,
8+
noBinary: false,
9+
profanitySureness: 0
710
};
811
module.exports = function textlintRuleAlex(context, options = {}) {
912
const {Syntax, RuleError, report, getSource} = context;
1013
const helper = new RuleHelper(context);
11-
const allowWords = options.allow || defaultOptions.allow;
14+
const opts = {...defaultOptions, ...options};
15+
console.log('opts', opts);
1216
/*
1317
{ [1:5-1:14: `boogeyman` may be insensitive, use `boogey` instead]
1418
message: '`boogeyman` may be insensitive, use `boogey` instead',
@@ -35,7 +39,7 @@ module.exports = function textlintRuleAlex(context, options = {}) {
3539
return;
3640
}
3741
const text = getSource(node);
38-
const messages = alex(text, allowWords).messages;
42+
const messages = alex(text, opts).messages;
3943
messages.forEach((result) => {
4044
reportError(node, result);
4145
});

0 commit comments

Comments
 (0)