The pluggable natural language linter for text and markdown.
MIT License
Bot releases are visible (Hide)
Published by github-actions[bot] over 1 year ago
plugins
for --init
option by @chick-p in https://github.com/textlint/textlint/pull/1039
$ npm install textlint textlint-plugin-html textlint-rule-preset-ja-technical-writing
$ npx textlint --init
will generate .textlintrc.json
{
"plugins": {
"html": true
},
"filters": {},
"rules": {
"preset-ja-technical-writing": true
}
}
Full Changelog: https://github.com/textlint/textlint/compare/v13.0.5...13.1.0
Published by github-actions[bot] over 1 year ago
This release correct ast-node-type
types.
Full Changelog: https://github.com/textlint/textlint/compare/v13.0.4...13.0.5
Published by github-actions[bot] over 1 year ago
It will reduce textlint
package size.
https://bundlephobia.com/package/[email protected]
https://bundlephobia.com/package/[email protected]
172.8kb ⬇️
Full Changelog: https://github.com/textlint/textlint/compare/v13.0.3...13.0.4
Published by github-actions[bot] over 1 year ago
It will reduce @textlint/kernel
package size.
15.1kb ⬇️
Full Changelog: https://github.com/textlint/textlint/compare/v13.0.2...13.0.3
Published by github-actions[bot] over 1 year ago
Full Changelog: https://github.com/textlint/textlint/compare/v13.0.1...13.0.2
Published by github-actions[bot] over 1 year ago
If you have used TextNodeRange
, TxtNodeLineLocation
, TxtNodePosition
, please change following:
- import type { TextNodeRange, TxtNodeLineLocation, TxtNodePosition } from "@textlint/ast-node-types";
+ import type { TxtNodeRange, TxtNodeLocation, TxtNodePosition } from "@textlint/ast-node-types";
Full Changelog: https://github.com/textlint/textlint/compare/v13.0.0...13.0.1
Published by github-actions[bot] over 1 year ago
textlint v13 support ESM rules/plugins 🎉
We have rewritten CLI and textlint
package.
However, it is not a breaking change for most textlint
CLI users.
Almost CLI behaviors are the same as textlint v12.
Please share your feedback to us!
textlint --init
output .textlintrc.json
textlint --init
output .textlintrc
@textlint/ast-node-types
types
- import type { TextNodeRange, TxtNodeLineLocation, TxtNodePosition } from "@textlint/ast-node-types";
+ import type { TxtNodeRange, TxtNodeLocation, TxtNodePosition } from "@textlint/ast-node-types";
createLinter
/loadTextlintrc
/loadLinterFormatter
/loadFixerFormatter
( If you want to know new APIs, please read Use as Node Modules)--stdin-filename
with --stdin
--stdin-filename
may be optional in Old-CLI0
: No Error
1
: Lint Error
2
: Fatal Error
textlint v12 supported next textlintrc, but it is undocumented way.
{
"rules": {
"preset-ja-technical-writing": true,
"ja-technical-writing/sentence-length": {
"max": 100 // It override preset-ja-technical-writing's option
}
}
}
textlint v13 will remove this undocumented way.
You need to use next textlintrc.
{
"rules": {
"preset-ja-technical-writing": {
"sentence-length": {
"max": 100 // It override preset-ja-technical-writing's option
}
}
}
}
For more details, see Configuring textlint · textlint
@textlint/ast-node-types
@textlint/ast-node-types
These types are defined in @textlint/ast-node-types
.
Type name | Node type | Description |
---|---|---|
ASTNodeTypes.Document | TxtDocumentNode(TxtParentNode) | Root Node |
ASTNodeTypes.DocumentExit | TxtDocumentNode(TxtParentNode) | |
ASTNodeTypes.Paragraph | TxtParagraphNode(TxtParentNode) | Paragraph Node |
ASTNodeTypes.ParagraphExit | TxtParagraphNode(TxtParentNode) | |
ASTNodeTypes.BlockQuote | TxtBlockQuoteNode(TxtParentNode) | > Block Quote Node |
ASTNodeTypes.BlockQuoteExit | TxtBlockQuoteNode(TxtParentNode) | |
ASTNodeTypes.List | TxtListNode(TxtParentNode) | List Node |
ASTNodeTypes.ListExit | TxtListNode(TxtParentNode) | |
ASTNodeTypes.ListItem | TxtListItemNode(TxtParentNode) | List (each) item Node |
ASTNodeTypes.ListItemExit | TxtListItemNode(TxtParentNode) | |
ASTNodeTypes.Header | TxtHeaderNode(TxtParentNode) | # Header Node |
ASTNodeTypes.HeaderExit | TxtHeaderNode(TxtParentNode) | |
ASTNodeTypes.CodeBlock | TxtCodeBlockNode(TxtParentNode) | Code Block Node |
ASTNodeTypes.CodeBlockExit | TxtCodeBlockNode(TxtParentNode) | |
ASTNodeTypes.HtmlBlock | TxtHtmlBlockNode(TxtParentNode) | HTML Block Node |
ASTNodeTypes.HtmlBlockExit | TxtHtmlBlockNode(TxtParentNode) | |
ASTNodeTypes.Link | TxtLinkNode(TxtParentNode) | Link Node |
ASTNodeTypes.LinkExit | TxtLinkNode(TxtParentNode) | |
ASTNodeTypes.Delete | TxtDeleteNode(TxtParentNode) | Delete Node(~Str~ ) |
ASTNodeTypes.DeleteExit | TxtDeleteNode(TxtParentNode) | |
ASTNodeTypes.Emphasis | TxtEmphasisNode(TxtParentNode) | Emphasis(*Str* ) |
ASTNodeTypes.EmphasisExit | TxtEmphasisNode(TxtParentNode) | |
ASTNodeTypes.Strong | TxtStrongNode(TxtParentNode) | Strong Node(**Str** ) |
ASTNodeTypes.StrongExit | TxtStrongNode(TxtParentNode) | |
ASTNodeTypes.Break | TxtBreakNode | Hard Break Node(Str<space><space> ) |
ASTNodeTypes.BreakExit | TxtBreakNode | |
ASTNodeTypes.Image | TxtImageNode | Image Node |
ASTNodeTypes.ImageExit | TxtImageNode | |
ASTNodeTypes.HorizontalRule | TxtHorizontalRuleNode | Horizontal Node(--- ) |
ASTNodeTypes.HorizontalRuleExit | TxtHorizontalRuleNode | |
ASTNodeTypes.Comment | TxtCommentNode | Comment Node |
ASTNodeTypes.CommentExit | TxtCommentNode | |
ASTNodeTypes.Str | TxtStrNode | Str Node |
ASTNodeTypes.StrExit | TxtStrNode | |
ASTNodeTypes.Code | TxtCodeNode | Inline Code Node |
ASTNodeTypes.CodeExit | TxtCodeNode | |
ASTNodeTypes.Html | TxtHtmlNode | Inline HTML Node |
ASTNodeTypes.HtmlExit | TxtHtmlNode | |
ASTNodeTypes.Table | TxtTableNode | Table node. textlint 13+ |
ASTNodeTypes.TableExit | TxtTableNode | |
ASTNodeTypes.TableRow | TxtTableRowNode | Table row node. textlint 13+ |
ASTNodeTypes.TableRowExit | TxtTableRowNode | |
ASTNodeTypes.TableCell | TxtTableCellNode | Table cell node. textlint 13+ |
ASTNodeTypes.TableCellExit | TxtTableCellNode |
Some nodes have additional properties.
For example, TxtHeaderNode
has level
property.
export interface TxtHeaderNode extends TxtParentNode {
type: "Header";
depth: 1 | 2 | 3 | 4 | 5 | 6;
children: PhrasingContent[];
}
For more details, see @textlint/ast-node-types
.
Full Changelog: https://github.com/textlint/textlint/compare/v12.6.1...13.0.0
Published by github-actions[bot] over 1 year ago
Full Changelog: https://github.com/textlint/textlint/compare/v12.6.0...12.6.1
Published by github-actions[bot] over 1 year ago
Full Changelog: https://github.com/textlint/textlint/compare/v12.5.1...12.6.0
Published by github-actions[bot] over 1 year ago
Full Changelog: https://github.com/textlint/textlint/compare/v12.5.1...12.5.2
Published by azu almost 2 years ago
Full Changelog: https://github.com/textlint/textlint/compare/v12.5.0...v12.5.1
Published by azu almost 2 years ago
--format=fixed-result
option to fixer format (755dba5), closes #967 by @Sean0628 in https://github.com/textlint/textlint/pull/978
Example:
$ cat README.md | npx textlint --stdin --stdin-filename README.md --fix --format fixed-result --output-file NEW.md
For more details, see https://textlint.github.io/docs/cli.html#pipe-to-textlint
Full Changelog: https://github.com/textlint/textlint/compare/v12.4.0...v12.5.0
Published by azu almost 2 years ago
Full Changelog: https://github.com/textlint/textlint/compare/v12.3.1...v12.4.0
Published by azu almost 2 years ago
createLinter
/loadTextlintrc
/loadLinterFormatter
/loadFixerFormatter
TextLintCore
/TextFixEngine
/TextLintEngine
📝 ESM Rules/Filter/Pluugins only works in createLinter
API.
This is because TextLintCore
/TextFixEngine
/TextLintEngine
were assumed to be synchronous processes.
createLinter
API does loading as async.
No changes in existing CLI.
--stdin-filename
with --stdin
--stdin-filename
may be optional in Old-CLI0
: No Error
1
: Lint Error
2
: Fatal Error
Ww introduce new API like createLinter
for supporting Async APIs.
v13 continue to support current TextLintEngine
and TextFixEngine
for backward compatible.
New createLinter
and loadTextlintrc
support ESM rules/plugins.
In other hands, TextLintEngine
and TextFixEngine
can not support ESM rules/plugins.
API | Description | Behavior | Target Platform | Prev Status | Next Status |
---|---|---|---|---|---|
cli | Command LIne Interface | Async | Node.js | ✅ | ✅ (Use createTextlint internally) |
textlint | TextLintCore alias | Async | Node.js/CommonJS | ❌ Deprecated | ❌ Deprecated |
TextLintCore | Old API. It is Procedural API. Lint Only Single File. Recommended to use @texltint/kernel module instead of It. | Async | Node.js/CommonJS | ❌ Deprecated | ❌ Deprecated |
TextLintEngine | Lint Engine API. It load .textlintrc automaticaly | ◉ Loading is Sync ◉ Linting is Async | Node.js/CommonJS | ✅ Recommended | ❌ Deprecated |
TextFixEngine | Fix Engine API. It load .textlintrc automaticaly | ◉ Loading is Sync ◉ Fixing is Async | Node.js/CommonJS | ✅ Recommended | ❌ Deprecated |
createLinter/loadTextlintrc | Support Async APIs. | ◉ Loading is Async◉ Linting/Fixing is Async | Node.js/CommonJS and ESM | None | ✅ Recommended |
createLinter
: create linter instance
lintFiles(files)
: lint files and return linter messageslintText(text, filePath)
lint text with virtual filePath and return linter messagesfixFiles(files
lint text and return fixer messagesfixText(text, filePath)
lint text with virtual filePath and return fixer messages
fixFiles
and fixText
does not modify filesloadTextlintrc
: load .textlintrc
config file and return a descriptor objectloadLinerFormatter
and loadFixerFormatter
: load formatterLint files and output to console.
import { createLinter, loadTextlintrc, loadLinterFormatter } from "textlint";
// descriptor is a structure object for linter
// It includes rules, plugins, and options
const descriptor = await loadTextlintrc();
const linter = createLinter({
descriptor
});
const results = await linter.lintFiles(["*.md"]);
// textlint has two types formatter sets for linter and fixer
const formatter = await loadLinterFormatter({ formatterName: "stylish" })
const output = formatter.format(results);
console.log(output);
For more details, see https://textlint.github.io/docs/use-as-modules.html
New CLI is opt-in for avoiding Breaking Changes.
It will be default in next major version.
You can try new textlint CLI via textlint-esm
command.
- $ textlint "**/*.md"
+ $ textlint-esm "**/*.md"
Or, when TEXTLINT_USE_NEW_CLI=1
is set, textlint use new CLI
$ TEXTLINT_USE_NEW_CLI=1 textlint "**/*.md"
🔥 Welcome to feedback on Discussion: https://github.com/textlint/textlint/discussions/968
fix #868
fix https://github.com/textlint/textlint/issues/744 - new CLI fix this
fix https://github.com/textlint/textlint/issues/103 - new CLI fix this
fix #797 - extends descriptor
instead of Config
fix #293 - TextlintCore
will be removed in the future
Published by azu almost 2 years ago
This release allow to lint dot file when setting dot file name for extensions
.
{
plugins: {
'@textlint/text': {
extensions: ['.lint-todo'],
},
}
rules: {
'eol-last': true,
}
};
This version can lint .lint-todo
file.
npx textlint .lint-todo
Published by azu almost 2 years ago
Published by azu about 2 years ago
This will fix pnpm issue #903
Published by azu over 2 years ago
Full Changelog: https://github.com/textlint/textlint/compare/v12.1.0...v12.2.1
Published by azu over 2 years ago
Implement Improve error location RFC #835
It will make the error location more details.
This change is for rule developer.
loc
and range
property to TextlintMessage
(result)padding
prorperty to RuleError(message, details)
.locator
object to rule's context
lcoator.at(index)
, locator.range([startIndex, endIndex])
, and locator.loc({ start: { line, column }, end: { line, column }})
.valid
and invalid
support range
propertyindex
, line
and column
property on TextlintMessage
and report
function
filterMessages
to use new range
property on TextlintMessage
readonly [number, number]
as range in all packagesfilterMessages
bug https://github.com/textlint/textlint/pull/836/commits/c8a670f9b4fd7ce628a940dc4c8faabd5e62d396
padding
and locator
objectpeerDependencies
notetextlint v12.2.0 will introduce padding
and locator
.
If your will use it, please add peerDependencies
to package.json
on your rule package.
"peerDependencies": {
"textlint": ">= 12.2.0"
},
"peerDependenciesMeta": {
"textlint": {
"optional": true
}
}
Before:
const { Syntax, report, RuleError } = context;
// .....
report(node, new RuleError(message, {
index: 1
}));
After:
const { Syntax, report, RuleError, locator } = context;
// .....
report(node, new RuleError(message, {
padding: locator.at(1)
}));
If you want to get more correct location, please use locator.range
or locator.loc
const { Syntax, report, RuleError, locator } = context;
// .....
report(node, new RuleError(message, {
padding: locator.range([1, 5]) // The error related to 1 - 5 index.
}));
For more details, see https://textlint.github.io/docs/rule.html#ruleerror