Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[compiler] Surface unused opt out directives in eslint #30721

Merged
merged 10 commits into from
Aug 16, 2024

Conversation

poteto
Copy link
Member

@poteto poteto commented Aug 16, 2024

Stack from ghstack (oldest at bottom):

This PR updates the eslint plugin to report unused opt out directives.
One of the downsides of the opt out directive is that it opts the
component/hook out of compilation forever, even if the underlying issue
was fixed in product code or fixed in the compiler.

[ghstack-poisoned]
Copy link

vercel bot commented Aug 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 16, 2024 9:46pm

poteto added a commit that referenced this pull request Aug 16, 2024
This PR updates the eslint plugin to report unused opt out directives.
One of the downsides of the opt out directive is that it opts the
component/hook out of compilation forever, even if the underlying issue
was fixed in product code or fixed in the compiler.

Additionally, the opt out directive would effectively disable our eslint
plugin from running on the opted out component/hook, which increases the
chances of said function accruing more rules of React violations or
other anti-patterns.

ghstack-source-id: 7446d1732605a5efda0904e6bfe29d6359a01be7
Pull Request resolved: #30721
@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Aug 16, 2024
[ghstack-poisoned]
poteto added a commit that referenced this pull request Aug 16, 2024
This PR updates the eslint plugin to report unused opt out directives.
One of the downsides of the opt out directive is that it opts the
component/hook out of compilation forever, even if the underlying issue
was fixed in product code or fixed in the compiler.

Additionally, the opt out directive would effectively disable our eslint
plugin from running on the opted out component/hook, which increases the
chances of said function accruing more rules of React violations or
other anti-patterns.

ghstack-source-id: 33b2662431164a23f4c19cf4b0e0dffa922ed646
Pull Request resolved: #30721
[ghstack-poisoned]
poteto added a commit that referenced this pull request Aug 16, 2024
This PR updates the eslint plugin to report unused opt out directives.
One of the downsides of the opt out directive is that it opts the
component/hook out of compilation forever, even if the underlying issue
was fixed in product code or fixed in the compiler.

Additionally, the opt out directive would effectively disable our eslint
plugin from running on the opted out component/hook, which increases the
chances of said function accruing more rules of React violations or
other anti-patterns.

ghstack-source-id: cf7458b04395290a79397b94905eaf0477717bb1
Pull Request resolved: #30721
[ghstack-poisoned]
poteto added a commit that referenced this pull request Aug 16, 2024
This PR updates the eslint plugin to report unused opt out directives.
One of the downsides of the opt out directive is that it opts the
component/hook out of compilation forever, even if the underlying issue
was fixed in product code or fixed in the compiler.

ghstack-source-id: e288fff57efb31c4e16ad5d74a0cc1d72bbf78db
Pull Request resolved: #30721
Comment on lines +301 to +317
FunctionDeclaration(fnDecl) {
for (const stmt of fnDecl.body.body) {
reportUnusedOptOutDirective(stmt);
}
},
ArrowFunctionExpression(fnExpr) {
if (fnExpr.body.type === 'BlockStatement') {
for (const stmt of fnExpr.body.body) {
reportUnusedOptOutDirective(stmt);
}
}
},
FunctionExpression(fnExpr) {
for (const stmt of fnExpr.body.body) {
reportUnusedOptOutDirective(stmt);
}
},
Copy link
Contributor

Choose a reason for hiding this comment

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

This won't necessarily match 1:1 with functions that the compiler attempted to compile, in particular it might find more functions. But I guess that's okay, if you have a "use no memo" in a component that isn't being recognized as a component/hook that's also an error.

Copy link
Contributor

@josephsavona josephsavona left a comment

Choose a reason for hiding this comment

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

awesomesauce

[ghstack-poisoned]
poteto added a commit that referenced this pull request Aug 16, 2024
This PR updates the eslint plugin to report unused opt out directives.
One of the downsides of the opt out directive is that it opts the
component/hook out of compilation forever, even if the underlying issue
was fixed in product code or fixed in the compiler.

ghstack-source-id: 20df08f227d03da57ca8d48eb779ec8866981d7c
Pull Request resolved: #30721
poteto added a commit that referenced this pull request Aug 16, 2024
This PR updates the eslint plugin to report unused opt out directives.
One of the downsides of the opt out directive is that it opts the
component/hook out of compilation forever, even if the underlying issue
was fixed in product code or fixed in the compiler.

ghstack-source-id: 20df08f227d03da57ca8d48eb779ec8866981d7c
Pull Request resolved: #30721
[ghstack-poisoned]
poteto added a commit that referenced this pull request Aug 16, 2024
This PR updates the eslint plugin to report unused opt out directives.
One of the downsides of the opt out directive is that it opts the
component/hook out of compilation forever, even if the underlying issue
was fixed in product code or fixed in the compiler.

ghstack-source-id: 38718f8fd2e6bae189e3b283871f183449326f53
Pull Request resolved: #30721
[ghstack-poisoned]
poteto added a commit that referenced this pull request Aug 16, 2024
This PR updates the eslint plugin to report unused opt out directives.
One of the downsides of the opt out directive is that it opts the
component/hook out of compilation forever, even if the underlying issue
was fixed in product code or fixed in the compiler.

ghstack-source-id: 8182bdcfe1229fedd67b92eaa802a87c72697346
Pull Request resolved: #30721
[ghstack-poisoned]
poteto added a commit that referenced this pull request Aug 16, 2024
This PR updates the eslint plugin to report unused opt out directives.
One of the downsides of the opt out directive is that it opts the
component/hook out of compilation forever, even if the underlying issue
was fixed in product code or fixed in the compiler.

ghstack-source-id: eca25236a63eba2c6515e70c8efe4ce36c44be45
Pull Request resolved: #30721
[ghstack-poisoned]
[ghstack-poisoned]
@poteto poteto merged commit 177d684 into gh/poteto/5/base Aug 16, 2024
19 checks passed
poteto added a commit that referenced this pull request Aug 16, 2024
This PR updates the eslint plugin to report unused opt out directives.
One of the downsides of the opt out directive is that it opts the
component/hook out of compilation forever, even if the underlying issue
was fixed in product code or fixed in the compiler.

ghstack-source-id: 81deb5c11b7c57f07f6ab13266066cd73b2f3729
Pull Request resolved: #30721
@poteto poteto deleted the gh/poteto/5/head branch August 16, 2024 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants