Skip to content

Added eslint-plugin-react-you-might-not-need-an-effect#5945

Merged
witoszekdev merged 3 commits intomainfrom
add-eslint-plugin
Oct 6, 2025
Merged

Added eslint-plugin-react-you-might-not-need-an-effect#5945
witoszekdev merged 3 commits intomainfrom
add-eslint-plugin

Conversation

@witoszekdev
Copy link
Member

@witoszekdev witoszekdev commented Oct 6, 2025

Added ESLint plugin to detect unnecesary usage of useEffect in our codebase.

Following new warnings were added:

  • src/apps/hooks/useActiveAppsInstallations.ts:88:7: Avoid passing data to parents in an effect. Instead, let the parent fetch the data itself and pass it down to the child as a prop. [Warning/react-you-might-not-need-an-effect/no-pass-data-to-parent]
  • src/apps/hooks/useActiveAppsInstallations.ts:140:22: Avoid passing data to parents in an effect. Instead, let the parent fetch the data itself and pass it down to the child as a prop. [Warning/react-you-might-not-need-an-effect/no-pass-data-to-parent]
  • src/apps/hooks/useActiveAppsInstallations.ts:144:11: Avoid passing data to parents in an effect. Instead, let the parent fetch the data itself and pass it down to the child as a prop. [Warning/react-you-might-not-need-an-effect/no-pass-data-to-parent]
  • src/attributes/components/AttributeDetails/NumericUnits.tsx:74:19: Avoid passing live state to parents in an effect. Instead, lift the state to the parent and pass it down to the child as a prop. [Warning/react-you-might-not-need-an-effect/no-pass-live-state-to-parent]
  • src/attributes/components/AttributeDetails/NumericUnits.tsx:101:7: Avoid initializing state in an effect. Instead, pass "unitData"'s initial value to its useState. [Warning/react-you-might-not-need-an-effect/no-initialize-state]
  • src/attributes/components/AttributeDetails/NumericUnits.tsx:106:7: Avoid passing data to parents in an effect. Instead, let the parent fetch the data itself and pass it down to the child as a prop. [Warning/react-you-might-not-need-an-effect/no-pass-data-to-parent]
  • src/attributes/views/AttributeCreate/AttributeCreate.tsx:83:19: Avoid adjusting state when a prop changes. Instead, adjust the state directly during render, or refactor your state to avoid this need entirely. [Warning/react-you-might-not-need-an-effect/no-adjust-state-on-prop-change]
  • src/channels/components/AssignmentList/AssignmentListFooter.tsx:40:7: Avoid adjusting state when a prop changes. Instead, adjust the state directly during render, or refactor your state to avoid this need entirely. [Warning/react-you-might-not-need-an-effect/no-adjust-state-on-prop-change]
  • src/collections/components/CollectionProducts/useProductDrag.ts:26:5: Avoid storing derived state. Compute "items" directly during render, optionally with useMemo if it's expensive. [Warning/react-you-might-not-need-an-effect/no-derived-state]
  • src/components/AssignProductDialog/AssignProductDialogSingle.tsx:61:3: Avoid resetting all state when a prop changes. If "selectedId" is a key, pass it as key instead so React will reset the component. [Warning/react-you-might-not-need-an-effect/no-reset-all-state-on-prop-change]
  • src/components/AssignProductDialog/AssignProductDialogSingle.tsx:62:5: Avoid storing derived state. Compute "selectedProductId" directly during render, optionally with useMemo if it's expensive. [Warning/react-you-might-not-need-an-effect/no-derived-state]
  • src/components/CardMenu/CardMenu.tsx:114:3: Avoid resetting all state when a prop changes. If "menuItems" is a key, pass it as key instead so React will reset the component. [Warning/react-you-might-not-need-an-effect/no-reset-all-state-on-prop-change]
  • src/components/CardMenu/CardMenu.tsx:115:43: Avoid passing data to parents in an effect. Instead, let the parent fetch the data itself and pass it down to the child as a prop. [Warning/react-you-might-not-need-an-effect/no-pass-data-to-parent]
  • src/components/CardMenu/CardMenu.tsx:120:7: Avoid adjusting state when a prop changes. Instead, adjust the state directly during render, or refactor your state to avoid this need entirely. [Warning/react-you-might-not-need-an-effect/no-adjust-state-on-prop-change]
  • src/components/ColorPicker/ColorPicker.tsx:82:7: Avoid passing live state to parents in an effect. Instead, lift the state to the parent and pass it down to the child as a prop. [Warning/react-you-might-not-need-an-effect/no-pass-live-state-to-parent]
  • src/components/ColorPicker/ColorPicker.tsx:85:9: Avoid passing data to parents in an effect. Instead, let the parent fetch the data itself and pass it down to the child as a prop. [Warning/react-you-might-not-need-an-effect/no-pass-data-to-parent]
  • src/components/Combobox/components/Combobox.tsx:45:7: Avoid storing derived state. Compute "selectedValue" directly during render, optionally with useMemo if it's expensive. [Warning/react-you-might-not-need-an-effect/no-derived-state]
  • src/components/Combobox/components/Multiselect.tsx:44:5: Avoid resetting all state when a prop changes. If "value" is a key, pass it as key instead so React will reset the component. [Warning/react-you-might-not-need-an-effect/no-reset-all-state-on-prop-change]
  • src/components/Combobox/components/Multiselect.tsx:45:7: Avoid storing derived state. Compute "selectedValues" directly during render, optionally with useMemo if it's expensive. [Warning/react-you-might-not-need-an-effect/no-derived-state]
  • src/components/ConditionalFilter/useContainerState.ts:61:7: Avoid storing derived state. Compute "value" directly during render, optionally with useMemo if it's expensive. [Warning/react-you-might-not-need-an-effect/no-derived-state]
  • src/components/ConfirmButton/ConfirmButton.tsx:51:7: Avoid adjusting state when a prop changes. Instead, adjust the state directly during render, or refactor your state to avoid this need entirely. [Warning/react-you-might-not-need-an-effect/no-adjust-state-on-prop-change]
  • src/components/ConfirmButton/ConfirmButton.tsx:54:3: Avoid resetting all state when a prop changes. If "noTransition" is a key, pass it as key instead so React will reset the component. [Warning/react-you-might-not-need-an-effect/no-reset-all-state-on-prop-change]
  • src/components/Datagrid/ColumnPicker/useAvailableColumnsQuery.ts:10:7: Avoid storing derived state. Compute "query" directly during render, optionally with useMemo if it's expensive. [Warning/react-you-might-not-need-an-effect/no-derived-state]
  • src/components/Datagrid/ColumnPicker/useCategorySelection.ts:15:7: Avoid storing derived state. Compute "selectedCategory" directly during render, optionally with useMemo if it's expensive. [Warning/react-you-might-not-need-an-effect/no-derived-state]
  • src/components/Datagrid/Datagrid.tsx:166:7: Avoid passing live state to parents in an effect. Instead, lift the state to the parent and pass it down to the child as a prop. [Warning/react-you-might-not-need-an-effect/no-pass-live-state-to-parent]
  • src/components/DateTimeTimezoneField.tsx:53:5: Avoid passing live state to parents in an effect. Instead, lift the state to the parent and pass it down to the child as a prop. [Warning/react-you-might-not-need-an-effect/no-pass-live-state-to-parent]
  • src/components/SortableTree/hooks/useItems.ts:19:5: Avoid storing derived state. Compute "items" directly during render, optionally with useMemo if it's expensive. [Warning/react-you-might-not-need-an-effect/no-derived-state]
  • src/discounts/components/DiscountCreateForm/hooks/useRulesHandlers.ts:10:5: Avoid adjusting state when a prop changes. Instead, adjust the state directly during render, or refactor your state to avoid this need entirely. [Warning/react-you-might-not-need-an-effect/no-adjust-state-on-prop-change]
  • src/discounts/components/DiscountRules/DiscountRules.tsx:56:7: Avoid adjusting state when a prop changes. Instead, adjust the state directly during render, or refactor your state to avoid this need entirely. [Warning/react-you-might-not-need-an-effect/no-adjust-state-on-prop-change]
  • src/extensions/components/WebhookDetailsPage/WebhookDetailsPage.tsx:84:5: Avoid storing derived state. Compute "query" directly during render, optionally with useMemo if it's expensive. [Warning/react-you-might-not-need-an-effect/no-derived-state]
  • src/extensions/views/EditCustomExtension/EditCustomApp.tsx:62:3: This effect only uses props. Consider lifting the logic up to the parent. [Warning/react-you-might-not-need-an-effect/no-manage-parent]
  • src/extensions/views/EditCustomExtension/components/TokenCreateDialog/TokenCreateDialog.tsx:44:7: Avoid adjusting state when a prop changes. Instead, adjust the state directly during render, or refactor your state to avoid this need entirely. [Warning/react-you-might-not-need-an-effect/no-adjust-state-on-prop-change]
  • src/extensions/views/InstalledExtensions/hooks/useActiveAppsInstallations.ts:87:7: Avoid passing data to parents in an effect. Instead, let the parent fetch the data itself and pass it down to the child as a prop. [Warning/react-you-might-not-need-an-effect/no-pass-data-to-parent]
  • src/extensions/views/InstalledExtensions/hooks/useActiveAppsInstallations.ts:139:22: Avoid passing data to parents in an effect. Instead, let the parent fetch the data itself and pass it down to the child as a prop. [Warning/react-you-might-not-need-an-effect/no-pass-data-to-parent]
  • src/extensions/views/InstalledExtensions/hooks/useActiveAppsInstallations.ts:143:11: Avoid passing data to parents in an effect. Instead, let the parent fetch the data itself and pass it down to the child as a prop. [Warning/react-you-might-not-need-an-effect/no-pass-data-to-parent]
  • src/giftCards/GiftCardCreateDialog/GiftCardCreateMoneyInput.tsx:54:7: Avoid passing data to parents in an effect. Instead, let the parent fetch the data itself and pass it down to the child as a prop. [Warning/react-you-might-not-need-an-effect/no-pass-data-to-parent]
  • src/giftCards/GiftCardUpdate/GiftCardResendCodeDialog/utils.ts:21:7: Avoid adjusting state when a prop changes. Instead, adjust the state directly during render, or refactor your state to avoid this need entirely. [Warning/react-you-might-not-need-an-effect/no-adjust-state-on-prop-change]
  • src/giftCards/components/GiftCardDeleteDialog/GiftCardDeleteDialogContent.tsx:44:3: Avoid resetting all state when a prop changes. If "open" is a key, pass it as key instead so React will reset the component. [Warning/react-you-might-not-need-an-effect/no-reset-all-state-on-prop-change]
  • src/giftCards/components/GiftCardDeleteDialog/GiftCardDeleteDialogContent.tsx:46:7: Avoid adjusting state when a prop changes. Instead, adjust the state directly during render, or refactor your state to avoid this need entirely. [Warning/react-you-might-not-need-an-effect/no-adjust-state-on-prop-change]
  • src/giftCards/components/GiftCardSendToCustomer/GiftCardSendToCustomer.tsx:33:19: Avoid passing data to parents in an effect. Instead, let the parent fetch the data itself and pass it down to the child as a prop. [Warning/react-you-might-not-need-an-effect/no-pass-data-to-parent]
  • src/hooks/useLocalPageInfo.ts:12:5: Avoid adjusting state when a prop changes. Instead, adjust the state directly during render, or refactor your state to avoid this need entirely. [Warning/react-you-might-not-need-an-effect/no-adjust-state-on-prop-change]
  • src/hooks/useLocalPaginator.ts:48:5: Avoid storing derived state. Compute "state" directly during render, optionally with useMemo if it's expensive. [Warning/react-you-might-not-need-an-effect/no-derived-state]
  • src/hooks/useLocalPaginator.ts:77:7: Avoid storing derived state. Compute "paginationSection" directly during render, optionally with useMemo if it's expensive. [Warning/react-you-might-not-need-an-effect/no-derived-state]
  • src/hooks/useModalDialogOpen/useModalDialogOpen.ts:14:7: Avoid storing derived state. Compute "prevOpen" directly during render, optionally with useMemo if it's expensive. [Warning/react-you-might-not-need-an-effect/no-derived-state]
  • src/hooks/useStateFromProps.ts:25:57: Avoid passing live state to parents in an effect. Instead, lift the state to the parent and pass it down to the child as a prop. [Warning/react-you-might-not-need-an-effect/no-pass-live-state-to-parent]
  • src/hooks/useStateFromProps.ts:28:7: Avoid storing derived state. Compute "prevData" directly during render, optionally with useMemo if it's expensive. [Warning/react-you-might-not-need-an-effect/no-derived-state]
  • src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx:132:19: Avoid passing data to parents in an effect. Instead, let the parent fetch the data itself and pass it down to the child as a prop. [Warning/react-you-might-not-need-an-effect/no-pass-data-to-parent]
  • src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx:133:7: Avoid adjusting state when a prop changes. Instead, adjust the state directly during render, or refactor your state to avoid this need entirely. [Warning/react-you-might-not-need-an-effect/no-adjust-state-on-prop-change]
  • src/orders/components/OrderTransactionRefundPage/components/OrderTransactionReasonModal/OrderTransactionReasonModal.tsx:24:3: Avoid resetting all state when a prop changes. If "reason" is a key, pass it as key instead so React will reset the component. [Warning/react-you-might-not-need-an-effect/no-reset-all-state-on-prop-change]
  • src/orders/components/OrderTransactionRefundPage/components/OrderTransactionReasonModal/OrderTransactionReasonModal.tsx:25:5: Avoid storing derived state. Compute "tempReason" directly during render, optionally with useMemo if it's expensive. [Warning/react-you-might-not-need-an-effect/no-derived-state]
  • src/orders/components/OrderTransactionRefundPage/utils.ts:147:11: Avoid passing data to parents in an effect. Instead, let the parent fetch the data itself and pass it down to the child as a prop. [Warning/react-you-might-not-need-an-effect/no-pass-data-to-parent]
  • src/orders/components/OrderTransactionRefundPage/utils.ts:156:9: Avoid passing data to parents in an effect. Instead, let the parent fetch the data itself and pass it down to the child as a prop. [Warning/react-you-might-not-need-an-effect/no-pass-data-to-parent]
  • src/orders/views/OrderDetails/OrderNormalDetails/index.tsx:168:34: Avoid passing data to parents in an effect. Instead, let the parent fetch the data itself and pass it down to the child as a prop. [Warning/react-you-might-not-need-an-effect/no-pass-data-to-parent]
  • src/orders/views/OrderDetails/OrderNormalDetails/index.tsx:169:7: Avoid adjusting state when a prop changes. Instead, adjust the state directly during render, or refactor your state to avoid this need entirely. [Warning/react-you-might-not-need-an-effect/no-adjust-state-on-prop-change]
  • src/productTypes/components/ProductTypeVariantAttributes/ProductTypeVariantAttributes.tsx:113:7: Avoid passing data to parents in an effect. Instead, let the parent fetch the data itself and pass it down to the child as a prop. [Warning/react-you-might-not-need-an-effect/no-pass-data-to-parent]
  • src/products/views/ProductVariant/ProductVariant.tsx:82:3: Avoid resetting all state when a prop changes. If "variantId" is a key, pass it as key instead so React will reset the component. [Warning/react-you-might-not-need-an-effect/no-reset-all-state-on-prop-change]
  • src/products/views/ProductVariant/ProductVariant.tsx:83:5: Avoid adjusting state when a prop changes. Instead, adjust the state directly during render, or refactor your state to avoid this need entirely. [Warning/react-you-might-not-need-an-effect/no-adjust-state-on-prop-change]
  • src/taxes/utils/useTaxUrlRedirect.ts:35:3: This effect only uses props. Consider lifting the logic up to the parent. [Warning/react-you-might-not-need-an-effect/no-manage-parent]
  • src/utils/handlers/attributeValueSearchHandler.ts:52:9: Avoid using state and effects as an event handler. Instead, call the event handling code directly when the event occurs. [Warning/react-you-might-not-need-an-effect/no-event-handler]
  • src/warehouses/components/WarehouseSettings/WarehouseSettings.tsx:57:7: Avoid passing data to parents in an effect. Instead, let the parent fetch the data itself and pass it down to the child as a prop. [Warning/react-you-might-not-need-an-effect/no-pass-data-to-parent]

