A ferramenta de linha flascável para texto e marcação.
O TextLint é semelhante ao Eslint, mas é para uso com linguagem natural.
Visite https://textlint.github.io/.
npm install textlint-rule-xxx .Para um rápido tour pelo TextLint, consulte o Guia de Iniciação: Squirrel:
Você pode instalar o comando textlint usando o npm:
$ npm install textlint --save-dev
Requisitos :
Se você não tem certeza de qual versão do nó está executando, poderá executar node -v em seu console para descobrir.
textlint globalmente, também deve instalar cada regra de referência globalmente.textlint localmente, também deve instalar cada regra localmente. Recomendamos a instalação de textlint localmente.
Se você nunca usou o Node.js e o NPM, consulte o seguinte:

Textlint não tem regras padrão !!
Você pode executar o TextLint com o arquivo de configuração .textlintrc.json .
# Install textlint and rules into local directory
npm install --save-dev textlint textlint-rule-no-todo Comando npx textlint --init create .textlintrc.json Arquivo das regras instaladas.
npx textlint --init .textlintrc.json será criado assim:
{
"rules" : {
"no-todo" : true
}
}Arquivos de fiapos via textlint:
npx textlint ./README.md textlint load .textlintrc.json do diretório atual e lint README.md .
Execute npx textlint -h para obter informações sobre como usar a 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
--print-config Print the config object to stdout
-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, fixed-result, json, stylish - default: 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 - default: .textlintcache
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.
Ao executar o TextLint, você pode segmentar arquivos para fiapos usando os padrões do Glob. Certifique -se de que você inclua qualquer parâmetro glob que você passe em cotações.
$ npx textlint " docs/** "Para mais detalhes, consulte a documentação da CLI.
Exemplo:
.textlintrc é um arquivo de configuração que é carregado como JSON, YAML ou JS via AZU/RC-Config-carregador.
Executando o textlint com os seguintes argumentos
$ npx textlint --rule no-todo --rule very-nice-rule README.md
é equivalente a executar textlint README.md em um diretório com um .textlintrc.json contendo o seguinte JSON
{
"rules" : {
"no-todo" : true ,
"very-nice-rule" : true
}
} Você também pode configurar opções para regras específicas no seu arquivo .textlintrc.json .
{
"rules" : {
"no-todo" : false , // disable
"very-nice-rule" : {
"key" : " value "
}
}
} Por exemplo, aqui passamos as opções ("chave": "valor") para very-nice-rule .
As opções podem ser especificadas no seu arquivo .textlintrc.json da seguinte forma:
{
// Allow to comment in JSON
"rules" : {
"<rule-name>" : true | false | object
}
}Para mais detalhes, consulte
Um plug -in TextLint é um conjunto de regras e regulesconfig ou personalização.
Para ativar o plug-in, coloque o "nome do plug-in" em .textlintrc.json .
// `.textlintrc.json`
{
"plugins" : [
"plugin-name"
] ,
// overwrite-plugins rules config
// <plugin>/<rule>
"rules" : {
"plugin-name/rule-name" : false
}
}Veja docs/plugin.md
O TextLint suporta o Markdown e o texto sem formatação por padrão.
Instale o plug -in do processador e adicione suporte para formato de novo arquivo.
Por exemplo, se você deseja fins HTML, use o TextLint-Plugin-HTML como um plug-in.
npm install textlint-plugin-html --save-dev
Adicione "html" a .textlintrc.json
{
"plugins": [
"html"
]
}
Execute textlint nos arquivos .html :
textlint index.html
Tipos de arquivos suportados opcionais:
Consulte a lista de plug -in do processador para obter detalhes.
O TextLint não possui regras internas, mas existem mais de 100 regras tragáveis:
Consulte uma coleção da regra de textlint · Textlint/textlint wiki para obter mais detalhes.
Se você criar uma nova regra e adicioná -la ao wiki :)
Algumas regras são corrigíveis usando o sinalizador de linha de comando --fix .
$ npx textlint --fix README.md
# As a possible, textlint fix the content. 
Além disso, suporte o modo de execução a seco.
$ npx textlint --fix --dry-run --format diff README.md
# show the difference between fixed content and original content.
Você pode copiar e colar para o seu ReadMe.
[ ![ textlint fixable rule ] ( https://img.shields.io/badge/textlint-fixable-green.svg?style=social )] ( https://textlint.github.io/ )Use os seguintes formatados:
por exemplo, use formatador pretty-error :
$ npx textlint -f pretty-error file.md
Mais detalhes em @textlint/liner-formatter.
Você pode usar o TextLint como módulo do nó.
$ npm install textlint --save-dev
Uso mínimo:
import { createLinter , loadTextlintrc , loadLinterFormatter } from "textlint" ;
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 ) ;Mais informações sobre detalhes, leia os seguintes documentos:
@textlint/kernel é uma API de baixo nível para textlint. É útil para os ambientes de navegador ou não-node.js.
import { TextlintKernel } from "@textlint/kernel" ;
const kernel = new TextlintKernel ( ) ;
const options = {
filePath : "/path/to/file.md" ,
ext : ".md" ,
plugins : [
{
pluginId : "markdown" ,
plugin : require ( "@textlint/textlint-plugin-markdown" )
}
] ,
rules : [
{
ruleId : "no-todo" ,
rule : require ( "textlint-rule-no-todo" ) . default
}
]
} ;
kernel . lintText ( "TODO: text" , options ) . then ( result => {
assert . ok ( typeof result . filePath === "string" ) ;
assert . ok ( result . messages . length === 1 ) ;
} ) ; Textlint tem quatro pontos extensíveis:

Por favor, consulte Docs/
no-todo .<!-- textlint-disable --> ?Você pode usar a regra do filtro como o texto do filtro de textlint.
Consulte Ignorando texto · Textlint para mais detalhes.
Para mais detalhes, consulte o documento de integrações.
Este repositório é um monorepo que gerenciamos usando o Lerna. Isso significa que realmente publicamos vários pacotes no NPM da mesma base de código, incluindo:
Esses módulos são partes do texto.
| Pacote | Versão | Descrição |
|---|---|---|
textlint | Ferramenta de linha de comando textlint | |
@textlint/kernel | TextLint Módulo lógico principal. É JavaScript universal. | |
@textlint/linter-formatter | Textlint Output Formatter | |
@textlint/fixer-formatter | formatador de saída textlint para fixador | |
@textlint/textlint-plugin-markdown | Apoio ao textlint | |
@textlint/textlint-plugin-text | Suporte ao texto simples para textlint | |
@textlint/ast-tester | Testes de conformidade para AST de Textlint | |
@textlint/markdown-to-ast | Analisador de Markdown | |
@textlint/ast-traverse | TxtNode Traverse Library | |
@textlint/text-to-ast | Analisador de texto simples | |
@textlint/config-loader | Carregar o arquivo de configuração de carregamento |
Esses módulos são úteis para o autor da regra/plug -in TextLint.
| Pacote | Versão | Descrição |
|---|---|---|
@textlint/ast-node-types | TextLint AST (Sintaxe Resumo) Definição de Tipo | |
textlint-tester | Ferramentas de teste de regra de textlint | |
textlint-scripts | regra de textlint npm run scripts | |
create-textlint-rule | Crie regra de textlint sem configuração de compilação |
Esses módulos são uma integração útil com o TextLint.
| Pacote | Versão | Descrição |
|---|---|---|
gulp-textlint | plug -in gulp for textlint |
Esses módulos são o uso interno no monorepo.
| Pacote | Versão | Descrição |
|---|---|---|
@textlint/feature-flag | Recurso Gerenciador de sinalizadores |
Projeto TextLint Siga a versão semântica. No entanto, o TextLint não é diferente com a maioria do projeto Semver.
.d.ts )Para insetos e solicitações de recursos, crie um problema.
Pull Solicys é sempre bem -vindo.
Para mais detalhes, consulte o guia contribuinte.
Mit © azu
Copie algum código da ESLint.
ESLint
Copyright (c) 2013 Nicholas C. Zakas. All rights reserved.
https://github.com/eslint/eslint/blob/master/LICENSE
Download de textlint/mídia.
Obrigado a Eslint.
O site TextLint é alimentado pelo Netlify.