-
Notifications
You must be signed in to change notification settings - Fork 9
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
✨ feat: allow ignore components, sources #74
base: master
Are you sure you want to change the base?
Conversation
huynhducduy
commented
Nov 30, 2024
- Support ignore specific components, specific components imported from sources, or all components imported from sources
- Close Disable rule for react-router-dom <Route/> element. #67
@@ -53,6 +53,52 @@ With this configuration, the "style" attribute is ignored for native elements fo | |||
} | |||
``` | |||
|
|||
As of v3.4.0, each eslint-plugin-react-perf rule supports configuration to control whether custom components are ignored. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remember to change the version (v3.4.0) to your desired one
f2d6567
to
190167b
Compare
Hi @huynhducduy , when can we expect to get it merged ? 🙏 |
@harshVardhan4743 Sorry but I don't know when @cvazac has the time to review it. At the mean time, you can try this PR and all of my other PRs by using this patch https://gist.github.com/huynhducduy/46515b884c583e9ad95a353829010638 |
lib/utils/common.js
Outdated
options[0] || {}; | ||
|
||
const sourceMap = new Map(); | ||
const ignoreComponentsSet = new Set(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can just do this:
const ignoreComponentsSet = new Set(ignoreComponents || []);
Thanks for working on this @huynhducduy! Today, we have |
{ | ||
code: `import Foo from "react-foo";<Foo.Item style={${ruleCode}} />`, | ||
options: [ | ||
{ ignoreSources: [{ source: "react-foo", importNames: ["Item"] }] }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it make sense to instead namespace as importNames: ["Foo.Item"]
? wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean to drop the source
property?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to adjust the config to be able to, for example, allow the known patterns for Foo.Item
, but disallow for Bar.Item
.
import Foo from "react-foo"
import Bar from "react-bar"
render() {
return <><Foo.Item /><Bar.Item /></>
}
The options in the PR on line 118 don't distinguish between Foo
and Bar
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I didn't get it yet. It does disallow for Bar.Item
since Bar
is imported from react-bar
(not react-foo
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cvazac have I answered all your questions? Is there anything else you are unclear about?
IMO, the This is also my answer for #73 (comment) |