Skip to content

chore: Turn on set-state-in-effect rule#4435

Merged
mrCherry97 merged 16 commits intokyma-project:mainfrom
awoloszyn22:eslint-set-state-in-effect
Dec 23, 2025
Merged

chore: Turn on set-state-in-effect rule#4435
mrCherry97 merged 16 commits intokyma-project:mainfrom
awoloszyn22:eslint-set-state-in-effect

Conversation

@awoloszyn22
Copy link
Contributor

@awoloszyn22 awoloszyn22 commented Dec 9, 2025

Description

Changes proposed in this pull request:

Related issue(s)
#4396

Definition of done

  • The PR's title starts with one of the following prefixes:
    • feat: A new feature
    • fix: A bug fix
    • docs: Documentation only changes
    • refactor: A code change that neither fixes a bug nor adds a feature
    • test: Adding tests
    • revert: Revert commit
    • chore: Maintainance changes to the build process or auxiliary tools, libraries, workflows, etc.
  • Related issues are linked. To link internal trackers, use the issue IDs like backlog#4567
  • Explain clearly why you created the PR and what changes it introduces
  • All necessary steps are delivered, for example, tests, documentation, merging

@mrCherry97 mrCherry97 added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 10, 2025
Copy link
Contributor

@akucharska akucharska left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 15 to 21
useEffect(() => {
if (!showWizard) {
//Disabled because useState cannot be converted to useMemo as setState is passed to a child
//eslint-disable-next-line react-hooks/set-state-in-effect
setKubeconfig(undefined);
}
}, [showWizard]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider if this useEffect is valid, in my opinion we can remove it, and add to onClose function setting that to undefined. Also we are passing setKubeconfig to AddClusterWizard where we can set it in onComplete and onCancel to undefined instead of the useEffect here.

Comment on lines 78 to 81
useEffect(() => {
//eslint-disable-next-line react-hooks/set-state-in-effect
setToken(resource?.users?.[userIndex]?.user?.token);
}, [resource, userIndex]);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see added value on this, please double-check, but in my opinion this just could be removed, but I didn't check kubeconfigID flow.

const detailsOpen = useMemo(() => {
if (layoutState?.layout) {
setDetailsOpen(layoutState?.layout !== 'OneColumn');
console.log(layoutState?.layout !== 'OneColumn');
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
console.log(layoutState?.layout !== 'OneColumn');

Comment on lines 68 to 76
useEffect(() => {
if (chatHistory[0].messages.length > 1) {
//eslint-disable-next-line react-hooks/set-state-in-effect
setIsInitialScreen(false);
return;
} else {
setIsInitialScreen(true);
}
}, [chatHistory]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Couldn't this be like this?

Suggested change
useEffect(() => {
setIsInitialScreen(chatHistory[0].messages.length <= 1);
}, [chatHistory]);

Copy link
Contributor

@mrCherry97 mrCherry97 left a comment

Choose a reason for hiding this comment

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

I clicked approve instead of request changes, sorry

Copy link
Contributor

@mrCherry97 mrCherry97 left a comment

Choose a reason for hiding this comment

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

LGTM

@mrCherry97 mrCherry97 merged commit 2644100 into kyma-project:main Dec 23, 2025
22 of 24 checks passed
@mrCherry97 mrCherry97 removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants