1.1.0 • Published 7 years ago
eslint-plugin-metrics v1.1.0
eslint-plugin-metrics
Check metrics definition
Installation
You'll first need to install ESLint:
$ npm i eslint --save-devNext, install eslint-plugin-metrics:
$ npm install eslint-plugin-metrics --save-devNote: 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 isstringorTemplateLitteral.
metrics.increment('server.started');metrics-documentation: Check that anymetrics.incrementis 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