eslint-plugin-metrics

1.1.0 • Public • Published

eslint-plugin-metrics

Build Status

Check metrics definition

Installation

You'll first need to install ESLint:

$ npm i eslint --save-dev

Next, install eslint-plugin-metrics:

$ npm install eslint-plugin-metrics --save-dev

Note: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-metrics globally.

Usage

Add metrics to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "metrics"
    ]
}

Then configure the rules you want to use under the rules section.

{
    "rules": {
        "metrics/metrics-definition": 2,
        "metrics/metrics-documentation": 2,
    }
}

Supported Rules

  • metrics-definition: Check that a single argument is used to increment a metric and that its type is string or TemplateLitteral.
metrics.increment('server.started');
  • metrics-documentation: Check that any metrics.increment is documented with the appropriate format:
/**
 * @metric server.started Server has started
 */
metrics.increment('server.started');
 
// @metric server.started Server has started
metrics.increment('server.started');

Bin

A tool is also available to generate the metrics inventory in /docs/metrics.md:

The script is:

node ./node_modules/eslint-plugin-metrics/bin/metrics.js ./src
 
# Or in npm context: 
metrics ./src

Package Sidebar

Install

npm i eslint-plugin-metrics

Weekly Downloads

34

Version

1.1.0

License

ISC

Unpacked Size

39.1 kB

Total Files

19

Last publish

Collaborators

  • cptechadmin