All Projects → textlint → Textlint

textlint / Textlint

Licence: mit
The pluggable natural language linter for text and markdown.

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Textlint

Stylelint
A mighty, modern linter that helps you avoid errors and enforce conventions in your styles.
Stars: ✭ 9,350 (+333.27%)
Mutual labels:  linter, lint, markdown
Svlint
SystemVerilog linter
Stars: ✭ 103 (-95.23%)
Mutual labels:  linter, lint
Proselint
Proselint wrapper with a friendly reporter
Stars: ✭ 56 (-97.41%)
Mutual labels:  linter, markdown
Scopelint
scopelint checks for unpinned variables in go programs
Stars: ✭ 110 (-94.9%)
Mutual labels:  linter, lint
Clippy Check
📎 GitHub Action for PR annotations with clippy warnings
Stars: ✭ 159 (-92.63%)
Mutual labels:  linter, lint
Hint
重构到 ---> https://github.com/hustcc/lint-md
Stars: ✭ 30 (-98.61%)
Mutual labels:  lint, markdown
Atom Linter Alex
Linter plugin using alex to catch insensitive, inconsiderate writing
Stars: ✭ 87 (-95.97%)
Mutual labels:  linter, lint
Ansible Lint Action
GitHub Action for running ansible-lint as part of your workflows! [ https://github.com/marketplace/actions/ansible-lint ]
Stars: ✭ 124 (-94.25%)
Mutual labels:  linter, lint
Liche
Fast Link Checker for Markdown and HTML in Go
Stars: ✭ 123 (-94.3%)
Mutual labels:  linter, markdown
Editorconfig Checker
A tool to verify that your files are in harmony with your .editorconfig
Stars: ✭ 119 (-94.49%)
Mutual labels:  linter, lint
Remark Lint
Markdown code style linter
Stars: ✭ 718 (-66.73%)
Mutual labels:  lint, markdown
Protolint
A pluggable linter and fixer to enforce Protocol Buffer style and conventions.
Stars: ✭ 142 (-93.42%)
Mutual labels:  linter, lint
Lint Md
📚 检查中文 markdown 编写格式规范的命令行工具,基于 AST,方便集成 ci,写博客 / 文档必备。支持 API 调用!
Stars: ✭ 662 (-69.32%)
Mutual labels:  lint, markdown
Cflint
Static code analysis for CFML (a linter)
Stars: ✭ 156 (-92.77%)
Mutual labels:  linter, lint
Phplint
🐛 A tool that can speed up linting of php files by running several lint processes at once.
Stars: ✭ 646 (-70.06%)
Mutual labels:  linter, lint
Redbot
REDbot is lint for HTTP.
Stars: ✭ 475 (-77.99%)
Mutual labels:  linter, lint
Redpen
RedPen is an open source proofreading tool to check if your technical documents meet the writing standard. RedPen supports various markup text formats (Markdown, Textile, AsciiDoc, Re:VIEW, reStructuredText and LaTeX).
Stars: ✭ 466 (-78.41%)
Mutual labels:  linter, markdown
Gradle Lint Plugin
A pluggable and configurable linter tool for identifying and reporting on patterns of misuse or deprecations in Gradle scripts.
Stars: ✭ 473 (-78.08%)
Mutual labels:  linter, lint
Yamllint
A linter for YAML files.
Stars: ✭ 1,750 (-18.91%)
Mutual labels:  linter, lint
Njsscan
njsscan is a semantic aware SAST tool that can find insecure code patterns in your Node.js applications.
Stars: ✭ 128 (-94.07%)
Mutual labels:  linter, lint

textlint

textlint logo

The pluggable linting tool for text and markdown.
textlint is similar to ESLint, but it's for use with natural language.

GitHub Actions Build Status Travis CI Build Status Build status

Website

  • Online demo
  • Searchable documents
  • Release blog

Visit https://textlint.github.io/.

Features

Quick Tour

For a quick tour of textlint, checkout our Getting Started guide :squirrel:

Installation

You can install the textlint command using npm:

$ npm install textlint --global

Requirements:

  • Node.js 6.0.0+
  • npm 2.0.0+

If you're not sure what version of Node you're running, you can run node -v in your console to find out.

⚠️ Warning:

  • If you have installed textlint globally you must install each reference rule globally as well.
  • If you have installed textlint locally you must install each rule locally as well.

We recommend installing textlint locally.

For Node.js beginners

If you've never used Node.js and npm, please see the following:

Usage

screenshot lint pretty-error

textlint has no default rules!!

You can run textlint with the --rule or --rulesdir flag to specify rules, or you can just use a .textlintrc config file.

# Install textlint's rule
npm install --global textlint-rule-no-todo

Use with textlint-rule-no-todo rule. (Allow to short textlint-rule-no-todo to no-todo)

textlint --rule no-todo README.md

📝 We recommended using .textlintrc to specify rules instead of --rule or --rulesdir flags. Your .textlintrc is a great way to maintain your rules.

CLI

Run textlint -h for information on how to use the CLI.

$ textlint [options] file.md [file|dir|glob*]
  
  Options:
    -h, --help                  Show help.
    -c, --config path::String   Use configuration from this file or sharable config.
    --ignore-path path::String  Specify path to a file containing patterns that describes files to ignore. - default: .textlintignore
    --init                      Create the config file if not existed. - default: false
    --fix                       Automatically fix problems
    --dry-run                   Enable dry-run mode for --fix. Only show result, don't change the file.
    --debug                     Outputs debugging information
    -v, --version               Outputs the version number.

  Using stdin:
    --stdin                     Lint text provided on <STDIN>. - default: false
    --stdin-filename String     Specify filename to process STDIN as

  Output:
    -o, --output-file path::String  Enable report to be written to a file.
    -f, --format String         Use a specific output format.
                                Available formatter          : checkstyle, compact, jslint-xml, json, junit, pretty-error, stylish, table, tap, unix
                                Available formatter for --fix: compats, diff, json, stylish
    --no-color                  Disable color in piped output.
    --quiet                     Report errors only. - default: false

  Specifying rules and plugins:
    --no-textlintrc             Disable .textlintrc
    --plugin [String]           Set plugin package name
    --rule [String]             Set rule package name
    --preset [String]           Set preset package name and load rules from preset package.
    --rulesdir [path::String]   Use additional rules from this directory

  Caching:
    --cache                     Only check changed files - default: false
    --cache-location path::String  Path to the cache file or directory

  Experimental:
    --experimental              Enable experimental flag.Some feature use on experimental.
    --rules-base-directory path::String  Set module base directory. textlint load modules(rules/presets/plugins) from the base directory.
    --parallel                  Lint files in parallel
    --max-concurrency Number    maxConcurrency for --parallel

When running texlint, you can target files to lint using the glob patterns. Make sure that you enclose any glob parameter you pass in quotes.

$ textlint "docs/**"

Example:

.textlintrc

.textlintrc is config file that is loaded as JSON, YAML or JS via azu/rc-config-loader.

Running textlint with the following arguments

$ textlint --rule no-todo --rule very-nice-rule README.md

is equivalent to running textlint README.md in a directory with a .textlintrc containing the following json

{
  "rules": {
    "no-todo": true,
    "very-nice-rule": true
  }
}

You can also configure options for specific rules in your .textlintrc file.

{
  "rules": {
    "no-todo": false, // disable
    "very-nice-rule": {
        "key": "value"
    }
  }
}

For example here we pass the options ("key": "value") to very-nice-rule.

Options can be specified in your .textlintrc file as follows:

{
  // Allow to comment in JSON
  "rules": {
    "<rule-name>": true | false | object
  }
}

ℹ️ for more details see

Plugin

A textlint plugin is a set of rules and rulesConfig or customize parser.

To enable plugin, put the "plugin-name" into .textlintrc.

// `.textlintrc`
{
    "plugins": [
        "plugin-name"
    ],
    // overwrite-plugins rules config
    // <plugin>/<rule>
    "rules": {
        "plugin-name/rule-name" : false
    }
}

ℹ️ See docs/plugin.md

Supported file formats

textlint supports Markdown and plain text by default.

Install Processor Plugin and add new file format support.

For example, if you want to lint HTML, use textlint-plugin-html as a plugin.

npm install textlint-plugin-html

Add "html" to .textlintrc

{
    "plugins": [
        "html"
    ]
}

Run textlint on .html files:

textlint index.html

Optional supported file types:

See Processor Plugin List for details.

Rules list 💚

textlint has not built-in rules, but there are 100+ pluggable rules:

See A Collection of textlint rule · textlint/textlint Wiki for more details.

If you create a new rule, and add it to the wiki :)

