Skip to content

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

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

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: 7446d17
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: 33b2662
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: cf7458b
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: e288fff
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
Member

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
Member

@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: 20df08f
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: 20df08f
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: 38718f8
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: 8182bdc
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: eca2523
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: 81deb5c
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