-
Notifications
You must be signed in to change notification settings - Fork 350
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
Respect useTabs option when indenting an opening JSX element #404
base: master
Are you sure you want to change the base?
Conversation
lib/lines.js
Outdated
result += new Array(spaces + 1).join(" "); | ||
} | ||
|
||
return result; |
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 stick to four spaces per tab when adding new implementation code, please? I realize you're a fan of tabs (nothing wrong with that), but consistency is important here.
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 stick to four spaces per tab when adding new implementation code, please? I realize you're a fan of tabs (nothing wrong with that), but consistency is important here.
I apologize in advance, but I really can't help emphasizing the enormous amount of irony in the statement "consistency is important here" in reference to indents in a PR that is targeting a design flaw that produces inconsistent indents. (Not trying to be snippy or anything, I'm sorry if it came across that way)
Could issue #315 as well as this PR possibly be addressed sometime soon since this project appears like it's still maintained? These issues have been around for almost six years now, it would be pretty nice. In the meantime I switched to babel's generator which seems to have everything I need.
3043a97
to
02cfced
Compare
Oh, sorry for submitting broken commits like this :( I pushed a tabs-to-spaces change, and also changed the |
Steps to reproduce:
Run this node script:
Expected result:
The output is indented with tabs:
Actual result:
There are spaces before the JSX opening element:
The cause of the bug is:
Lines.prototype.join
method uses spaces to create the indent and doesn't respect theuseTabs
optionThe fix is to use a smarter algorithm from the
Lines.prototype.sliceString
function.However, this requires passing a new parameter to the
join
method and recursively addoptions
to many many calls. I'm wondering if there is a better solution for this. Do all the calls toconcat
andLines.prototype.join
need theoptions
argument?