New rules: Disallow or enforce spaces inside of curly braces and brackets (object-curly-spacing and array-bracket-spacing)
See original GitHub issuehttp://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:
- Created 7 years ago
- Reactions:22
- Comments:19 (8 by maintainers)
Top 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 >
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 Free
Top 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
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:
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.
🗒 There’s already a ban on spaces within curly braces inside of template strings.