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
[indent] Ternary doesn't allow extended indentation #7698
Comments
@not-an-aardvark does your #7618 fix this too? |
No, I think this is (mostly) working as intended. The correct output would be:
For what it's worth, I think this is a duplicate of #6606. |
To elaborate a bit more on why I think reporting an error here is correct behavior: const foo = Math.random()
? {
a: 3,
}
: {}; The question mark is indented at two spaces, but the To make this easier to see, suppose you decided to change your indent size to 4 spaces instead of 2: const foo = Math.random()
? {
a: 3,
}
: {}; In this case the closing |
I agree this is duplicate of #6606. We use this style pretty consistently, including with JSX and other expressions, where lint doesn't error: // works
const foo = Math.random()
? <div
id="test",
/>
: null;
// works
const foo = Math.random()
? parseInt(
"42",
16,
)
: 0; I see that this doesn't work as well when the indentation isn't two spaces and don't really have an answer for that, as I personally don't have experience with JS using different config. Perhaps if this was a configuration flag, it would only be used by people who have indent set to 2. |
Could you consider the following for 4 space indentation? const foo = Math.random()
? {
a: 3,
}
: {}; Or is that too far off? |
Closing because this is working as intended. |
Tell us about your environment
whatever is on the DEMO on eslint.org, unfortunately it doesn't show
n/a
m/a
dunno, environments is set to
node
,es6
Please show your full configuration:
indent
is onWhat did you do? Please include the actual source code causing the issue.
What did you expect to happen?
No warning.
What actually happened? Please include the actual, raw output from ESLint.
4:5 - Expected indentation of 2 spaces but found 4. (indent)
The text was updated successfully, but these errors were encountered: