textlint

textlint

  • Docs
  • Rules
  • Blog
  • Help
  • GitHub

›Recent Posts

Recent Posts

  • textlint v13.0.0
  • textlint v12.0.0
  • textlint 11 released
  • New website
  • Renewing

textlint v13.0.0

January 27, 2023

azu

We just publish textlint v13.0.0, which is a major release upgrade of textlint.

textlint v13 support ESM rules/plugins native.

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.

Summary

For textlint user

You can upgrade textlint via following commands:

npm install textlint@13 --save-dev
# or
yarn install textlint@13 --dev

textlint 13.0.0 requires Node.js 16+. If you use Node.js 14, you need to upgrade Node.js to 16+.

  • Download | Node.js

For textlint rule creator

You can write own rule as ESM module.

textlint v13.0.0 can load ESM rules native. So you need to transpile your rule to CommonJS.

textlint CLI load ESM rules and lint files!

:warning: However, textlint editor plugin may not support ESM rules yet. You need to wait for editor plugin author migrate to textlint new APIs.

For textlint module user

If you use textlint as node module, you should use new APIs.

textlint package provides new APIs from v12.3.0

We have introduced new API like createLinter for supporting Async APIs. v13 continue to support current TextlintCore, TextLintEngine and TextFixEngine for backward compatible. However, These API will be retired in the future.

New createLinter and loadTextlintrc supports ESM rules/plugins. textlint modules user should use these instead of TextlintCore, TextLintEngine and TextFixEngine.

ℹ️ Timeline:

  • textlint v12.3.0 support old APIs(deprecated) and new APIs
    • use old APIs as default
  • textlint v13.0.0 support old APIs(deprecated) and new APIs
    • use new APIs as default - CURRENT
  • textlint v14.0.0 drop to support old APIs
APIDescriptionBehaviorTarget Platformv13+
cliCommand LIne InterfaceAsyncNode.js✅ (Use createLinter and loadTextlintrc internally)
textlintTextLintCore aliasAsyncNode.js/CommonJS❌ Deprecated
TextLintCoreOld API. It is Procedural API. Lint Only Single File. Recommended to use @texltint/kernel module instead of It.AsyncNode.js/CommonJS❌ Deprecated
TextLintEngineLint Engine API. It load .textlintrc automaticaly◉ Loading is Sync
◉ Linting is Async
Node.js/CommonJS❌ Deprecated
TextFixEngineFix Engine API. It load .textlintrc automaticaly◉ Loading is Sync
◉ Fixing is Async
Node.js/CommonJS❌ Deprecated
createLinter/loadTextlintrcSupport Async APIs.◉ Loading is Async
◉ Linting/Fixing is Async
Node.js/CommonJS and ESM✅ Recommended

New APIs

textlint v12.3.0 introduce new APIs. textlint will drop support old APIs(textlint, TextLintEngine, TextFixEngine, and TextLintCore) in the future.

📝 Old APIs can not support ECMAScript modules, new APIs support ECMAScript modules.

  • createLinter: create linter instance
    • lintFiles(files): Promise<TextlintResult[]>: lint files and return linter messages
    • lintText(text, filePath): Promise<TextlintResult> lint text with virtual filePath and return linter messages
    • fixFiles(files): Promise<TextlintFixResult[]> lint text and return fixer messages
    • fixText(text, filePath): Promise<TextlintFixResult> lint text with virtual filePath and return fixer messages
      • fixFiles and fixText does not modify files
  • loadTextlintrc: load .textlintrc config file and return a descriptor object
  • loadLinerFormatter and loadFixerFormatter: load formatter

Examples

Lint 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, please read next document.

  • Use as Node Modules · textlint

If you have any questions, please ask us via GitHub Discussion.

  • Feedback for new APIs · Discussion #968 · textlint/textlint

ChangeLog

🔥 Breaking Changes

  • Require Node.js 16+
  • textlint --init output .textlintrc.json
    • Previously, textlint --init output .textlintrc
  • Improve @textlint/ast-node-types types
    • Now, All node types are defined!
    • It changes the existing node type and it is a breaking change
    • If you want to know TxtAST, please read TxtAST Interface
  • Use New-CLI instead of Old-CLI
    • textlint has introduced New-CLI and New-APIs in v12.3.0
    • New-CLI uses new APIs: createLinter/loadTextlintrc/loadLinterFormatter/loadFixerFormatter( If you want to know new APIs, please read Use as Node Modules)
    • It means that textlint support rules/plugins that are written by ESM 🎉
    • Remove Old-CLI

