New option in "object-curly-spacing" for empty objects
See original GitHub issueTell 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:
- Created 7 years ago
- Reactions:1
- Comments:16 (16 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.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.