-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Prettier v1.11.1 is mixing spaces and tabs for alignment #4199
Comments
As far as I know, it is on purpose. I think essentially the same discussion is currently going on in #4198. Since you mention ESLint … if that's your only issue the solution is easy. We recommend turning off all conflicting ESLint rules: https://prettier.io/docs/en/eslint.html#turn-off-eslint-s-formatting-rules |
@lydell I know that it's possible to disable ESLint formatting rules, but mixed spaces and tabs just don't look very good (for me). I've heard:
But maybe it should be optional. Because for me 2 tabs look more readable than 1 tab and 2 spaces. Even if it's not aligned. In #4198 the main discussion is about nested tabs. |
Pro-tip: Actually say so from the beginning then! Thanks :) |
@kiruh How does this indentation look to you (let's pretend that those spaces are tabs)? const store = useLoggerAndDevTools
? createStore(
reducer,
logRedux
? compose(applyMiddleware(createLogger(), thunk))
: compose(applyMiddleware(thunk))
)
: createStore(reducer, applyMiddleware(thunk)); |
@thorn0 It looks good. |
You have to change the eslint rule so it support smart-tabs: |
Even better: |
|
Sorry; thanks for the clarification. I don't have a horse in this race since I don't use tabs. I'll let those with informed opinions discuss this. |
I don't care either about the default. But I expect |
@teameh Please open an issue in eslint-config-prettier if there’s something it could do better :) |
@teameh Prettier’s use of mixed spaces and tabs is not configurable. |
@j-f1 Should it become configurable in future? |
@kiruh Not unless there’s lots of support — see our option philosophy. |
I wonder if there exists a tab user who would oppose to a spaceless formatting like this:
If there is no any, what is needed here is not configurability then. |
This is most definitely an issue. Why would you want to ever mix spaces and tabs? It just doesn't feel right. |
@jankalfus Sorry that's an issue. Unfortunately saying it "doesn't feel right" adds nothing to the discussion. And the "why" has already been discussed above. If you want to help, we'll take suggestions on how to improve this (no options), with real code examples. Or PRs. @thorn0 Are you interested in opening a PR with your suggestion? |
@duailibe Sorry for not being specific. I guess my question would be: Why has this even been introduced? What is the reasoning behind it? I simply don't understand why someone would want to mix tabs and spaces. Generally, if spaces are used, then it's because it is required that the code looks the same on all people's monitors. If tabs are used, then everybody can use whatever tab size they prefer. If I change tab size on my machine, the code will look broken with mixed spaces. |
@jankalfus Because prettier aligns everything after cond
? {
foo
} // this is aligned with the opening bracket
: foo;
Again this is the kind of statement that adds nothing to discussion and doesn't help getting your problem fixed. This is not a support center. We'll take suggestions but we don't need complaints. |
@duailibe I gave you an explanation. Taking a single sentence out of context doesn't make the rest of my post irrelevant. |
The question is, tabs-only is not aligned, which is why someone raised #2771. const store = useLoggerAndDevTools
? createStore(
reducer,
logRedux
? compose(applyMiddleware(createLogger(), thunk))
: compose(applyMiddleware(thunk))
) // <------------
: createStore(reducer, applyMiddleware(thunk));
What do you mean |
Scratch everything I said. You're right, it doesn't get broken with mixed tabs and spaces, I just realized it. Sorry! |
I'm going to close this as intended behavior. The arguments against doing this seem to be based on personal preference. However, if someone has a bad experience in their editor because of this and can explain why, I would be open to reconsidering. |
Prettier 1.11.1
Playground link
# Options --use-tabs --tab-width 4
Input:
Output:
Expected behaviour (as it were in v1.10.2):
v1.11.1 is mixing tabs and spaces as shown in output. ESLint is throwing an exception no-mixed-spaces-and-tabs.
Is it a bug? If not maybe there should be an option for mixing spaces and tabs for alignment.
The text was updated successfully, but these errors were encountered: