Textlint Runs Empty

Asked 2 years ago, Updated 2 years ago, 81 views

Node.js is using textlint, but I'm not sure why the messages are empty.
If anyone knows what the cause is, please let me know.

As a supplement, I am moving the above from the middleware of Nxt.js.

Run Environment
Node.js: 12.8.0
textlint:11.4.0

Results

"messages":[
    {
      "messages": [

      ],
      "filePath": "<text>"
    }
  ]
}

code

import express from "express";
import {TextLintEngine} from "textlint";
import {TextlintMessage} from "@textlint/types";

const app=express();

app.get("/run-lint", async(req:any, res:any)=>{
  constengine = new TextLintEngine({
    rulePaths: [
      "node_modules/textlint-rule-max-ten",
      "node_modules/textlint-rule-helper",
      "node_modules/textlint-rule-no-mix-dearu-desumasu",
      "node_modules/textlint-rule-preset-ja-technical-writing"
    ]
  });

  const messages = wait engine.executeOnText("Today.It was yesterday. So, ho, no, nu, la").catch(e=>{
    return [{messages:e}];
  });

  res.json({
    messages —messages
  });
});

module.exports={
  path: "/api",
  handler:app
};

node.js typescript

2022-09-30 13:50

2 Answers

It works fine in my environment.
If you are looking at this site and are still having trouble, please review the settings to see if the textlint rules are included correctly.

environment

Node.js: v10.15.3 (quite old…)
textlint:11.4.0
OS:Windows 10 Home 1903
browsers:Chrome, Internet Explorer

Code

import express from "express";
import {TextLintEngine} from "textlint";
import {TextlintMessage} from "@textlint/types";

const app=express();

app.get("/run-lint", async(req:any, res:any)=>{
  constengine = new TextLintEngine({
    rulePaths: [
      "node_modules/textlint-rule-max-ten",
      "node_modules/textlint-rule-helper",
      "node_modules/textlint-rule-no-mix-dearu-desumasu",
      "node_modules/textlint-rule-preset-ja-technical-writing"
    ]
  });

  const messages = wait engine.executeOnText("Today.It was yesterday. So, ho, no, nu, la").catch(e=>{
    return [{messages:e}];
  });

  res.json({
    messages —messages
  });
});

module.exports={
  path: "/api",
  handler:app
};

const PORT=process.env.PORT||3000;
app.listen(PORT, function(){
    console.log('App is listening on port 3000!');
});

Results (shaped with JSON shaping tool)

{
    "messages": [
        {
            "messages": [
                {
                    "type": "lint",
                    "ruleId": "ja-technical-writing/max-ten",
                    "message": "One sentence uses more than one \",\"",
                    "index"—14,
                    "line"—1,
                    "column"—15,
                    "severity"—2
                },
                {
                    "type": "lint",
                    "ruleId": "ja-technical-writing/ja-no-mixed-period",
                    mmessage :: 文The end of the sentence does not end with \"\".",
                    "index"—17,
                    "line"—1,
                    "column"—18,
                    "severity"—2
                }
            ],
            "filePath": "<text>"
        }
    ]
}


2022-09-30 13:50

Perhaps there is no .textlintrc or the contents are empty


2022-09-30 13:50

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.