Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
textlint-rule-helper
Advanced tools
This is helper library for creating textlint rule.
npm install textlint-rule-helper
Helper for traversing TxtAST.
Get parents of node.
The parent nodes are returned in order from the closest parent to the outer ones.
node
is not contained in the results.
Params
TxtNode
- the node is start point.####ruleHelper.isChildNode(node, types): boolean
Return true if node
is wrapped any one of node types
.
Params
TxtNode
- is target nodeArray.<string>
- are wrapped target nodeYou can manager ignoring range in texts.
Add the range of node
to ignoring range list.
Params
TxtNode
- target nodeAdd the range
to ignoring range list
Params
[number, number]
if the children node has the type that is included in ignoredNodeTypes
,
Add range of children node of node
to ignoring range list,
Params
TxtNode
- target nodeArray.<string>
- are node types for ignoringIf the index
is included in ignoring range list, return true.
Params
number
- index value start with 0If the range
is included in ignoring range list, return true.
Params
[number, number]
If the range
of node
is included in ignoring range list, return true.
Params
TxtNode
- target nodeA rule for textlint.
var RuleHelper = require("textlint-rule-helper").RuleHelper;
var IgnoreNodeManager = require("textlint-rule-helper").IgnoreNodeManager;
module.exports = function (context) {
var helper = new RuleHelper(context);
var ignoreNodeManager = new IgnoreNodeManager()
var exports = {}
var reportingErrors = [];
exports[context.Syntax.Paragraph] = function(node){
// Add `Code` node to ignoring list
ignoreNodeManager.ignoreChildrenByTypes(node, [context.Syntax.Code])
// do something
reportingErrors.push(node, ruleError);
};
exports[context.Syntax.Str] = function(node){
// parent nodes is any one Link or Image.
if(helper.isChildNode(node, [context.Syntax.Link, context.Syntax.Image]){
return;
}
// get Parents
var parents = helper.getParents(node);
}
[Syntax.Document + ":exit"](){
reportingErrors.forEach(function(node, ruleError){
// if the error is ignored, don't report
if(ignoreNodeManager.isIgnored(node)){
return;
}
// report actual
});
}
return exports;
}
You can see real use-case of this helper library.
# watch
npm run watch
# build
npm run build
# test
npm run test
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
MIT
FAQs
A helper library for textlint rule.
The npm package textlint-rule-helper receives a total of 85,564 weekly downloads. As such, textlint-rule-helper popularity was classified as popular.
We found that textlint-rule-helper demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 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
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.