@futdevpro/dynamo-eslint 1.20.12 → 1.20.18
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,211 +1,211 @@
|
|
|
1
|
-
# @futdevpro/dynamo-eslint
|
|
2
|
-
|
|
3
|
-
Shared ESLint presets, custom Dynamo rules, and validation tools for FutDevPro TypeScript projects. This package provides standardized linting configurations optimized for **lint-on-save** functionality across different project types.
|
|
4
|
-
|
|
5
|
-
## 🚀 Quick Start
|
|
6
|
-
|
|
7
|
-
### Installation
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install --save-dev @futdevpro/dynamo-eslint
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
### Required Peer Dependencies
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
npm install --save-dev \
|
|
17
|
-
eslint@~9.39.5 \
|
|
18
|
-
typescript@5.9.3 \
|
|
19
|
-
typescript-eslint@~8.67.0
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
For Angular projects, also install:
|
|
23
|
-
```bash
|
|
24
|
-
npm install --save-dev \
|
|
25
|
-
angular-eslint@~20.7.0
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
`angular-eslint` is an optional peer for Node-only consumers and is required when loading the `ngx` or
|
|
29
|
-
`ngx-package` preset.
|
|
30
|
-
|
|
31
|
-
## 📋 Available Presets
|
|
32
|
-
|
|
33
|
-
### 1. **base** - Core TypeScript Rules
|
|
34
|
-
Generic TypeScript projects with browser environment.
|
|
35
|
-
|
|
36
|
-
```javascript
|
|
37
|
-
const baseConfig = require('@futdevpro/dynamo-eslint/base');
|
|
38
|
-
|
|
39
|
-
module.exports = baseConfig;
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
**Features:**
|
|
43
|
-
- Browser environment
|
|
44
|
-
- 1000 line limit
|
|
45
|
-
- All Dynamo custom rules enabled
|
|
46
|
-
- Explicit return types required
|
|
47
|
-
|
|
48
|
-
### 2. **nts** - Node TypeScript Projects
|
|
49
|
-
Node.js TypeScript applications and services.
|
|
50
|
-
|
|
51
|
-
```javascript
|
|
52
|
-
const ntsConfig = require('@futdevpro/dynamo-eslint/nts');
|
|
53
|
-
|
|
54
|
-
module.exports = ntsConfig;
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
**Features:**
|
|
58
|
-
- Node environment
|
|
59
|
-
- 1500 line limit (extended for server code)
|
|
60
|
-
- Module source type
|
|
61
|
-
- All base rules + Node-specific optimizations
|
|
62
|
-
|
|
63
|
-
### 3. **ngx** - Angular Projects
|
|
64
|
-
Angular applications with component and template linting.
|
|
65
|
-
|
|
66
|
-
```javascript
|
|
67
|
-
const ngxConfig = require('@futdevpro/dynamo-eslint/ngx');
|
|
68
|
-
|
|
69
|
-
module.exports = ngxConfig;
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
**Features:**
|
|
73
|
-
- Angular ESLint integration
|
|
74
|
-
- Browser environment
|
|
75
|
-
- Component and template linting
|
|
76
|
-
- Angular-specific rules
|
|
77
|
-
|
|
78
|
-
### 4. **fsm** - Full Stack Module
|
|
79
|
-
Full-stack TypeScript modules (same as base).
|
|
80
|
-
|
|
81
|
-
```javascript
|
|
82
|
-
const fsmConfig = require('@futdevpro/dynamo-eslint/fsm');
|
|
83
|
-
|
|
84
|
-
module.exports = fsmConfig;
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### 5. **nts-package** - Node TypeScript Packages
|
|
88
|
-
NPM packages and libraries built with TypeScript.
|
|
89
|
-
|
|
90
|
-
```javascript
|
|
91
|
-
const ntsPackageConfig = require('@futdevpro/dynamo-eslint/nts-package');
|
|
92
|
-
|
|
93
|
-
module.exports = ntsPackageConfig;
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
**Features:**
|
|
97
|
-
- Relaxed `@typescript-eslint/ban-types` and `no-explicit-any` rules
|
|
98
|
-
- Optimized for package development
|
|
99
|
-
- Extended line limits for library code
|
|
100
|
-
|
|
101
|
-
### 6. **ngx-package** - Angular Packages
|
|
102
|
-
Angular libraries and packages.
|
|
103
|
-
|
|
104
|
-
```javascript
|
|
105
|
-
const ngxPackageConfig = require('@futdevpro/dynamo-eslint/ngx-package');
|
|
106
|
-
|
|
107
|
-
module.exports = ngxPackageConfig;
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
## ⚙️ Lint-on-Save Configuration
|
|
111
|
-
|
|
112
|
-
**Critical: Configure ESLint to run ONLY on save, not on type!**
|
|
113
|
-
|
|
114
|
-
### VSCode/Cursor Settings
|
|
115
|
-
|
|
116
|
-
Create `.vscode/settings.json` in your project root:
|
|
117
|
-
|
|
118
|
-
```json
|
|
119
|
-
{
|
|
120
|
-
"eslint.run": "onSave",
|
|
121
|
-
"eslint.workingDirectories": [{ "mode": "auto" }],
|
|
122
|
-
"editor.codeActionsOnSave": {
|
|
123
|
-
"source.fixAll.eslint": "explicit"
|
|
124
|
-
},
|
|
125
|
-
"eslint.validate": [
|
|
126
|
-
"javascript",
|
|
127
|
-
"typescript"
|
|
128
|
-
]
|
|
129
|
-
}
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
### Workspace vs User Settings
|
|
133
|
-
|
|
134
|
-
- **Workspace settings** (`.vscode/settings.json`): Apply only to current project
|
|
135
|
-
- **User settings**: Apply globally to all projects
|
|
136
|
-
|
|
137
|
-
For team consistency, use workspace settings.
|
|
138
|
-
|
|
139
|
-
### Multi-Root Workspace Configuration
|
|
140
|
-
|
|
141
|
-
For workspaces with multiple projects:
|
|
142
|
-
|
|
143
|
-
```json
|
|
144
|
-
{
|
|
145
|
-
"eslint.run": "onSave",
|
|
146
|
-
"eslint.workingDirectories": [
|
|
147
|
-
{ "mode": "auto" },
|
|
148
|
-
{ "directory": "./packages/package-a" },
|
|
149
|
-
{ "directory": "./packages/package-b" }
|
|
150
|
-
],
|
|
151
|
-
"editor.codeActionsOnSave": {
|
|
152
|
-
"source.fixAll.eslint": "explicit"
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
## 🔧 Custom Dynamo Rules
|
|
158
|
-
|
|
159
|
-
This package includes custom ESLint rules for Dynamo conventions:
|
|
160
|
-
|
|
161
|
-
### Import Rules
|
|
162
|
-
- **`@futdevpro/dynamo/import-order`**: Enforces consistent import ordering
|
|
163
|
-
- **`@futdevpro/dynamo/no-import-type`**: Forbids TypeScript `import type` syntax
|
|
164
|
-
- **`@futdevpro/dynamo/no-js-import`**: Prevents importing `.js` files in TypeScript
|
|
165
|
-
|
|
166
|
-
### Naming Rules
|
|
167
|
-
- **`@futdevpro/dynamo/naming-patterns`**: Enforces DyFM naming conventions
|
|
168
|
-
|
|
169
|
-
### Type Rules
|
|
170
|
-
- **`@futdevpro/dynamo/explicit-types`**: Enforces explicit type annotations on all TypeScript declarations (functions, variables, parameters, class properties, destructuring)
|
|
171
|
-
|
|
172
|
-
## 🛠️ CLI Validation Tools
|
|
173
|
-
|
|
174
|
-
Use these commands to validate your codebase:
|
|
175
|
-
|
|
176
|
-
```bash
|
|
177
|
-
# Validate import ordering across all TypeScript files
|
|
178
|
-
dynamo-validate-imports
|
|
179
|
-
|
|
180
|
-
# Validate naming conventions across all TypeScript files
|
|
181
|
-
dynamo-validate-naming
|
|
182
|
-
|
|
183
|
-
# Audit ESLint configurations for duplicate rules
|
|
184
|
-
dynamo-eslintrc-audit
|
|
185
|
-
|
|
186
|
-
# Run comprehensive fixes
|
|
187
|
-
dynamo-fix
|
|
188
|
-
|
|
189
|
-
# Fix missing type annotations (functions, variables, parameters, class properties)
|
|
190
|
-
dynamo-fix-return-types
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
### NPM Scripts Integration
|
|
194
|
-
|
|
195
|
-
Add to your `package.json`:
|
|
196
|
-
|
|
197
|
-
```json
|
|
198
|
-
{
|
|
199
|
-
"scripts": {
|
|
200
|
-
"lint": "eslint src --ext .ts",
|
|
201
|
-
"lint:fix": "eslint src --ext .ts --fix",
|
|
202
|
-
"validate:imports": "dynamo-validate-imports",
|
|
203
|
-
"validate:naming": "dynamo-validate-naming",
|
|
204
|
-
"audit:eslintrc": "dynamo-eslintrc-audit",
|
|
205
|
-
"fix": "dynamo-fix",
|
|
206
|
-
"fix:types": "dynamo-fix-return-types"
|
|
207
|
-
}
|
|
208
|
-
}
|
|
1
|
+
# @futdevpro/dynamo-eslint
|
|
2
|
+
|
|
3
|
+
Shared ESLint presets, custom Dynamo rules, and validation tools for FutDevPro TypeScript projects. This package provides standardized linting configurations optimized for **lint-on-save** functionality across different project types.
|
|
4
|
+
|
|
5
|
+
## 🚀 Quick Start
|
|
6
|
+
|
|
7
|
+
### Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install --save-dev @futdevpro/dynamo-eslint
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Required Peer Dependencies
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install --save-dev \
|
|
17
|
+
eslint@~9.39.5 \
|
|
18
|
+
typescript@5.9.3 \
|
|
19
|
+
typescript-eslint@~8.67.0
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
For Angular projects, also install:
|
|
23
|
+
```bash
|
|
24
|
+
npm install --save-dev \
|
|
25
|
+
angular-eslint@~20.7.0
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`angular-eslint` is an optional peer for Node-only consumers and is required when loading the `ngx` or
|
|
29
|
+
`ngx-package` preset.
|
|
30
|
+
|
|
31
|
+
## 📋 Available Presets
|
|
32
|
+
|
|
33
|
+
### 1. **base** - Core TypeScript Rules
|
|
34
|
+
Generic TypeScript projects with browser environment.
|
|
35
|
+
|
|
36
|
+
```javascript
|
|
37
|
+
const baseConfig = require('@futdevpro/dynamo-eslint/base');
|
|
38
|
+
|
|
39
|
+
module.exports = baseConfig;
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Features:**
|
|
43
|
+
- Browser environment
|
|
44
|
+
- 1000 line limit
|
|
45
|
+
- All Dynamo custom rules enabled
|
|
46
|
+
- Explicit return types required
|
|
47
|
+
|
|
48
|
+
### 2. **nts** - Node TypeScript Projects
|
|
49
|
+
Node.js TypeScript applications and services.
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
const ntsConfig = require('@futdevpro/dynamo-eslint/nts');
|
|
53
|
+
|
|
54
|
+
module.exports = ntsConfig;
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Features:**
|
|
58
|
+
- Node environment
|
|
59
|
+
- 1500 line limit (extended for server code)
|
|
60
|
+
- Module source type
|
|
61
|
+
- All base rules + Node-specific optimizations
|
|
62
|
+
|
|
63
|
+
### 3. **ngx** - Angular Projects
|
|
64
|
+
Angular applications with component and template linting.
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
const ngxConfig = require('@futdevpro/dynamo-eslint/ngx');
|
|
68
|
+
|
|
69
|
+
module.exports = ngxConfig;
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Features:**
|
|
73
|
+
- Angular ESLint integration
|
|
74
|
+
- Browser environment
|
|
75
|
+
- Component and template linting
|
|
76
|
+
- Angular-specific rules
|
|
77
|
+
|
|
78
|
+
### 4. **fsm** - Full Stack Module
|
|
79
|
+
Full-stack TypeScript modules (same as base).
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
const fsmConfig = require('@futdevpro/dynamo-eslint/fsm');
|
|
83
|
+
|
|
84
|
+
module.exports = fsmConfig;
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 5. **nts-package** - Node TypeScript Packages
|
|
88
|
+
NPM packages and libraries built with TypeScript.
|
|
89
|
+
|
|
90
|
+
```javascript
|
|
91
|
+
const ntsPackageConfig = require('@futdevpro/dynamo-eslint/nts-package');
|
|
92
|
+
|
|
93
|
+
module.exports = ntsPackageConfig;
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Features:**
|
|
97
|
+
- Relaxed `@typescript-eslint/ban-types` and `no-explicit-any` rules
|
|
98
|
+
- Optimized for package development
|
|
99
|
+
- Extended line limits for library code
|
|
100
|
+
|
|
101
|
+
### 6. **ngx-package** - Angular Packages
|
|
102
|
+
Angular libraries and packages.
|
|
103
|
+
|
|
104
|
+
```javascript
|
|
105
|
+
const ngxPackageConfig = require('@futdevpro/dynamo-eslint/ngx-package');
|
|
106
|
+
|
|
107
|
+
module.exports = ngxPackageConfig;
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## ⚙️ Lint-on-Save Configuration
|
|
111
|
+
|
|
112
|
+
**Critical: Configure ESLint to run ONLY on save, not on type!**
|
|
113
|
+
|
|
114
|
+
### VSCode/Cursor Settings
|
|
115
|
+
|
|
116
|
+
Create `.vscode/settings.json` in your project root:
|
|
117
|
+
|
|
118
|
+
```json
|
|
119
|
+
{
|
|
120
|
+
"eslint.run": "onSave",
|
|
121
|
+
"eslint.workingDirectories": [{ "mode": "auto" }],
|
|
122
|
+
"editor.codeActionsOnSave": {
|
|
123
|
+
"source.fixAll.eslint": "explicit"
|
|
124
|
+
},
|
|
125
|
+
"eslint.validate": [
|
|
126
|
+
"javascript",
|
|
127
|
+
"typescript"
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Workspace vs User Settings
|
|
133
|
+
|
|
134
|
+
- **Workspace settings** (`.vscode/settings.json`): Apply only to current project
|
|
135
|
+
- **User settings**: Apply globally to all projects
|
|
136
|
+
|
|
137
|
+
For team consistency, use workspace settings.
|
|
138
|
+
|
|
139
|
+
### Multi-Root Workspace Configuration
|
|
140
|
+
|
|
141
|
+
For workspaces with multiple projects:
|
|
142
|
+
|
|
143
|
+
```json
|
|
144
|
+
{
|
|
145
|
+
"eslint.run": "onSave",
|
|
146
|
+
"eslint.workingDirectories": [
|
|
147
|
+
{ "mode": "auto" },
|
|
148
|
+
{ "directory": "./packages/package-a" },
|
|
149
|
+
{ "directory": "./packages/package-b" }
|
|
150
|
+
],
|
|
151
|
+
"editor.codeActionsOnSave": {
|
|
152
|
+
"source.fixAll.eslint": "explicit"
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## 🔧 Custom Dynamo Rules
|
|
158
|
+
|
|
159
|
+
This package includes custom ESLint rules for Dynamo conventions:
|
|
160
|
+
|
|
161
|
+
### Import Rules
|
|
162
|
+
- **`@futdevpro/dynamo/import-order`**: Enforces consistent import ordering
|
|
163
|
+
- **`@futdevpro/dynamo/no-import-type`**: Forbids TypeScript `import type` syntax
|
|
164
|
+
- **`@futdevpro/dynamo/no-js-import`**: Prevents importing `.js` files in TypeScript
|
|
165
|
+
|
|
166
|
+
### Naming Rules
|
|
167
|
+
- **`@futdevpro/dynamo/naming-patterns`**: Enforces DyFM naming conventions
|
|
168
|
+
|
|
169
|
+
### Type Rules
|
|
170
|
+
- **`@futdevpro/dynamo/explicit-types`**: Enforces explicit type annotations on all TypeScript declarations (functions, variables, parameters, class properties, destructuring)
|
|
171
|
+
|
|
172
|
+
## 🛠️ CLI Validation Tools
|
|
173
|
+
|
|
174
|
+
Use these commands to validate your codebase:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# Validate import ordering across all TypeScript files
|
|
178
|
+
dynamo-validate-imports
|
|
179
|
+
|
|
180
|
+
# Validate naming conventions across all TypeScript files
|
|
181
|
+
dynamo-validate-naming
|
|
182
|
+
|
|
183
|
+
# Audit ESLint configurations for duplicate rules
|
|
184
|
+
dynamo-eslintrc-audit
|
|
185
|
+
|
|
186
|
+
# Run comprehensive fixes
|
|
187
|
+
dynamo-fix
|
|
188
|
+
|
|
189
|
+
# Fix missing type annotations (functions, variables, parameters, class properties)
|
|
190
|
+
dynamo-fix-return-types
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### NPM Scripts Integration
|
|
194
|
+
|
|
195
|
+
Add to your `package.json`:
|
|
196
|
+
|
|
197
|
+
```json
|
|
198
|
+
{
|
|
199
|
+
"scripts": {
|
|
200
|
+
"lint": "eslint src --ext .ts",
|
|
201
|
+
"lint:fix": "eslint src --ext .ts --fix",
|
|
202
|
+
"validate:imports": "dynamo-validate-imports",
|
|
203
|
+
"validate:naming": "dynamo-validate-naming",
|
|
204
|
+
"audit:eslintrc": "dynamo-eslintrc-audit",
|
|
205
|
+
"fix": "dynamo-fix",
|
|
206
|
+
"fix:types": "dynamo-fix-return-types"
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
209
|
```
|
|
210
210
|
|
|
211
211
|
### Explicit legacy boolean-name exceptions
|
|
@@ -227,109 +227,109 @@ Use this only for fields whose rename requires an explicit data/API migration. T
|
|
|
227
227
|
configuration and continues to enforce every unlisted boolean property.
|
|
228
228
|
|
|
229
229
|
## 🔄 Migration from Manual Configs
|
|
230
|
-
|
|
231
|
-
### Quick Migration Checklist
|
|
232
|
-
|
|
233
|
-
1. **Install the package and peer dependencies**
|
|
234
|
-
2. **Replace your `.eslintrc.json`** with the appropriate preset
|
|
235
|
-
3. **Configure lint-on-save** in VSCode/Cursor settings
|
|
236
|
-
4. **Run validation tools** to check for issues
|
|
237
|
-
5. **Update CI/CD** to use the new configuration
|
|
238
|
-
|
|
239
|
-
### Common Migration Issues
|
|
240
|
-
|
|
241
|
-
- **Peer dependency conflicts**: Ensure all peer dependencies are installed
|
|
242
|
-
- **Working directory issues**: Use `"eslint.workingDirectories": [{ "mode": "auto" }]`
|
|
243
|
-
- **Rule conflicts**: The presets handle most conflicts automatically
|
|
244
|
-
|
|
245
|
-
> 📖 **Detailed Migration Guide**: See [Migration Guide](./docs/migration.md) for step-by-step instructions.
|
|
246
|
-
|
|
247
|
-
## 🐛 Troubleshooting
|
|
248
|
-
|
|
249
|
-
### Lint-on-Save Not Working
|
|
250
|
-
|
|
251
|
-
1. **Check ESLint is running on save only:**
|
|
252
|
-
```json
|
|
253
|
-
{
|
|
254
|
-
"eslint.run": "onSave" // NOT "onType"
|
|
255
|
-
}
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
2. **Verify working directories:**
|
|
259
|
-
```json
|
|
260
|
-
{
|
|
261
|
-
"eslint.workingDirectories": [{ "mode": "auto" }]
|
|
262
|
-
}
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
3. **Check file associations:**
|
|
266
|
-
```json
|
|
267
|
-
{
|
|
268
|
-
"eslint.validate": ["javascript", "typescript"]
|
|
269
|
-
}
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
### Peer Dependency Issues
|
|
273
|
-
|
|
274
|
-
Ensure all peer dependencies are installed with compatible versions:
|
|
275
|
-
|
|
276
|
-
```bash
|
|
277
|
-
npm ls typescript-eslint angular-eslint eslint typescript
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
### ESLint v9 Flat Config
|
|
281
|
-
|
|
282
|
-
This package now uses ESLint v9 flat config format (`eslint.config.js`) for all exported presets. The package itself also uses flat config for self-linting.
|
|
283
|
-
|
|
284
|
-
## 📁 Examples
|
|
285
|
-
|
|
286
|
-
Reference implementations are available in the `samples/` directory:
|
|
287
|
-
|
|
288
|
-
- `samples/base/eslint.config.js` - Base preset example
|
|
289
|
-
- `samples/nts/eslint.config.js` - Node TypeScript example
|
|
290
|
-
- `samples/ngx/eslint.config.js` - Angular example
|
|
291
|
-
- `samples/fsm/eslint.config.js` - Full Stack Module example
|
|
292
|
-
- `samples/nts-package/eslint.config.js` - Node TypeScript Package example
|
|
293
|
-
- `samples/ngx-package/eslint.config.js` - Angular Package example
|
|
294
|
-
|
|
295
|
-
## 🔧 Recent Fixes
|
|
296
|
-
|
|
297
|
-
### TypeScript AST Transformation Context Fix
|
|
298
|
-
|
|
299
|
-
The `dynamo-fix-return-types` script includes a fix for TypeScript AST transformation context issues. This resolves compilation errors when using `ts.visitEachChild()` by properly providing the `TransformationContext` parameter:
|
|
300
|
-
|
|
301
|
-
```typescript
|
|
302
|
-
// Fixed implementation
|
|
303
|
-
return ts.visitEachChild(node, visit, {} as ts.TransformationContext);
|
|
304
|
-
```
|
|
305
|
-
|
|
306
|
-
This ensures compatibility with TypeScript's AST transformation APIs.
|
|
307
|
-
|
|
308
|
-
### Enhanced Type Annotation Fixing
|
|
309
|
-
|
|
310
|
-
The `dynamo-fix-return-types` script now handles comprehensive type annotation fixing:
|
|
311
|
-
|
|
312
|
-
- **Function declarations**: Adds return type annotations
|
|
313
|
-
- **Arrow functions**: Adds return type annotations
|
|
314
|
-
- **Variable declarations**: Adds type annotations based on initializer types
|
|
315
|
-
- **Function parameters**: Adds parameter type annotations
|
|
316
|
-
- **Class properties**: Adds property type annotations
|
|
317
|
-
|
|
318
|
-
The script uses TypeScript's type checker to infer appropriate types and automatically adds them to your code.
|
|
319
|
-
|
|
320
|
-
## 📚 Self-Linting
|
|
321
|
-
|
|
322
|
-
This package uses its own presets and rules for self-linting. The ESLint v9 flat config is in `eslint.config.js` and demonstrates advanced configuration patterns.
|
|
323
|
-
|
|
324
|
-
## 🏗️ Architecture
|
|
325
|
-
|
|
326
|
-
- **Presets**: Standardized rule configurations for different project types
|
|
327
|
-
- **Custom Rules**: Dynamo-specific linting rules for import order and naming
|
|
328
|
-
- **CLI Tools**: Validation and fixing utilities
|
|
329
|
-
- **TypeScript Integration**: Full TypeScript AST transformation support
|
|
330
|
-
|
|
331
|
-
---
|
|
332
|
-
|
|
333
|
-
**Maintained by**: Future Development Program Ltd.
|
|
334
|
-
**License**: ISC
|
|
335
|
-
**Version**: 1.20.3
|
|
230
|
+
|
|
231
|
+
### Quick Migration Checklist
|
|
232
|
+
|
|
233
|
+
1. **Install the package and peer dependencies**
|
|
234
|
+
2. **Replace your `.eslintrc.json`** with the appropriate preset
|
|
235
|
+
3. **Configure lint-on-save** in VSCode/Cursor settings
|
|
236
|
+
4. **Run validation tools** to check for issues
|
|
237
|
+
5. **Update CI/CD** to use the new configuration
|
|
238
|
+
|
|
239
|
+
### Common Migration Issues
|
|
240
|
+
|
|
241
|
+
- **Peer dependency conflicts**: Ensure all peer dependencies are installed
|
|
242
|
+
- **Working directory issues**: Use `"eslint.workingDirectories": [{ "mode": "auto" }]`
|
|
243
|
+
- **Rule conflicts**: The presets handle most conflicts automatically
|
|
244
|
+
|
|
245
|
+
> 📖 **Detailed Migration Guide**: See [Migration Guide](./docs/migration.md) for step-by-step instructions.
|
|
246
|
+
|
|
247
|
+
## 🐛 Troubleshooting
|
|
248
|
+
|
|
249
|
+
### Lint-on-Save Not Working
|
|
250
|
+
|
|
251
|
+
1. **Check ESLint is running on save only:**
|
|
252
|
+
```json
|
|
253
|
+
{
|
|
254
|
+
"eslint.run": "onSave" // NOT "onType"
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
2. **Verify working directories:**
|
|
259
|
+
```json
|
|
260
|
+
{
|
|
261
|
+
"eslint.workingDirectories": [{ "mode": "auto" }]
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
3. **Check file associations:**
|
|
266
|
+
```json
|
|
267
|
+
{
|
|
268
|
+
"eslint.validate": ["javascript", "typescript"]
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Peer Dependency Issues
|
|
273
|
+
|
|
274
|
+
Ensure all peer dependencies are installed with compatible versions:
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
npm ls typescript-eslint angular-eslint eslint typescript
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### ESLint v9 Flat Config
|
|
281
|
+
|
|
282
|
+
This package now uses ESLint v9 flat config format (`eslint.config.js`) for all exported presets. The package itself also uses flat config for self-linting.
|
|
283
|
+
|
|
284
|
+
## 📁 Examples
|
|
285
|
+
|
|
286
|
+
Reference implementations are available in the `samples/` directory:
|
|
287
|
+
|
|
288
|
+
- `samples/base/eslint.config.js` - Base preset example
|
|
289
|
+
- `samples/nts/eslint.config.js` - Node TypeScript example
|
|
290
|
+
- `samples/ngx/eslint.config.js` - Angular example
|
|
291
|
+
- `samples/fsm/eslint.config.js` - Full Stack Module example
|
|
292
|
+
- `samples/nts-package/eslint.config.js` - Node TypeScript Package example
|
|
293
|
+
- `samples/ngx-package/eslint.config.js` - Angular Package example
|
|
294
|
+
|
|
295
|
+
## 🔧 Recent Fixes
|
|
296
|
+
|
|
297
|
+
### TypeScript AST Transformation Context Fix
|
|
298
|
+
|
|
299
|
+
The `dynamo-fix-return-types` script includes a fix for TypeScript AST transformation context issues. This resolves compilation errors when using `ts.visitEachChild()` by properly providing the `TransformationContext` parameter:
|
|
300
|
+
|
|
301
|
+
```typescript
|
|
302
|
+
// Fixed implementation
|
|
303
|
+
return ts.visitEachChild(node, visit, {} as ts.TransformationContext);
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
This ensures compatibility with TypeScript's AST transformation APIs.
|
|
307
|
+
|
|
308
|
+
### Enhanced Type Annotation Fixing
|
|
309
|
+
|
|
310
|
+
The `dynamo-fix-return-types` script now handles comprehensive type annotation fixing:
|
|
311
|
+
|
|
312
|
+
- **Function declarations**: Adds return type annotations
|
|
313
|
+
- **Arrow functions**: Adds return type annotations
|
|
314
|
+
- **Variable declarations**: Adds type annotations based on initializer types
|
|
315
|
+
- **Function parameters**: Adds parameter type annotations
|
|
316
|
+
- **Class properties**: Adds property type annotations
|
|
317
|
+
|
|
318
|
+
The script uses TypeScript's type checker to infer appropriate types and automatically adds them to your code.
|
|
319
|
+
|
|
320
|
+
## 📚 Self-Linting
|
|
321
|
+
|
|
322
|
+
This package uses its own presets and rules for self-linting. The ESLint v9 flat config is in `eslint.config.js` and demonstrates advanced configuration patterns.
|
|
323
|
+
|
|
324
|
+
## 🏗️ Architecture
|
|
325
|
+
|
|
326
|
+
- **Presets**: Standardized rule configurations for different project types
|
|
327
|
+
- **Custom Rules**: Dynamo-specific linting rules for import order and naming
|
|
328
|
+
- **CLI Tools**: Validation and fixing utilities
|
|
329
|
+
- **TypeScript Integration**: Full TypeScript AST transformation support
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
**Maintained by**: Future Development Program Ltd.
|
|
334
|
+
**License**: ISC
|
|
335
|
+
**Version**: 1.20.3
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-as-cast.d.ts","sourceRoot":"","sources":["../../../../src/plugin/rules/ts/no-as-cast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"no-as-cast.d.ts","sourceRoot":"","sources":["../../../../src/plugin/rules/ts/no-as-cast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAgF9B;;;;GAIG;AACH,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UA6DhB,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -39,6 +39,36 @@ function isRequestInputExpression(expression) {
|
|
|
39
39
|
&& current.type === 'Identifier'
|
|
40
40
|
&& REQUEST_IDENTIFIER_REGEX.test(current.name);
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* BFR-MASTERPROMPTER-038 — LITERALRA alkalmazott cast-e?
|
|
44
|
+
*
|
|
45
|
+
* Egy literalra alkalmazott cast a literalt OTT HELYBEN hozza letre: nincs mogotte mar letezo adat,
|
|
46
|
+
* amirol hazudhatna (`[] as T[]` sosem lehet valotlan). Az AZONOSITORA / property-accessre / hivasra
|
|
47
|
+
* alkalmazott cast viszont egy MAR LETEZO erteket nevez at mas tipusuva — ez a tenyleges kockazati
|
|
48
|
+
* osztaly, es futasidoben dolhet el rosszul.
|
|
49
|
+
*
|
|
50
|
+
* ⚠️ Ez a megkulonboztetes SZANDEKOSAN egyezik a `dc rev` `no-as-cast` review-javal: a ket
|
|
51
|
+
* implementacio ugyanazon a neven fut, es korabban ugyanarra a kodbazisra gyokeresen mast mondott.
|
|
52
|
+
* Ha itt vagy ott valtozik a predikatum, a masikat is at kell vezetni.
|
|
53
|
+
*/
|
|
54
|
+
function isLiteralExpression(expression) {
|
|
55
|
+
if (!expression) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
switch (expression.type) {
|
|
59
|
+
case 'Literal': // 'x' | 1 | true | null
|
|
60
|
+
case 'TemplateLiteral':
|
|
61
|
+
case 'ArrayExpression': // [] | [a, b]
|
|
62
|
+
case 'ObjectExpression': // {} | { k: v }
|
|
63
|
+
return true;
|
|
64
|
+
case 'Identifier':
|
|
65
|
+
return expression.name === 'undefined';
|
|
66
|
+
case 'UnaryExpression': // -1
|
|
67
|
+
return isLiteralExpression(expression.argument);
|
|
68
|
+
default:
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
42
72
|
/**
|
|
43
73
|
* No-as-cast szabály: TypeScript `as` type cast tilos.
|
|
44
74
|
* CCAP "no-as-cast" review ESLint AST-portja.
|
|
@@ -51,9 +81,20 @@ const rule = {
|
|
|
51
81
|
description: 'Forbid TypeScript `as` type casts (except `as const`); design issue indicator.',
|
|
52
82
|
recommended: true,
|
|
53
83
|
},
|
|
54
|
-
schema: [
|
|
84
|
+
schema: [
|
|
85
|
+
{
|
|
86
|
+
type: 'object',
|
|
87
|
+
properties: {
|
|
88
|
+
// BFR-MASTERPROMPTER-038: alapbol NEM jelezzuk a literal-castokat — ugyanaz a dontes, mint
|
|
89
|
+
// a `dc rev` oldalan (`flagLiteralCasts: false`), hogy a ket implementacio egyezzen.
|
|
90
|
+
allowLiteralCasts: { type: 'boolean' },
|
|
91
|
+
},
|
|
92
|
+
additionalProperties: false,
|
|
93
|
+
},
|
|
94
|
+
],
|
|
55
95
|
messages: {
|
|
56
|
-
noAsCast: '`as {{typeName}}`
|
|
96
|
+
noAsCast: '`as {{typeName}}` cast egy MAR LETEZO erteken. Mas tipusuva nevezi at a meglevo adatot, '
|
|
97
|
+
+ 'ami tervezesi problemat jelezhet es futasidoben dolhet el rosszul — hasznalj rendes tipust.',
|
|
57
98
|
},
|
|
58
99
|
},
|
|
59
100
|
create(context) {
|
|
@@ -75,6 +116,11 @@ const rule = {
|
|
|
75
116
|
if (isRequestInputExpression(node.expression)) {
|
|
76
117
|
return;
|
|
77
118
|
}
|
|
119
|
+
// BFR-MASTERPROMPTER-038 — a literal-cast nem tud hazudni; alapbol kihagyjuk.
|
|
120
|
+
const allowLiteralCasts = context.options?.[0]?.allowLiteralCasts !== false;
|
|
121
|
+
if (allowLiteralCasts && isLiteralExpression(node.expression)) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
78
124
|
const typeName = context.sourceCode.getText(annotation);
|
|
79
125
|
context.report({
|
|
80
126
|
node: node,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-as-cast.js","sourceRoot":"","sources":["../../../../src/plugin/rules/ts/no-as-cast.ts"],"names":[],"mappings":";;AAEA,0DAA0D;AAC1D,MAAM,kBAAkB,GAAa,CAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,CAAE,CAAC;AAE9E,iEAAiE;AACjE,MAAM,wBAAwB,GAAW,gBAAgB,CAAC;AAE1D;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAS,wBAAwB,CAAC,UAAe;IAC/C,IAAI,OAAO,GAAQ,UAAU,CAAC;IAC9B,IAAI,WAAW,GAAY,KAAK,CAAC;IAEjC,OAAO,OAAO,IAAI,OAAO,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;QACtD,MAAM,QAAQ,GAAQ,OAAO,CAAC,QAAQ,CAAC;QACvC,IACE,QAAQ;eACL,QAAQ,CAAC,IAAI,KAAK,YAAY;eAC9B,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAC7C,CAAC;YACD,WAAW,GAAG,IAAI,CAAC;QACrB,CAAC;QACD,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAC3B,CAAC;IAED,OAAO,WAAW;WACb,CAAC,CAAC,OAAO;WACT,OAAO,CAAC,IAAI,KAAK,YAAY;WAC7B,wBAAwB,CAAC,I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AAO,EACvC,CAAC;wBACD,OAAO;oBACT,CAAC;oBACD,4EAA4E;oBAC5E,IAAI,wBAAwB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;wBAC9C,OAAO;oBACT,CAAC;oBACD,8EAA8E;oBAC9E,MAAM,iBAAiB,GAAY,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,iBAAiB,KAAK,KAAK,CAAC;oBACrF,IAAI,iBAAiB,IAAI,mBAAmB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;wBAC9D,OAAO;oBACT,CAAC;oBACD,MAAM,QAAQ,GAAW,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;oBAChE,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,IAAI;wBACV,SAAS,EAAE,UAAU;wBACrB,IAAI,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;qBAC7B,CAAC,CAAC;gBACL,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,KAAK,CAAC,+CAA+C,EAAE,KAAK,CAAC,CAAC;gBACxE,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,kBAAe,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@futdevpro/dynamo-eslint",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.18",
|
|
4
4
|
"description": "Shared ESLint configs, Dynamo-powered plugin and validators for FutDevPro stacks",
|
|
5
5
|
"author": "Future Development Program Ltd.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
}
|
|
90
90
|
},
|
|
91
91
|
"dependencies": {
|
|
92
|
-
"@futdevpro/fsm-dynamo": "1.20.
|
|
92
|
+
"@futdevpro/fsm-dynamo": "1.20.31",
|
|
93
93
|
"eslint-plugin-max-params-no-constructor": "0.0.4",
|
|
94
94
|
"eslint-plugin-unused-imports": "4.4.1",
|
|
95
95
|
"fast-glob": "3.3.3",
|