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.

New option in "object-curly-spacing" for empty objects

See original GitHub issue

Tell us about your environment

  • ESLint Version: v3.8.0
  • Node Version: v6.7.0
  • npm Version: v3.10.7

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

Default

Please show your full configuration:

{
  "rules": {
    "object-curly-spacing": ["error", "never"]
  }
}

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

var a = { }

What did you expect to happen?

I expected that the rules should complain about the stray space between the curly braces { }

I also think it would be a good idea to add a separate config for empty objects, since I think that people who have this rule set to “always” still doesn’t want any whitespace inside empty objects.

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

No error was raised.

(Note: Re-opening https://github.com/eslint/eslint/issues/7380 for discussion, as suggested)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:16 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
not-an-aardvarkcommented, Oct 15, 2018

I’m going to go ahead and mark this as “evaluating” again – the accepted label was originally added when this was considered a bug, but now it seems to be proposing a new option.

1reaction
pmcelhaneycommented, Sep 6, 2017

I don’t care about the difference between { } and {} but I work with someone who refuses to let it go and continues to clog up pull requests with bike shed comments.

I’m going to work on a PR to make the treatment of empty objects an option.

  • spaceInEmptyObject: "always": Require a space inside of an empty object literal ({ } is valid)
  • spaceInEmptyObject: "never": Disallow a space inside of an empty object literal ({} is valid)

If spaceInEmptyObject is not specified, either { } or {} is allowed.

If you don’t hear from me within the next week, assume that I got too busy and gave up on the idea.

Read more comments on GitHub >

github_iconTop Results From Across the Web

object-curly-spacing - ESLint - Pluggable JavaScript Linter
This rule enforces consistent spacing inside braces of object literals, destructuring assignments, and import/export specifiers. Options. This rule has two ...
Read more >
object-curly-spacing | typescript-eslint
Enforce consistent spacing inside braces. ... This rule extends the base eslint/object-curly-spacing rule. It adds support for TypeScript's object types.
Read more >
vue/object-curly-spacing
vue/object-curly-spacing #. Enforce consistent spacing inside braces in <template>. The --fix option on the command line can automatically ...
Read more >
Eslint adds unnecessary space between braces, Prettier ...
How can I solve this? EDIT: I want to keep the destructuring assignment space (eg ({ variable }) ) but not on empty...
Read more >
Object Curly Spacing - Unibeautify
Object Curly Spacing ; Config Key: object_curly_spacing ; Description: Inserts a space before/after brackets for object literals, destructuring assignments, and ...
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