The pluggable natural language linter for text and markdown.
MIT License
Bot releases are hidden (Show)
Published by azu almost 8 years ago
Published by azu almost 8 years ago
Published by azu about 8 years ago
Published by azu over 8 years ago
--experimental
flag of shouldIgnore()
(b1e2a17)Filter rule provide filtering error that is reported by linting rule.
For example, textlint-filter-rule-comments provide filtering function by using comments.
<!-- textlint-disable -->
Disables all rules between comments
<!-- textlint-enable -->`
Allow to short textlint-filter-rule-comments
to comments
.
Add filter rule name to filters
field.
{
"filters": {
"comments": true
}
}
One more example, very-nice-rule
is useful, but you want to ignore some reported error in your text.
very-nice-rule
also check the BlockQuote
text, but you want to ignore the BlockQuote
text.
textlint-filter-rule-node-types rule resolve the issue.
{
"filters": {
"node-types": {
"nodeTypes": ["BlockQuote"]
}
},
"rules": {
"very-nice-rule": true
}
}
See Sharable Configuration for details.
Example : azu/textlint-config-readme: Sharable config for textlint
You can use the config via two step.
npm i -D @azu/textlint-config-readme textlint
$(npm bin)/textlint --config @azu/textlint-config-readme README.md
textlint 7.0 has some breaking change.
It will not affect textlint user, but affect to textlint rule developer.
Duplicated messages is ignored by default.
Duplicated messages is that have same range and same message.
(Not depended on ruleId. ruleId is flexible property)
textlint 7.0 sort message by line and column.
The rule that depended on the order of messages may fail test.
textlint 7.0 not support Node.js 0.12. (But still it work)
Requirement: Node.js 4.0.0 >=
Published by azu over 8 years ago
This is beta release
Please try it :)
npm install textlint@beta
Filter rule provide filtering error that is reported by linting rule.
For example, textlint-filter-rule-comments provide filtering function by using comments.
<!-- textlint-disable -->
Disables all rules between comments
<!-- textlint-enable -->`
Allow to short textlint-filter-rule-comments
to comments
.
Add filter rule name to filters
field.
{
"filters": {
"comments": true
}
}
One more example, very-nice-rule
is useful, but you want to ignore some reported error in your text.
very-nice-rule
also check the BlockQuote
text, but you want to ignore the BlockQuote
text.
textlint-filter-rule-node-types rule resolve the issue.
{
"filters": {
"node-types": {
"nodeTypes": ["BlockQuote"]
}
},
"rules": {
"very-nice-rule": true
}
}
See Sharable Configuration for details.
Example : azu/textlint-config-readme: Sharable config for textlint
You can use the config via two step.
npm i -D @azu/textlint-config-readme textlint
$(npm bin)/textlint --config @azu/textlint-config-readme README.md
textlint 7.0 has some breaking change.
It will not affect textlint user, but affect to textlint rule developer.
Duplicated messages is ignored by default.
Duplicated messages is that have same range and same message.
(Not depended on ruleId. ruleId is flexible property)
textlint 7.0 sort message by line and column.
The rule that depended on the order of messages may fail test.
textlint 7.0 not support Node.js 0.12. (But still it work)
Requirement: Node.js 4.0.0 >=
AST explorer for textlint is useful for understanding AST.
Try to run DEBUG=textlint* textlint README
See https://github.com/textlint/textlint/blob/master/docs/rule.md#implementation-node-memo for details.
These features are experimental
You can use it with --experimental
flag
$ textlint --experimental
Duplicated messages is ignored by default.
Duplicated messages is that have same position information(index) and same message.
Proposal #212 and implement #214
Support "filters" field and Drop support "ignoring-rule"
These are experimental feature. 🚧
See filter rule document for details.
{
"filters": {
"node-types": {
"nodeTypes": ["BlockQuote"]
}
},
"rules": {}
}
shouldIgnore(range, { ruleId })
API
shouldIgnore
.internal
MessageProcessManager
.TextLintMessage
s.{ ruleId }
option object to shouldIgnore
(#208) (de0ff6f)When the ruleId
of option object is matched ruleId of error message, filter only the message,
Default is filter all message in the ignoring range.
https://github.com/textlint/textlint-rule-ignore-comment
<!-- textlint-disable ruleA -->
this is wrong
<!-- textlint-enable -->
Disable specific rule on the fly.
shouldIgnore(range)
only ignore messages of the ruleId
.
It means that shouldIgnore(range)
=== shouldIgnore(range, { ruleId : this.id })
.
It attempt to make safe by default.
"*"
is danger because "*"
affect to other rules.
Published by azu over 8 years ago
shouldIgnore(range)
API #203Previously, ignoring api is shouldIgnore(<node>)
. #194
But, I think that shouldIgnore([start, end])
is better.
Because, ignoring rule is not always depended on .
It always depended on <range>
which is like [number, number]
.
This change is breaking change, but ignoring feature is experimental support.
As as result, we have published as minor version.
Fix: #202
Refs: #193
Published by azu over 8 years ago
You can use this TextLintNodeType
value by the following way:
import {TextLintNodeType} from "textlint";
console.log(TextLintNodeType.Str); // "Str"
Please see https://github.com/textlint/textlint/blob/master/docs/txtnode.md
Ignore rule is experimental. It used with --experimental
.
Please see https://github.com/textlint/textlint/blob/master/docs/rule.md
context.shouldIgnore(node)
🆕Show where the error is occurring.
When throw error in the rule.
module.exports = function (context) {
var exports = {};
exports[context.Syntax.Str + ":exit"] = function () {
throw new Error("Error in rule");
};
return exports;
};
Before:
Error in rule
After:
Error in rule at ~/textlint/textlint/test/rule-context/fixtures/test.md