The pluggable natural language linter for text and markdown.
MIT License
Bot releases are visible (Hide)
If you want to know for detail, please see the documents: https://github.com/textlint/textlint/blob/master/docs/rule.md#ruleerror
Previously, textlint's RuleError
support line
and column
.
e.g.) It is wrong that column
doen't consider line break.
// surrogate pair
function stringToArray(value) {
return value.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
}
export default function (context) {
let {Syntax, RuleError, report, getSource} = context;
return {
[Syntax.Str](node){
const text = getSource(node);
const strArray = stringToArray(text);
for (let index = 0; index < strArray.length; index++) {
const item = strArray[index];
if (/❌/.test(item)) {
report(node, new RuleError("Use X insteadof ❌", {
column: index
}));
}
}
}
}
}
Input:
string
❌
string
Result of TextLintMessage:
{
"message": "Use X insteadof ❌",
"line": 1,
"column": 7
}
Expected:
{
"message": "Use X insteadof ❌",
"line": 2,
"column": 1
}
5.6.0 allow to write this like
// surrogate pair
function stringToArray(value) {
return value.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
}
export default function (context) {
let {Syntax, RuleError, report, getSource} = context;
return {
[Syntax.Str](node){
const text = getSource(node);
const strArray = stringToArray(text);
for (let index = 0; index < strArray.length; index++) {
const item = strArray[index];
if (/❌/.test(item)) {
report(node, new RuleError("Use X insteadof ❌", {
index: index // <= index
}));
}
}
}
}
}
)
Published by azu over 8 years ago
Published by azu over 8 years ago
Published by azu over 8 years ago
--fix
and --experimental
support ⚠️Status: experimental 🚧
You can use automatically fixes feature with experimental flag.
$ textlint --experimental --fix README.md
# fixed by each rule
Currently, --fix
is unstable(use with --experimental
).
It mean that there is a possibility of change in the future.
Not all rules is fixable.
So, it is difficult that make all rules fixable.
🚧 If you found a bug, please file issue 🆘
ℹ️ Please See Creating fixable rule for detail.
If you want to improve fixable feature, please comment above the issue.
We don't think that this feature is complete 💭
If you see following error
.../node_modules/textlint/lib/textlint-core.js:80
throw new Error('Definition for rule \'' + key + '\' was not found.');
^
Error: Definition for rule 'prh' was not found.
You should update textlint to ^5.5
.
Some rules like textlint-rule-prh
dependent on textlint >= 5.5
.
npm install -D textlint@^5.5
Published by azu over 8 years ago
Published by azu over 8 years ago
fix
options (8fce575)Published by azu over 8 years ago
If you see this warning, please update textlint to 5.4.1.
(node) warning: possible EventEmitter memory leak detected. 11 Str listeners added. Use emitter.setMaxListeners() to increase limit.
Published by azu over 8 years ago
--init
option like eslint. #127 by @takahashimtextlint --init
create a .textlintrc
file in your directory.
$ textlint --init
If you are instersted in improving this, please see --init options: Create .textlintrc file #129
In previous version, textlint can't lint specific file that contain table syntax.
[email protected] can lint the file that contain table syntax.
| Hello | World |
| :---- | -----: |
| How | are |
| you | today? |
We have updated markdown-to-ast@3.2.3 and remark@4.0.0.
[email protected] contain some breaking changes.
But, these changes are not related with things that are defined in textlint's specification.
Example:
See Release 4.0.0 · wooorm/remark for more detail on.
Not set rule and Not configure .textlintrc
Before:
$ textlint README.md
After:
$ textlint README.md
== Not have rules, textlint do not anything ==
=> How to set rule?
See https://github.com/textlint/textlint/blob/master/docs/configuring.md
-f
option resolve from pcakage name (b6b2b5b)See https://github.com/textlint/textlint/blob/master/docs/formatter.md for details on.
Published by azu almost 9 years ago
textlint-rule-preset-XXX
support
e.g.)
Rule-preset is a collection of rules.
Published by azu almost 9 years ago
Make Lint API asynchronous!
Lint API always return Promise.
TextLintCore#LintFile
TextLintCore#LintText
TextLintEngine#executeOnFiles
TextLintEngine#executeOnText
cli#execute
var textlint = new TextLintCore();
textlint.lintMarkdown("text").then(result => {
//
});
export default function (context) {
return {
[Syntax.Str](node){
// textlint wait for resolved the promise.
return new Promise((resolve, reject) => {
// async task
});
}
}
}
value
(c00646c)Published by azu almost 9 years ago
Published by azu almost 9 years ago