Adviser

Adviser

  • Docs
  • API
  • Help
  • GitHub
  • Blog

›Development

Welcome

  • About Adviser

Getting Started

  • Installation
  • Arguments
  • Configuration
  • Built in rules
  • Plugins

Development

  • Create plugins
  • Create rules
  • Contribute in the core

API

  • API

Testing

  • Testing

Create rules

To create rules Adviser provides an API that help the engine with the rule's lifecycle.

Create your first rule

To use the Adviser's API you should have Adviser installed among your project dependencies and extend from Adviser.Rule.

An example of rule will be:

const Adviser = require('adviser');

class ExampleRule extends Adviser.Rule {
  constructor(context) {
    super(context);
  }

  run(sandbox) {}
  ruleExecutionFailed(feedback, error) {}
  ruleExecutionEnded(feedback) {}
}

module.exports = ExampleRule;

Rule's context

Adviser sends the rule's context in the constructor, the context includes:

  • dirname
  • filename
  • options defined in the configuration file
  • ruleId
  • severity

Run method

Execution Failed Hook

Execution Ended Hook

Last updated on 10/1/2019 by Iran Reyes
← Create pluginsContribute in the core →
  • Create your first rule
    • Rule's context
    • Run method
    • Execution Failed Hook
    • Execution Ended Hook
Adviser
Docs
Getting StartedDevelopmentAPI Reference
Community
DiscordTwitterIssues
More
BlogGitHubStar
Crafted with Love by your Open Source team at Jam3 in Canada