diff --git a/site/.knip.jsonc b/site/.knip.jsonc index 01862f11c1c..2b9ed680446 100644 --- a/site/.knip.jsonc +++ b/site/.knip.jsonc @@ -15,6 +15,7 @@ "@shadcn/lint", "@tailwindcss/typography", "@types/react-virtualized-auto-sizer", + "eslint-plugin-react-you-might-not-need-an-effect", "tailwindcss", "tw-animate-css", "ts-proto" diff --git a/site/.oxlintrc.jsonc b/site/.oxlintrc.jsonc index b76c2f14fdd..160c1a45593 100644 --- a/site/.oxlintrc.jsonc +++ b/site/.oxlintrc.jsonc @@ -1,6 +1,7 @@ { "$schema": "./node_modules/oxlint/configuration_schema.json", "plugins": ["typescript", "unicorn", "oxc", "react", "jsx-a11y", "vitest"], + "jsPlugins": ["eslint-plugin-react-you-might-not-need-an-effect"], "rules": { // --- a11y (jsx-a11y) --- "no-access-key": "error", @@ -207,6 +208,9 @@ { "functions": false, "classes": false, "variables": false } ], + // --- react-you-might-not-need-an-effect --- + "react-you-might-not-need-an-effect/no-pass-live-state-to-parent": "error", + // ========================================================== // Migration backlog (temporary; shrinks as we go). // Each rule maps to a Biome rule, but oxlint's implementation @@ -240,6 +244,16 @@ "vitest/valid-expect": "off", // (small) "purity": "off", // (small) + // react-you-might-not-need-an-effect rules with existing violations. + "react-you-might-not-need-an-effect/no-event-handler": "off", // (xl) + "react-you-might-not-need-an-effect/no-adjust-state-on-prop-change": "off", // (large) + "react-you-might-not-need-an-effect/no-pass-data-to-parent": "off", // (medium) + "react-you-might-not-need-an-effect/no-initialize-state": "off", // (medium) + "react-you-might-not-need-an-effect/no-chain-state-updates": "off", // (medium) + "react-you-might-not-need-an-effect/no-derived-state": "off", // (medium) + "react-you-might-not-need-an-effect/no-external-store-subscription": "off", // (small) + "react-you-might-not-need-an-effect/no-reset-all-state-on-prop-change": "off", // (small) + "no-restricted-imports": [ "error", { diff --git a/site/package.json b/site/package.json index 9ebcb7798be..fe0948dcbf4 100644 --- a/site/package.json +++ b/site/package.json @@ -160,6 +160,7 @@ "babel-plugin-react-compiler": "1.0.0", "dpdm": "3.15.1", "emojibase": "17.0.0", + "eslint-plugin-react-you-might-not-need-an-effect": "1.2.0", "express": "4.22.3", "jest-canvas-mock": "2.5.2", "jest-websocket-mock": "2.5.0", diff --git a/site/pnpm-lock.yaml b/site/pnpm-lock.yaml index cc8e4e36990..169701de2c6 100644 --- a/site/pnpm-lock.yaml +++ b/site/pnpm-lock.yaml @@ -172,6 +172,8 @@ overrides: brace-expansion@<2: 1.1.21 minimatch@>=10: 11.0.1 +packageExtensionsChecksum: sha256-KJ5S0mcdz92ou1yEBoRPMk7tFYXOsL0VDXlqdmR0uXs= + patchedDependencies: cmdk@1.1.1: 1fd7e2e50791a6122cefa7103f66878943a4d18d434ebc6d1035e736e538caa5 @@ -528,6 +530,9 @@ importers: emojibase: specifier: 17.0.0 version: 17.0.0 + eslint-plugin-react-you-might-not-need-an-effect: + specifier: 1.2.0 + version: 1.2.0 express: specifier: 4.22.3 version: 4.22.3(supports-color@7.2.0) @@ -4502,6 +4507,15 @@ packages: resolution: {integrity: sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==, tarball: https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz} engines: {node: '>=12'} + eslint-plugin-react-you-might-not-need-an-effect@1.2.0: + resolution: {integrity: sha512-ieSAjWnVO92c2kyDPYgGJplcX1Fs4dhCmbEVgM9PMJ3Kg0mE9BBacT7HQRyKqrhaxVyneiIlA8BsY7vzF+bQ4A==, tarball: https://registry.npmjs.org/eslint-plugin-react-you-might-not-need-an-effect/-/eslint-plugin-react-you-might-not-need-an-effect-1.2.0.tgz} + engines: {node: '>=14.0.0'} + peerDependencies: + eslint: '>=8.40.0' + peerDependenciesMeta: + eslint: + optional: true + esm-env@1.2.2: resolution: {integrity: sha512-Epxrv+Nr/CaL4ZcFGPJIYLWFom+YeV1DqMLHJoEd9SYRxNbaFruBwfEX/kkHUJf55j2+TUbmDcmuilbP1TmXHA==, tarball: https://registry.npmjs.org/esm-env/-/esm-env-1.2.2.tgz} @@ -10783,6 +10797,8 @@ snapshots: escape-string-regexp@5.0.0: {} + eslint-plugin-react-you-might-not-need-an-effect@1.2.0: {} + esm-env@1.2.2: {} esprima@4.0.1: {} diff --git a/site/pnpm-workspace.yaml b/site/pnpm-workspace.yaml index b04f29ed2e7..471730300a1 100644 --- a/site/pnpm-workspace.yaml +++ b/site/pnpm-workspace.yaml @@ -25,3 +25,10 @@ allowBuilds: patchedDependencies: cmdk@1.1.1: patches/cmdk@1.1.1.patch + +# Oxlint loads these ESLint plugins through jsPlugins, so the eslint peer is not needed. +packageExtensions: + eslint-plugin-react-you-might-not-need-an-effect: + peerDependenciesMeta: + eslint: + optional: true