@dmitryrechkin/eslint-standard 1.4.6 → 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 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
- - **Brace Style**: Allman style (braces on new lines) via Prettier
105
- - **Indentation**: Tabs with consistent spacing
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
@@ -88,29 +88,23 @@ export default function ({
88
88
  '@typescript-eslint/explicit-function-return-type': 'error',
89
89
  '@typescript-eslint/no-explicit-any': 'error', // Ban 'any' type for type safety
90
90
 
91
- // Original coding guidelines
92
- 'brace-style': 'off', // Disabled in favor of @stylistic/brace-style
93
- '@stylistic/brace-style': ['error', 'allman', { allowSingleLine: false }],
94
- '@stylistic/block-spacing': ['error', 'never'], // Enforce consistent spacing inside blocks
95
- indent: 'off', // Disabled to avoid conflicts with @stylistic/indent and our JSDoc plugin
96
- '@stylistic/indent': ['error', 'tab', {
97
- SwitchCase: 1,
98
- ignoredNodes: [
99
- 'ImportDeclaration', // Fix for maximum call stack issue with complex imports
100
- 'TSTypeReference' // Fix for TypeScript type references causing recursion
101
- ]
102
- }],
103
- quotes: 'off', // Disabled in favor of @stylistic/quotes
104
- '@stylistic/quotes': ['error', 'single'],
105
- semi: 'off', // Disabled in favor of @stylistic/semi
106
- '@stylistic/semi': ['error', 'always'],
91
+ // Original coding guidelines - formatting rules disabled in favor of prettier
92
+ 'brace-style': 'off', // Handled by prettier-plugin-brace-style
93
+ '@stylistic/brace-style': 'off', // Handled by prettier-plugin-brace-style
94
+ '@stylistic/block-spacing': 'off', // Handled by prettier
95
+ indent: 'off', // Handled by prettier (useTabs: true, tabWidth: 4)
96
+ '@stylistic/indent': 'off', // Handled by prettier (useTabs: true, tabWidth: 4)
97
+ quotes: 'off', // Handled by prettier (singleQuote: true)
98
+ '@stylistic/quotes': 'off', // Handled by prettier (singleQuote: true)
99
+ semi: 'off', // Handled by prettier (semi: true)
100
+ '@stylistic/semi': 'off', // Handled by prettier (semi: true)
107
101
  '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
108
- 'no-trailing-spaces': 'off', // Disabled in favor of @stylistic/no-trailing-spaces
109
- '@stylistic/no-trailing-spaces': 'error',
110
- 'eol-last': 'off', // Disabled in favor of @stylistic/eol-last
111
- '@stylistic/eol-last': ['error', 'always'],
112
- 'comma-dangle': 'off', // Disabled in favor of @stylistic/comma-dangle
113
- '@stylistic/comma-dangle': ['error', 'never'],
102
+ 'no-trailing-spaces': 'off', // Handled by prettier
103
+ '@stylistic/no-trailing-spaces': 'off', // Handled by prettier
104
+ 'eol-last': 'off', // Handled by prettier
105
+ '@stylistic/eol-last': 'off', // Handled by prettier
106
+ 'comma-dangle': 'off', // Handled by prettier (trailingComma: 'none')
107
+ '@stylistic/comma-dangle': 'off', // Handled by prettier (trailingComma: 'none')
114
108
 
115
109
  // Comprehensive naming conventions based on coding standards
116
110
 
@@ -354,6 +348,11 @@ export default function ({
354
348
  format: ['camelCase', 'UPPER_CASE'],
355
349
  leadingUnderscore: 'forbid',
356
350
  },
351
+ {
352
+ selector: 'objectLiteralProperty',
353
+ format: ['camelCase', 'UPPER_CASE'],
354
+ leadingUnderscore: 'forbid',
355
+ },
357
356
  {
358
357
  selector: 'enumMember',
359
358
  format: ['camelCase', 'UPPER_CASE'],
@@ -383,7 +382,7 @@ export default function ({
383
382
  IIFEs: true
384
383
  }],
385
384
  'max-statements': ['error', 20], // Max 20 statements per function
386
- 'max-params': ['error', 4], // Max 4 parameters per function
385
+ 'max-params': ['error', 7], // Max 7 parameters per function
387
386
  'max-depth': ['error', { max: 3 }], // Max 3 levels of block nesting
388
387
  'max-nested-callbacks': ['error', 3], // Max 3 levels of callback nesting
389
388
  'max-lines': ['warn', {
@@ -401,7 +400,7 @@ export default function ({
401
400
  ignoreComments: true
402
401
  }],
403
402
  'max-statements-per-line': ['error', { max: 1 }],
404
- '@typescript-eslint/max-params': ['error', { max: 4 }], // TypeScript-aware version
403
+ '@typescript-eslint/max-params': ['error', { max: 7 }], // TypeScript-aware version
405
404
  'no-else-return': ['error', { allowElseIf: false }], // Encourage early returns
406
405
  'no-lonely-if': 'error', // Avoid single if in else block
407
406
  'no-nested-ternary': 'error', // Avoid complex ternary operators
@@ -803,7 +802,12 @@ export default function ({
803
802
  {
804
803
  parser: 'typescript',
805
804
  plugins: [import.meta.resolve('prettier-plugin-brace-style')],
806
- braceStyle: 'allman'
805
+ braceStyle: 'allman',
806
+ singleQuote: true,
807
+ useTabs: true,
808
+ tabWidth: 4,
809
+ semi: true,
810
+ trailingComma: 'none'
807
811
  }
808
812
  ]
809
813
  }
@@ -816,7 +820,12 @@ export default function ({
816
820
  'error',
817
821
  {
818
822
  parser: 'astro',
819
- plugins: [import.meta.resolve('prettier-plugin-astro')]
823
+ plugins: [import.meta.resolve('prettier-plugin-astro')],
824
+ singleQuote: true,
825
+ useTabs: true,
826
+ tabWidth: 4,
827
+ semi: true,
828
+ trailingComma: 'none'
820
829
  }
821
830
  ]
822
831
  }
@@ -845,6 +854,22 @@ export default function ({
845
854
  'security/detect-non-literal-fs-filename': 'off', // Tests legitimately need dynamic file paths
846
855
  'unicorn/prefer-module': 'off', // Tests may need __dirname for reliable paths
847
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
+
848
873
  // Keep as warnings - still worth improving when possible
849
874
  'unicorn/no-null': 'off', // APIs often use null, but const can be better
850
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.6",
4
+ "version": "1.4.8",
5
5
  "main": "eslint.config.mjs",
6
6
  "exports": {
7
7
  ".": "./eslint.config.mjs"