Difference between Old-CLI and New-CLI

  • New CLI support ESM rules/plugins
  • New CLI must require --stdin-filename with --stdin
    • --stdin-filename may be optional in Old-CLI
  • Correct exit status

Exit Status on new CLI

0: No Error

  • Not found lint error
  • --fix: found errors but fix all errors, so exit with 0
  • --output-file: Found lint error but --output-file is specified
  • --dryRun: Found lint error but --dryRun is specified

1: Lint Error

  • found lint error
  • --fix: found errors and could not fix all errors, so exit with 1

2: Fatal Error

  • Crash textlint process
  • Fail to load config/rule/plugin etc...

🆕 Features

Add individual Node type and Add Table/TableRow/TableCell node #1008

  • Define all node types in @textlint/ast-node-types
  • Add Table/TableRow/TableCell node to @textlint/ast-node-types

These types are defined in @textlint/ast-node-types.

Type nameNode typeDescription
ASTNodeTypes.DocumentTxtDocumentNode(TxtParentNode)Root Node
ASTNodeTypes.DocumentExitTxtDocumentNode(TxtParentNode)
ASTNodeTypes.ParagraphTxtParagraphNode(TxtParentNode)Paragraph Node
ASTNodeTypes.ParagraphExitTxtParagraphNode(TxtParentNode)
ASTNodeTypes.BlockQuoteTxtBlockQuoteNode(TxtParentNode)> Block Quote Node
ASTNodeTypes.BlockQuoteExitTxtBlockQuoteNode(TxtParentNode)
ASTNodeTypes.ListTxtListNode(TxtParentNode)List Node
ASTNodeTypes.ListExitTxtListNode(TxtParentNode)
ASTNodeTypes.ListItemTxtListItemNode(TxtParentNode)List (each) item Node
ASTNodeTypes.ListItemExitTxtListItemNode(TxtParentNode)
ASTNodeTypes.HeaderTxtHeaderNode(TxtParentNode)# Header Node
ASTNodeTypes.HeaderExitTxtHeaderNode(TxtParentNode)
ASTNodeTypes.CodeBlockTxtCodeBlockNode(TxtParentNode)Code Block Node
ASTNodeTypes.CodeBlockExitTxtCodeBlockNode(TxtParentNode)
ASTNodeTypes.HtmlBlockTxtHtmlBlockNode(TxtParentNode)HTML Block Node
ASTNodeTypes.HtmlBlockExitTxtHtmlBlockNode(TxtParentNode)
ASTNodeTypes.LinkTxtLinkNode(TxtParentNode)Link Node
ASTNodeTypes.LinkExitTxtLinkNode(TxtParentNode)
ASTNodeTypes.DeleteTxtDeleteNode(TxtParentNode)Delete Node(~Str~)
ASTNodeTypes.DeleteExitTxtDeleteNode(TxtParentNode)
ASTNodeTypes.EmphasisTxtEmphasisNode(TxtParentNode)Emphasis(*Str*)
ASTNodeTypes.EmphasisExitTxtEmphasisNode(TxtParentNode)
ASTNodeTypes.StrongTxtStrongNode(TxtParentNode)Strong Node(**Str**)
ASTNodeTypes.StrongExitTxtStrongNode(TxtParentNode)
ASTNodeTypes.BreakTxtBreakNodeHard Break Node(Str<space><space>)
ASTNodeTypes.BreakExitTxtBreakNode
ASTNodeTypes.ImageTxtImageNodeImage Node
ASTNodeTypes.ImageExitTxtImageNode
ASTNodeTypes.HorizontalRuleTxtHorizontalRuleNodeHorizontal Node(---)
ASTNodeTypes.HorizontalRuleExitTxtHorizontalRuleNode
ASTNodeTypes.CommentTxtCommentNodeComment Node
ASTNodeTypes.CommentExitTxtCommentNode
ASTNodeTypes.StrTxtStrNodeStr Node
ASTNodeTypes.StrExitTxtStrNode
ASTNodeTypes.CodeTxtCodeNodeInline Code Node
ASTNodeTypes.CodeExitTxtCodeNode
ASTNodeTypes.HtmlTxtHtmlNodeInline HTML Node
ASTNodeTypes.HtmlExitTxtHtmlNode
ASTNodeTypes.TableTxtTableNodeTable node. textlint 13+
ASTNodeTypes.TableExitTxtTableNode
ASTNodeTypes.TableRowTxtTableRowNodeTable row node. textlint 13+
ASTNodeTypes.TableRowExitTxtTableRowNode
ASTNodeTypes.TableCellTxtTableCellNodeTable cell node. textlint 13+
ASTNodeTypes.TableCellExitTxtTableCellNode

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.

  • @textlint/ast-node-types/src/NodeType.ts.

