--dry-run
option is specified. by @Sean0628 in https://github.com/textlint/textlint/pull/1092Full Changelog: https://github.com/textlint/textlint/compare/v13.3.0...13.3.1
type
and ruleKey
to config descriptor by @azu in https://github.com/textlint/textlint/pull/1074Full Changelog: https://github.com/textlint/textlint/compare/v13.2.0...13.3.0
import TextLintTester from "textlint-tester";
import rule from "textlint-rule-no-todo";
const tester = new TextLintTester();
tester.run("rule name", rule, {
valid: [
{ text: "This is ok", description: "It is normal text" }
],
invalid: [
{
text: "- [ ] string",
description: "It todo test",
errors: [
{
message: "Found TODO: '- [ ] string'",
range: [2, 6]
}
]
}
]
});
Dependency Updates
Full Changelog: https://github.com/textlint/textlint/compare/v13.1.4...13.2.0
Full Changelog: https://github.com/textlint/textlint/compare/v13.1.3...13.1.4
engines
to require Node.js 16+ by @azu in https://github.com/textlint/textlint/pull/1054Full Changelog: https://github.com/textlint/textlint/compare/v13.1.2...13.1.3
Full Changelog: https://github.com/textlint/textlint/compare/v13.1.1...13.1.2
Full Changelog: https://github.com/textlint/textlint/compare/v13.1.0...13.1.1
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
}
}
Testing
Full Changelog: https://github.com/textlint/textlint/compare/v13.0.5...13.1.0
This release correct ast-node-type
types.
Full Changelog: https://github.com/textlint/textlint/compare/v13.0.4...13.0.5
It will reduce textlint
package size.
https://bundlephobia.com/package/textlint@13.0.3
https://bundlephobia.com/package/textlint@13.0.4
172.8kb ⬇️
Full Changelog: https://github.com/textlint/textlint/compare/v13.0.3...13.0.4
It will reduce @textlint/kernel
package size.
15.1kb ⬇️
Dependency UpdatesFull Changelog: https://github.com/textlint/textlint/compare/v13.0.2...13.0.3
Full Changelog: https://github.com/textlint/textlint/compare/v13.0.1...13.0.2
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";
Refactoring
Full Changelog: https://github.com/textlint/textlint/compare/v13.0.0...13.0.1
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!
🔥 Breaking Changestextlint --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
🆕 Features Add individual Node type and Add Table/TableRow/TableCell node #1008@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
Full Changelog: https://github.com/textlint/textlint/compare/v12.6.0...12.6.1
Full Changelog: https://github.com/textlint/textlint/compare/v12.5.1...12.6.0
Full Changelog: https://github.com/textlint/textlint/compare/v12.5.1...12.5.2
Full Changelog: https://github.com/textlint/textlint/compare/v12.5.0...v12.5.1
--format=fixed-result
option to fixer format (755dba5), closes #967 by @Sean0628 in https://github.com/textlint/textlint/pull/978Example:
$ 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
New ContributorsFull Changelog: https://github.com/textlint/textlint/compare/v12.4.0...v12.5.0
Full Changelog: https://github.com/textlint/textlint/compare/v12.3.1...v12.4.0
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.
Difference between Old-CLI and New-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 instancelintFiles(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 messagesfixFiles
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
How to use New CLINew 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
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
This will fix pnpm issue #903
Dependencies UpdatesFull Changelog: https://github.com/textlint/textlint/compare/v12.1.0...v12.2.1
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 contextlcoator.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
functionfilterMessages
to use new range
property on TextlintMessage
readonly [number, number]
as range in all packagesfilterMessages
bug https://github.com/textlint/textlint/pull/836/commits/c8a670f9b4fd7ce628a940dc4c8faabd5e62d396padding
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
}
}
For textlint rule creator
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
It will resolve the following audit alert.
ansi-regex 2.1.1 ~ 5.0.0 is vulnerable to Inefficient Regular Expression Complexity: https://github.com/advisories/GHSA-93q8-gq69-wqmw
Thanks to @massongit
CommitsThe npm dependency table@3.8.3 depends on ajv@4.11.8 which is vulnerable #801
12.0.2 fixes this dependendies
Bug FixesBlog: https://textlint.github.io/blog/2021/05/24/textlint-12.html
SummaryFor textlint user
textlint improves markdown parsing, so it may found newer errors.
You can upgrade textlint via following commands:
npm install textlint@12
# or
yarn install textlint@12
textlint 12.0.0 requires Node.js 12+. If you are using Node.js 10.x, please upgrade your Node.js env.
For textlint rule creator
textlint-tester
and textlint-scripts
are updated.
npm install textlint-scripts@12 --save-dev
# or
yarn install textlint-scripts@12 --dev
textlint-tester@12
use export default
instead of modules.exports =
.
So, you need to use import TextLintTester from "textlint-tester"
instead of const TextLintTester = require("textlint-tester")
.
- const TextLintTester = require("textlint-tester");
+ import TextLintTester from "textlint-tester";
Breaking Changes
@textlint/*
internal modules use same version12.0.0
.engines
filels to "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
@textlint/markdown-to-ast@12
use remark@13.0.0Breaking Changes | Package | Previous version | Current version |
---|---|---|---|
✔ | textlint | 11.9.1 | 12.0.0 |
✔ | textlint-tester | 5.3.5 | 12.0.0 |
✔ | textlint-scripts | 3.0.0 | 12.0.0 |
@textlint/ast-node-types | 4.4.3 | 12.0.0 | |
@textlint/ast-traverse | 2.3.5 | 12.0.0 | |
@textlint/ast-tester | 2.3.5 | 12.0.0 | |
@textlint/feature-flag | 3.3.5 | 12.0.0 | |
@textlint/fixer-formatter | 3.3.5 | 12.0.0 | |
@textlint/kernel | 3.4.5 | 12.0.0 | |
@textlint/linter-formatter | 3.3.5 | 12.0.0 | |
@textlint/module-interop | 1.2.5 | 12.0.0 | |
✔ | @textlint/textlint-plugin-markdown | 5.3.5 | 12.0.0 |
@textlint/textlint-plugin-text | 4.3.5 | 12.0.0 | |
✔ | @textlint/types | 1.5.5 | 12.0.0 |
@textlint/utils | 1.2.5 | 12.0.0 |
Now, This monorepo includes textlint-scripts
package. #779
Move https://github.com/textlint/textlint-scripts to https://github.com/textlint/textlint/tree/master/packages/textlint-scripts
@textlint/markdown-to-ast
It is a markdown parser in textlint. We have updated to remark@13.0.0 #717 and it has many changes related to Markdown AST
You can see the changes at feat(markdown-to-ast): update to remark-parse@9 #767
It also updates trim
package that is CVE-2020-7753.
FootnoteReference
node
The NATO phonetic alphabet[^wiki].
[^wiki]: Read more about it on wikipedia: <http://en.wikipedia.org/wiki/NATO_phonetic_alphabet>.
Previously, It is called LinkReference
, textlint@12 treat it as FootnoteReference
.
Some rules may report new errors on FootnoteReference
.
textlint-tester
export default
instead of export =
#775 #689 The textlint-tester
user should use import
instead of require
.
- const TextLintTester = require("textlint-tester");
+ import TextLintTester from "textlint-tester";
Or, pick default
property.
- const TextLintTester = require("textlint-tester");
+ const TextLintTester = require("textlint-tester").default;
textlint-scripts
@textlint/types
getSource
argument type #770 @textlint/ast-tester
Discussion: https://github.com/textlint/textlint/discussions/789
textlint user
npm install textlint@beta
textlint rule creator
npm install textlint-scripts@beta
See details in #738
12.0.0 beta release
See details in #738.
Please try it and report bugs
npm install textlint@beta
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
Bug Fixes
Features
-f
option resolve from pcakage name (b6b2b5b)See https://github.com/textlint/textlint/blob/master/docs/formatter.md for details on.
textlint-rule-preset-XXX
support
e.g.)
Rule-preset is a collection of rules.
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 => {
//
});
Festures
export default function (context) {
return {
[Syntax.Str](node){
// textlint wait for resolved the promise.
return new Promise((resolve, reject) => {
// async task
});
}
}
}
value
(c00646c)Breaking Change
TextLintMessage
#38 #40 The Breaking Change related to textlint
module user(use-as-modules.md).
Features
TextLintEngine#executeOnText
and textlint#lintText
support ext
arguments. #36 executeOnText(text, ".md")
TextLintCore
#41 Fixed
Breaking Changesuse mdast instead of CommonMark by azu · Pull Request #3 · azu/markdown-to-ast
markdown-to-ast 3.0.0 has some breaking changes.
use mdast instead of CommonMarkBreak CommonMark dependent. If you have used CommonMark-dependent code, it may be broken.
CodeBlock
Node
before:
CodeBlock.raw
have not contain CodeBlock mark like ```
var code = 1;
after:
CodeBlock.raw
have contain CodeBlock mark like ```
The raw value of CodeBlock
node is following:
```
var code = 1;
```
if you want to get only code value, can get from node.vaule
.
before(CommonMark):
Alt text of Image node is Str
node.
after(mdast):
Alt text of Image node is not Str
node.
It is true that Alt text is a attribute of Image Node.
Rename CLIEngine to TextLintEngine
Update document and please see docs/use-as-modules.md.
Usage:
"use strict";
var TextLintEngine = require("textlint").TextLintEngine;
var path = require("path");
function lintFile(filePath) {
/**
* @type {TextLintConfig}
* See lib/_typing/textlint.d.ts
*/
var options = {
// load rules from [../rules]
rulePaths: [path.join(__dirname, "..", "rules/")],
formatterName: "pretty-error"
};
var engine = new TextLintEngine(options);
var filePathList = [path.resolve(process.cwd(), filePath)];
var results = engine.executeOnFiles(filePathList);
if (engine.isErrorResults(results)) {
var output = engine.formatResults(results);
console.log(output);
}
}
Bug Fixes
Features
We use azu/markdown-to-ast as markdown parser module, now! (It's based on CommonMarkdown)
It make context.getSource()
more correct!