@dmitryrechkin/eslint-standard 1.1.3 โ 1.1.4
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 +102 -2
- package/eslint.config.mjs +43 -0
- package/package.json +1 -1
- package/src/plugins/interface-brace.mjs +1 -1
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@ A comprehensive ESLint configuration package with TypeScript support, featuring
|
|
|
9
9
|
- ๐ **Automatic Import Sorting**: Organizes imports with type imports and regular imports properly grouped
|
|
10
10
|
- ๐๏ธ **Class Member Ordering**: Auto-reorders class members by visibility (public โ protected โ private) and type (fields โ constructor โ methods)
|
|
11
11
|
- ๐ **JSDoc Alignment**: Automatically fixes JSDoc comment indentation and alignment with proper tab formatting
|
|
12
|
+
- ๐ **JSDoc Requirements**: Enforces comprehensive JSDoc documentation with auto-generation of comment blocks
|
|
12
13
|
- ๐งน **Unused Import Removal**: Automatically detects and removes unused imports
|
|
13
14
|
|
|
14
15
|
### **Code Style Enforcement**
|
|
@@ -16,6 +17,7 @@ A comprehensive ESLint configuration package with TypeScript support, featuring
|
|
|
16
17
|
- **Modern JavaScript**: Supports ECMAScript 2020 and newer features
|
|
17
18
|
- **Consistent Formatting**: Enforces Allman brace style, tab indentation, single quotes, and semicolons
|
|
18
19
|
- **Naming Conventions**: Comprehensive naming rules for variables, functions, classes, and more
|
|
20
|
+
- **JSDoc Documentation**: Requires comprehensive documentation for all exported functions, classes, methods, interfaces, types, and enums
|
|
19
21
|
- **Customizable**: Flexible configuration options for different project needs
|
|
20
22
|
|
|
21
23
|
## ๐ฆ Installation
|
|
@@ -68,7 +70,14 @@ export default eslintStandard({
|
|
|
68
70
|
rules: {
|
|
69
71
|
// Override or add custom rules
|
|
70
72
|
'no-console': 'warn',
|
|
71
|
-
'perfectionist/sort-classes': 'off' // Disable auto class member sorting if needed
|
|
73
|
+
'perfectionist/sort-classes': 'off', // Disable auto class member sorting if needed
|
|
74
|
+
// Disable JSDoc requirements if needed
|
|
75
|
+
'jsdoc/require-jsdoc': 'off',
|
|
76
|
+
'jsdoc/require-description': 'off',
|
|
77
|
+
// Disable type hint requirements (if you prefer TypeScript-only types)
|
|
78
|
+
'jsdoc/require-param-type': 'off',
|
|
79
|
+
'jsdoc/require-returns-type': 'off',
|
|
80
|
+
'jsdoc/no-types': ['error', { contexts: ['any'] }]
|
|
72
81
|
}
|
|
73
82
|
});
|
|
74
83
|
```
|
|
@@ -131,7 +140,10 @@ When you run `eslint --fix`, this configuration will automatically:
|
|
|
131
140
|
2. **๐ Reorder Class Members**: Arrange class members by visibility and type:
|
|
132
141
|
- Static properties โ Instance properties โ Constructor โ Static methods โ Instance methods
|
|
133
142
|
- Within each group: public โ protected โ private
|
|
134
|
-
3. **๐ Fix JSDoc
|
|
143
|
+
3. **๐ Fix JSDoc Comments**:
|
|
144
|
+
- Generate missing JSDoc comment blocks for functions, classes, methods, interfaces, types, and enums
|
|
145
|
+
- Align JSDoc comments with proper tab indentation
|
|
146
|
+
- Add parameter and return value placeholders
|
|
135
147
|
4. **๐งน Remove Unused Imports**: Clean up unused import statements
|
|
136
148
|
5. **โจ Format Code**: Apply consistent spacing, quotes, semicolons, and brace styles
|
|
137
149
|
|
|
@@ -195,6 +207,44 @@ export class UserService
|
|
|
195
207
|
}
|
|
196
208
|
```
|
|
197
209
|
|
|
210
|
+
#### JSDoc Documentation with Type Hints
|
|
211
|
+
```typescript
|
|
212
|
+
// โ Before - Missing JSDoc
|
|
213
|
+
export function processUser(userData: UserData): ProcessedResult {
|
|
214
|
+
return process(userData);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// โ ๏ธ After (auto-fixed) - JSDoc block generated but missing type hints
|
|
218
|
+
/**
|
|
219
|
+
*
|
|
220
|
+
* @param userData
|
|
221
|
+
* @returns
|
|
222
|
+
*/
|
|
223
|
+
export function processUser(userData: UserData): ProcessedResult {
|
|
224
|
+
return process(userData);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// โ Still fails - Missing type hints and descriptions
|
|
228
|
+
// ESLint errors:
|
|
229
|
+
// - Missing JSDoc @param "userData" type
|
|
230
|
+
// - Missing JSDoc @param "userData" description
|
|
231
|
+
// - Missing JSDoc @returns type
|
|
232
|
+
// - Missing JSDoc block description
|
|
233
|
+
|
|
234
|
+
// โ
Complete JSDoc with type hints (must be added manually)
|
|
235
|
+
/**
|
|
236
|
+
* Processes user data and returns formatted result.
|
|
237
|
+
* @param {UserData} userData - The user data to process
|
|
238
|
+
* @returns {ProcessedResult} The processed user result
|
|
239
|
+
*/
|
|
240
|
+
export function processUser(userData: UserData): ProcessedResult {
|
|
241
|
+
return process(userData);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// โ ๏ธ Note: ESLint cannot auto-generate type hints from TypeScript types.
|
|
245
|
+
// Type annotations must be added manually to satisfy the linter requirements.
|
|
246
|
+
```
|
|
247
|
+
|
|
198
248
|
#### JSDoc Alignment
|
|
199
249
|
```typescript
|
|
200
250
|
// โ Before
|
|
@@ -220,6 +270,56 @@ export class UserService
|
|
|
220
270
|
- **Enum Members**: `UPPER_CASE` or `PascalCase`
|
|
221
271
|
- **Type Parameters**: `PascalCase`
|
|
222
272
|
|
|
273
|
+
### ๐ JSDoc with Type Hints Requirements
|
|
274
|
+
|
|
275
|
+
This configuration requires comprehensive JSDoc documentation with type hints:
|
|
276
|
+
|
|
277
|
+
- **Type Annotations Required**: All parameters and return values must include JSDoc type hints
|
|
278
|
+
- **Description Required**: All functions, parameters, and return values must have descriptions
|
|
279
|
+
- **Auto-generation Limited**: ESLint can generate JSDoc blocks but cannot infer TypeScript types
|
|
280
|
+
- **Manual Completion Needed**: Type hints must be added manually after auto-generation
|
|
281
|
+
|
|
282
|
+
#### Required JSDoc Format
|
|
283
|
+
|
|
284
|
+
```javascript
|
|
285
|
+
/**
|
|
286
|
+
* Function description is required.
|
|
287
|
+
* @param {string} name - Parameter description is required
|
|
288
|
+
* @param {number} age - Type hint {number} is required
|
|
289
|
+
* @returns {string} Return type and description required
|
|
290
|
+
*/
|
|
291
|
+
function greet(name: string, age: number): string {
|
|
292
|
+
return `Hello ${name}, you are ${age} years old`;
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
#### Common Type Hint Patterns
|
|
297
|
+
|
|
298
|
+
```javascript
|
|
299
|
+
// Basic types
|
|
300
|
+
@param {string} name
|
|
301
|
+
@param {number} count
|
|
302
|
+
@param {boolean} isActive
|
|
303
|
+
@param {Object} config
|
|
304
|
+
@param {Array<string>} items
|
|
305
|
+
@param {Function} callback
|
|
306
|
+
|
|
307
|
+
// Complex types
|
|
308
|
+
@param {UserData} userData - Custom type
|
|
309
|
+
@param {Promise<Response>} response - Generic type
|
|
310
|
+
@param {string|number} id - Union type
|
|
311
|
+
@param {{name: string, age: number}} person - Object type
|
|
312
|
+
@param {string[]} names - Array shorthand
|
|
313
|
+
@returns {void} - For functions with no return
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
#### Important Notes
|
|
317
|
+
|
|
318
|
+
1. **ESLint Cannot Auto-Generate Types**: While ESLint can create JSDoc blocks, it cannot determine TypeScript types
|
|
319
|
+
2. **Manual Work Required**: After running `--fix`, you must manually add all type hints
|
|
320
|
+
3. **Duplication with TypeScript**: This approach duplicates type information already in TypeScript
|
|
321
|
+
4. **Maintenance Overhead**: Types must be kept in sync between TypeScript and JSDoc
|
|
322
|
+
|
|
223
323
|
## โ ๏ธ Troubleshooting
|
|
224
324
|
|
|
225
325
|
### Peer Dependency Warnings
|
package/eslint.config.mjs
CHANGED
|
@@ -155,6 +155,49 @@ export default function ({
|
|
|
155
155
|
'jsdoc/check-indentation': 'off', // Disabled to avoid conflicts with our custom plugin
|
|
156
156
|
'jsdoc/tag-lines': 'off', // Disabled to avoid conflicts with our custom plugin
|
|
157
157
|
'jsdoc-indent/jsdoc-indent': ['error', { tabWidth: 4 }],
|
|
158
|
+
|
|
159
|
+
// JSDoc requirements with type hints
|
|
160
|
+
'jsdoc/require-jsdoc': ['error', {
|
|
161
|
+
enableFixer: false, // Don't auto-generate empty JSDoc blocks
|
|
162
|
+
require: {
|
|
163
|
+
FunctionDeclaration: true,
|
|
164
|
+
MethodDefinition: true,
|
|
165
|
+
ClassDeclaration: true,
|
|
166
|
+
ArrowFunctionExpression: true,
|
|
167
|
+
FunctionExpression: true
|
|
168
|
+
},
|
|
169
|
+
contexts: [
|
|
170
|
+
'TSInterfaceDeclaration',
|
|
171
|
+
'TSTypeAliasDeclaration',
|
|
172
|
+
'TSEnumDeclaration'
|
|
173
|
+
// Removed 'ClassProperty' and 'PropertyDefinition' - no JSDoc required for properties
|
|
174
|
+
]
|
|
175
|
+
}],
|
|
176
|
+
'jsdoc/require-description': 'error',
|
|
177
|
+
'jsdoc/require-param': 'error',
|
|
178
|
+
'jsdoc/require-param-description': 'error',
|
|
179
|
+
'jsdoc/require-param-name': 'error',
|
|
180
|
+
'jsdoc/require-returns': 'error',
|
|
181
|
+
'jsdoc/require-returns-description': 'error',
|
|
182
|
+
'jsdoc/check-param-names': 'error',
|
|
183
|
+
'jsdoc/check-tag-names': 'error',
|
|
184
|
+
'jsdoc/check-types': 'error',
|
|
185
|
+
'jsdoc/valid-types': 'error',
|
|
186
|
+
'jsdoc/no-undefined-types': 'error',
|
|
187
|
+
'jsdoc/require-yields': 'error',
|
|
188
|
+
'jsdoc/require-throws': 'error',
|
|
189
|
+
'jsdoc/check-alignment': 'off', // Handled by custom plugin
|
|
190
|
+
'jsdoc/multiline-blocks': ['error', {
|
|
191
|
+
noMultilineBlocks: false,
|
|
192
|
+
minimumLengthForMultiline: 40
|
|
193
|
+
}],
|
|
194
|
+
|
|
195
|
+
// JSDoc with type hints requirements
|
|
196
|
+
'jsdoc/require-param-type': 'error', // Require type hints for parameters
|
|
197
|
+
'jsdoc/require-returns-type': 'error', // Require type hints for returns
|
|
198
|
+
'jsdoc/no-types': 'off', // Allow type annotations in JSDoc
|
|
199
|
+
'jsdoc/check-types': 'error', // Ensure valid JSDoc types
|
|
200
|
+
'jsdoc/valid-types': 'error', // Validate type syntax
|
|
158
201
|
|
|
159
202
|
// Enhanced: Interface brace style
|
|
160
203
|
'interface-brace/interface-brace-style': 'error',
|
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.1.
|
|
4
|
+
"version": "1.1.4",
|
|
5
5
|
"main": "eslint.config.mjs",
|
|
6
6
|
"bin": {
|
|
7
7
|
"eslint-standard": "./src/cli/index.mjs"
|
|
@@ -103,7 +103,7 @@ const interfaceBraceRule = {
|
|
|
103
103
|
// Replace the space before the brace with a newline and proper indentation
|
|
104
104
|
return fixer.replaceTextRange(
|
|
105
105
|
[equalsToken.range[1], openingBrace.range[0]],
|
|
106
|
-
'
|
|
106
|
+
'\n' + baseIndent
|
|
107
107
|
);
|
|
108
108
|
}
|
|
109
109
|
});
|