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:
Then configure the rules you want to use under the rules section.
Supported Rules
metrics-definition
: Check that a single argument is used to increment a metric and that its type isstring
orTemplateLitteral
.
metrics;
metrics-documentation
: Check that anymetrics.increment
is documented with the appropriate format:
/** * @metric server.started Server has started */metrics; // @metric server.started Server has startedmetrics;
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