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.

Key-spacing alignment problem.

See original GitHub issue

I really like intelliJ Idea style object alignment. But I didn’t create a linting rule for desired alignment style. For instance the following snippet is properly formatted in My IDE.

let items = {
  item115: {
    id      : 100,
    name    : 'item1',
    itemList: [1, 2, 3]
  },
  item2  : {
    id      : 101,
    name    : 'item2',
    itemList: [1, 2, 3]
  }
};

My key-spacing rule is:

{
  "key-spacing"    : [
    "error",
    {
      "singleLine": {
        "beforeColon": false,
        "afterColon" : true
      },
      "multiLine" : {
        "beforeColon": true,
        "afterColon" : true,
        "align"      : "colon"
      }
    }
  ]
}

IMHO multiLine beforeColon option should be three stated. true, false and off. Is there a way to properly linting above code snippet?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
btmillscommented, Nov 29, 2016

@firatkucuk thanks, let’s see if we can get support from the team to accept this so you can start working.


To the team: We had an accepted proposal in #2668 that would support IntelliJ-style alignment in key-spacing, but the issue was closed when nobody was interested in working on it. @firatkucuk has volunteered to work on a PR, so I’ll copy the proposal here and see what you all think.

A new option "grouping" which has two possible values:

  • "multi-line" (default): Values spanning multiple lines end their group
  • "empty-line": Blank lines (no comments, no code, just whitespace) create new groups

I do think we should support IntelliJ-style alignment, so I’ll champion.

0reactions
nzakascommented, Sep 21, 2018

Unfortunately, it looks like there wasn’t enough interest from the team or community to implement this change. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to be implemented after 90 days tend to never be implemented, and as such, we close those issues. This doesn’t mean the idea isn’t interesting or useful, just that it’s not something the team can commit to.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"key-spacing" tab alignment · Issue #12432 · eslint ... - GitHub
This revisits issues #1727 and #9523. What rule do you want to change? key-spacing Does this change cause the rule to produce more...
Read more >
Key-spacing - ESLint - W3cubDocs
This rule enforces spacing around the colon in object literal properties. It can verify each property individually, or it can ensure horizontal alignment...
Read more >
ESLint always throwing key-spacing error - vue.js
in a multi-line assignment, the colons line up horizontally, and there is a space both before and after each colon. the strange thing...
Read more >
How can I correct wrong key spacing of an accoustic piano?
You align the keys by spacing the front rail and balance rail pins, but before you do that, you have to know WHY...
Read more >
Issue with the alignment of the array - LaTeX Stack Exchange
I am having the issue with the alignment of an array. Please, find the below code: \documentclass[12 pt, a4paper]{book} ...
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