textlint

The pluggable natural language linter for text and markdown.

MIT License

Downloads
7.4M
Stars
2.8K
Committers
83

Bot releases are hidden (Show)

textlint -

Published by azu over 6 years ago

Summary

Move core modules to @textlint namespace · Issue #455

Move core pacakges to @textlint scoped.

PR Before After
#473 txt-to-ast @textlint/text-to-ast
#460 markdown-to-ast @textlint/markdown-to-ast
#483 textlint-ast-test @textlint/ast-tester
#484 txt-ast-traverse @textlint/ast-traverse
#482 textlint-fixer-formatter @textlint/fixer-formatter
#474 textlint-formatter @textlint/linter-formatter
#485 textlint-plugin-markdown @textlint/textlint-plugin-markdown
#486 textlint-plugin-text @textlint/textlint-plugin-text

For more details, see #455

For textlint user

If you have seen following deprecated warning, please update latester textlint, textlint-tester, or textlint-scripts.

warning textlint-scripts > textlint-tester > textlint > [email protected]: See https://github.com/textlint/textlint/issues/455
warning textlint-scripts > textlint-tester > textlint > [email protected]: See https://github.com/textlint/textlint/issues/455
warning textlint-scripts > textlint-tester > textlint > [email protected]: See https://github.com/textlint/textlint/issues/455
warning textlint-scripts > textlint-tester > textlint > [email protected]: See https://github.com/textlint/textlint/issues/455
warning textlint-scripts > textlint-tester > textlint > textlint-plugin-text > [email protected]: See https://github.com/textlint/textlint/issues/455
warning textlint-scripts > textlint-tester > textlint > textlint-plugin-markdown > [email protected]: See https://github.com/textlint/textlint/issues/455
warning textlint-scripts > textlint-tester > textlint > @textlint/kernel > [email protected]: See https://github.com/textlint/textlint/issues/455

Update latest version

npm install textlint@latest
npm install textlint-scripts@latest

For node modules user

If you use someone of Migration pacakges, please move to scoped version.

For example, If you use markdown-to-ast, you migrate from markdown-to-ast to @textlint/markdown-to-ast.

npm uninstall markdown-to-ast
npm install @textlint/markdown-to-ast

And, you should change require("markdown-to-ast") to require("@textlint/markdown-to-ast").

textlint-tester: use with plugin #488

textlint-tester support multiple rules and plugins.

You can write a test for using plugins.

const TextLintTester = require("textlint-tester");
const htmlPlugin = require("textlint-plugin-html");
const noTodoRule = require("textlint-rule-no-todo");
const maxNumberOfLineRule = require("textlint-rule-max-number-of-lines");
const tester = new TextLintTester();

tester.run(
    "new-style-of-test: rule and plugin",
    {
        plugins: [
            {
                pluginId: "html",
                plugin: htmlPlugin
            }
        ],
        rules: [
            {
                ruleId: "no-todo",
                rule: noTodoRule
            }
        ]
    },
    {
        valid: [
            {
                text: "<p>日本語 is Japanese.</p>",
                ext: ".html"
            }
        ],
        invalid: [
            // line, column
            {
                text: `<p>TODO: no todo</p>
<p>Another paragraph</p>
<p>Yet another paragraph</p>`,
                ext: ".html",
                errors: [
                    {
                        message: "Found TODO: 'TODO: no todo'",
                        line: 1,
                        column: 4
                    }
                ]
            }
        ]
    }
);

Changelog

@textlint/[email protected]

fixes

@textlint/[email protected]

fixes

@textlint/[email protected]

fixes

[email protected]

fixes

  • textlint-tester: clarify when multiple options were found (5ffe903)
  • textlint-tester: correct options handling for rules and plugins (985d03a)
  • textlint-tester: make plugins at TestConfig optional (3ebc1d7)
  • textlint-tester: add user-defined type guard (77b0e95)
  • textlint-tester: improve codes according to review comments (178ba8a)
  • textlint-tester: rename TestTarget to TestConfig (59ed69d)
  • textlint-tester: update README (46aed3f)
  • textlint-tester: update README with new function signature (d419a15),

features

  • textlint-tester: add multiple rules and plugins test support (bedf761)
  • textlint-tester: add new style test case (9e36143)
  • textlint-tester: add valid test case which pass a TestConfig that has multiple rules only (c02a1ec)
  • textlint-tester: implement configuration assertion (09c9db3)
textlint - Migrate to @textlint pacakges

Published by azu almost 7 years ago

Migrate to @textlint pacakges

