keyword-spacing else ghost default
See original GitHub issueTell 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:
- Created 4 years ago
- Comments:7 (6 by maintainers)
Top GitHub Comments
I will take a look
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.