Added eslint-plugin-react-you-might-not-need-an-effect#5945
Added eslint-plugin-react-you-might-not-need-an-effect#5945witoszekdev merged 3 commits intomainfrom
Conversation
|
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
There was a problem hiding this comment.
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.
Differences FoundExpandLicense Package MIT eslint-plugin-react-you-might-not-need-an-effect MIT eslint-utils SummaryExpand
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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.
Added ESLint plugin to detect unnecesary usage of
useEffectin 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 itsuseState. [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 withuseMemoif 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 askeyinstead 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 withuseMemoif 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 askeyinstead 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 withuseMemoif 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 askeyinstead 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 withuseMemoif 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 withuseMemoif 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 askeyinstead 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 withuseMemoif 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 withuseMemoif 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 withuseMemoif 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 withuseMemoif 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 askeyinstead 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 withuseMemoif 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 withuseMemoif 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 withuseMemoif 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 withuseMemoif 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 askeyinstead 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 withuseMemoif 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 askeyinstead 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]