Currently, textlint move to scoped pacakge(@textlint). #455
This release is progress report in this migration.

PR Before After
#473 txt-to-ast @textlint/text-to-ast
#460 markdown-to-ast @textlint/markdown-to-ast
#483 textlint-ast-test @textlint/ast-tester
txt-ast-traverse @textlint/ast-traverse
#482 textlint-fixer-formatter @textlint/fixer-formatter
#474 textlint-formatter @textlint/linter-formatter
textlint-plugin-markdown @textlint/textlint-plugin-markdown
textlint-plugin-text @textlint/textlint-plugin-text

ℹ️ Migration information for user

If you use someone of Migration pacakges, please move to scoped version.

For example, If you use markdown-to-ast, you migrate from markdown-to-ast to @textlint/markdown-to-ast.

npm uninstall markdown-to-ast
npm install @textlint/markdown-to-ast

And, you should change require("markdown-to-ast") to require("@textlint/markdown-to-ast").

CHANGELOGS

@textlint/[email protected]

  • ast-tester: add publishConfig (e7a150b)

@textlint/[email protected]

  • fixer-formatter: add publishConfig (3e89e3c)

@textlint/[email protected]

  • linter-formatter: add publishConfig (9f54a5a)

@textlint/[email protected]

  • markdown-to-ast: add "publishConfig" (929b575)

[email protected]

  • tester: fix "main" and "types" field in package.json (567ba65)
textlint -

Published by azu almost 7 years ago

[email protected] includes following changes.

