diff --git a/README.md b/README.md index 6cc0153..e111391 100644 --- a/README.md +++ b/README.md @@ -31,9 +31,9 @@ $ textlint --rule alex README.md ## Options -### `allow` +See [Alex's configuration documentation](https://github.com/get-alex/alex#configuration). -See Alex's document: [Ignoring messages](https://github.com/wooorm/alex#ignoring-messages "Ignoring messages") +### `allow` ```json { @@ -45,6 +45,42 @@ See Alex's document: [Ignoring messages](https://github.com/wooorm/alex#ignoring } ``` +### `deny` + +```json +{ + "rules": { + "alex": { + "deny": ["boogeyman-boogeywoman"] + } + } +} +``` + +### `noBinary` + +```json +{ + "rules": { + "alex": { + "noBinary": true + } + } +} +``` + +### `profanitySureness` + +```json +{ + "rules": { + "alex": { + "profanitySureness": 2 + } + } +} +``` + ## Tests npm test diff --git a/src/textlint-rule-alex.js b/src/textlint-rule-alex.js index 2a1371b..79d9905 100644 --- a/src/textlint-rule-alex.js +++ b/src/textlint-rule-alex.js @@ -3,12 +3,16 @@ import {RuleHelper} from "textlint-rule-helper"; import alex from "alex"; const defaultOptions = { - allow: [] + allow: undefined, + deny: undefined, + noBinary: false, + profanitySureness: 0 }; module.exports = function textlintRuleAlex(context, options = {}) { const {Syntax, RuleError, report, getSource} = context; const helper = new RuleHelper(context); - const allowWords = options.allow || defaultOptions.allow; + const opts = {...defaultOptions, ...options}; + console.log('opts', opts); /* { [1:5-1:14: `boogeyman` may be insensitive, use `boogey` instead] message: '`boogeyman` may be insensitive, use `boogey` instead', @@ -35,7 +39,7 @@ module.exports = function textlintRuleAlex(context, options = {}) { return; } const text = getSource(node); - const messages = alex(text, allowWords).messages; + const messages = alex(text, opts).messages; messages.forEach((result) => { reportError(node, result); });