Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
textlint-tester
Advanced tools
Mocha test helper library for textlint rule.
npm install --save-dev textlint-tester mocha
textlint-tester
{string} ruleName
ruleName is a name of the rule.{Function} rule
rule is the exported function of the rule.{string[]|object[]} valid
valid is an array of text which should be passed.
object
if you want to specify some options. object
can have the following properties:
{string} text
: a text to be linted{object} options
: options to be passed to the rule{string} ext
: an extension key. Default: .md
(Markdown)valid
object example:
[
"text",
{ text : "text" },
{
text: "text",
options: {
"key": "value",
},
},
{
text: "<p>this sentence is parsed as HTML document.</p>",
ext: ".html",
},
]
{object[]} invalid
invalid is an array of object which should be failed.
object
can have the following properties:
{string} text
: a text to be linted.{string} output
: a fixed text.{string} ext
: an extension key.{object[]} errors
: an array of error objects which should be raised againt the text.invalid
object example:
[
{
text: "text",
output: "text",
ext: ".txt",
errors: [
{
messages: "expected message",
line: 1,
column: 1
}
]
}
]
test/example-test.js
:
const TextLintTester = require("textlint-tester");
const tester = new TextLintTester();
// rule
const rule = require("textlint-rule-no-todo");
// ruleName, rule, { valid, invalid }
tester.run("no-todo", rule, {
valid: [
"This is ok",
{
// text with options
text: "This is test",
options: {
"key": "value"
}
}
],
invalid: [
// line, column
{
text: "- [ ] string",
errors: [
{
message: "Found TODO: '- [ ] string'",
line: 1,
column: 3
}
]
},
// index
{
text: "- [ ] string",
errors: [
{
message: "Found TODO: '- [ ] string'",
index: 2
}
]
},
{
text: "TODO: string",
options: {"key": "value"},
errors: [
{
message: "found TODO: 'TODO: string'",
line: 1,
column: 1
}
]
},
{
text: "TODO: string",
output: "string", // <= fixed output
errors: [
{
message: "found TODO: 'TODO: string'",
line: 1,
column: 1
}
]
}
]
});
Run the tests:
$(npm bin)/mocha test/
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
MIT
FAQs
testing tool for textlint rule.
The npm package textlint-tester receives a total of 17,169 weekly downloads. As such, textlint-tester popularity was classified as popular.
We found that textlint-tester demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.