@textlint/[email protected]

  • kernel: fix return type of SourceCode#getSource (1b55894) #444
  • kernel: pass the file path to preProcess() that is on FixerProcessor (#458) (5b947aa) #458
textlint -

Published by azu almost 7 years ago

@textlint/[email protected]

  • ast-node-types: Make ASTNodeTypes string enum #422

@textlint/[email protected]

  • feature-flag: Update MapLile@2 (5b261f0)

[email protected]

  • fixer-formatter: getFormatterList method is renamed.
textlint -

Published by azu almost 7 years ago

🌟 Highlight

Improve textlint --help #85 by @0x6b

textlint -h show available formatter name list.

textlint [options] file.md [file|dir|glob*]

Options:
  -h, --help                 Show help.
  -c, --config path::String  Use configuration from this file or sharable config.
  --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:
  --plugin [String]          Set plugin package name
  --rule [path::String]      Set rule package name
  --preset [path::String]    Set preset package name and load rules from preset package.
  --rulesdir [path::String]  Set rules from this directory and set all default rules to off.

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.

Imrove error message when not rules in .textlintrc

Return an exit status(code 0) when no rules found (#408) (3dc76e4), closes #406 by @sapegin

🎉 New Collaborator

  • @0x6b join to @textlint/collaborator #418

CHANGELOG

@textlint/[email protected]

  • monorepo: fix TypeScript module resolution in monorepo (d5df499)

@textlint/[email protected]

  • kernel: fix import path (02d98fe)
  • monorepo: fix TypeScript module resolution in monorepo (d5df499)

[email protected]

  • textlint-fixer-formatter: add getFormatterList function (8de3fef)

[email protected]

  • textlint-formatter: define TextLintFormatterOption interface (31146c7)
  • textlint-formatter: run all tests (6d507c2), closes #402
  • textlint-formatter: Update API (8f4901f),- textlint-formatter: add getFormatterList function (25e1113)
  • textlint-formatter: add new option to cli (30351a8),- textlint-formatter: export { createFormatter } instead of { default }

[email protected]

  • textlint: Return an exit status when no rules found (#408) (3dc76e4), closes #406
  • textlint: show available formatter in help (af6b0da), closes #85

[email protected]

  • monorepo: fix TypeScript module resolution in monorepo (d5df499)
  • txt-ast-traverse: fix test scripts (a78f99b)
  • txt-ast-traverse: fix txt-ast-traverse test reference (190723b)
textlint -

Published by azu almost 7 years ago

textlint 10.0.1 (2017-12-19)

Bug Fixes

  • textlint: throw an error if file is not encoded in UTF8 (dfe7e28)

textlint-tester 4.0.1 (2017-12-19)

Bug Fixes

  • textlint-tester: Correct output ${text} (d0ecbab)
textlint - textlint 10.0.0

Published by azu almost 7 years ago

🆕 Features

@textlint/ast-node-types: TxtNode type interface

@textlint/ast-node-types get TxtNode type interface #358
It is useful for TypeScript user.

For more details. see https://github.com/textlint/textlint/blob/master/docs/txtnode.md

textlint: Use with TypeScript #248

@textlint/kernel and textlint export type interfaces.

// Types
import {
    TextlintResult,
    TextlintFixResult,
    TextlintFixCommand,
    TextlintMessage,
    // Kernel rule/filter/plugin format
    TextlintKernelRule,
    TextlintKernelFilterRule,
    TextlintKernelPlugin,
    // Notes: Following interface will be separated module in the future.
    // textlint rule interface
    TextlintRuleCreator,
    TextlintRuleOptions,
    // textlint filter rule interface
    TextlintFilterRuleCreator,
    TextlintFilterRuleOptions,
    // textlint plugin interface
    TextlintPluginCreator,
    TextlintPluginOptions,
    TextlintPluginProcessor,
    TextlintPluginProcessorConstructor
} from "@textlint/kernel";

If you want to improve TypeScript integration, please file issue or track following issue.

textlint-tester: support inputPath option #394

textlint-tester support inputPath options.
It can test path-based rules.

🔥 Breaking Change

A breaking change, but this changes not affect to textlint tool user.
This changes affect to user that user textlint as node modules.

textlint: Export as ES module #337 #344

Before

Export as common js module.

module.exports = {
  textlint,
  TextLintEngine,
}

After

Export as named module.

export { 
  textlint,
  TextLintEngine
}

You can import it as es named import.

import { textlint } from "textlint"

or

You can import it as common js module

const textlint = require("textlint").textlint

Stop to export unused name #344

We have removed following from textlint.

  • TextLintNodeType
  • TextLintMessageSeverityLevel
  • TextLintMessageType
    • Use @textlint/ast-node-types insteadof it

📝 Documentaion

Improve Contributing Guide.

Issues/PR: #380 #379 #355 #352 #353 #341 #387 by @Leko and @0x6b

We have improved Contributing Guide.
This Contributing Guide help you to contribute to textlint.

If you want to contribute to texltlint, let's see issues with the good first issue label.

♻️ Polish

Monorepo #270

Import following modules into this monorepo.

  • textlint-formatter #359
  • textlint-ast-test #357
  • txt-ast-traverse #356
  • textlint-fixer-formatter #347

Thanks to @Leko

🎉 New Contributors

  • @Leko – Refactor modules, fixes bug, and improve stability of textlint
  • @0x6b - improve Contributing Guide
textlint -

Published by azu almost 7 years ago

Bug fixes

[email protected] add shorthand of scoped pacakge support in .textlintrc #326
But it is not working on preset module #327

texlint 9.1.1 just fixes the scoped preset module bug #329

Work following shorthand of preset module.

{
  "rules": {
    "@textlint-rule/preset-google": true
  }
}
textlint -

Published by azu almost 7 years ago

Features

  • textlint: Support shortcut scoped package name #326

You can write @scope/name in .textlintrc.
@scope/name is shortcut name of @scope/textlint-rule-name.

For more details, See Configuration document.

textlint - textlint 9.0.0

Published by azu almost 7 years ago

♻️ Refactor

textlint-kernel: Convert JavaScript to TypeScript #248 #301

Convert @textlint/kernel from JavaScript to Typescript.

If you instersting in TypeScript support, please see #248 .

Currently, Type definition is unstable. It means that break change in minor version.

🆕 Feature

Plugins can be initialized with plugin options #296

Allow to specify following options.

{
  "plugins": {
     "text": { "custom": "value" }
  }
}

For mode details, See document of plugin.

textlint-tester: support "index" expected param #324

Allow to write following index based testing.

const TextLintTester = require("textlint-tester");
const tester = new TextLintTester();
tester.run("rule", rule, {
    invalid: [
        // index
        {
            text: "- [ ] string",
            errors: [
                {
                    message: "Found TODO: '- [ ] string'",
                    index: 2
                }
            ]
        }
    ]
});

🐛 Bug Fixes

textlint: don't use error.code when catch error #323

Fix to use correct exit code. Thanks to @buzztaiki

🔥 BREAKING CHANGE

These breaking change is for plugin/rule author.

Remove context.config #294 #295

You can use context.getConfigBaseDir() instead of context.config.

  • getConfigBaseDir() return config base directory path that is the place of .textlintrc
    • e.g.) /path/to/dir/.textlintrc
    • getConfigBaseDir() return "/path/to/dir/".

Related rules changes:

Drop "rules" and "rulesConfig" from plugin #291 #313

You can use preset feature instead of plugin.
The textlint plugin should focus on processor.

Disallow to use 3rd argument of context.report function #316

It prevent wrong usage of report function:

NG:

report(node,
  new RuleError(`using "please" in a set of instructions is overdoing the politeness.`), {
    index,
    fix: fixer.replaceTextRange(range, result.replace)
  }
)

OK:

report(node,
  new RuleError(`using "please" in a set of instructions is overdoing the politeness.`, {
    index,
    fix: fixer.replaceTextRange(range, result.replace)
  });
)
textlint -

Published by azu over 7 years ago

8.2.1 (2017-05-21)

Bug Fixes

  • textlint: fix config.configFile is undefined at sometimes (#297) (cd64560), closes #297
textlint -

Published by azu over 7 years ago

8.2.0 (2017-05-21)

Features

  • textlint-kernel: add configBaseDir option (#295) (85dad8a)
textlint -

Published by azu over 7 years ago

Features

This is main logic of textlint.
Also it is Universal JavaScript. It means that no-depended on platform like Node.js.

textlint -

Published by azu over 7 years ago

8.0.1 (2017-05-11)

Bug Fixes

  • textlint: remove shelljs dependencies (#287) (0e88942)
textlint -

Published by azu over 7 years ago

BREAKING CHANGES

  • textlint: markdown-to-ast@4 includes some breaking change
  • It enhance some linting result.
    • use remark@7 #278

Bug Fixes

  • textlint: fix thrown error when --fix empty result. (#274) (7013cee), closes #274
  • textilnt: fix JSDoc (8a417e0)

Features

  • packages: import textlint-plugin-text (1b7a571)
  • textlint: update built-in textlint-plugin-markdown@^2 (#282) (448fef9)
textlint -

Published by azu over 7 years ago

Features

  • cli: Support quiet mode #268

Now, work textlint --quite.

Thanks to @fand

textlint -

Published by azu over 7 years ago

Features

  • #261 #264 Support glob pattern

$ textlint "*pattern" (need to wrap ")

textlint "./docs/"
# Results
[ 'docs/configuring.md',
  'docs/faq/failed-to-load-textlints-module.md',
  'docs/faq/line-column-or-index.md',
  'docs/filter-rule.md',
  'docs/formatter.md',
  'docs/getting-started.md',
  'docs/plugin.md',
  'docs/README.md',
  'docs/rule-advanced.md',
  'docs/rule-fixable.md',
  'docs/rule-preset.md',
  'docs/rule.md',
  'docs/txtnode.md',
  'docs/use-as-modules.md' ]
textlint "./docs/**"
# Results
[ 'docs/configuring.md',
  'docs/faq/failed-to-load-textlints-module.md',
  'docs/faq/line-column-or-index.md',
  'docs/filter-rule.md',
  'docs/formatter.md',
  'docs/getting-started.md',
  'docs/plugin.md',
  'docs/README.md',
  'docs/rule-advanced.md',
  'docs/rule-fixable.md',
  'docs/rule-preset.md',
  'docs/rule.md',
  'docs/txtnode.md',
  'docs/use-as-modules.md' ]
textlint "./docs/faq/*.md"
# Results
[ 'docs/faq/failed-to-load-textlints-module.md',
  'docs/faq/line-column-or-index.md' ]
textlint -

Published by azu over 7 years ago

Fixes:

  • fix(config): use rc-config-loader insteadof rc-loader #262 #39

This change also fix following issue.

webpack2 + textlint throw error like this.

ERROR in ./~/rc/index.js
Module parse failed: /Users/azu/.ghq/github.com/textlint/textlint.github.io/node_modules/rc/index.js Unexpected character '#' (1:0)
You may need an appropriate loader to handle this file type.
| #! /usr/bin/env node
| var cc   = require('./lib/utils')
| var join = require('path').join
 @ ./~/rc-loader/dist/index.js 10:10-23
 @ ./~/textlint/lib/config/config-loader.js
 @ ./~/textlint/lib/config/config.js
 @ ./~/textlint/lib/cli.js
 @ ./~/textlint/lib/index.js
 @ ./src/components/TextlintDemo/TextlintEditor.js
 @ ./src/components/TextlintDemo.js
 @ ./src/components/App.js
 @ ./src/index.js
textlint - https://github.com/textlint/textlint/releases/tag/7.2.1

Published by azu almost 8 years ago

Bug Fixes

  • config: --cache-location doesn't support directory yet. (325df3f)
textlint -

Published by azu almost 8 years ago

Features

  • cli: --cache && --cache-location support (#251) (04533c7)

--cache:

Store the info about processed files in order to only operate on the changed ones.

textlint --cache docs/

--cache-location:

Path to the cache location. Default: .textlintcache