@jmlweb/eslint-config-react 2.0.4 → 2.0.6

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 +45 -10
  3. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @jmlweb/eslint-config-react
2
2
 
3
+ ## 2.0.6
4
+
5
+ ### Patch Changes
6
+
7
+ - 30f8ffb: Add "Why Use This?" sections to package READMEs explaining configuration philosophy and design decisions
8
+ - Updated dependencies [30f8ffb]
9
+ - @jmlweb/eslint-config-base@2.0.5
10
+
11
+ ## 2.0.5
12
+
13
+ ### Patch Changes
14
+
15
+ - 4a9ece1: Update documentation to use pnpm commands instead of npm
16
+ - Updated dependencies [4a9ece1]
17
+ - @jmlweb/eslint-config-base@2.0.4
18
+
3
19
  ## 2.0.4
4
20
 
5
21
  ### Patch Changes
package/README.md CHANGED
@@ -23,7 +23,7 @@
23
23
  ## 📦 Installation
24
24
 
25
25
  ```bash
26
- npm install --save-dev @jmlweb/eslint-config-react eslint @eslint/js typescript-eslint eslint-config-prettier eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-simple-import-sort @jmlweb/eslint-config-base
26
+ pnpm add -D @jmlweb/eslint-config-react eslint @eslint/js typescript-eslint eslint-config-prettier eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-simple-import-sort @jmlweb/eslint-config-base
27
27
  ```
28
28
 
29
29
  > 💡 **Upgrading from a previous version?** See the [Migration Guide](#-migration-guide) for breaking changes and upgrade instructions.
@@ -156,9 +156,47 @@ import { Component } from './component';
156
156
  Fix import order automatically:
157
157
 
158
158
  ```bash
159
- npx eslint --fix .
159
+ pnpm exec eslint --fix .
160
160
  ```
161
161
 
162
+ ## 🤔 Why Use This?
163
+
164
+ > **Philosophy**: React components should be predictable, composable, and easy to reason about. Strict linting catches bugs before they reach production.
165
+
166
+ This package extends the base TypeScript config with React-specific rules that enforce best practices, prevent common pitfalls, and ensure proper Hook usage. React's declarative nature requires different patterns than traditional imperative code.
167
+
168
+ ### Design Decisions
169
+
170
+ **React Hooks Rules (`eslint-plugin-react-hooks`)**: Enforces Rules of Hooks and exhaustive dependencies
171
+
172
+ - **Why**: Hooks rely on call order and closure capture. Violating Hook rules causes subtle bugs that are hard to debug. Exhaustive dependencies prevent stale closures and missing reactive updates
173
+ - **Trade-off**: May require adding dependencies you think are unnecessary, but this prevents bugs from stale values
174
+ - **When to override**: Never for rules of hooks. For exhaustive deps, only when you understand the implications (use `eslint-disable-next-line` with a comment explaining why)
175
+
176
+ **JSX Accessibility (`eslint-plugin-jsx-a11y`)**: Enforces accessibility best practices (included via recommended)
177
+
178
+ - **Why**: Accessibility is not optional. Many common React patterns create inaccessible UIs by default. These rules catch issues early
179
+ - **Trade-off**: May require more verbose markup (explicit labels, ARIA attributes), but creates inclusive applications
180
+ - **When to override**: Rarely. If you must, document why the pattern is accessible despite the warning
181
+
182
+ **Modern JSX Transform**: Configured for React 17+ (no `React` import needed)
183
+
184
+ - **Why**: The new JSX transform is more efficient and doesn't require importing React in every file. It's the modern standard
185
+ - **Trade-off**: None - this is the recommended approach for React 17+
186
+ - **When to override**: If stuck on React 16 or earlier (but you should upgrade)
187
+
188
+ **Component Display Names**: Enforces display names for debugging
189
+
190
+ - **Why**: Display names improve debugging in React DevTools and error messages. Anonymous components are harder to track down
191
+ - **Trade-off**: Requires naming arrow function components or adding explicit displayName
192
+ - **When to override**: For simple, obvious components where the name is clear from context (rare)
193
+
194
+ **Extends Base TypeScript Config**: Inherits all strict type checking rules
195
+
196
+ - **Why**: React components benefit from strict typing. Props, state, and event handlers should all be explicitly typed
197
+ - **Trade-off**: More verbose component definitions, but prevents prop drilling bugs and refactoring issues
198
+ - **When to override**: Follow the same guidelines as the base TypeScript config
199
+
162
200
  ## 🎯 When to Use
163
201
 
164
202
  Use this configuration when you want:
@@ -213,8 +251,8 @@ Add linting scripts to your `package.json`:
213
251
  Then run:
214
252
 
215
253
  ```bash
216
- npm run lint # Lint all files
217
- npm run lint:fix # Fix auto-fixable issues
254
+ pnpm lint # Lint all files
255
+ pnpm lint:fix # Fix auto-fixable issues
218
256
  ```
219
257
 
220
258
  ## 📋 Requirements
@@ -319,7 +357,7 @@ useEffect(() => {
319
357
  Ensure React is installed:
320
358
 
321
359
  ```bash
322
- npm install react
360
+ pnpm add react
323
361
  ```
324
362
 
325
363
  Or explicitly specify the React version:
@@ -360,7 +398,7 @@ This config should handle `.tsx` files automatically. If you're having issues:
360
398
  2. Verify TypeScript is installed:
361
399
 
362
400
  ```bash
363
- npm install --save-dev typescript
401
+ pnpm add -D typescript
364
402
  ```
365
403
 
366
404
  3. Check that your tsconfig.json is in the project root
@@ -378,10 +416,7 @@ npm install --save-dev typescript
378
416
  **Solution:**
379
417
 
380
418
  ```bash
381
- # Use --legacy-peer-deps during installation
382
- npm install --legacy-peer-deps
383
-
384
- # Or use pnpm which handles peer deps automatically
419
+ # pnpm automatically handles peer dependencies
385
420
  pnpm install
386
421
  ```
387
422
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jmlweb/eslint-config-react",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "description": "ESLint configuration for React libraries with TypeScript, extending base config with React-specific rules",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -54,10 +54,10 @@
54
54
  "eslint-plugin-react-hooks": "^5.0.0",
55
55
  "eslint-plugin-simple-import-sort": "^12.0.0",
56
56
  "typescript-eslint": "^8.0.0",
57
- "@jmlweb/eslint-config-base": "2.0.3"
57
+ "@jmlweb/eslint-config-base": "2.0.5"
58
58
  },
59
59
  "dependencies": {
60
- "@jmlweb/eslint-config-base": "2.0.3"
60
+ "@jmlweb/eslint-config-base": "2.0.5"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@eslint/js": "^9.39.2",
@@ -70,8 +70,8 @@
70
70
  "tsup": "^8.5.1",
71
71
  "typescript": "^5.9.3",
72
72
  "typescript-eslint": "^8.34.1",
73
- "@jmlweb/eslint-config-base": "2.0.3",
74
- "@jmlweb/tsconfig-internal": "0.0.1"
73
+ "@jmlweb/tsconfig-internal": "0.0.1",
74
+ "@jmlweb/eslint-config-base": "2.0.5"
75
75
  },
76
76
  "scripts": {
77
77
  "build": "tsup",