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

Add custom config to use double negation instead of Boolean #96

Merged
merged 3 commits into from
May 29, 2024

Conversation

ShridharGoel
Copy link
Contributor

@ShridharGoel ShridharGoel commented Apr 28, 2024

Comment on lines 15 to 25
fix(fixer) {
const sourceCode = context.getSourceCode();
const argumentText = sourceCode.getText(node.arguments[0]);
return fixer.replaceText(node, `!!${argumentText}`);
},
Copy link
Contributor

Choose a reason for hiding this comment

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

this will fail in this case Boolean(random1 || random2)

@@ -15,6 +15,8 @@ module.exports = {
'rulesdir/no-call-actions-from-actions': 'error',
'rulesdir/no-api-side-effects-method': 'error',
'rulesdir/prefer-localization': 'error',
'rulesdir/onyx-props-must-have-default': 'error',
Copy link
Contributor

Choose a reason for hiding this comment

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

why ?

@ShridharGoel
Copy link
Contributor Author

@ishpaul777 Updated.

const goodExample2 = '!!(test1 || test2)';

const badExample1 = 'Boolean(test)';
const badExample2 = 'Boolean(test1 || test2)';
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please add more test cases to cover more cases like &&, test1 && test2 || test3, test ? '' : "random" etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will update this soon.

@ShridharGoel ShridharGoel requested a review from ishpaul777 May 8, 2024 13:56
Comment on lines 26 to 46
ruleTester.run('use-!!-instead-of-Boolean()', rule, {
valid: [
{
code: goodExample1,
},
{
code: goodExample2,
},
{
code: goodExample3,
},
{
code: goodExample4,
},
{
code: goodExample5,
},
{
code: goodExample6,
},
],
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB, but can you please use the code here directly like we use in other test files, for better readability

Copy link
Contributor

Choose a reason for hiding this comment

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

This is last one, rest LGTM!

@ShridharGoel ShridharGoel requested a review from ishpaul777 May 9, 2024 14:53
@aldo-expensify
Copy link
Contributor

@ShridharGoel seems like you have some misconfiguration in your dev env and only some of the commits are signed:

image

I can't merge like this

image

Signing commits is mentioned as a requirement here: https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md#begin-coding-your-solution-in-a-pull-request

},
});

ruleTester.run('use-!!-instead-of-Boolean()', rule, {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ruleTester.run('use-!!-instead-of-Boolean()', rule, {
ruleTester.run('use-double-negation-instead-of-boolean()', rule, {

Maybe name it the same as the rule so it is easy to find by the name of the rule? same comment for the file name to use use-double-negation-instead-of-boolean.test.js instead of prefer-double-negation.test..js

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shouldn't it be Boolean() with a capital B?

@@ -0,0 +1,31 @@
const message = require('./CONST').MESSAGE.USE_DOUBLE_NEGATION_INSTEAD_OF_BOOLEAN;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we name this file use-double-negation-instead-of-boolean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was the initial name but was suggested to update: #96 (comment)

Will change it again.

Copy link
Contributor

@aldo-expensify aldo-expensify left a comment

Choose a reason for hiding this comment

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

Need to fix commits, maybe the easiest way is to just create a new branch were you commit again

Left some minor comments

@ShridharGoel
Copy link
Contributor Author

Will get back to this tomorrow.

@fabioh8010
Copy link
Contributor

@ShridharGoel kind bump 🙂

@ShridharGoel ShridharGoel force-pushed the boolean-update branch 7 times, most recently from 0f258cb to e6e0c69 Compare May 16, 2024 18:50
aldo-expensify
aldo-expensify previously approved these changes May 16, 2024
@aldo-expensify aldo-expensify changed the title Add custom config to use double negation instead of Boolean [HOLD merge freeze] Add custom config to use double negation instead of Boolean May 16, 2024
@ishpaul777
Copy link
Contributor

ishpaul777 commented May 16, 2024

it seems to have a failing test on main (unrelated to PR)

Screenshot 2024-05-17 at 12 45 46 AM

@ishpaul777
Copy link
Contributor

ishpaul777 commented May 28, 2024

hello 👋 @aldo-expensify, is the merge freeze ongoing, when can we expect this PR to be merged ?

@aldo-expensify
Copy link
Contributor

aldo-expensify commented May 29, 2024

@ishpaul777 I understand that the merge freeze has been lifted for the App and eslint-config-expensify repos.

@ShridharGoel can you resolve conflicts 🙏

@ShridharGoel
Copy link
Contributor Author

@aldo-expensify Done.

@aldo-expensify
Copy link
Contributor

Thank you @ShridharGoel

@aldo-expensify aldo-expensify changed the title [HOLD merge freeze] Add custom config to use double negation instead of Boolean Add custom config to use double negation instead of Boolean May 29, 2024
@aldo-expensify aldo-expensify merged commit 89be844 into Expensify:main May 29, 2024
Copy link
Contributor

🚀 Published in 2.0.50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants