@jmlweb/eslint-config-react 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 +14 -0
  2. package/README.md +155 -0
  3. package/package.json +6 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @jmlweb/eslint-config-react
2
2
 
3
+ ## 2.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 6b73301: Add changelog section with link to CHANGELOG.md in package READMEs
8
+ - Updated dependencies [6b73301]
9
+ - @jmlweb/eslint-config-base@2.0.3
10
+
11
+ ## 2.0.3
12
+
13
+ ### Patch Changes
14
+
15
+ - beae5ae: Add trailing newlines to source files for consistency.
16
+
3
17
  ## 2.0.2
4
18
 
5
19
  ### Patch Changes
package/README.md CHANGED
@@ -26,6 +26,8 @@
26
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
27
27
  ```
28
28
 
29
+ > 💡 **Upgrading from a previous version?** See the [Migration Guide](#-migration-guide) for breaking changes and upgrade instructions.
30
+
29
31
  ## 🚀 Quick Start
30
32
 
31
33
  Create an `eslint.config.js` file in your project root:
@@ -244,10 +246,163 @@ See real-world usage examples:
244
246
 
245
247
  ## 🔗 Related Packages
246
248
 
249
+ ### Internal Packages
250
+
247
251
  - [`@jmlweb/eslint-config-base`](../eslint-config-base) - Base TypeScript ESLint config (extended by this package)
248
252
  - [`@jmlweb/tsconfig-react`](../tsconfig-react) - TypeScript configuration for React libraries
249
253
  - [`@jmlweb/prettier-config-base`](../prettier-config-base) - Prettier config for consistent formatting
250
254
 
255
+ ### External Tools
256
+
257
+ - [ESLint](https://eslint.org/) - Pluggable linting utility for JavaScript and TypeScript
258
+ - [TypeScript ESLint](https://typescript-eslint.io/) - TypeScript tooling for ESLint
259
+ - [React](https://react.dev/) - JavaScript library for building user interfaces
260
+ - [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) - React-specific linting rules
261
+ - [eslint-plugin-react-hooks](https://www.npmjs.com/package/eslint-plugin-react-hooks) - Enforces Rules of Hooks
262
+ - [Prettier](https://prettier.io/) - Opinionated code formatter
263
+
264
+ ## ⚠️ Common Issues
265
+
266
+ > **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).
267
+
268
+ ### React Hooks Exhaustive Dependencies Warning
269
+
270
+ **Symptoms:**
271
+
272
+ - Warning: "React Hook useEffect has a missing dependency"
273
+ - ESLint suggests adding dependencies to the dependency array
274
+
275
+ **Cause:**
276
+
277
+ - `eslint-plugin-react-hooks` enforces the Rules of Hooks
278
+ - Missing dependencies can cause stale closures and bugs
279
+
280
+ **Solution:**
281
+
282
+ Add the missing dependencies:
283
+
284
+ ```typescript
285
+ // Before
286
+ useEffect(() => {
287
+ fetchData(userId);
288
+ }, []); // Missing dependency: userId
289
+
290
+ // After
291
+ useEffect(() => {
292
+ fetchData(userId);
293
+ }, [userId]); // Include all dependencies
294
+ ```
295
+
296
+ If you intentionally want to omit a dependency (use sparingly):
297
+
298
+ ```typescript
299
+ useEffect(() => {
300
+ fetchData(userId);
301
+ // eslint-disable-next-line react-hooks/exhaustive-deps
302
+ }, []); // Explicitly disable the rule with a comment
303
+ ```
304
+
305
+ ### React Version Not Detected
306
+
307
+ **Symptoms:**
308
+
309
+ - Warning: "Warning: React version not specified in eslint-plugin-react settings"
310
+ - Or incorrect React version being used
311
+
312
+ **Cause:**
313
+
314
+ - This config uses `detect` to auto-detect React version from package.json
315
+ - May fail if React is not installed or in an unexpected location
316
+
317
+ **Solution:**
318
+
319
+ Ensure React is installed:
320
+
321
+ ```bash
322
+ npm install react
323
+ ```
324
+
325
+ Or explicitly specify the React version:
326
+
327
+ ```javascript
328
+ // eslint.config.js
329
+ import reactConfig from '@jmlweb/eslint-config-react';
330
+
331
+ export default [
332
+ ...reactConfig,
333
+ {
334
+ settings: {
335
+ react: {
336
+ version: '18.2', // Specify your React version
337
+ },
338
+ },
339
+ },
340
+ ];
341
+ ```
342
+
343
+ ### JSX Not Recognized in .tsx Files
344
+
345
+ **Symptoms:**
346
+
347
+ - Parsing errors in `.tsx` files with JSX
348
+ - "Unexpected token <" errors
349
+
350
+ **Cause:**
351
+
352
+ - TypeScript parser not configured correctly
353
+ - File extension not recognized
354
+
355
+ **Solution:**
356
+
357
+ This config should handle `.tsx` files automatically. If you're having issues:
358
+
359
+ 1. Ensure your file has the `.tsx` extension (not `.ts`)
360
+ 2. Verify TypeScript is installed:
361
+
362
+ ```bash
363
+ npm install --save-dev typescript
364
+ ```
365
+
366
+ 3. Check that your tsconfig.json is in the project root
367
+
368
+ ### Peer Dependency Warnings
369
+
370
+ **Symptoms:**
371
+
372
+ - npm warnings about unmet peer dependencies for `eslint-plugin-react` or `eslint-plugin-react-hooks`
373
+
374
+ **Cause:**
375
+
376
+ - These plugins may not have updated peer dependencies for ESLint 9.x yet
377
+
378
+ **Solution:**
379
+
380
+ ```bash
381
+ # Use --legacy-peer-deps during installation
382
+ npm install --legacy-peer-deps
383
+
384
+ # Or use pnpm which handles peer deps automatically
385
+ pnpm install
386
+ ```
387
+
388
+ The warnings are usually safe to ignore if linting works correctly.
389
+
390
+ ## 🔄 Migration Guide
391
+
392
+ ### Upgrading to a New Version
393
+
394
+ > **Note:** If no breaking changes were introduced in a version, it's safe to upgrade without additional steps.
395
+
396
+ **No breaking changes have been introduced yet.** This package follows semantic versioning. When breaking changes are introduced, detailed migration instructions will be provided here.
397
+
398
+ For version history, see the [Changelog](./CHANGELOG.md).
399
+
400
+ **Need Help?** If you encounter issues during migration, please [open an issue](https://github.com/jmlweb/tooling/issues/new).
401
+
402
+ ## 📜 Changelog
403
+
404
+ See [CHANGELOG.md](./CHANGELOG.md) for version history and release notes.
405
+
251
406
  ## 📄 License
252
407
 
253
408
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jmlweb/eslint-config-react",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
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",
@@ -48,16 +48,16 @@
48
48
  },
49
49
  "peerDependencies": {
50
50
  "@eslint/js": "^9.0.0",
51
- "@jmlweb/eslint-config-base": "^2.0.2",
52
51
  "eslint": "^9.0.0",
53
52
  "eslint-config-prettier": "^9.1.0",
54
53
  "eslint-plugin-react": "^7.37.0",
55
54
  "eslint-plugin-react-hooks": "^5.0.0",
56
55
  "eslint-plugin-simple-import-sort": "^12.0.0",
57
- "typescript-eslint": "^8.0.0"
56
+ "typescript-eslint": "^8.0.0",
57
+ "@jmlweb/eslint-config-base": "2.0.3"
58
58
  },
59
59
  "dependencies": {
60
- "@jmlweb/eslint-config-base": "2.0.2"
60
+ "@jmlweb/eslint-config-base": "2.0.3"
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/tsconfig-internal": "0.0.1",
74
- "@jmlweb/eslint-config-base": "2.0.2"
73
+ "@jmlweb/eslint-config-base": "2.0.3",
74
+ "@jmlweb/tsconfig-internal": "0.0.1"
75
75
  },
76
76
  "scripts": {
77
77
  "build": "tsup",