@jmlweb/eslint-config-base 2.0.3 → 2.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @jmlweb/eslint-config-base
2
2
 
3
+ ## 2.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 4a9ece1: Update documentation to use pnpm commands instead of npm
8
+ - Updated dependencies [4a9ece1]
9
+ - @jmlweb/eslint-config-base-js@1.0.4
10
+
3
11
  ## 2.0.3
4
12
 
5
13
  ### Patch Changes
package/README.md CHANGED
@@ -22,7 +22,7 @@
22
22
  ## 📦 Installation
23
23
 
24
24
  ```bash
25
- npm install --save-dev @jmlweb/eslint-config-base eslint @eslint/js typescript-eslint eslint-config-prettier eslint-plugin-simple-import-sort @jmlweb/eslint-config-base-js
25
+ pnpm add -D @jmlweb/eslint-config-base eslint @eslint/js typescript-eslint eslint-config-prettier eslint-plugin-simple-import-sort @jmlweb/eslint-config-base-js
26
26
  ```
27
27
 
28
28
  > 💡 **Upgrading from a previous version?** See the [Migration Guide](#-migration-guide) for breaking changes and upgrade instructions.
@@ -217,9 +217,59 @@ import { Component } from './component';
217
217
  Fix import order automatically:
218
218
 
219
219
  ```bash
220
- npx eslint --fix .
220
+ pnpm exec eslint --fix .
221
221
  ```
222
222
 
223
+ ## 🤔 Why Use This?
224
+
225
+ > **Philosophy**: Maximize type safety. Catch bugs at compile time, not runtime. Make invalid states unrepresentable.
226
+
227
+ This package enforces strict TypeScript practices inspired by the principle that "if it compiles, it works." The configuration choices reflect a philosophy of using TypeScript's type system to its fullest potential to prevent bugs before they happen.
228
+
229
+ ### Design Decisions
230
+
231
+ **Strict Type Checking (`strictTypeChecked`)**: Enables all strict type-aware rules
232
+
233
+ - **Why**: TypeScript's power comes from its type system. Strict checking catches errors like unreachable code, unnecessary conditions, and type mismatches that would otherwise cause runtime bugs
234
+ - **Trade-off**: More initial errors when adopting this config, and requires explicit typing. However, the bugs caught far outweigh the extra effort
235
+ - **When to override**: If migrating a large JavaScript codebase and need a gradual transition (consider using `@jmlweb/eslint-config-base-js` with recommended TypeScript rules instead)
236
+
237
+ **Explicit Return Types (`@typescript-eslint/explicit-function-return-type`)**: Requires explicit return types on functions
238
+
239
+ - **Why**: Explicit return types prevent accidental type changes and make code easier to reason about. They serve as inline documentation and catch errors where functions return unexpected types
240
+ - **Trade-off**: More verbose code, but improved clarity and safety. Inference can hide bugs
241
+ - **When to override**: For simple, obvious functions where the return type is trivial (but be conservative - explicit is usually better)
242
+
243
+ **No `any` Type (`@typescript-eslint/no-explicit-any`)**: Prohibits using `any`
244
+
245
+ - **Why**: `any` defeats the purpose of TypeScript by disabling type checking. It's a common escape hatch that creates type holes and runtime bugs
246
+ - **Trade-off**: Forces you to properly type external libraries or complex types. Requires more upfront work but prevents bugs
247
+ - **When to override**: Only when dealing with truly dynamic data that can't be typed (rare). Consider `unknown` first
248
+
249
+ **Type-Only Imports (`@typescript-eslint/consistent-type-imports`)**: Enforces `import type` for type-only imports
250
+
251
+ - **Why**: Separates runtime imports from type imports, improving tree-shaking and build performance. Makes it clear what's used at runtime vs. compile time
252
+ - **Trade-off**: More explicit imports, but clearer code and better build optimization
253
+ - **When to override**: Never - this is a best practice with no real downsides
254
+
255
+ **No Enums (`no-restricted-syntax`)**: Prevents TypeScript enum usage
256
+
257
+ - **Why**: TypeScript enums have surprising runtime behavior, bundling issues, and const vs. regular enum confusion. Const maps with `as const` provide the same benefits without the pitfalls
258
+ - **Trade-off**: Slightly more verbose syntax (`const Status = { ... } as const`), but more predictable and type-safe
259
+ - **When to override**: If you're comfortable with enum limitations or maintaining legacy code
260
+
261
+ **No Default Exports (`no-restricted-exports`)**: Enforces named exports only
262
+
263
+ - **Why**: Named exports enable better tree-shaking, clearer imports, easier refactoring, and better IDE autocomplete. Default exports hide what's being imported
264
+ - **Trade-off**: Can't use `import Foo from './foo'` syntax. Requires `import { Foo } from './foo'`
265
+ - **When to override**: For compatibility with libraries that require default exports (Next.js pages, etc.) - override per-file
266
+
267
+ **Naming Conventions (`@typescript-eslint/naming-convention`)**: Enforces consistent naming patterns
268
+
269
+ - **Why**: Consistent naming improves readability and prevents bugs. For example, booleans starting with `is/has/can` are self-documenting
270
+ - **Trade-off**: May conflict with legacy code or third-party APIs
271
+ - **When to override**: When integrating with external APIs that use different conventions
272
+
223
273
  ## 🎯 When to Use
224
274
 
225
275
  Use this configuration when you want:
@@ -274,8 +324,8 @@ Add linting scripts to your `package.json`:
274
324
  Then run:
275
325
 
276
326
  ```bash
277
- npm run lint # Lint all files
278
- npm run lint:fix # Fix auto-fixable issues
327
+ pnpm lint # Lint all files
328
+ pnpm lint:fix # Fix auto-fixable issues
279
329
  ```
280
330
 
281
331
  ## 📋 Requirements
@@ -337,10 +387,7 @@ See real-world usage examples:
337
387
  **Solution:**
338
388
 
339
389
  ```bash
340
- # Use --legacy-peer-deps flag during installation
341
- npm install --legacy-peer-deps
342
-
343
- # Or with pnpm (automatically handles peer dependencies)
390
+ # pnpm automatically handles peer dependencies
344
391
  pnpm install
345
392
  ```
346
393
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jmlweb/eslint-config-base",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "Base ESLint configuration for TypeScript projects with strict type checking and best practices",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -53,7 +53,7 @@
53
53
  "typescript-eslint": "^8.0.0"
54
54
  },
55
55
  "dependencies": {
56
- "@jmlweb/eslint-config-base-js": "1.0.3"
56
+ "@jmlweb/eslint-config-base-js": "1.0.4"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@eslint/js": "^9.39.2",