1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

textlintrcを使わないで設定する

1
Posted at

動的に設定を流したいよねって話

$ npm init --yes
$ npm install --save-dev textlint
// TODOをチェックするルール
$ npm install --save-dev textlint-rule-no-todo
// 連続する漢字をチェックするルール
$ npm install --save-dev textlint-rule-max-kanji-continuous-len

textlintrc: falseしておくことで.textlintrcを拾わないようにする

cl.js
"use strict";
const TextLintEngine = require('textlint').TextLintEngine;

const text = "TODO: this is TODO 一二三四五六";
const options = {
  rules: [
    "no-todo",
    "max-kanji-continuous-len",
  ],
  rulesConfig: {
    "no-todo": true,
    "max-kanji-continuous-len": true,
  },
  textlintrc: false,
};
const engine = new TextLintEngine(options);
engine.executeOnText(text).then(results => {
  if (engine.isErrorResults(results)) {
    var output = engine.formatResults(results);
    console.log(output);
  } else {
    console.log("All Passed!");
  }
});
$ node cl.js

<text>
  1:1   error  Found TODO: 'TODO: this is TODO 一二三四五六'  no-todo
  1:20  error  漢字が6つ以上連続しています: 一二三四五六      max-kanji-continuous-len

? 2 problems (2 errors, 0 warnings)

参照情報

textlint/index.js at master · textlint/textlint

textlint/config.ts at 0503af68f4a34beaab2e45c34463ad4e0e24a958 · textlint/textlint

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?