textlint

textlint

  • Docs
  • Rules
  • Blog
  • Help
  • GitHub

›User Manual

User Manual

  • Getting Started with textlint
  • Command Line Interface
  • Configuring textlint
  • Ignoring Text
  • Integrating with Editors, Tools, etc..

Developer Guide

  • Creating Rules
  • Creating Filter Rule
  • Creating Fixable Rule
  • Creating Preset
  • Advanced: Paragraph Rule
  • How to implement "after-all" in the rule?
  • Plugin
  • Formatter
  • Use as Node Modules
  • TxtAST Interface

Contributing

  • Contributing Guideline
Edit

Getting Started with textlint

textlint does the following steps:

  1. textlint loads rules, every single rule is a plugin and you can add more at runtime.
  2. textlint parses texts using Markdown/Text/HTML parser plugin.
  3. textlint uses an AST(Abstract Syntax Tree) to evaluate patterns in texts.
  4. textlint reports errors/warning if exist.

Installation and Usage

NOTICE: If you run the following procedures on Windows, please use PowerShell.

Create new workspace

Create <your-workspace> directory and package.json file. A package.json manages dependencies of packages that include textlint:

# Create your workspace directory and move to it.
mkdir your-workspace
cd your-workspace

# `npm init` command creates `package.json` file.
npm init --yes

Installation of textlint

You can install textlint using npm. We recommend that you install textlint locally by running npm command with --save-dev option. This means that npm installs textlint in the <your-workspace>/node_modules folder.

# Installed textlint locally
npm install --save-dev textlint

Installation of rules

You can find a rule in A Collection of textlint rule.

As an example, let's install textlint-rule-no-todo. If you have installed textlint locally, you must install each rule locally as well.

npm install --save-dev textlint-rule-no-todo

Usage

You can run textlint on any Markdown files:

# file.md

- [ ] Write usage instructions

`- [ ]` is a code and not error.

npx textlint --rule no-todo file.md

screenshot lint error

Configuration

We recommend using textlint with .textlintrc.json configuration file.

Create a .textlintrc.json file in your workspace:

npx textlint --init

In this file, you'll see some rules configured like this:

{
  "plugins": {},
  "filters": {},
  "rules": {
    "no-todo": true
  }
}

If there is a .textlintrc(.textlintrc.{json,js,cjs,yaml,yml}) file in your workspace, textlint loads .textlintrc automatically. So you can run textlint without any command line options:

npx textlint file.md

Next Steps

  • Learn about advanced configuring of textlint.
  • Explore textlint's rules
  • Can't find just the right rule? Make your own custom rule.
  • Can't handling .ext file? Make your own custom plugin.
  • Make textlint even better by contributing.
Command Line Interface →
  • Installation and Usage
    • Create new workspace
    • Installation of textlint
    • Installation of rules
    • Usage
  • Configuration
  • Next Steps
textlint
Docs
User ManualDeveloper Guide
Community
Project Chat
More
BlogGitHubStar
Copyright © 2023 textlint organization