@dmitryrechkin/eslint-standard 1.4.7 → 1.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -4
- package/eslint.config.mjs +23 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @dmitryrechkin/eslint-standard
|
|
2
2
|
|
|
3
|
-
A comprehensive ESLint configuration package with TypeScript support, featuring Prettier integration and industry-standard rules.
|
|
3
|
+
A comprehensive ESLint configuration package with TypeScript support, featuring **Prettier integration with Allman brace style** and industry-standard rules for maximum code quality.
|
|
4
4
|
|
|
5
5
|
## 🚀 Quick Start
|
|
6
6
|
|
|
@@ -101,10 +101,20 @@ npx @dmitryrechkin/eslint-standard check-deps --install
|
|
|
101
101
|
- **Performance**: Avoid performance anti-patterns
|
|
102
102
|
|
|
103
103
|
### Code Style & Formatting
|
|
104
|
-
- **
|
|
105
|
-
- **
|
|
104
|
+
- **Prettier Integration**: Automatic code formatting with industry-standard plugins
|
|
105
|
+
- **Brace Style**: Allman style (braces on new lines) via `prettier-plugin-brace-style`
|
|
106
|
+
- **Indentation**: Tabs (4-space width) for accessibility and user preference
|
|
107
|
+
- **Quotes**: Single quotes for consistency
|
|
106
108
|
- **Import Organization**: Automatic import sorting and grouping
|
|
107
|
-
- **JSDoc**: Required documentation with proper formatting
|
|
109
|
+
- **JSDoc**: Required documentation with proper alignment and formatting
|
|
110
|
+
|
|
111
|
+
### Code Complexity & Architecture
|
|
112
|
+
- **Function Complexity**: Max 10 cyclomatic complexity (industry standard)
|
|
113
|
+
- **Cognitive Complexity**: Max 15 (SonarJS) for maintainable code
|
|
114
|
+
- **Function Length**: Max 100 lines (300 for tests) following clean code principles
|
|
115
|
+
- **File Length**: Max 300 lines (500 for tests) for focused modules
|
|
116
|
+
- **Function Parameters**: Max 7 parameters (allows dependency injection patterns)
|
|
117
|
+
- **Nesting Depth**: Max 3 levels to prevent callback hell
|
|
108
118
|
|
|
109
119
|
### Modern JavaScript/TypeScript
|
|
110
120
|
- **ES2020+ Features**: Prefer modern syntax and APIs
|
|
@@ -125,6 +135,40 @@ npx @dmitryrechkin/eslint-standard check-deps --install
|
|
|
125
135
|
| Return type hints | Error | Error | Explicit |
|
|
126
136
|
| Type safety | High | High | Very High |
|
|
127
137
|
|
|
138
|
+
## 📈 Industry Standards Comparison
|
|
139
|
+
|
|
140
|
+
| Metric | This Package | Google | Airbnb | SonarQube | Clean Code |
|
|
141
|
+
|--------|--------------|--------|---------|-----------|------------|
|
|
142
|
+
| Max Parameters | 7 | 4 | No limit* | 7 | 3-4 |
|
|
143
|
+
| Max Function Lines | 100 | 50 | No limit | 200 | 20 |
|
|
144
|
+
| Max File Lines | 300 | 2000 | 2500 | 1000 | 300 |
|
|
145
|
+
| Cyclomatic Complexity | 10 | 10 | No limit | 10 | 5-10 |
|
|
146
|
+
| Max Nesting | 3 levels | 3 levels | No limit | 3 levels | 2-3 levels |
|
|
147
|
+
| Brace Style | Allman | 1TBS | 1TBS | Configurable | Any |
|
|
148
|
+
| Indentation | Tabs (4) | Spaces (2) | Spaces (2) | Configurable | Spaces (4) |
|
|
149
|
+
|
|
150
|
+
*Airbnb recommends objects for >3 parameters
|
|
151
|
+
|
|
152
|
+
## 🎨 Prettier Integration Features
|
|
153
|
+
|
|
154
|
+
This package includes seamless **Prettier integration** that handles all formatting automatically:
|
|
155
|
+
|
|
156
|
+
### Supported File Types
|
|
157
|
+
- **TypeScript/JavaScript**: `.ts`, `.js`, `.tsx`, `.jsx` with Allman brace style
|
|
158
|
+
- **Astro**: `.astro` files with optimized formatting via `prettier-plugin-astro`
|
|
159
|
+
|
|
160
|
+
### Automatic Formatting
|
|
161
|
+
- **Allman Brace Style**: All braces on new lines for maximum readability
|
|
162
|
+
- **Single Quotes**: Consistent string quoting throughout codebase
|
|
163
|
+
- **Tab Indentation**: Accessible indentation with 4-space tab width
|
|
164
|
+
- **Semicolons**: Always required for statement clarity
|
|
165
|
+
- **No Trailing Commas**: Clean object/array formatting
|
|
166
|
+
|
|
167
|
+
### ESLint-Prettier Harmony
|
|
168
|
+
- All conflicting ESLint formatting rules are **automatically disabled**
|
|
169
|
+
- Prettier handles formatting, ESLint handles code quality
|
|
170
|
+
- **No configuration conflicts** - works out of the box
|
|
171
|
+
|
|
128
172
|
## 🔧 External Tools Integration
|
|
129
173
|
|
|
130
174
|
For comprehensive unused code detection, consider these additional tools:
|
package/eslint.config.mjs
CHANGED
|
@@ -348,6 +348,11 @@ export default function ({
|
|
|
348
348
|
format: ['camelCase', 'UPPER_CASE'],
|
|
349
349
|
leadingUnderscore: 'forbid',
|
|
350
350
|
},
|
|
351
|
+
{
|
|
352
|
+
selector: 'objectLiteralProperty',
|
|
353
|
+
format: ['camelCase', 'UPPER_CASE'],
|
|
354
|
+
leadingUnderscore: 'forbid',
|
|
355
|
+
},
|
|
351
356
|
{
|
|
352
357
|
selector: 'enumMember',
|
|
353
358
|
format: ['camelCase', 'UPPER_CASE'],
|
|
@@ -377,7 +382,7 @@ export default function ({
|
|
|
377
382
|
IIFEs: true
|
|
378
383
|
}],
|
|
379
384
|
'max-statements': ['error', 20], // Max 20 statements per function
|
|
380
|
-
'max-params': ['error',
|
|
385
|
+
'max-params': ['error', 7], // Max 7 parameters per function
|
|
381
386
|
'max-depth': ['error', { max: 3 }], // Max 3 levels of block nesting
|
|
382
387
|
'max-nested-callbacks': ['error', 3], // Max 3 levels of callback nesting
|
|
383
388
|
'max-lines': ['warn', {
|
|
@@ -395,7 +400,7 @@ export default function ({
|
|
|
395
400
|
ignoreComments: true
|
|
396
401
|
}],
|
|
397
402
|
'max-statements-per-line': ['error', { max: 1 }],
|
|
398
|
-
'@typescript-eslint/max-params': ['error', { max:
|
|
403
|
+
'@typescript-eslint/max-params': ['error', { max: 7 }], // TypeScript-aware version
|
|
399
404
|
'no-else-return': ['error', { allowElseIf: false }], // Encourage early returns
|
|
400
405
|
'no-lonely-if': 'error', // Avoid single if in else block
|
|
401
406
|
'no-nested-ternary': 'error', // Avoid complex ternary operators
|
|
@@ -849,6 +854,22 @@ export default function ({
|
|
|
849
854
|
'security/detect-non-literal-fs-filename': 'off', // Tests legitimately need dynamic file paths
|
|
850
855
|
'unicorn/prefer-module': 'off', // Tests may need __dirname for reliable paths
|
|
851
856
|
|
|
857
|
+
// Relax complexity rules for test files
|
|
858
|
+
'max-lines-per-function': ['error', {
|
|
859
|
+
max: 300,
|
|
860
|
+
skipBlankLines: true,
|
|
861
|
+
skipComments: true,
|
|
862
|
+
IIFEs: true
|
|
863
|
+
}],
|
|
864
|
+
'max-lines': ['warn', {
|
|
865
|
+
max: 500,
|
|
866
|
+
skipBlankLines: true,
|
|
867
|
+
skipComments: true
|
|
868
|
+
}],
|
|
869
|
+
'complexity': ['error', 20], // Higher complexity allowed in tests
|
|
870
|
+
'max-statements': ['error', 40], // More statements allowed in test functions
|
|
871
|
+
'sonarjs/cognitive-complexity': ['error', 30], // Higher cognitive complexity for tests
|
|
872
|
+
|
|
852
873
|
// Keep as warnings - still worth improving when possible
|
|
853
874
|
'unicorn/no-null': 'off', // APIs often use null, but const can be better
|
|
854
875
|
'sonarjs/no-duplicate-string': 'off', // Test strings repeat, but constants still help readability
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dmitryrechkin/eslint-standard",
|
|
3
3
|
"description": "This package provides a shared ESLint configuration which includes TypeScript support and a set of specific linting rules designed to ensure high-quality and consistent code style across projects.",
|
|
4
|
-
"version": "1.4.
|
|
4
|
+
"version": "1.4.8",
|
|
5
5
|
"main": "eslint.config.mjs",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./eslint.config.mjs"
|