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.

Option to disable key-spacing for singleLine

See original GitHub issue

What rule do you want to change?

key-spacing

Does this change cause the rule to produce more or fewer warnings?

Fewer.

How will the change be implemented? (New option, new default behavior, etc.)?

The singleLine and multiLine options would gain a new valid setting, "off" (or alternatively, false). e.g.

"key-spacing": ["error", {
    singleLine: "off",
    multiLine: {
        beforeColon: false,
        afterColon: true,
        mode: 'strict',
    }
}],

Please provide some example code that this change will affect:

This would disable the inspection for single-line objects:

// correct
<BlueBox className="cr-form" style={{minWidth:'500px'}}>

// correct
<BlueBox className="cr-form" style={{minWidth: '500px'}}>

While still enforcing spacing on multi-line objects such as:

// correct
call({
    foobar: 42,
    bat: 2 * 2
});

// incorrect
call({
    foobar:42,
    bat:2 * 2
});

What does the rule currently do for this code?

Prevents spaceless single-line objects from being valid.

What will the rule do after it’s changed?

Allow you to enable/disable singleLine and multiLine settings independently.


Alternatively, if we could specify that 0 or 1 space is allowed after the colon, that would also work even better than disabling it completely. You could implement this as mode: "loose".

Version: 3.7.1

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
btmillscommented, Oct 14, 2016

I like that “off” is explicit. I’ll give a 👍 for it. @mnpenner would you be willing to send a PR to implement this if it’s accepted?

0reactions
not-an-aardvarkcommented, Jan 19, 2018

Thanks for your interest in improving ESLint. Unfortunately, it looks like this issue didn’t get consensus from the team, so I’m closing it. We define consensus as having three 👍s from team members, as well as a team member willing to champion the proposal. This is a high bar by design – we can’t realistically accept and maintain every feature request in the long term, so we only accept feature requests which are useful enough that there is consensus among the team that they’re worth adding.

Since ESLint is pluggable and can load custom rules at runtime, the lack of consensus among the ESLint team doesn’t need to be a blocker for you using this in your project, if you’d find it useful. It just means that you would need to implement the rule yourself, rather than using a bundled rule that is packaged with ESLint.

Read more comments on GitHub >

github_iconTop Results From Across the Web

key-spacing - ESLint - Pluggable JavaScript Linter
Options. This rule has an object option: "beforeColon": false (default) | true ... "singleLine" specifies a spacing style for single-line object literals.
Read more >
key-spacing for one-liner object literals · Issue #4697 - GitHub
This rule will warn when spacing in single-line objects does not match the specified options for single-line objects.
Read more >
vue/singleline-html-element-content-newline
The --fix option on the command line can automatically fix some of the problems reported by this rule. Rule Details #. This rule...
Read more >
Change the line spacing in Word - Microsoft Support
Select one or more paragraphs to update. Press Ctrl + A to select all. · Go to Home > Line and Paragraph Spacing...
Read more >
require or disallow an empty line between class members ...
"never" disallows an empty line after class members. Object option: "exceptAfterSingleLine": false (default) do not skip checking empty lines after single-line ...
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