Skip to content

Commit 0bdc1c3

Browse files
feat(recommended.cjs): set react-hooks/exhaustive-deps from warn to error
BREAKING CHANGE: Existing repos may comply with react-hooks/exhaustive-deps warn, but error will surface code that does not have an eslint-disable directive
1 parent 8925228 commit 0bdc1c3

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

docs/breaking-changes/v18.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# Breaking changes in v18
22

33
- `eslint-plugin-babel-compiler` superseded by `eslint-plugin-react-hooks` v7. Consumers will need to remove direct `react-compiler/react-compiler` references.
4+
- `react-hooks/exhaustive-deps` upgraded from "warn" to "error" severity, to match `web-schumacher-app`.

recommended.cjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,26 @@ module.exports = {
3737
],
3838
},
3939
],
40+
/**
41+
* We enforce this as error in `web-schumacher-app`, and we should start more strictly enforcing it in other repos, too,
42+
* to be more thoroughly React Compiler-compliant.
43+
*
44+
* {@link https://github.com/turo/web-schumacher-app/pull/10307 Schumacher PR}
45+
* {@link https://react.dev/reference/eslint-plugin-react-hooks/lints/exhaustive-deps docs}
46+
*/
47+
"react-hooks/exhaustive-deps": "error",
4048
/**
4149
* Set as "warn" by default, we want to error on incompatible library APIs for dev visibility (to require // eslint-disable)
4250
*
4351
* {@link https://react.dev/reference/eslint-plugin-react-hooks/lints/incompatible-library docs}
4452
*/
4553
"react-hooks/incompatible-library": "error",
54+
/**
55+
* Not a rule we expect to see, but all other rules are set to "error", and so we set this one to "error" too (to require // eslint-disable)
56+
*
57+
* {@link https://react.dev/reference/eslint-plugin-react-hooks/lints/unsupported-syntax docs}
58+
*/
59+
"react-hooks/unsupported-syntax": "error",
4660
// don't force .jsx extension
4761
"react/jsx-filename-extension": "off",
4862
// In TS you must use the Fragment syntax instead of the shorthand

test/__snapshots__/test.spec.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7997,7 +7997,7 @@ exports[`validate config the legacy recommended config is correct 1`] = `
79977997
"error",
79987998
],
79997999
"react-hooks/exhaustive-deps": [
8000-
"warn",
8000+
"error",
80018001
],
80028002
"react-hooks/gating": [
80038003
"error",
@@ -8033,7 +8033,7 @@ exports[`validate config the legacy recommended config is correct 1`] = `
80338033
"error",
80348034
],
80358035
"react-hooks/unsupported-syntax": [
8036-
"warn",
8036+
"error",
80378037
],
80388038
"react-hooks/use-memo": [
80398039
"error",

0 commit comments

Comments
 (0)