Skip to content

[docs-infra] Fix React Compiler ESLint issues in website components#42566

Merged
aarongarciah merged 13 commits intomui:nextfrom
aarongarciah:website-fix-eslint-react-compiler-issues
Jul 3, 2024
Merged

[docs-infra] Fix React Compiler ESLint issues in website components#42566
aarongarciah merged 13 commits intomui:nextfrom
aarongarciah:website-fix-eslint-react-compiler-issues

Conversation

@aarongarciah
Copy link
Copy Markdown
Member

@aarongarciah aarongarciah commented Jun 7, 2024

Part of #42564

Fixes or silences errors reported by eslint-plugin-react-compiler in the website components.

The silenced occurrences are prepended with a comment because we use the --report-unused-disable-directives and we can't silence rules that are not configured, like the ones coming from eslint-plugin-react-compiler, which is disabled by default as of today.

// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- useEnhancedEffect uses useEffect under the hood

Apart from that, add a missing React key.

How to test

Make sure the parts of the docs that are affected by the changes work as expected. Half of the changes are just silencing the corresponding ESLint rule.

@aarongarciah aarongarciah added the scope: docs-infra Involves the docs-infra product (https://www.notion.so/mui-org/b9f676062eb94747b6768209f7751305). label Jun 7, 2024
@mui-bot
Copy link
Copy Markdown

mui-bot commented Jun 7, 2024

Netlify deploy preview

https://deploy-preview-42566--material-ui.netlify.app/

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against e861ac6

const objectRect = target.current.getBoundingClientRect();
const newWidth = clientX - objectRect.left + dragOffset;
target.current.style.width = `clamp(${minWidth}, ${Math.floor(newWidth)}px, ${maxWidth})`;
target.current.style.setProperty(
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Using style.setProperty so there's no "mutation".

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This feels strange: facebook/react#29832.

@aarongarciah aarongarciah marked this pull request as ready for review June 7, 2024 15:48
@aarongarciah
Copy link
Copy Markdown
Member Author

aarongarciah commented Jun 7, 2024

Looking into the reported ESLint errors:

Definition for rule 'react-compiler/react-compiler' was not found react-compiler/react-compiler

We use the --report-unused-disable-directives ESLint flag so we can't disable rules that are not configured and we only enable the eslint-plugin-react-compiler rules manually on local development for now.

@aarongarciah aarongarciah added the on hold There is a blocker, we need to wait. label Jun 7, 2024
@aarongarciah
Copy link
Copy Markdown
Member Author

I've pushed a change commenting the ESLint disable comments for the react-compiler rules e.g.

- // eslint-disable-next-line react-compiler/react-compiler -- useEnhancedEffect uses useEffect under the hood
+ // TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- useEnhancedEffect uses useEffect under the hood

We can't have disabled rules that are not configured because we use the --report-unused-disable-directives ESLint flag.

@aarongarciah aarongarciah added website Pages that are not documentation-related, marketing-focused. and removed on hold There is a blocker, we need to wait. labels Jun 10, 2024
@aarongarciah aarongarciah requested a review from brijeshb42 June 10, 2024 09:12
const objectRect = target.current.getBoundingClientRect();
const newWidth = clientX - objectRect.left + dragOffset;
target.current.style.width = `clamp(${minWidth}, ${Math.floor(newWidth)}px, ${maxWidth})`;
target.current.style.setProperty(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This feels strange: facebook/react#29832.

@aarongarciah aarongarciah force-pushed the website-fix-eslint-react-compiler-issues branch from 7d56792 to e861ac6 Compare June 10, 2024 17:01
@aarongarciah aarongarciah requested review from DiegoAndai and mnajdova and removed request for brijeshb42 and mnajdova June 20, 2024 09:28
'import/no-default-export': 'error',
'import/prefer-default-export': 'off',
...(ENABLE_REACT_COMPILER_PLUGIN ? { 'react-compiler/react-compiler': 'off' } : {}),
'react-compiler/react-compiler': 'off',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is ENABLE_REACT_COMPILER_PLUGIN no longer useful?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

For now we leave it always off for Base UI.

}

return () => {
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- useEnhancedEffect uses useEffect under the hood
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What's the plan with these comments? To fix it in the future or to keep the disable?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The plan is to keep the disable but remove the comment/TODO once we enable the corresponding ESLint plugin.

Copy link
Copy Markdown
Member

@DiegoAndai DiegoAndai left a comment

Choose a reason for hiding this comment

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

LGTM

@aarongarciah aarongarciah merged commit f0c14cf into mui:next Jul 3, 2024
joserodolfofreitas pushed a commit to joserodolfofreitas/material-ui that referenced this pull request Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: docs-infra Involves the docs-infra product (https://www.notion.so/mui-org/b9f676062eb94747b6768209f7751305). website Pages that are not documentation-related, marketing-focused.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants