-
Notifications
You must be signed in to change notification settings - Fork 240
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
[RRFC] Don't expand tabs by default #420
Comments
For a new package, if editorconfig is present, I’d expect that to be read - separately, I’d expect an npm config value i can set to tell npm i always want tabs for indentation. |
Adding new |
Parsing editor config files might be tricky, since there are a lot of editors out here, but maybe that's worth exploring as a default. If we make it a config value, you could just put it in a project |
I believe simply not expanding tabs by default should be sufficient. Then whoever wants customisation could further expand them to something else anyways. That's precisely what tabs are intended for. The trick is, until you have them, you can treat them however you like, but when they're pre-expanded already, it takes extra effort to undo that. |
isn't It would be awesome if the default was always tabs instead of spaces, but I assume that would be much too disruptive a change (and would invite way too much bikeshedding). |
Personally, I think I'm aware that any kind of "spaces vs tabs" discussion is usually shied away, because for many developers it doesn't really matter. The problem with that is, it does matter for some developers, and then the benefit of unexpanded tabs becomes clear. |
In case anyone is wondering, the only reason that npm has always used 2-space indentation for json files is that npm uses 2-space indentation for code internally. The only reason why npm has always used 2-space indentation for code is because Node.js did. The reason why node did is that 2-space indentation was the standard in the ruby community and in V8, and Ryan Dahl was a rubyist and C++ dev before ever touching JavaScript. So, while I 100% agree with all of the reasons why tabs are objectively superior, and used tabs in all my code prior to 2009 for all these extremely rational reasons, it just wasn't worth having that fight while in the minority on this issue. At this point, changing the default is potentially pretty disruptive, so we'd have to be prepared to withstand a lot of noise about it. |
Thanks for the clarification. Even though I fail to see how this change would disrupt any workflow, I agree that it would be impossible to predict that, e.g. someone might be doing some custom post-processing of the generated That being said, I hope we don't sacrifice the greater good for the sake of how things got the way they currently are. I'd say that if this change is properly announced in an upcoming version, it should roll out just fine. |
I think it would be fine if we had It's tempting to say that someone preferring spaces over tabs is irrational, ignorant/insensitive to accessibility concerns, etc. But I've found most people have their reasons, and it's best not to rock the boat within a major version release line. |
It looks like a sound plan, in my opinion. And I agree, no need to judge the reasoning behind the current state to figure out ways of moving forward. |
Oh, one other thing on this:
Anyone making that assumption today is likely already dealing with a brittle and error-prone situation. npm defaults to 2-space indents, but it maintains whatever you have in package.json currently when it edits it. So, if you convert the package.json and package-lock.json to tabs in a project, that's another workaround you could use today (albeit less convenient than a config, of course). |
Yes, that's the trick I'm using today, I'm glad it works like that. For new files, I just need to run |
I put together an RRFC that I believe can supersede this one and wanted to confirm it covered the changes requested here: #423 (comment) It adds a few other config items and bikesheds the names a bit, but it should cover the cases of changing |
@diogoeichert Based on the latest discussion from the RFC meeting last week (#423 (comment)), I think we landed on a proposed solution that would work here. I'm going to close this issue but you can comment over there or reopen this if you have any issues with the new proposal. |
Motivation ("The Why")
Expanded tabs can be harmful to some developers and should be avoided. Currently, new packages created with
npm init
producepackage*.json
files with their tabs expanded to a couple spaces, which in turn won't respect editor configurations. This can be specially harmful to developers which rely on custom editor configurations. The whole motivation for this is having the concept of "safe defaults" in place for the broader community.Example
Generate the new files with their tabs intact instead.
How
Current Behaviour
Tabs expanded to a couple spaces:
Desired Behaviour
Intact tabs:
References
Please refer to this article if you're new to the subject: https://alexandersandberg.com/tabs-for-accessibility/
This issue was previously discussed here: npm/feedback#200
The text was updated successfully, but these errors were encountered: