-
Notifications
You must be signed in to change notification settings - Fork 27
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
Add rules: Handle No Multiple Onyx in file #73
Add rules: Handle No Multiple Onyx in file #73
Conversation
Co-authored-by: Tim Golen <tgolen@gmail.com>
…studentofcoding/eslint-config-expensify into Handle-No-Multiple-Onyx-in-file
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.
valid: [
{
code: `
withOnyx({
key: 'value',
})(Component);
`,
},
],
invalid: [
{
code: `
withOnyx({
key1: 'value1',
})(Component1);
withOnyx({
key1: 'value1',
})(Component2);
`,
errors: [
{
message,
},
],
},
],
@studentofcoding Could you explain how the test will be work? I don't see the difference on the code of valid or invalid.
This comment was marked as outdated.
This comment was marked as outdated.
Oops I miss understand the test and sharing the wrong info @mollfpr, so the test is covering:
Thus in the example above we can see that it's failing with 4 |
@studentofcoding Yes, it should be failing when there are multiple |
Yupp, in that case, it's already handle that |
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.
Looks great, thank you!
Don't forget to make an App PR after this is merged to update the eslint-config version so we can include this.
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.
Note: I am also working on a related fix which will help us to remove the duplicate calls to |
@studentofcoding I have published this to NPM https://www.npmjs.com/package/eslint-config-expensify so you can move forward with the Expensify/App PR now to update the version. |
Details
ESLint Rules extend - Create an ESLint rule to detect multiple uses of withOnyx
Fixed Issues
$ 27463
PROPOSAL: Expensify/App#27463 (comment)
Tests
no-multiple-onyx-in-file.js
andno-multiple-onyx-in-file.test.js
andNO_MULTIPLE_ONYX_IN_FILE: 'Only use the same details withOnyx() once. If there are dependent Onyx keys, they can all be handled in a single instance of withOnyx through the use of selectors.',
Offline tests
QA Steps
no-multiple-onyx-in-file.js
andno-multiple-onyx-in-file.test.js
andNO_MULTIPLE_ONYX_IN_FILE: 'Only use the same details withOnyx() once. If there are dependent Onyx keys, they can all be handled in a single instance of withOnyx through the use of selectors.',
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Result
We will see this on the file
cc: @neil-marcellini @mollfpr @tgolen