118 lines
3.2 KiB
Markdown
118 lines
3.2 KiB
Markdown
# @ruject/eslint-config
|
|
|
|

|
|

|
|

|
|
|
|
A comprehensive ESLint configuration package designed for TypeScript projects, enforcing stylistic consistency, code quality, and modern best practices.
|
|
|
|
## Why This Config?
|
|
|
|
* Reduces boilerplate setup across multiple projects.
|
|
* Enforces consistent style and property ordering in classes/interfaces/objects.
|
|
* Integrates modern ESLint ecosystem plugins in a single, maintainable config.
|
|
* Designed for **TypeScript projects** with type-aware linting.
|
|
|
|
## Features
|
|
|
|
* **TypeScript support** via [`typescript-eslint`](https://typescript-eslint.io/).
|
|
* **Code style enforcement** with [`eslint-plugin-perfectionist`](https://github.com/azz/eslint-plugin-perfectionist) and [`eslint-plugin-prettier`](https://github.com/prettier/eslint-plugin-prettier).
|
|
* **Quality & bug detection** using [`eslint-plugin-sonarjs`](https://github.com/SonarSource/eslint-plugin-sonarjs) and [`eslint-plugin-unicorn`](https://github.com/sindresorhus/eslint-plugin-unicorn).
|
|
* **Custom sorting rules** for classes, interfaces, objects, and object types.
|
|
* **Prettier integration** for consistent formatting.
|
|
* Ignores build output directories like `dist/**`.
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
bun install -D @ruject/eslint-config
|
|
# or
|
|
npm install --save-dev @ruject/eslint-config
|
|
```
|
|
|
|
> All ESLint plugins and TypeScript ESLint should be installed as dev dependencies alongside this package.
|
|
|
|
---
|
|
|
|
## Usage
|
|
|
|
### Flat config (recommended)
|
|
|
|
Create a `eslint.config.js` in your project:
|
|
|
|
```js
|
|
import config from '@ruject/eslint-config';
|
|
export default config;
|
|
```
|
|
|
|
### Legacy config
|
|
|
|
Create a `.eslintrc.js` in your project:
|
|
|
|
```js
|
|
module.exports = {
|
|
extends: ['@ruject/eslint-config'],
|
|
};
|
|
```
|
|
|
|
---
|
|
|
|
## Rules
|
|
|
|
### Sorting with Perfectionist
|
|
|
|
* **Classes, Interfaces, Objects, Object Types** are sorted according to custom natural rules.
|
|
* `sortBaseRule` — base sorting order for objects and interfaces.
|
|
* `sortDetailedRule` — detailed sorting for classes, including static/private/protected properties and methods.
|
|
* Keys like `type`, `id`, `name`, `meta`, `author`, `version` are prioritized, unknown properties are moved to the bottom.
|
|
|
|
* All other members (methods, properties, accessors, static blocks) are sorted naturally with detailed rules.
|
|
|
|
### Prettier
|
|
|
|
* Enforces single quotes.
|
|
* Automatically checks formatting errors.
|
|
* Ensures code is formatted consistently across the project.
|
|
|
|
### SonarJS Rules
|
|
|
|
* Integrates recommended SonarJS rules for detecting code smells and maintainability issues.
|
|
|
|
### Unicorn Rules
|
|
|
|
* Enables all Unicorn plugin rules for safer and cleaner code.
|
|
|
|
---
|
|
|
|
## Ignored Files
|
|
|
|
Automatically ignores:
|
|
|
|
```plain
|
|
dist/**
|
|
**/dist/**
|
|
build/**
|
|
**/build/**
|
|
```
|
|
|
|
---
|
|
|
|
## Customization
|
|
|
|
You can extend or override any rule as needed:
|
|
|
|
```js
|
|
module.exports = {
|
|
extends: ['@ruject/eslint-config'],
|
|
rules: {
|
|
'perfectionist/sort-classes': 'off',
|
|
'prettier/prettier': ['error', { singleQuote: false }],
|
|
},
|
|
};
|
|
```
|
|
|
|
---
|
|
|
|
## License
|
|
|
|
See [LICENSE](LICENSE) for details.
|