eslint-plugin-max-methods-per-class

1.0.2 • Public • Published

🍱 An ESLint plugin to enforce a maximum number of methods per class (max-methods-per-class)

Classes containing a lot of methods:

This plugin aims to spot large classes and to enforce splitting them up into smaller ones.

Install

npm install eslint-plugin-max-methods-per-class --save-dev

Usage

The rule takes one option, a number, which is the maximum number of methods for each class. The default is 6.

You can set the option in configuration like this:

{
  "plugins": ["max-methods-per-class"],
  "rules": {
    "max-methods-per-class/max-methods-per-class": ["warn", 4]
  }
}

Examples

Fail

/* eslint max-methods-per-class: ["error", 3] */

class Listing {
  constructor() {}
  componentDidMount() {}
  renderRow() {}
  render() {}
}

Pass

/* eslint max-methods-per-class: ["error", 3] */

class Listing {
  constructor() {}
  componentDidMount() {}
  render() {}
}

Package Sidebar

Install

npm i eslint-plugin-max-methods-per-class

Weekly Downloads

7

Version

1.0.2

License

MIT

Unpacked Size

3.82 kB

Total Files

4

Last publish

Collaborators

  • mawrkus