Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

textlint-rule-helper

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

textlint-rule-helper

Helper for textlint rule.

  • 1.1.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
101K
increased by13.92%
Maintainers
1
Weekly downloads
 
Created
Source

textlint-rule-helper

This is helper library for creating textlint rule.

Installation

npm install textlint-rule-helper

Usage - API

####class: RuleHelper Members

#####new RuleHelper() RuleHelper is helper class for textlint.

#####ruleHelper.getParents(node) 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

  • node TxtNode - the node is start point.

Returns: Array.<TxtNode>
#####ruleHelper.isChildNode(node, types) Return true if node is wrapped any one of node types.

Params

  • node TxtNode - is target node
  • types Array.<string> - are wrapped target node

Returns: boolean

####ruleHelper.getParents(node) 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

  • node TxtNode - the node is start point.

Returns: Array.<TxtNode>

####ruleHelper.isChildNode(node, types) Return true if node is wrapped any one of node types.

Params

  • node TxtNode - is target node
  • types Array.<string> - are wrapped target node

Returns: boolean

Example

A rule for textlint.

var RuleHelper = require("textlint-rule-helper").RuleHelper;
module.exports = function (context) {
    var helper = new RuleHelper(context);
    var exports = {}
    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);
        
    }
    return exports;
}

Development

# watch
npm run watch
# build
npm run build
# test
npm run test
# Generate README from tempalte
npm run docs

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT

FAQs

Package last updated on 29 Oct 2015

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc