0.0.2 • Published 5 years ago

eslint-plugin-max-comments-per-function v0.0.2

Weekly downloads
28
License
MIT
Repository
github
Last release
5 years ago

eslint-plugin-max-comments-per-function

Rule to limit the number of comments in a function body.

Experimental. A dumb heuristic to reduce line noise. Comments as percentage of line count might be a smarter choice.

Based on max-lines-per-function from the ESLint core rules, originally by Pete Ward. LICENSE (MIT) preserved.

Installation

$ npm install --save-dev eslint-plugin-max-comments-per-function
# or
$ yarn add -D eslint-plugin-max-comments-per-function

Configuration

.eslintrc additions:

---
plugins:
  - max-comments-per-function
rules:
  - max-comments-per-function/max-comments-per-function:
    - error
    - 3

Disallowed

function foo() {
  // I
  const a = 1;

  // love
  let b = 2;

  // comments
  b++;

  // so much
  return b;
}

Allowed

function foo() {
  // I love
  const a = 1;

  // comments
  let b = 2;

  // a bit
  b++;
  return b;
}