§ Idea

It's an ESLint plugin which automatically updates row numbers inside every console.log:


§ Setup

First, make sure eslint itself is installed among the dev dependencies. "i" below means install, "-D" below means "dev dependency" (as opposed to a normal dependency). Quick refresher — when you publish an npm package and somebody installs it, its dev dependencies don't get installed when they npm i your package. That's the point of separating dev and normal dependencies.

Both eslint and eslint-plugin-row-num are for your program's testing, so we install them as "dev" dependencies, via -D flag:

npm i -D eslint
npm i -D eslint-plugin-row-num

§ Some basics

Then, you need to configure ESLint to use the plugin.

As you know, ESLint is pluggable which is the reason why it won over predecessors JSLint and JSHint — ESLint runs only the rules you asked for, and at the warning levels you asked for.

We need to do the asking.

We'll use an ESLint configuration file opens in a new tab. If you don't have a config file yet, you can nip the config file from another project and tweak it or, you can use initiation script eslint --init. Mind you, eslint configs are dot files which are hidden by the system. It's best practice to make them visible opens in a new tab.

But now, some basics first.

For example, the following rule configuration row:

"row-num/correct-row-num": "error",


"set the rule "correct-row-num" from plugin "row-num" (which comes from npm package "eslint-plugin-row-num") to report findings at an "error" level.

§ Setup instructions

We need to add row-num to the plugins section of your .eslintrc configuration file, for example, here's a real config file we use — notice the "row-num" in "plugins" key:

"env": {
"es6": true,
"node": true
"extends": [
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
"plugins": ["row-num"],
"ignorePatterns": [
"rules": {
"curly": "error",
"no-constant-condition": [
"checkLoops": false
"no-else-return": "error",
"no-inner-declarations": "error",
"no-unneeded-ternary": "error",
"no-useless-return": "error",
"no-var": "error",
"one-var": ["error", "never"],
"prefer-arrow-callback": "error",
"prefer-const": "error",
"prefer-template": "error",
"row-num/correct-row-num": "error",
"strict": "error",
"symbol-description": "error",
"yoda": [
"exceptRange": true

Reciting the ESLint documentation, rules can have different settings:

"off" or 0 - turn the rule off

"warn" or 1 - turn the rule on as a warning (doesn't affect exit code)

"error" or 2 - turn the rule on as an error (exit code is 1 when triggered)


Which means, you can put 2 (as number, without quotes) or "error" (as string, so with quotes):

"rules": {
"row-num/correct-row-num": 2


"rules": {
"row-num/correct-row-num": "error"

Both are the same thing.

§ Changelog

See it in the monorepo opens in a new tab, on GitHub.

§ Contributing

To report bugs or request features or assistance, raise an issue on GitHub opens in a new tab.

Any code contributions welcome! All Pull Requests will be dealt promptly.

§ Licence

MIT opens in a new tab

Copyright © 2010–2021 Roy Revelt and other contributors

Related packages:

📦 eslint-plugin-test-num 1.5.14
ESLint plugin to update unit test numbers automatically