https://github.com/mawrkus/eslint-plugin-max-methods-per-class
🍱 An ESLint plugin to enforce a maximum number of methods per class (max-methods-per-class)
https://github.com/mawrkus/eslint-plugin-max-methods-per-class
class eslint eslint-plugin lint linter methods static-analysis
Last synced: 7 months ago
JSON representation
🍱 An ESLint plugin to enforce a maximum number of methods per class (max-methods-per-class)
- Host: GitHub
- URL: https://github.com/mawrkus/eslint-plugin-max-methods-per-class
- Owner: mawrkus
- Created: 2021-08-18T22:10:34.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-09-12T13:46:12.000Z (about 4 years ago)
- Last Synced: 2024-04-30T06:00:24.497Z (over 1 year ago)
- Topics: class, eslint, eslint-plugin, lint, linter, methods, static-analysis
- Language: JavaScript
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🍱 An ESLint plugin to enforce a maximum number of methods per class (max-methods-per-class)
Classes containing a lot of methods:
- might be harder to understand,
- might be harder to maintain,
- might indicate that the [single responsibility principle](https://en.wikipedia.org/wiki/Single-responsibility_principle) has been violated.This plugin aims to spot large classes and to enforce splitting them up into smaller ones.
## Install
```shell
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:
```json
{
"plugins": ["max-methods-per-class"],
"rules": {
"max-methods-per-class/max-methods-per-class": ["warn", 4]
}
}
```## Examples
### Fail
```js
/* eslint max-methods-per-class: ["error", 3] */class Listing {
constructor() {}
componentDidMount() {}
renderRow() {}
render() {}
}
```### Pass
```js
/* eslint max-methods-per-class: ["error", 3] */class Listing {
constructor() {}
componentDidMount() {}
render() {}
}
```