@witoszekdev witoszekdev requested a review from a team as a code owner October 6, 2025 11:43
@changeset-bot
Copy link

changeset-bot bot commented Oct 6, 2025

⚠️ No Changeset found

Latest commit: 44c28b6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Oct 6, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
saleor-dashboard-storybook Ignored Ignored Preview Oct 6, 2025 0:42am

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds the ESLint plugin "eslint-plugin-react-you-might-not-need-an-effect" to help identify unnecessary useEffect usage in the React codebase. The plugin detects various anti-patterns where effects are used when simpler alternatives would be more appropriate.

  • Added the ESLint plugin as a dev dependency
  • Configured the plugin in the ESLint configuration to use its recommended rules

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
package.json Added eslint-plugin-react-you-might-not-need-an-effect as a dev dependency
eslint.config.mjs Imported and configured the plugin with recommended rules

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@witoszekdev witoszekdev added the skip changeset Use if your changes doesn't need entry in changelog label Oct 6, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 2025

Differences Found

⚠️ 2 packages or licenses were added.

Expand
License	Package
MIT	eslint-plugin-react-you-might-not-need-an-effect
MIT	eslint-utils

Summary

Expand
License Name Package Count Packages
0BSD 1
Packages
  • tslib
CC-BY-3.0 1
Packages
  • spdx-exceptions
