eslint-plugin-metrics
v1.1.0
Published
Check metrics definition
Downloads
166
Maintainers
Readme
eslint-plugin-metrics
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 isstring
orTemplateLitteral
.
metrics.increment('server.started');
metrics-documentation
: Check that anymetrics.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