@dmitryrechkin/eslint-standard 1.4.7 → 1.4.9
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 +27 -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
|
@@ -130,12 +130,16 @@ export default function ({
|
|
|
130
130
|
'index-signature',
|
|
131
131
|
'static-property',
|
|
132
132
|
'property',
|
|
133
|
+
'protected-static-property',
|
|
133
134
|
'protected-property',
|
|
135
|
+
'private-static-property',
|
|
134
136
|
'private-property',
|
|
135
137
|
'constructor',
|
|
136
138
|
'static-method',
|
|
137
139
|
'method',
|
|
140
|
+
'protected-static-method',
|
|
138
141
|
'protected-method',
|
|
142
|
+
'private-static-method',
|
|
139
143
|
'private-method'
|
|
140
144
|
]
|
|
141
145
|
}
|
|
@@ -348,6 +352,11 @@ export default function ({
|
|
|
348
352
|
format: ['camelCase', 'UPPER_CASE'],
|
|
349
353
|
leadingUnderscore: 'forbid',
|
|
350
354
|
},
|
|
355
|
+
{
|
|
356
|
+
selector: 'objectLiteralProperty',
|
|
357
|
+
format: ['camelCase', 'UPPER_CASE'],
|
|
358
|
+
leadingUnderscore: 'forbid',
|
|
359
|
+
},
|
|
351
360
|
{
|
|
352
361
|
selector: 'enumMember',
|
|
353
362
|
format: ['camelCase', 'UPPER_CASE'],
|
|
@@ -377,7 +386,7 @@ export default function ({
|
|
|
377
386
|
IIFEs: true
|
|
378
387
|
}],
|
|
379
388
|
'max-statements': ['error', 20], // Max 20 statements per function
|
|
380
|
-
'max-params': ['error',
|
|
389
|
+
'max-params': ['error', 7], // Max 7 parameters per function
|
|
381
390
|
'max-depth': ['error', { max: 3 }], // Max 3 levels of block nesting
|
|
382
391
|
'max-nested-callbacks': ['error', 3], // Max 3 levels of callback nesting
|
|
383
392
|
'max-lines': ['warn', {
|
|
@@ -395,7 +404,7 @@ export default function ({
|
|
|
395
404
|
ignoreComments: true
|
|
396
405
|
}],
|
|
397
406
|
'max-statements-per-line': ['error', { max: 1 }],
|
|
398
|
-
'@typescript-eslint/max-params': ['error', { max:
|
|
407
|
+
'@typescript-eslint/max-params': ['error', { max: 7 }], // TypeScript-aware version
|
|
399
408
|
'no-else-return': ['error', { allowElseIf: false }], // Encourage early returns
|
|
400
409
|
'no-lonely-if': 'error', // Avoid single if in else block
|
|
401
410
|
'no-nested-ternary': 'error', // Avoid complex ternary operators
|
|
@@ -849,6 +858,22 @@ export default function ({
|
|
|
849
858
|
'security/detect-non-literal-fs-filename': 'off', // Tests legitimately need dynamic file paths
|
|
850
859
|
'unicorn/prefer-module': 'off', // Tests may need __dirname for reliable paths
|
|
851
860
|
|
|
861
|
+
// Relax complexity rules for test files
|
|
862
|
+
'max-lines-per-function': ['error', {
|
|
863
|
+
max: 300,
|
|
864
|
+
skipBlankLines: true,
|
|
865
|
+
skipComments: true,
|
|
866
|
+
IIFEs: true
|
|
867
|
+
}],
|
|
868
|
+
'max-lines': ['warn', {
|
|
869
|
+
max: 500,
|
|
870
|
+
skipBlankLines: true,
|
|
871
|
+
skipComments: true
|
|
872
|
+
}],
|
|
873
|
+
'complexity': ['error', 20], // Higher complexity allowed in tests
|
|
874
|
+
'max-statements': ['error', 40], // More statements allowed in test functions
|
|
875
|
+
'sonarjs/cognitive-complexity': ['error', 30], // Higher cognitive complexity for tests
|
|
876
|
+
|
|
852
877
|
// Keep as warnings - still worth improving when possible
|
|
853
878
|
'unicorn/no-null': 'off', // APIs often use null, but const can be better
|
|
854
879
|
'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.9",
|
|
5
5
|
"main": "eslint.config.mjs",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./eslint.config.mjs"
|