MIT/X11 1
Packages
  • nub
MPL-1.1 1
Packages
  • harmony-reflect
MPL-2.0 1
Packages
  • dompurify
Public Domain 1
Packages
  • jsonify
Python-2.0 1
Packages
  • argparse
WTFPL 1
Packages
  • utf8-byte-length
<<missing>> 2
Packages
  • busboy
  • streamsearch
CC-BY-4.0 2
Packages
  • @saleor/macaw-ui
  • caniuse-lite
CC0-1.0 2
Packages
  • spdx-license-ids
  • type-fest
SEE LICENSE IN LICENSE 2
Packages
  • posthog-js
  • spawndamnit
BlueOak-1.0.0 3
Packages
  • jackspeak
  • package-json-from-dist
  • path-scurry
BSD-2-Clause 24
Packages
  • browser-process-hrtime
  • css-select
  • css-what
  • domelementtype
  • domhandler
  • domutils
  • dotenv
  • dotenv-expand
  • entities
  • escodegen
  • eslint-scope
  • espree
  • esprima
  • esrecurse
  • estraverse
  • esutils
  • normalize-package-data
  • nth-check
  • regjsparser
  • stringify-object
  • And 4 more...
BSD-3-Clause 43
Packages
  • @saleor/app-sdk
  • @sentry/cli
  • @sentry/cli-darwin
  • @sentry/cli-linux-arm
  • @sentry/cli-linux-arm64
  • @sentry/cli-linux-i686
  • @sentry/cli-linux-x64
  • @sentry/cli-win32-arm64
  • @sentry/cli-win32-i686
  • @sentry/cli-win32-x64
  • @sinonjs/commons
  • @sinonjs/fake-timers
  • abab
  • asn1js
  • babel-plugin-istanbul
  • chroma-js
  • dataloader
  • diff
  • esquery
  • exenv
  • And 23 more...
