-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Allow falsey, yet valid options for codeFrameColumns() #7341
Conversation
const linesAbove = opts.linesAbove || 2; | ||
const linesBelow = opts.linesBelow || 3; | ||
const linesAbove = isNaN(opts.linesAbove) ? 2 : opts.linesAbove; | ||
const linesBelow = isNaN(opts.linesBelow) ? 3 : opts.linesBelow; |
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.
isNaN
is imho a legacy API and should not be used nowadays, not sure what the intention was but I guess this should be fine, right?
const linesAbove = typeof opts.linesAbove !== 'number' ? 2 : opts.linesAbove;
const linesBelow = typeof opts.linesBelow !== 'number' ? 3 : opts.linesBelow;
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.
seems like it's just to allow 0
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.
yes, to allow 0. I agree about the isNaN usage - i would have preferred to use destructuring with defaults. But, guess I was going for lowest impacting change lol.
I'd be happy to replace isNaN if you guys prefer?
Allow for overriding default linesAbove/linesBelow values.
@Andarist better? |
@hulkish Yeah, that works too. |
Do we just need to rebase this? Since the other prs are passing |
There is no need to rebase: it will work when merged, since the failing test has been fixed in code not touched by this PR. |
thanks @hulkish! good find |
Allow for overriding default linesAbove/linesBelow values.
When will there be a release of |
You can try it in Babel 7 beta ( |
Allow for overriding default linesAbove/linesBelow values.
Improved option defaulting logic, small change.