question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

brace-style "allowSingleLine" should differentiate between if/else and function statements.

See original GitHub issue

What version of ESLint are you using?

v2.2.0

What parser (default, Babel-ESLint, etc.) are you using?

Default.

Please show your full configuration:

"brace-style": [2, "1tbs", { "allowSingleLine": true }]

What did you do? Please include the actual source code causing the issue.

I have two snippets that eslint is (correctly) reporting. However, I’d like to disable half of the violations.

good, please continue flagging as an error

if (foo) { doFoo(); } else { doOther(); }

please allow me to disable errors for these statements

var o = { action: function () { doSomething(); } };

What did you expect to happen?

I expected "allowSingleLine" to accept an object to expose more granularity in my config.

"brace-style": [2, "1tbs", { "allowSingleLine": { "ifStatements": false, "functions": true } }]

What actually happened? Please include the actual, raw output from ESLint.

I’m seeing the usual errors being reported. Nothing out of the ordinary.

error  Statement inside of curly braces should be on next line   brace-style

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
albertocommented, Aug 1, 2016

Thanks for your interest in improving eslint. Unfortunately, it looks like consensus couldn’t be reached on this issue and so I’m closing it. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to reach consensus after 21 days tend never to reach consensus, and as such, we close those issues. This doesn’t mean the idea isn’t interesting, just that it’s not something the team can commit to.

As a reminder, you can still create a custom rule for your use use.

0reactions
Drooganscommented, Mar 16, 2016

Would // eslint-disable-line brace-style work on a case-by-case basis?

I’d much rather revert all one-liner functions to multi-line to avoid that issue entirely. I would go mad trying to keep an entire team’s worth of contributions using both single line functions and this comment above them all!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Are methods and if/else statements functions? - Codecademy
I know this does not explain much, but it does show the more obvious differences. With exception of object literals, which use curly...
Read more >
brace-style - ESLint - Pluggable JavaScript Linter
Brace style is closely related to indent style in programming and describes the placement of braces relative to their control statement and body....
Read more >
demo-outil-edition - node_modules - eslint - CHANGELOG.md
39dfe08 Update: false positives in function-call-argument-newline (fixes ... 6cb63fd Update: Add iife to padding-line-between-statements ...
Read more >
Are braces necessary in one-line statements in JavaScript?
No. But they are recommended. If you ever expand the statement you will need them. This is perfectly valid if (cond) alert("Condition met!...
Read more >
Difference Between if else and Switch - Scaler Topics
The else statement can either be a single statement, or it can even be a block of statements. Syntax of if-else statement. if...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found