textlint

The pluggable natural language linter for text and markdown.

MIT License

Downloads
7.4M
Stars
2.8K
Committers
83

Bot releases are visible (Hide)

textlint -

Published by azu over 8 years ago

Features

  • rule: context.report support index-based postion (7a0c80b), closes #134

If you want to know for detail, please see the documents: https://github.com/textlint/textlint/blob/master/docs/rule.md#ruleerror

Motivation

Previously, textlint's RuleError support line and column.

e.g.) It is wrong that column doen't consider line break.

//  surrogate pair 
function stringToArray(value) {
    return value.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
}

export default function (context) {
    let {Syntax, RuleError, report, getSource} = context;
    return {
        [Syntax.Str](node){
            const text = getSource(node);
            const strArray = stringToArray(text);
            for (let index = 0; index < strArray.length; index++) {
                const item = strArray[index];
                if (//.test(item)) {
                    report(node, new RuleError("Use X insteadof ❌", {
                          column: index
                    }));
                }
            }
        }
    }
}

Input:

string
string

Result of TextLintMessage:

{
   "message": "Use X insteadof ❌",
   "line": 1,
   "column": 7
}

Expected:

{
   "message": "Use X insteadof ❌",
   "line": 2,
   "column": 1
}

5.6.0 allow to write this like

//  surrogate pair 
function stringToArray(value) {
    return value.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
}

export default function (context) {
    let {Syntax, RuleError, report, getSource} = context;
    return {
        [Syntax.Str](node){
            const text = getSource(node);
            const strArray = stringToArray(text);
            for (let index = 0; index < strArray.length; index++) {
                const item = strArray[index];
                if (//.test(item)) {
                    report(node, new RuleError("Use X insteadof ❌", {
                          index: index // <= index
                    }));
                }
            }
        }
    }
}

)

Performance Improvements

  • example: use --cache-min 9999999 (d9035b3)
textlint - https://github.com/textlint/textlint/releases/tag/5.5.5

Published by azu over 8 years ago

textlint - https://github.com/textlint/textlint/releases/tag/5.5.4

Published by azu over 8 years ago

Bug Fixes

  • cli: fix detection of --experimental flag (fe5b4bf)
  • cli: fix detection of cli (ee69a6f)
textlint - 5.5.3: --fix & --experimental support

Published by azu over 8 years ago

Features(--experimental)

--fix and --experimental support ⚠️

Status: experimental 🚧

You can use automatically fixes feature with experimental flag.

$ textlint --experimental --fix README.md
# fixed by each rule

⚠️ Caution ⚠️

Currently, --fix is unstable(use with --experimental).
It mean that there is a possibility of change in the future.

Not all rules is fixable.
So, it is difficult that make all rules fixable.

🚧 If you found a bug, please file issue 🆘

What are rules fixable?

How to create fixable rule?

ℹ️ Please See Creating fixable rule for detail.

How to testing

Related Issues

If you want to improve fixable feature, please comment above the issue.

We don't think that this feature is complete 💭

Error ⚠️

If you see following error

.../node_modules/textlint/lib/textlint-core.js:80
                    throw new Error('Definition for rule \'' + key + '\' was not found.');
                    ^

Error: Definition for rule 'prh' was not found.

You should update textlint to ^5.5.
Some rules like textlint-rule-prh dependent on textlint >= 5.5.

npm install -D textlint@^5.5

  • cli: --fix options support (ebc058e)
  • cli: add --experimental flag (13b0593)
  • example: add fix example (277c253)
  • typescript: update textlint.d.ts (065751f)

Bug Fixes

textlint - https://github.com/textlint/textlint/releases/tag/5.5.3-0

Published by azu over 8 years ago

Bug Fixes

  • fixer: fix to pass options fixer function of rule (79c7565)
textlint - https://github.com/textlint/textlint/releases/tag/5.5.2-0

Published by azu over 8 years ago

Features

  • rule-error: RuleError support fix options (8fce575)
textlint - https://github.com/textlint/textlint/releases/tag/5.5.1-0

Published by azu over 8 years ago

Bug Fixes

  • task: remove memory leak detected message (52d35b2)
  • test: rename text to output (97d277a)

Features

  • fixer: add SourceCodeFixer#revertFixes (7006219)
  • fixer: initial implementation of fixer (9f5f3a9)
textlint -

Published by azu over 8 years ago

Bug Fixes

  • cli: remove memory leak detected warning. (97c6bdc) #33 #132

If you see this warning, please update textlint to 5.4.1.

(node) warning: possible EventEmitter memory leak detected. 11 Str listeners added. Use emitter.setMaxListeners() to increase limit.

textlint - https://github.com/textlint/textlint/releases/tag/5.5.0-0

Published by azu over 8 years ago

Features

  • fixer: add SourceCodeFixer#revertFixes (96d1fc1)
  • fixer: initial implementation of fixer (d28dfbc)