Fixable

textlint rule

Some rules are fixable using the --fix command line flag.

$ textlint --fix README.md
# As a possible, textlint fix the content.

fixable-error

Also, support dry run mode.

$ textlint --fix --dry-run --format diff README.md
# show the difference between fixed content and original content.

You can copy and paste to your README.

[![textlint fixable rule](https://img.shields.io/badge/textlint-fixable-green.svg?style=social)](https://textlint.github.io/)

Built-in formatters

Use the following formatters:

  • stylish (defaults)
  • compact
  • checkstyle
  • jslint-xml
  • junit
  • tap
  • table
  • pretty-error
  • json
  • unix

e.g. use pretty-error formatter:

$ textlint -f pretty-error file.md

More details in @textlint/linter-formatter.

Use as node module

You can use textlint as node module.

$ npm install textlint --save-dev

Minimal usage:

import { TextLintEngine } from "textlint";
const engine = new TextLintEngine({
    rulePaths: ["path/to/rule-dir"]
});
engine.executeOnFiles(["README.md"]).then((results) => {
    console.log(results[0].filePath); // => "README.md"
    // messages are `TextLintMessage` array.
    console.log(results[0].messages);
    /*
    [
        {
            id: "rule-name",
            message:"lint message",
            line: 1, // 1-based columns(TextLintMessage)
            column:1 // 1-based columns(TextLintMessage)
        }
    ]
     */
    if (engine.isErrorResults(results)) {
        const output = engine.formatResults(results);
        console.log(output);
    }
});

Low level usage:

import { textlint } from "textlint";
textlint.setupRules({
    // rule-key : rule function(see docs/rule.md)
    "rule-key"(context) {
        const exports = {};
        exports[context.Syntax.Str] = function (node) {
            context.report(node, new context.RuleError("error message"));
        };
        return exports;
    }
});
textlint.lintMarkdown("# title").then((results) => {
    console.log(results[0].filePath); // => "README.md"
    console.log(results[0].messages); // => [{message:"lint message"}]
});

More details on:

Conclusion

textlint has four extensible points:

  • rule
    • rule is a rule for linting.
  • filter rule
    • filter rule is a rule for filtering result of errors.
  • rule-preset
    • rule-preset contains rules.
  • plugin
    • plugin contains a processor.

rule-preset-plugin

FAQ: How to create rules?

Please see docs/

FAQ: How to suppress error by comments like <!-- textlint-disable -->?

You can use filter rule like textlint-filter-rule-comments.

Please see docs/configuring.md for more details.

Integrations

For more details, see integrations document.

App

  • textlint-app
    • Standalone cross platform app. No need Node.js environment.

Build Systems

Editors

Browser

Other

Who's using textlint?

Packages

This repository is a monorepo that we manage using Lerna. That means that we actually publish several packages to npm from the same codebase, including:

Core

These modules are parts of textlint.

Package Version Description
textlint npm textlint command line tool itself
@textlint/kernel npm textlint main logic module. It is universal JavaScript.
@textlint/linter-formatter npm textlint output formatter
@textlint/fixer-formatter npm textlint output formatter for fixer
@textlint/textlint-plugin-markdown npm markdown support for textlint
@textlint/textlint-plugin-text npm plain text support for textlint
@textlint/ast-tester npm Compliance tests for textlint's AST
@textlint/markdown-to-ast npm markdown parser
@textlint/ast-traverse npm TxtNode traverse library
@textlint/text-to-ast npm plain text parser

Rule/Plugin helper

These modules are useful for textlint rule/plugin author.

Package Version Description
@textlint/ast-node-types npm textlint AST(Abstract Syntax Tree) type definition
textlint-tester npm textlint rule testing tools
textlint-scripts npm textlint rule npm run-scripts
create-textlint-rule npm create textlint rule with no build configuration

Integrations

These modules are useful integration with textlint.

Package Version Description
gulp-textlint npm gulp plugin for textlint

Internal

These modules are internal usage in the monorepo.

Package Version Description
@textlint/feature-flag npm feature flag manager

Semantic Versioning Policy

textlint project follow Semantic Versioning. However, textlint is not different with most semver project.

  • Patch release (intended to not break your lint build)
    • A bug fix to the CLI or core (including formatters).
    • Improvements to documentation.
    • Non-user-facing changes such as refactoring.
    • Re-releasing after a failed release (i.e., publishing a release that doesn't work for anyone).
  • Minor release (might break your lint build)
    • A new option.
    • An existing rule is deprecated.
    • A new CLI capability is created.
    • New public API are added (new classes, new methods, new arguments to existing methods, etc.).
      • It might break type interface(.d.ts)
    • A new formatter is created.
  • Major release (break your lint build)
    • A new option to an existing rule that results in textlint reporting more errors by default.
    • An existing formatter is removed.
    • Part of the public API is removed or changed in an incompatible way.

Contributing

For bugs and feature requests, please create an issue.

Pull requests is always welcome.

For more details, see Contributing Guide.

License

MIT © azu

Copy some code from ESLint.

ESLint
Copyright (c) 2013 Nicholas C. Zakas. All rights reserved.
https://github.com/eslint/eslint/blob/master/LICENSE

Logos & Icons

Download from textlint/media.

Related Work

Acknowledgements

Thanks to ESLint.

textlint website is powered by Netlify.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].