@jmlweb/eslint-config-base 2.0.2 → 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.
Files changed (3) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +190 -4
  3. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
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
+
11
+ ## 2.0.3
12
+
13
+ ### Patch Changes
14
+
15
+ - 6b73301: Add changelog section with link to CHANGELOG.md in package READMEs
16
+ - Updated dependencies [6b73301]
17
+ - @jmlweb/eslint-config-base-js@1.0.3
18
+
3
19
  ## 2.0.2
4
20
 
5
21
  ### Patch Changes
package/README.md CHANGED
@@ -22,9 +22,11 @@
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
+ > 💡 **Upgrading from a previous version?** See the [Migration Guide](#-migration-guide) for breaking changes and upgrade instructions.
29
+
28
30
  ## 🚀 Quick Start
29
31
 
30
32
  Create an `eslint.config.js` file in your project root:
@@ -215,9 +217,59 @@ import { Component } from './component';
215
217
  Fix import order automatically:
216
218
 
217
219
  ```bash
218
- npx eslint --fix .
220
+ pnpm exec eslint --fix .
219
221
  ```
220
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
+
221
273
  ## 🎯 When to Use
222
274
 
223
275
  Use this configuration when you want:
@@ -272,8 +324,8 @@ Add linting scripts to your `package.json`:
272
324
  Then run:
273
325
 
274
326
  ```bash
275
- npm run lint # Lint all files
276
- npm run lint:fix # Fix auto-fixable issues
327
+ pnpm lint # Lint all files
328
+ pnpm lint:fix # Fix auto-fixable issues
277
329
  ```
278
330
 
279
331
  ## 📋 Requirements
@@ -302,11 +354,145 @@ See real-world usage examples:
302
354
 
303
355
  ## 🔗 Related Packages
304
356
 
357
+ ### Internal Packages
358
+
305
359
  - [`@jmlweb/eslint-config-base-js`](../eslint-config-base-js) - JavaScript ESLint config (extended by this package)
306
360
  - [`@jmlweb/eslint-config-react`](../eslint-config-react) - ESLint config for React projects
307
361
  - [`@jmlweb/prettier-config-base`](../prettier-config-base) - Prettier config for consistent formatting
308
362
  - [`@jmlweb/tsconfig-base`](../tsconfig-base) - TypeScript configuration
309
363
 
364
+ ### External Tools
365
+
366
+ - [ESLint](https://eslint.org/) - Pluggable linting utility for JavaScript and TypeScript
367
+ - [TypeScript ESLint](https://typescript-eslint.io/) - TypeScript tooling for ESLint
368
+ - [Prettier](https://prettier.io/) - Opinionated code formatter (pairs with eslint-config-prettier)
369
+ - [eslint-plugin-simple-import-sort](https://github.com/lydell/eslint-plugin-simple-import-sort) - Auto-sorts imports
370
+
371
+ ## ⚠️ Common Issues
372
+
373
+ > **Note:** This section documents known issues and their solutions. If you encounter a problem not listed here, please [open an issue](https://github.com/jmlweb/tooling/issues/new).
374
+
375
+ ### Peer Dependency Warnings
376
+
377
+ **Symptoms:**
378
+
379
+ - `npm WARN` messages about unmet peer dependencies during installation
380
+ - Messages like "requires a peer of eslint@^8.0.0 but none is installed"
381
+
382
+ **Cause:**
383
+
384
+ - Some ESLint plugins haven't updated their peer dependencies to support ESLint 9.x
385
+ - This is a transitional issue as the ecosystem adapts to ESLint's flat config
386
+
387
+ **Solution:**
388
+
389
+ ```bash
390
+ # pnpm automatically handles peer dependencies
391
+ pnpm install
392
+ ```
393
+
394
+ The warnings are usually safe to ignore if your linting works correctly. The plugins typically work fine with ESLint 9.x despite the warnings.
395
+
396
+ ### ESLint Not Picking Up Configuration
397
+
398
+ **Symptoms:**
399
+
400
+ - ESLint rules not being applied
401
+ - IDE showing no linting errors
402
+ - Files outside `src/` directory not being linted
403
+
404
+ **Cause:**
405
+
406
+ - Missing TypeScript project service configuration
407
+ - `tsconfig.json` not in the correct location
408
+ - IDE ESLint extension not configured for flat config
409
+
410
+ **Solution:**
411
+
412
+ 1. Ensure your `tsconfig.json` is in your project root
413
+ 2. Verify your `eslint.config.js` is using flat config format
414
+ 3. For VS Code, update `.vscode/settings.json`:
415
+
416
+ ```json
417
+ {
418
+ "eslint.experimental.useFlatConfig": true
419
+ }
420
+ ```
421
+
422
+ 4. Restart your IDE/ESLint server
423
+
424
+ ### Type-Aware Linting Not Working
425
+
426
+ **Symptoms:**
427
+
428
+ - Type-aware rules like `@typescript-eslint/no-unnecessary-condition` not triggering
429
+ - "Parsing error: Cannot read file" messages
430
+
431
+ **Cause:**
432
+
433
+ - TypeScript project service not finding your `tsconfig.json`
434
+ - Multiple `tsconfig.json` files causing confusion
435
+
436
+ **Solution:**
437
+
438
+ Check your project structure:
439
+
440
+ ```bash
441
+ # Your tsconfig.json should be in the root
442
+ project/
443
+ ├── tsconfig.json
444
+ ├── eslint.config.js
445
+ └── src/
446
+ ```
447
+
448
+ If you have multiple tsconfig files, this config uses TypeScript project service which automatically detects them.
449
+
450
+ ### Conflicts with Prettier
451
+
452
+ **Symptoms:**
453
+
454
+ - ESLint auto-fix and Prettier format fighting each other
455
+ - Code gets reformatted back and forth
456
+
457
+ **Cause:**
458
+
459
+ - ESLint formatting rules conflicting with Prettier
460
+ - Running both tools without proper integration
461
+
462
+ **Solution:**
463
+
464
+ This config already includes `eslint-config-prettier` to disable conflicting rules. Ensure you:
465
+
466
+ 1. Run Prettier before ESLint:
467
+
468
+ ```json
469
+ {
470
+ "scripts": {
471
+ "format": "prettier --write .",
472
+ "lint": "eslint .",
473
+ "check": "prettier --check . && eslint ."
474
+ }
475
+ }
476
+ ```
477
+
478
+ 2. Configure your IDE to format with Prettier first, then lint with ESLint
479
+
480
+ ## 🔄 Migration Guide
481
+
482
+ ### Upgrading to a New Version
483
+
484
+ > **Note:** If no breaking changes were introduced in a version, it's safe to upgrade without additional steps.
485
+
486
+ **No breaking changes have been introduced yet.** This package follows semantic versioning. When breaking changes are introduced, detailed migration instructions will be provided here.
487
+
488
+ For version history, see the [Changelog](./CHANGELOG.md).
489
+
490
+ **Need Help?** If you encounter issues during migration, please [open an issue](https://github.com/jmlweb/tooling/issues/new).
491
+
492
+ ## 📜 Changelog
493
+
494
+ See [CHANGELOG.md](./CHANGELOG.md) for version history and release notes.
495
+
310
496
  ## 📄 License
311
497
 
312
498
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jmlweb/eslint-config-base",
3
- "version": "2.0.2",
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.2"
56
+ "@jmlweb/eslint-config-base-js": "1.0.4"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@eslint/js": "^9.39.2",