Package Exports
- eslint-plugin-quality-gates
- eslint-plugin-quality-gates/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (eslint-plugin-quality-gates) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
eslint-plugin-quality-gates
An ESLint plugin that enforces best practices in JavaScript/TypeScript codebases. This plugin helps maintain code quality and consistency by enforcing common best practices and patterns.
Installation
npm install --save-dev eslint-plugin-quality-gates
Requirements
- ESLint >= 8.0.0
- Node.js >= 16.0.0
Usage
Basic Configuration
Add eslint-plugin-quality-gates
to the plugins section of your ESLint configuration file:
{
"plugins": [
"eslint-plugin-quality-gates"
]
}
Flat Config (ESLint 8.21.0+)
If you're using the new flat config format:
// eslint.config.js
import eslintPluginQualityGates from 'eslint-plugin-quality-gates';
export default [
{
plugins: {
'eslint-plugin-quality-gates': eslintPluginQualityGates,
},
rules: {
// Configure your rules here
},
},
];
Rules
file-naming-convention
Enforces consistent file naming patterns across your codebase. By default, it ensures files follow camelCase naming, but you can specify any pattern for any folder.
Flexible Examples:
// .eslintrc.js
module.exports = {
rules: {
'eslint-plugin-quality-gates/file-naming-convention': ['error', {
patterns: [
{ pattern: '^[a-z][a-zA-Z0-9]*$', folders: ['src/components'] }, // camelCase
{ pattern: '^[A-Z][a-zA-Z0-9]*$', folders: ['src/pages'] }, // PascalCase
{ pattern: '^[a-z][a-z0-9-]*$', folders: ['src/utils'] }, // kebab-case
{ pattern: '^special-[a-z0-9-]+$', folders: ['src/special'] }, // special prefix
{ pattern: '^[a-z][a-zA-Z0-9]*$', folders: ['.'] } // fallback
]
}]
}
};
This rule:
- Allows you to specify different naming conventions for different folders
- Supports fallback/default patterns
- Works with any valid regex pattern
- Helps maintain a consistent naming convention across your project
require-exports
Ensures that specified named exports are present in specific files. This is useful for maintaining consistent module interfaces across your codebase.
// In your ESLint config
module.exports = {
rules: {
'eslint-plugin-quality-gates/require-exports': ['error', {
exports: ['metadata', 'config'] // Specify required exports
}]
}
};
This rule:
- Enforces the presence of specific exports in files
- Helps maintain consistent module interfaces
- Useful for ensuring configuration files have required exports
- Supports both variable and function exports
Contributing
We welcome contributions! Here's how you can help:
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Install dependencies (
npm install
) - Make your changes
- Run tests (
npm test
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Development Setup
# Install dependencies
npm install
# Run tests
npm test
# Run linting
npm run lint
# Build the project
npm run build
Adding New Rules
- Create a new file in
src/rules/
for your rule - Export your rule following the pattern in existing rules
- Add your rule to
src/index.ts
- Add tests in
src/rules/__tests__/
- Update this README with documentation for your rule
Author
License
ISC