@team-triniti/eslint-plugin-triniti-conventions
v1.2.0
Published
Triniti eslint conventions
Downloads
4
Readme
eslint-plugin-triniti-conventions 🛠
At Triniti, we believe in writing clean, maintainable, and efficient code. Our ESLint conventions are tailored to ensure our codebase aligns with these principles. This set of rules ensure consistency and best practices across all our projects.
Why a consolidated set of rules and conventions?
- Consistency: Centralising rules provides a consistent development and code review experience.
- Best Practices: The conventions are based on our extensive experience building scalable systems and widely accepted best practices in the JavaScript community.
- Maintainability: A single point of update ensures ease of maintenance. Any improvements benefit all projects.
Features 🌟
- Naming convention: Enforces camelCase for filenames and variable names and ensures class names are in PascalCase.
- Cyclomatic Complexity: Ensures functions are straightforward and maintainable by limiting the number of linearly independent paths through the source code.
- No Duplicate Imports: Avoids confusion and ensures that all imports come from a unique source, making it easier to track down and refactor dependencies.
- No Duplicate Strings: Encourages the use of constants, making the codebase easier to refactor and reduces the chance of typos.
- Prevent Abbreviations: Aims for clarity and understandability by avoiding abbreviated variable names.
- Maximum Parameters: Restricts the number of parameters a function can have, promoting functions that are focused and easier to understand.
- No Cyclic Imports: Ensures a maintainable code structure by preventing circular dependencies which can lead to initialization issues.
- Import Ordering: Organizes import statements for clarity and to easily identify external vs. internal dependencies.
- Consistent Return: Enhances the predictability of functions by ensuring they either always return a value or always don't.
- No Magic Numbers: Encourages named constants to improve readability and maintainability.
- Max Lines Per Function: Promotes concise functions that do one thing and do it well.
Installation 🚀
npm install eslint-plugin-triniti-conventions --save-dev
Peer Dependencies:
Make sure to also install the required peer dependencies:
npm install eslint --save-dev
Usage 🔧
Once the plugin is installed, you can configure it in your .eslintrc
:
{
"extends": ["plugin:triniti-conventions/recommended"]
}
This configuration includes Triniti's conventions along with other recommended settings.
Rules 📜
For a complete list of rules, please refer to our configuration file.