Skip to content
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

Enable code folding in most IDEs/Editors by placing else { on a newline. #1143

Closed
nyteshade opened this issue May 31, 2018 · 2 comments

Comments

@nyteshade
Copy link

commented May 31, 2018

What version of standard?
11.0.1

What operating system, Node.js, and npm version?
Node.js (v8.11.2), npm (6.1.0)

What did you expect to happen?
Given

// code snippet
if (true) {
  console.log('something');
}
else {
  console.log('something else')
}

What actually happened?
We get

// code snippet
if (true) {
  console.log("something");
} else {
  console.log("something else");
}

The reason behind requesting this is that in many IDEs and editors, code folding is allowed. Fundamentally I am not really at odds with the way standardjs formats things like } else { other than that it prevents nearly every editor and IDE out there from successfully folding the if and not the else.

If else { starts on its own line, this problem goes away. For my team, given how we document our code, this is crucial and should be allowed. It is one of the only reasons, we are not currently able to use standardjs to solve our needs.

@LinusU

This comment has been minimized.

Copy link
Member

commented May 31, 2018

screen shot 2018-05-31 at 10 39 57

Works in VS Code, which editor are you using?

Having } else { on the same line is, as far as I know, the most popular choice in JavaScript. Seems like maybe this is a bug in your editor...

Either way, changing this would make 100% of all current code using Standard fail so the chances of us changing this are super slim. In every major version of Standard we take great care to only introduce rules that breaks a small percent of the current code, otherwise the burden of keeping up with new Standard releases would be too high.

Also, on a very personal note, I really don't like the proposed style at all 😆

I'll leave this open for some of the other maintainers to weigh in, but I'm afraid I don't see this happening...

@stale

This comment has been minimized.

Copy link

commented Aug 29, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale label Aug 29, 2018

@stale stale bot closed this Sep 5, 2018

@lock lock bot locked as resolved and limited conversation to collaborators Dec 4, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
2 participants
You can’t perform that action at this time.