Open gabrielmaldi opened 9 years ago
Every time I think I've seen it all...
I see the logic of your formatting, but getting that behavior is harder than you might think.
It's an interaction of #200 and #286 - we take out indents where they look redundant, but that led to under indenting of the conditional expressions inside if()
in some cases. We fixed that, and by that logic the existing behavior makes sense. You're inside the conditional for the if
, everything in there should be indented.
I'm open to discussing, but this seems like a low priority issue at best.
I understand the complexity and that fixing this could cause other subtle issues. I say we wait and see if more people vote for this and maybe it becomes worth addressing.
Thanks
Late to comment but I really wish I could combine how we beautify the code and the rules in eslints "indent" rule.
Beautified:
var Count = function () {
return new Promise(function (resolve, reject) {
Client.count({
index: 'something',
type: 'data',
body: {}
})
.then(resolve, reject);
});
};
It will fail on the object being called in the function. So either I declare the object outside the function or I put .count on a new line to code around the linting.
As another option jsfiddle does the following:
var Count = function () {
return new Promise(function (resolve, reject) {
Client.count({
index: 'something',
type: 'data',
body: {}
})
.then(resolve, reject);
});
};
I have a problem that I'm wondering if it's related to this.
Is there a way that I can get rid of the extra indentation in the Output section below?
Input/Expected (only one indentation before method
, and no indentation before })
(which seem to conflict with ESLint's "indent": ["error", 2]
)):
fetch('https://example.com', {
method: 'POST'
})
.then(() => {})
Actual output:
fetch('https://example.com', {
method: 'POST'
})
.then(() => {})
.jsbeautify
:
{}
I have also tried with "unindent-chained-methods": true
.
The version of js-beautify 1.10.2.
Thank you!
There is an issue for my comment above in #1651.
Beautifying the following chunk of code (which to me it is already beautified the right way):
Produces:
Is this behavior by design or is it something that can be improved?
Thanks!