ISC 50
Packages
  • @isaacs/cliui
  • @istanbuljs/load-nyc-config
  • anymatch
  • boolbase
  • cli-width
  • cliui
  • electron-to-chromium
  • fastq
  • flatted
  • foreground-child
  • fs.realpath
  • get-caller-file
  • get-own-enumerable-property-symbols
  • glob
  • glob-parent
  • graceful-fs
  • hosted-git-info
  • inflight
  • inherits
  • ini
  • And 30 more...
Apache-2.0 57
Packages
  • @ampproject/remapping
  • @editorjs/editorjs
  • @eslint/config-array
  • @eslint/config-helpers
  • @eslint/core
  • @eslint/object-schema
  • @eslint/plugin-kit
  • @humanfs/core
  • @humanfs/node
  • @humanwhocodes/module-importer
  • @humanwhocodes/retry
  • @opentelemetry/api
  • @opentelemetry/semantic-conventions
  • @playwright/test
  • @pollyjs/adapter
  • @pollyjs/core
  • @pollyjs/persister
  • @pollyjs/utils
  • @swc/core
  • @swc/core-darwin-arm64
  • And 37 more...
MIT 1262
Packages
  • @adobe/css-tools
  • @apollo/client
  • @ardatan/relay-compiler
  • @ardatan/sync-fetch
  • @babel/code-frame
  • @babel/compat-data
  • @babel/core
  • @babel/generator
  • @babel/helper-annotate-as-pure
  • @babel/helper-compilation-targets
  • @babel/helper-create-class-features-plugin
  • @babel/helper-globals
  • @babel/helper-member-expression-to-functions
  • @babel/helper-module-imports
  • @babel/helper-module-transforms
  • @babel/helper-optimise-call-expression
  • @babel/helper-plugin-utils
  • @babel/helper-replace-supers
  • @babel/helper-skip-transparent-expression-wrappers
  • @babel/helper-string-parser
  • And 1242 more...

@codecov
Copy link

codecov bot commented Oct 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 40.06%. Comparing base (2d2d61f) to head (44c28b6).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #5945    +/-   ##
========================================
  Coverage   40.06%   40.06%            
========================================
  Files        2473     2473            
  Lines       40228    40228            
  Branches     8853     9184   +331     
========================================
  Hits        16118    16118            
  Misses      24083    24083            
  Partials       27       27            

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@witoszekdev witoszekdev enabled auto-merge (squash) October 6, 2025 11:49
Copilot AI review requested due to automatic review settings October 6, 2025 12:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@witoszekdev witoszekdev merged commit 79ed00b into main Oct 6, 2025
19 checks passed
@witoszekdev witoszekdev deleted the add-eslint-plugin branch October 6, 2025 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip changeset Use if your changes doesn't need entry in changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants