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

"brace-style": "1tbs" should warn for brace-less else expression on wrong line #4591

Closed
andy-hanson opened this issue Dec 2, 2015 · 2 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion

Comments

@andy-hanson
Copy link

This is the code I'm linting:

// This correctly warns.
if (true) {
    console.log(1)
    console.log(2)
}
else {
    console.log(3)
}

// This does not warn.
if (true) {
    console.log(1)
    console.log(2)
}
else
    console.log(3)

And here's my package.json:

{
    "scripts": {
        "lint": "eslint src test"
    },
    "devDependencies": {
        "eslint": "1.10.3"
    },
    "eslintConfig": {
        "rules": {
            "brace-style": 1
        }
    }
}

I get the following output:

/home/andy/git/ESLINT/src/foo.js
  6:6  warning  Closing curly brace does not appear on the same line as the subsequent block  brace-style

✖ 1 problem (0 errors, 1 warning)

It makes sense to me that the following style should be preferred for consistency with 1tbs:

if (true) {
    console.log(1)
    console.log(2)
} else
    console.log(3)
@nzakas
Copy link
Member

nzakas commented Dec 2, 2015

This rule does not enforce the use of braces. Use curly for that: http://eslint.org/docs/rules/curly.html

@nzakas nzakas closed this as completed Dec 2, 2015
@andy-hanson
Copy link
Author

The final sample in the issue is what I want code to look like. I don't want to enforce the use of braces. When there are braces, I want the closing curly brace to appear on the same line as the subsequent statement.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 7, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion
Projects
None yet
Development

No branches or pull requests

2 participants