exabugs / WebIDE

0 stars 0 forks source link

テキストの Lint を追加 #15

Open exabugs opened 6 years ago

exabugs commented 6 years ago

https://github.com/textlint/textlint

TextLintEngine デフォルトで カレントの .textlintrc が読み込まれる

function lint_text({ fp }, callback) {
  const engine = new TextLintEngine();
  engine.executeOnFiles([fp]).then(results => {
    const result = results[0];
    const data = result.messages.map(info => {
      // console.log(info);
      return {
        from: Pos(info.line, info.column),
        to: Pos(info.line, info.column + 1),
        message: info.message,
        severity: 'warning',
      };
    });
    callback(null, data);
  }).catch(err => {
    callback(err);
  });
}

.textlintrc

{
  "rules": {
    "preset-ja-technical-writing": {
      "no-exclamation-question-mark": false
    },
    "spellcheck-tech-word": true
  }
}
exabugs commented 6 years ago
    "prh": "^5.4.3",
    "textlint": "^9.1.1",
    "textlint-rule-preset-ja-technical-writing": "^2.0.0",
    "textlint-rule-prh": "^5.0.1",
    "textlint-rule-spellcheck-tech-word": "^5.0.0",