Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
textlint-tester
Advanced tools
Mocha test helper library for textlint rule.
npm install -D 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
:
var TextLintTester = require("textlint-tester");
var tester = new TextLintTester();
// rule
var rule = require("textlint-rule-no-todo");
// ruleName, rule, { valid, invalid }
tester.run("no-todo", rule, {
valid: [
"this is test",
{
// text with options
text: "this is test",
options: {
"key": "value"
}
}
],
invalid: [
{
text: "- [ ] string",
errors: [
{
message: "found TODO: '- [ ] string'"
}
]
},
{
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/
$(npm bin)/mocha test/
# npm 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 20,922 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.