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.

Allow object-curly-newline to permit newlines around single property

See original GitHub issue

What rule do you want to change?

object-curly-newline: ["error", { "multiline": true }]

Does this change cause the rule to produce more or fewer warnings?

This change would optionally cause fewer warnings.

How will the change be implemented? (New option, new default behavior, etc.)?

New option, or new configuration added to an existing option.

Please provide some example code that this change will affect:

let a = {
    b: "c"
};

What does the rule currently do for this code?

Warns “Unexpected a line break after this open brace. (object-curly-newline)” on the first line and “Unexpected a line break before this close brace. (object-curly-newline)” on the last line.

What will the rule do after it’s changed?

Not warn when an object with a single property places that property on its own line.


As @platinumazure said on Gitter:

It seems like the option enforces two rules: No linebreaks around curlies if all properties are on the same line; and required linebreaks around curlies if all properties are not on the same line. Seems like you want just the second half of that.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
vitorbalcommented, Jun 6, 2017

Sorry @captbaritone @ivantcov, looks like i lost track of this!

@eslint/eslint-team this would be a backwards-compatible enhancement to object-curly-newline to allow newlines between curlies if there is only one property in the object literal. Here’s the proposed schema: https://github.com/eslint/eslint/issues/7609#issuecomment-261014672. Looks like @captbaritone would also be willing to implement this if it gets accepted. Anyone interested in giving some 👍 's?

0reactions
not-an-aardvarkcommented, Aug 14, 2017

Thanks for your interest in improving ESLint. Unfortunately, it looks like this issue didn’t get enough support from the team 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 a long time tend to never do it, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

object-curly-newline - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Curly braces to new line - Prettier - Stack Overflow
1 Answer 1 · Locate your . · Add the following line to the config files for both dotnet 5 and 6: ·...
Read more >
JS.BASE.OBJECT.PROPERTY.NEWLINE
This rule permits you to restrict the locations of property ... an object literal to have all parts of all of its property...
Read more >
Code Syntax Style: Braces for Single Nested Statements
C# specification allows you to safely omit braces around single nested statements ... formatting rules for braces layout (whitespaces, tabs, and new lines)....
Read more >
Airbnb JavaScript Style Guide()
They allow you to define all the properties of an object in one place. ... 4.7 Use line breaks after open and before...
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