Releases: textlint/textlint-rule-helper
Releases · textlint/textlint-rule-helper
2.1.0
Bug Fixes
Features
- wrap: add
wrapReportHandler(context, options, handler): TextlintRuleReportHandlerfunction (c8fb78b)
wrapReportHandler is high-level and declarative API for ignore nodes.
We have designed that wrapReportHandler is easy to use.
If you want to ignore some Node's type, we recommended to use wrapReportHandler.
import { wrapReportHandler } from "textlint-rule-helper";
const reporter = function (context) {
const { Syntax, getSource } = context;
return wrapReportHandler(context, {
ignoreNodeTypes: [Syntax.BlockQuote, Syntax.Code]
},report => { // <= wrap version of context.report
// handler should return a rule handler object
return {
[Syntax.Paragraph](node) {
const text = getSource(node);
const index = text.search("code");
/*
* Following text is matched, but it will not reported.
* ----
* This is `code`.
* > code
* ----
*/
if(index === -1){
return;
}
report(node, new context.RuleError(item.name, {
index
}));
}
}
});
};
module.exports = reporter;2.0.1
2.0.0
Featues from 1.x
- add
IgnoreNodeManagerclass that it is useful for linting Paragraph node.
Breaking Change
- Fix typo: IgnoreNodeManger -> IgnoreNodeManager #5
You can upgrade and fix require like following
-var IgnoreNodeManger = require("textlint-rule-helper").IgnoreNodeManger;
+var IgnoreNodeManager = require("textlint-rule-helper").IgnoreNodeManager;