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.

Intendation for const variables

See original GitHub issue

It’s likely that this issued has already raised in the repo, but I could not find it 😞

My proposal is to change aligning of const variables declaration.

Current view:

const locomotive = require('locomotive'),
  Controller = locomotive.Controller;

Desired:

const locomotive = require('locomotive'),
      Controller = locomotive.Controller,

Issue Analytics

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

github_iconTop GitHub Comments

6reactions
vjeuxcommented, Mar 3, 2017

You are the first to have raised it.

Some thoughts:

  • Nowhere in prettier do we indent by an arbitrary amount of spaces to match the indentation of a keyword. So this would be an exception and may be seen as inconsistent.

  • If you have series of const and let, it would look very odd having the indentation be off.

const locomotive = require('locomotive'),
      Controller = locomotive.Controller;
let locomotive = require('locomotive'),
    Controller = locomotive.Controller;

My suggestion is for you to add a const before each line, this way they all look nicely aligned:

const locomotive = require('locomotive');
const Controller = locomotive.Controller;
3reactions
lydellcommented, Mar 6, 2017

I use one const (or let or var) per variable. Makes it easier to move the declarations around.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How should we indent `const` declarations?
I'm a huge fan of the additions to JavaScript of let and const to declare block-scoped variables. In particular, I love const for...
Read more >
How to align const indent in ESLint? - javascript - Stack Overflow
If I set the rule to: "indent": ["error", 4, {"VariableDeclarator": {"const": 1}}], The correct align will be 4 spaces: const cc = 3,...
Read more >
C Style Guide
C Style Guidelines · Meaningful names for variables, constants and functions. · Good indentation (3 or 4 spaces). · If variables have the...
Read more >
2022-03-14 Proper indentation after a const in Emacs
When using const to declare variables, and the declaration not fitting in one line, the indentation of the next line was broken like...
Read more >
Declarations (indent: Indent and Format C Program Source)
By default indent will line up identifiers, in the column specified by the ... The value given to the -di option will still...
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