-
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 custom config to use double negation instead of Boolean #96
Conversation
fix(fixer) { | ||
const sourceCode = context.getSourceCode(); | ||
const argumentText = sourceCode.getText(node.arguments[0]); | ||
return fixer.replaceText(node, `!!${argumentText}`); | ||
}, |
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.
this will fail in this case Boolean(random1 || random2)
rules/expensify.js
Outdated
@@ -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', |
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.
why ?
@ishpaul777 Updated. |
const goodExample2 = '!!(test1 || test2)'; | ||
|
||
const badExample1 = 'Boolean(test)'; | ||
const badExample2 = 'Boolean(test1 || test2)'; |
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.
Can you please add more test cases to cover more cases like &&
, test1 && test2 || test3
, test ? '' : "random"
etc.
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.
bump @ShridharGoel!
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.
Will update this soon.
ruleTester.run('use-!!-instead-of-Boolean()', rule, { | ||
valid: [ | ||
{ | ||
code: goodExample1, | ||
}, | ||
{ | ||
code: goodExample2, | ||
}, | ||
{ | ||
code: goodExample3, | ||
}, | ||
{ | ||
code: goodExample4, | ||
}, | ||
{ | ||
code: goodExample5, | ||
}, | ||
{ | ||
code: goodExample6, | ||
}, | ||
], |
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.
NAB, but can you please use the code here directly like we use in other test files, for better readability
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.
This is last one, rest LGTM!
@ShridharGoel seems like you have some misconfiguration in your dev env and only some of the commits are signed: I can't merge like this 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, { |
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.
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
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.
Shouldn't it be Boolean()
with a capital B?
@@ -0,0 +1,31 @@ | |||
const message = require('./CONST').MESSAGE.USE_DOUBLE_NEGATION_INSTEAD_OF_BOOLEAN; |
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.
Should we name this file use-double-negation-instead-of-boolean
?
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.
That was the initial name but was suggested to update: #96 (comment)
Will change it again.
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.
Need to fix commits, maybe the easiest way is to just create a new branch were you commit again
Left some minor comments
Will get back to this tomorrow. |
@ShridharGoel kind bump 🙂 |
0f258cb
to
e6e0c69
Compare
e6e0c69
to
1515072
Compare
hello 👋 @aldo-expensify, is the merge freeze ongoing, when can we expect this PR to be merged ? |
@ishpaul777 I understand that the merge freeze has been lifted for the App and eslint-config-expensify repos. @ShridharGoel can you resolve conflicts 🙏 |
@aldo-expensify Done. |
Thank you @ShridharGoel |
🚀 Published in 2.0.50 |
Expensify/App#39126