Skip to content

Latest commit

 

History

History
102 lines (69 loc) · 2.88 KB

getting-started.md

File metadata and controls

102 lines (69 loc) · 2.88 KB
id title
getting-started
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