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.

curly multi-or-nest incorrect example with a comment

See original GitHub issue

Tell us about your environment

  • ESLint Version: v7.0.0-alpha.1
  • Node Version: v12.14.0
  • npm Version: v6.13.4

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

Please show your full configuration:

Configuration
module.exports = {
    parserOptions: {
        ecmaVersion: 2015,
    },
};

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

Online Demo (v6.8.0)

/*eslint curly: ["error", "multi-or-nest"]*/

if (foo)
    // some comment
    bar();
eslint index.js

What did you expect to happen?

In curly multi-or-nest documentation this is one of the examples of incorrect code (the last one).

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

no errors.

Are you willing to submit a pull request to fix this bug?

I’m not sure should this be fixed in the rule or in the docs. This may be a bug, but I have concerns about the impact if we change the behavior now.

Relevant issue/PRs: #7538, #7539, #7597.

The intention was to allow this:

/*eslint curly: ["error", "multi-or-nest"]*/

if (foo) {
    // some comment
    bar();
}

but I can’t tell from the relevant discussions whether the intention was also to disallow the code that was added to the incorrect examples.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mdjermanoviccommented, Apr 6, 2020

PR #13151 updates the docs to match the actual behavior.

I’d vote to leave the rule as is. This could be unintended behavior, but fixing it looks like a big change for users now.

0reactions
eslint-deprecated[bot]commented, May 8, 2020

Unfortunately, it looks like there wasn’t enough interest from the team or community to implement this change. 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 accepted status after 21 days tend to never be accepted, and as such, we close those issues. This doesn’t mean the idea isn’t interesting or useful, just that it’s not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

Read more comments on GitHub >

github_iconTop Results From Across the Web

curly: "multi-or-nest" option. · Issue #1806 · eslint/eslint - GitHub
I've long been a fan of the (seemingly unpopular) curly style that allows omitting the braces for a single statement. However, I like...
Read more >
curly - ESLint - Pluggable JavaScript Linter
JavaScript allows the omission of curly braces when a block contains only one statement. ... Examples of incorrect code for the "multi-or-nest" option:....
Read more >
What does ${} (dollar sign and curly braces) mean in a string ...
Functionally, it looks like it allows you to nest a variable inside a string without doing concatenation using the + operator. I'm looking...
Read more >
BUG? Unable to nest multi-line mata command within false if ...
I have a program where a multi-line mata command appears inside an if condition. When the condition evaluates to false I get an...
Read more >
Why do most programming languages not nest block ...
It might be a bad idea to comment out code, but that is not the reason comments don't nest in C-derived languages. The...
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