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 rules: Disallow or enforce spaces inside of curly braces and brackets (object-curly-spacing and array-bracket-spacing)

See original GitHub issue

http://eslint.org/docs/rules/object-curly-spacing

http://eslint.org/docs/rules/array-bracket-spacing

Standard JS should define if there should be spaces inside of brackets and curly braces or not.

By now, following code is allowed but looks awkward:

import { foo } from 'bar';
import {foo} from 'bar';
let a = [1, 2]
let a = [ 1, 2 ]
var obj = {foo: 'bar'};
var obj = { foo: 'bar' };

Personally I have no preference if there should be spaces or not.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:22
  • Comments:19 (8 by maintainers)

github_iconTop GitHub Comments

8reactions
capajcommented, May 4, 2017

I personally prefer without spaces. The reason is saving editor space-the line has only 80 characters and even two spaces can make a difference whether the line is overflowing or not.

Many people would argue that it’s more apparent when the braces are spaced-to those I would say-configure your editor to highlight them. Here’s my editor:

image

I use a plugin https://marketplace.visualstudio.com/items?itemName=2gua.rainbow-brackets to make them more apparent and that works out better than trying to use spaces.

6reactions
langri-shacommented, May 6, 2017

🗒 There’s already a ban on spaces within curly braces inside of template strings.

Read more comments on GitHub >

github_iconTop Results From Across the Web

object-curly-spacing - ESLint - Pluggable JavaScript Linter
Rule Details. This rule enforces consistent spacing inside braces of object literals, destructuring assignments, and import/export specifiers.
Read more >
jsonc/array-bracket-spacing | eslint-plugin-jsonc
disallow or enforce spaces inside of brackets. ... This rule enforces consistent spacing inside array brackets.
Read more >
object-curly-spacing | typescript-eslint
See What About Formatting? for more information. Enforce consistent spacing inside braces.. Some problems reported by this rule are automatically fixable by ...
Read more >
tslint-eslint-rules - npm Package Health Analysis | Snyk
Learn more about tslint-eslint-rules: package health score, popularity, ... array-bracket-spacing, enforce consistent spacing inside array brackets.
Read more >
Available rules - eslint-plugin-vue
Rule ID Description vue/multi‑word‑component‑names require component names to be always multi‑word... vue/no‑arrow‑functions‑in‑watch disallow using arrow functions to define watcher... vue/no‑computed‑properties‑in‑data disallow accessing computed properties in data...
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