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.

keyword-spacing else ghost default

See original GitHub issue

Tell us about your environment

  • ESLint Version: 6.5.1
  • Node Version: 10.16.3
  • npm Version: 6.9.0

What parser (default, Babel-ESLint, etc.) are you using? default Please show your full configuration:

Configuration
rules: {
  keyword-spacing: ["error", {
    before: false,
    after: true,
    overrides: {
      else: {after: false},
      if: {after: false}
    }
  }],
}

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

if(false) {
  console.info("will not log");
}else{
  console.info("will log");
}
eslint index.js

What did you expect to happen? before: false should set it so every keyword requires no spacing before it, as no overrides set it to true.

What actually happened? Please include the actual, raw output from ESLint.

/path/to/my/file/index.js
  3:2  error  Expected space(s) before "else"  keyword-spacing

Although the before property appears to work on every other keyword added to the overrides I’ve tried (if, for example, works fine using the above config), else for some reason sets it to true. Explicitly setting before: false in the else override appears to be a temporary solution to this bug.

Are you willing to submit a pull request to fix this bug? I am unsure of how it would be fixed, but I would be willing to submit a PR if I did.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
tickctcommented, Oct 7, 2019

I will take a look

1reaction
mdjermanoviccommented, Oct 17, 2019

Tested the original example in:

eslint@5.13 - no error eslint@5.14 - error

Seems that #11288 changed behavior here, but tests didn’t catch that.

I think that proposed change in PR #12411 is correct, and it would be also good to add tests to show that overrides can override just "before" or just "after" or both. Maybe also improve the docs.

The problem might be that this change can now produce more warnings in some cases.

Read more comments on GitHub >

github_iconTop Results From Across the Web

keyword-spacing - ESLint - Pluggable JavaScript Linter
"before": true (default) requires at least one space before keywords; "before": false disallows spaces before keywords; "after": true (default) requires at ...
Read more >
Ghost and SEO: Everything You Need to Know - Epilocal
One thing that Ghost does particularly well by default, is SEO, or Search Engine Optimization. For those not familiar, SEO is all about ......
Read more >
keyword-spacing - Rules - ESLint中文文档
"before": true (default) requires at least one space before keywords · "before": false disallows spaces before keywords · "after": true (default) requires at ......
Read more >
ghost-storage-cloudinary - UNPKG
The CDN for ghost-storage-cloudinary. ... 26, "default-case": 2,. 27, "dot-location": 2,. 28, "dot-notation": 2, ... 49, "keyword-spacing": 2,.
Read more >
7. The WhyML Language Reference - Why3
Blank characters are space, horizontal tab, carriage return, and line feed. ... Keyword ghost marks the expression as ghost code added for verification ......
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