Full Changelog

  • textlint v13.0.0 - textlint

Thanks for Support!

Many people support us, Thanks!

If you're interested in GitHub Sponsor, please check @azu on GitHub Sponsors!

textlint v12.0.0

May 24, 2021

azu

We just publish textlint v12.0.0, which is a major release upgrade of textlint.

This release adds some new features and fixes several bugs found in the previous release. This release also has some breaking changes.

Summary

For 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.

  • Download | Node.js

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";

Migration script using Semgrep.

# Install semgrep
# For macOS
$ brew install semgrep

# For Ubuntu / Windows via WSL / Linux / macOS
$ python3 -m pip install semgrep

# ---- After installation ----

# Run migration script
semgrep --config s/azu:textlint-12-migration

Breaking Changes

  • All @textlint/* internal modules use same version
    • All modules are released as 12.0.0.
  • Drop Node.js 10.x support #600
    • update engines filels to "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
  • Modules require ES2015 supported environments #777 #774
    • Now, all module target is ES2015
    • It means that textlint does not support IE
    • 📝 Node.js 12+ support ES2018+
  • Built-in markdown parser is updated
    • @textlint/markdown-to-ast@12 use remark@13.0.0

Package Versions

Breaking ChangesPackagePrevious versionCurrent version
✔textlint11.9.112.0.0
✔textlint-tester5.3.512.0.0
✔textlint-scripts3.0.012.0.0
@textlint/ast-node-types4.4.312.0.0
@textlint/ast-traverse2.3.512.0.0
@textlint/ast-tester2.3.512.0.0
@textlint/feature-flag3.3.512.0.0
@textlint/fixer-formatter3.3.512.0.0
@textlint/kernel3.4.512.0.0
@textlint/linter-formatter3.3.512.0.0
@textlint/module-interop1.2.512.0.0
✔@textlint/textlint-plugin-markdown5.3.512.0.0
@textlint/textlint-plugin-text4.3.512.0.0
✔@textlint/types1.5.512.0.0
@textlint/utils1.2.512.0.0

Now, This monorepo includes textlint-scripts package in #779.

@textlint/markdown-to-ast

It is a markdown parser in textlint. We have updated to remark@13.0.0, 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

This package updates also includes security fixes. CVE-2020-7753 has been fixed in textlint 12.0.0.

  • Regular Expression Denial of Service in trim · CVE-2020-7753 · GitHub Advisory Database

Features

Add 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.

Known bugs

  • gfm parsing bug that generate broken AST: remarkjs/remark-gfm#16
    • → textlint use workaround: remarkjs/remark-gfm#16 (comment) at c99218e
    • → markdown-to-ast does not generate broken AST.

textlint-tester

  • use 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

  • Update to mocha@8

@textlint/types

  • Fix getSource argument type #770

@textlint/ast-tester

  • Improve error message #783

Community News 🆕

  • textlint-plugin-latex2e reach to v1.0.0 🎉
    • textlint can lint LaTeX files with this plugin
  • @textlint/editor beta released 🎉
    • textlint works on your browser as browser extension
    • textlint editor - Firefox
    • textlint editor - Chrome
    • It's purpose is privacy first linting tools!

Thanks to Support!

VELC supports @azu as GitHub Sponsors!

  • 会社(ヴェルク)としてGithub Sponsorsになりました - ヴェルク - IT起業の記録 (Japanese blog)

Many people support me, Thanks again!

If you're interested in GitHub Sponsor, please check @azu on GitHub Sponsors!

textlint 11 released

July 22, 2018

azu

We just pushed textlint v11.0.0, which is a major release upgrade of textlint.

This release adds some new features and fixes several bugs found in the previous release. This release also has some breaking changes.

Highlights

⭐️ Features

@textlint/textlint-plugin-text and @textlint/textlint-plugin-markdown support extensions option

Notes: @textlint/textlint-plugin-text and @textlint/textlint-plugin-markdown are built-in plugin.

For example, if you want to treat .hown as markdown, put extensions options to .textlintrc

{
    "plugins": {
        "@textlint/markdown": {
            "extensions": [".hown"]
        }
    }
}

For more details, please see custom extension example.

For developer:

if you want to support extensions options, see Plugin · textlint.

Show message if textlint --init is success #529

Add message to textlint --init

screen shot

🔥BREAKING CHANGE

Drop Node.js 4.x support #443

textlint does no more test on Node.js 4.x. Node.js 4.x was end of support.

  • nodejs/Release: Node.js Foundation Release Working Group

If you use Node.js 4.x, please update Node.js.

  • Node.js official site

[Developer] Freeze Rule's Context #508

textlint 11 freeze rule's context object.

Next code should throw error in textlint 11.

export default function(context) {
    // Error: `context` object can not be modified
    context.modifiedContext = true;
    const { Syntax } = context;
    return {
        [Syntax.Str](node) {
        }
    };
}

[Developer] Change default value of Rule's options and Plugin's options #535 #540

textlint@11 change the default value of options from true to {} (empty object).

For example, very-nice-rule's option is true(enable the rule) in .textlintrc

{
  "rules": {
    "very-nice-rule": true
  }
}

Before

very-nice-rule.js rule get true as options.

export default function(context, options) {
    console.log(options); // true
}

After:

very-nice-rule.js rule get {} (emptry object) as options.

export default function(context, options) {
    console.log(options); // {}
}

⚠ Deprecation

[Developer] Deprecate static availableExtensions() in plugin Processor

Insteadof it, support availableExtensions() instance method in plugin #534

You should change the implementaion of plugin. textlint still support static availableExtensions for backward-compatibility.

-    static availableExtensions() {
+    availableExtensions() {
        return [".txt", ".text"];
    }

This change allow to extends availableExtensions() by options.

  • Example: feat: markdown/text plugin support "extensions" options by azu · Pull Request #537 · textlint/textlint

For more information, see availableExtensions(): string[].


ALL CHANGELOG

textlint@11.0.0

fixes

  • textlint: add engine.availableExtensions for backward-compatible (e8652bc)
  • textlint: fix config type (0f2fd6f)
  • deps: update mocha (5df8af4)
  • textlint: add type of public TextlintrcDescriptor (7268b9e)
  • textlint: make static availableExtensions() optional (d471637)
  • remove @textlint/textlintrc-descriptor (3613e1f)
  • textlint: use shallowMerge (95d056d)
  • kernel: merge textlintrc-descriptor to kernel (3c01067)
  • kernel: separate linter and fixer descriptor (b5bc8bd)
  • textlint: fix to import util (6629bd5)
  • textlint: remove `extensions` from Config (7bc9ab8)
  • textlintrc-descriptor: Introduce textlintrc-descriptor (6177794)

features

  • textlint: show message if `textlint --init` is success (#529) (102d568)
  • textlint: support availableExtensions() instance method in plugin (a7cd053)
  • kernel: add plugin's option tests (f362257)
  • textlint: add cli output test (#533) (abd314a), closes #532
  • textlint: add tests for object-to-kernel-format (5fbb22d)
  • textlint: fix plugin tests (bbfc8f6)

breakingChanges

#535 #540

Change default value of Rule's options and Plugin's options.

textlint@11 change the default value of options from true to {} (empty object).

For example, very-nice-rule's option is true(enable the rule) in .textlintrc

{
  "rules": {
    "very-nice-rule": true
  }
}

Before

very-nice-rule.js rule get true as options.

export default function(context, options) {
    console.log(options); // true
}

After:

very-nice-rule.js rule get {} (emptry object) as options.

export default function(context, options) {
    console.log(options); // {}
}

@textlint/kernel@3.0.0

fixes

  • kernel: kernel use TextlintrcDescriptor (efd89c2)
  • kernel: make rule and plugin's option value {} by default (b7aa63d)
  • deps: update mocha (5df8af4)
  • remove @textlint/textlintrc-descriptor (3613e1f)
  • kernel: add comment (582d0d6)
  • kernel: add Processor validation (86ed609)
  • kernel: fix test title (4eeeff8)
  • kernel: support instance availableExtensions() method (b821fc5)
  • textlint: make static availableExtensions() optional (d471637)
  • textlint: use shallowMerge (95d056d)
  • kernel: merge textlintrc-descriptor to kernel (3c01067)
  • kernel: remove TextlintRuleDescriptorType (a5b0f30)
  • kernel: Replace Object.freeze directly with factory function (c43580b)
  • kernel: separate linter and fixer descriptor (b5bc8bd)
  • kernel: use textlintrc-descriptor instead of rule-creator-helper (f0eb4bf)
  • textlintrc-descriptor: Introduce textlintrc-descriptor (6177794)
  • typescript: update to TypeScript 2.8 (f7b2b08)

features

  • kernel: Freeze Context (7fc9ec8), closes #508 #508
  • textlint: support availableExtensions() instance method in plugin (a7cd053)
  • kernel: Add missing Readonly<T> (c5313c8)
  • kernel: add plugin's option tests (f362257)
  • textlint: add tests for object-to-kernel-format (5fbb22d)

breakingChanges

  • kernel: Previously, textlint pass true to rule and plugin as default value of option. #535 #540

@textlint/textlint-plugin-markdown@5.0.0

fixes

  • kernel: make rule and plugin's option value {} by default (b7aa63d)
  • deps: update mocha (5df8af4)
  • plugin: add plugin configuration (6e179ec)

features

  • textlint-plugin-markdown: Support "extensions" option (c3d55fe)

breakingChanges

  • kernel: Previously, textlint pass true to rule and plugin as default value of option. #535 #540

@textlint/textlint-plugin-text@4.0.0

fixes

  • kernel: make rule and plugin's option value {} by default (b7aa63d)
  • deps: update mocha (5df8af4)
  • plugin: add "extensions" option to docs (8026997)
  • plugin: add plugin configuration (6e179ec)

features

  • textlint-text-markdown: support "extensions" option (cce29ed)

breakingChanges

  • kernel: Previously, textlint pass `true` to rule and plugin as default value of option. #535 #540

gulp-textlint@5.0.11

fixes

  • deps: update to natives@1.1.3 (0c20f42)
  • deps: update mocha (5df8af4)

textlint-tester@5.0.0

fixes

  • kernel: make rule and plugin's option value {} by default (b7aa63d)
  • deps: update mocha (5df8af4)
  • kernel: separate linter and fixer descriptor (b5bc8bd)

breakingChanges

  • kernel: Previously, textlint pass `true` to rule and plugin as default value of option.

textlint-website@10.4.0

fixes

  • website: update index.css (6f7977e)
  • website: use https image (4495ed3)
  • website: use short menu name (81911ad)
  • website: add { search: true }, (0c3c4a9)
  • website: add Edit url (e85c6bf)
  • website: add new blog (cabc987)
  • website: add project link (2000dc4)
  • website: add textlint icon (54873c0)
  • website: change vuejs usecase (9d832e5)
  • website: Add a project depends on textlint (#523) (80b4b73)

features

  • website: enable search (9e18b9e)

New website

May 22, 2018

azu

textlint get a new website!

website

  • @0x6b start to work migrate exising document to website.
  • @uetchy design this website.
  • @azu implement the design and deploy.

If you have used textlint in your project or your office, please pull request to add your project to Users!

  • textlint · users

Related Issues

  • Introduce Docusaurus by 0x6b · Pull Request #461 · textlint/textlint
  • website: design · Issue #467 · textlint/textlint

Renewing

January 13, 2018

0x6b

We're renewing our website to be able to give you better experience.

textlint
Docs
User ManualDeveloper Guide
Community
Project Chat
More
BlogGitHubStar
Copyright © 2023 textlint organization