textlint -

Published by azu over 8 years ago

Features

  • add --init option like eslint. #127 by @takahashim

textlint --init create a .textlintrc file in your directory.

$ textlint --init

If you are instersted in improving this, please see --init options: Create .textlintrc file #129

Bug Fixes

textlint -

Published by azu over 8 years ago

Bug Fixes

  • Allow to parse every markdown

In previous version, textlint can't lint specific file that contain table syntax.

[email protected] can lint the file that contain table syntax.

| Hello | World  |
| :---- | -----: |
| How   |    are |
| you   | today? |

For rule creator

We have updated markdown-to-ast@3.2.3 and remark@4.0.0.

[email protected] contain some breaking changes.
But, these changes are not related with things that are defined in textlint's specification.

Example:

  • Rename link, src, href properties to url
  • Remove undefined value for checked on list-items
  • Rename horizontalRule to thematicBreak

See Release 4.0.0 · wooorm/remark for more detail on.


textlint -

Published by azu over 8 years ago

Features

  • cli: add --stdin-filename option (5f65619), closes #117

Usecase

cat readme.md | textlint --format compact --stdin

stdin as .txt by default.

cat readme.md | textlint --format compact --stdin --stdin-filename readme.md

stdin as .md

textlint -

Published by azu over 8 years ago

Document Features

  • When not have rules, suggest to what to do #111

Not set rule and Not configure .textlintrc

Before:

$ textlint README.md

After:

$ textlint README.md

== Not have rules, textlint do not anything ==
=> How to set rule?
See https://github.com/textlint/textlint/blob/master/docs/configuring.md

Bug Fixes

  • docs: lint docs by textlint (c5d1a5e)
  • test: fix multiple done called (f51f3c2)

Features

  • textlint: add alexjs for linting docs (541683f)
  • typescript: add typing dir for npm (7816b99), closes #102
  • typescript: add property to d.ts (d0b238c)
textlint -

Published by azu almost 9 years ago

Features

  • formatter: -f option resolve from pcakage name (b6b2b5b)

See https://github.com/textlint/textlint/blob/master/docs/formatter.md for details on.

textlint - https://github.com/textlint/textlint/releases/tag/5.1.2

Published by azu almost 9 years ago

textlint -

Published by azu almost 9 years ago

Features

rule-preset support

textlint-rule-preset-XXX support

e.g.)

Rule-preset is a collection of rules.

  • rule
    • rule is a rule for linting.
  • rule-preset
    • rule-preset contains rules.
  • plugin
    • plugin contains rules and a processor.

rule-preset-plugin


  • cli: add --preset option to cli (ac7b477)
  • config: add "disabledRules" to config (a7a0665)
  • rule: support "preset" of rules (c16a475), closes #96
  • rule: support scoped module (545b763) #99
textlint -

Published by azu almost 9 years ago

Bug Fixes

  • rule-context: correct padding column number (bbd5793) #90
textlint - 5.0.0: Async support

Published by azu almost 9 years ago

Breaking Change

Make Lint API asynchronous!

Lint API always return Promise.

  • TextLintCore#LintFile
  • TextLintCore#LintText
  • TextLintEngine#executeOnFiles
  • TextLintEngine#executeOnText
  • cli#execute
var textlint = new TextLintCore();
textlint.lintMarkdown("text").then(result => {
      // 
});

Festures

  • Rule: async support #74

How to write async rule?

export default function (context) {
    return {
        [Syntax.Str](node){
            // textlint wait for resolved the promise.
            return new Promise((resolve, reject) => {
                // async task
            });
        }
    }
}

Bug Fixes

  • async: fix race condition on async (07dd51c)
  • use interop-require instead of require for dynamic loading (86e3004), closes #81
    • could use code generated by Babel 6
  • docs: remove value (c00646c)
  • example: add pretest (f1c7a57)
  • test: fix test that are broken at timing (1ea0def)
  • test: fix throws test (64ee56b)
  • test: install textlint-plugin-html with devDependencies (7d3eaf0)
  • test: fix all test for async (f19a64b)

Features

  • example: add use-as-module example (bc41157)

Performance Improvements

  • test: use production env for test (ba2b501)

Related Modules

textlint - https://github.com/textlint/textlint/releases/tag/5.0.0-beta.2

Published by azu almost 9 years ago

Bug Fixes

  • engine: remove console.log (ef35b00)
textlint - https://github.com/textlint/textlint/releases/tag/5.0.0-beta.1

Published by azu almost 9 years ago

Bug Fixes

  • async: fix race condition on async (07dd51c)
  • test: fix all test for async (f19a64b)
  • use interop-require instead of require for dynamic loading (86e3004), closes #81

Performance Improvements

  • core: improve perfoemance (c7b27d1)
  • engine: initialize available extensions at once (60d9a8f)