eslint-config-functype 1.2.0 → 2.0.0
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 +32 -18
- package/dist/cli/list-rules.js +417 -299
- package/dist/cli/list-rules.js.map +1 -1
- package/dist/configs/recommended.d.ts +71 -65
- package/dist/configs/recommended.js +77 -196
- package/dist/configs/recommended.js.map +1 -1
- package/dist/configs/strict.d.ts +62 -64
- package/dist/configs/strict.js +16 -215
- package/dist/configs/strict.js.map +1 -1
- package/dist/index.d.ts +138 -136
- package/dist/index.js +14 -261
- package/dist/index.js.map +1 -1
- package/dist/utils/dependency-validator.d.ts +13 -11
- package/dist/utils/dependency-validator.js +78 -99
- package/dist/utils/dependency-validator.js.map +1 -1
- package/package.json +50 -21
- package/dist/cli/list-rules.d.ts +0 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ A curated ESLint configuration bundle for functional TypeScript programming. Thi
|
|
|
7
7
|
Instead of recreating functional programming rules, this plugin provides carefully curated configurations that combine rules from:
|
|
8
8
|
|
|
9
9
|
- **eslint-plugin-functional**: Core functional programming rules
|
|
10
|
-
- **@typescript-eslint/eslint-plugin**: TypeScript-specific functional patterns
|
|
10
|
+
- **@typescript-eslint/eslint-plugin**: TypeScript-specific functional patterns
|
|
11
11
|
- **ESLint core**: JavaScript immutability basics
|
|
12
12
|
|
|
13
13
|
## Installation
|
|
@@ -77,18 +77,18 @@ export default [
|
|
|
77
77
|
// Core immutability
|
|
78
78
|
"prefer-const": "error",
|
|
79
79
|
"no-var": "error",
|
|
80
|
-
|
|
80
|
+
|
|
81
81
|
// TypeScript functional patterns
|
|
82
82
|
"@typescript-eslint/consistent-type-imports": "error",
|
|
83
83
|
"@typescript-eslint/no-explicit-any": "error",
|
|
84
84
|
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
|
|
85
|
-
|
|
85
|
+
|
|
86
86
|
// Functional programming rules
|
|
87
87
|
"functional/no-let": "error",
|
|
88
88
|
"functional/immutable-data": "warn",
|
|
89
89
|
"functional/no-loop-statements": "off", // Enable as "error" for strict mode
|
|
90
90
|
},
|
|
91
|
-
}
|
|
91
|
+
},
|
|
92
92
|
]
|
|
93
93
|
```
|
|
94
94
|
|
|
@@ -111,6 +111,7 @@ You can also use individual rules without our presets:
|
|
|
111
111
|
## What Rules Are Included
|
|
112
112
|
|
|
113
113
|
### Recommended Configuration
|
|
114
|
+
|
|
114
115
|
- ✅ `prefer-const` / `no-var` - Basic immutability
|
|
115
116
|
- ✅ `functional/no-let` - Disallow `let` declarations
|
|
116
117
|
- ⚠️ `functional/immutable-data` - Warn on data mutation
|
|
@@ -119,7 +120,9 @@ You can also use individual rules without our presets:
|
|
|
119
120
|
- ✅ `@typescript-eslint/no-explicit-any` - Type safety
|
|
120
121
|
|
|
121
122
|
### Strict Configuration
|
|
123
|
+
|
|
122
124
|
All recommended rules plus:
|
|
125
|
+
|
|
123
126
|
- ✅ `functional/no-loop-statements` - Disallow imperative loops
|
|
124
127
|
- ✅ `functional/immutable-data` - Error on data mutation
|
|
125
128
|
- ✅ `functional/prefer-immutable-types` - Encourage readonly types
|
|
@@ -129,14 +132,17 @@ All recommended rules plus:
|
|
|
129
132
|
|
|
130
133
|
```typescript
|
|
131
134
|
// ❌ Bad (will be flagged)
|
|
132
|
-
let x = 1
|
|
133
|
-
arr.push(item)
|
|
134
|
-
for
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
135
|
+
let x = 1 // functional/no-let
|
|
136
|
+
arr.push(item) // functional/immutable-data
|
|
137
|
+
for (
|
|
138
|
+
let i = 0;
|
|
139
|
+
i < 10;
|
|
140
|
+
i++ // functional/no-loop-statements (strict only)
|
|
141
|
+
)
|
|
142
|
+
// ✅ Good
|
|
143
|
+
const x = 1
|
|
144
|
+
const newArr = [...arr, item]
|
|
145
|
+
arr.forEach((item) => process(item))
|
|
140
146
|
```
|
|
141
147
|
|
|
142
148
|
## Configurations
|
|
@@ -149,7 +155,7 @@ arr.forEach(item => process(item));
|
|
|
149
155
|
This plugin follows the principle of **composition over recreation**. Rather than maintaining custom rules, we curate and combine battle-tested rules from the community, ensuring:
|
|
150
156
|
|
|
151
157
|
- ✅ Less maintenance burden
|
|
152
|
-
- ✅ Better rule quality and edge case handling
|
|
158
|
+
- ✅ Better rule quality and edge case handling
|
|
153
159
|
- ✅ Automatic updates from upstream plugins
|
|
154
160
|
- ✅ Community-driven improvements
|
|
155
161
|
|
|
@@ -164,7 +170,7 @@ See exactly which rules are configured in each preset:
|
|
|
164
170
|
pnpm run list-rules
|
|
165
171
|
|
|
166
172
|
# Show rule options/configuration
|
|
167
|
-
pnpm run list-rules:verbose
|
|
173
|
+
pnpm run list-rules:verbose
|
|
168
174
|
|
|
169
175
|
# Show usage examples
|
|
170
176
|
pnpm run list-rules:usage
|
|
@@ -191,13 +197,19 @@ npx eslint-config-functype functype-list-rules
|
|
|
191
197
|
## CI/CD
|
|
192
198
|
|
|
193
199
|
This plugin includes GitHub Actions workflows for:
|
|
194
|
-
|
|
195
|
-
- ✅ **
|
|
200
|
+
|
|
201
|
+
- ✅ **Testing** on Node.js 22
|
|
202
|
+
- ✅ **Linting** with our own rules
|
|
196
203
|
- ✅ **Building** and validation
|
|
197
204
|
- ✅ **Publishing** to npm on version changes
|
|
198
205
|
|
|
199
206
|
## Development
|
|
200
207
|
|
|
208
|
+
### Requirements
|
|
209
|
+
|
|
210
|
+
- Node.js 22.0.0 or higher
|
|
211
|
+
- pnpm (recommended package manager)
|
|
212
|
+
|
|
201
213
|
```bash
|
|
202
214
|
# Install dependencies
|
|
203
215
|
pnpm install
|
|
@@ -208,7 +220,7 @@ pnpm run build
|
|
|
208
220
|
# Lint
|
|
209
221
|
pnpm run lint
|
|
210
222
|
|
|
211
|
-
# List rules during development
|
|
223
|
+
# List rules during development
|
|
212
224
|
pnpm run list-rules
|
|
213
225
|
```
|
|
214
226
|
|
|
@@ -219,6 +231,7 @@ pnpm run list-rules
|
|
|
219
231
|
If you see errors like `Definition for rule '@typescript-eslint/no-explicit-any' was not found`, you're missing peer dependencies.
|
|
220
232
|
|
|
221
233
|
**Quick Check:**
|
|
234
|
+
|
|
222
235
|
```bash
|
|
223
236
|
pnpm run check-deps
|
|
224
237
|
```
|
|
@@ -226,6 +239,7 @@ pnpm run check-deps
|
|
|
226
239
|
This will show you exactly which dependencies are missing and provide the installation command.
|
|
227
240
|
|
|
228
241
|
**Manual Installation:**
|
|
242
|
+
|
|
229
243
|
```bash
|
|
230
244
|
pnpm add -D @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-plugin-functional eslint-plugin-prettier eslint-plugin-simple-import-sort prettier
|
|
231
|
-
```
|
|
245
|
+
```
|