eslint-plugin-enhancer v0.1.0
eslint-plugin-enhancer
Welcome to eslint-plugin-enhancer
! This custom ESLint plugin is here to help you write cleaner, more maintainable code. π It includes rules to organize your files, keep your classes tidy, and make your regular expressions easy to understand. Letβs level up your linting game! π
π§ Installation
Getting started is easy! Just add this plugin to your project:
npm install eslint-plugin-enhancer --save-dev
π Rules
ποΈ enhancer/enforce-one-class-per-file
Keep it simple: one file, one class. This makes your code easier to navigate and maintain. πΌ
- Recommended Severity:
error
Example
β Invalid:
class A {}
class B {}
β Valid:
class A {}
// Other classes go in separate files!
π enhancer/enforce-max-lines-per-class
Letβs keep those classes concise and readable! This rule sets a maximum number of lines per class. βοΈ
- Recommended Severity:
error
- Options:
max
(number): Maximum number of lines allowed in a class.
Example Configuration
"enhancer/enforce-max-lines-per-class": ["error", { "max": 55 }]
β Invalid:
class A {
// Too many lines!
}
β Valid:
class A {
// Neatly within the limit.
}
π enhancer/require-regexp-explanation
Regular expressions can be tricky. This rule makes sure every regex comes with a helpful comment or explanation. π§ββοΈβ¨
- Recommended Severity:
warn
Example
β Invalid:
const regex = /[a-z]{2}/;
β Valid:
// Matches two lowercase letters.
const regex = /[a-z]{2}/;
π― Usage
Add the plugin to your ESLint configuration and start enhancing your code! π
module.exports = {
plugins: ["enhancer"],
rules: {
"enhancer/enforce-one-class-per-file": "error",
"enhancer/enforce-max-lines-per-class": ["error", { "max": 55 }],
"enhancer/require-regexp-explanation": "warn",
},
};
π License
This plugin is licensed under the MIT License. Feel free to contribute or share! π
8 months ago