[keyword-spacing] override this before: false with greater than #14712
Labels
accepted
There is consensus among the team that this change meets the criteria for inclusion
archived due to age
This issue has been archived; please open a new issue for any further discussion
bug
ESLint is working incorrectly
repro:yes
rule
Relates to ESLint's core rules
Projects
Tell us about your environment
What parser (default,
@babel/eslint-parser
,@typescript-eslint/parser
, etc.) are you using?@typescript-eslint/parser
but also tested with only using eslint and the problem still exists.
Please show your full configuration:
Configuration
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
Here is a demo showing the problem:
https://eslint.org/demo#eyJ0ZXh0IjoiLyogZXNsaW50IGtleXdvcmQtc3BhY2luZzogWydlcnJvcicsIHtcbiAgICAgICAgICAgIFwib3ZlcnJpZGVzXCI6IHtcbiAgICAgICAgICAgICAgICBcInRoaXNcIjogeyBcImJlZm9yZVwiOiBmYWxzZSB9LFxuICAgICAgICAgICAgICAgIFwibmV3XCI6IHsgXCJiZWZvcmVcIjogZmFsc2UgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XSAqL1xuXG5pZiAodGhpcy5yZWZ1bmRBbW91bnQgPiB0aGlzLm1heGltdW1SZWZ1bmQpIHt9Iiwib3B0aW9ucyI6eyJwYXJzZXJPcHRpb25zIjp7ImVjbWFWZXJzaW9uIjoxMSwic291cmNlVHlwZSI6InNjcmlwdCIsImVjbWFGZWF0dXJlcyI6e319LCJydWxlcyI6e30sImVudiI6e319fQ==
(note that when you change the
>
into a<
the lint error goes away.I wasn't sure what to expect from this configuration of the rule. I had to set "this" and "new" to before: false, because I don't want a space between casting angle brackets
<Thing>this.blah
or<Thing>new Blah()
.And I was happy when it seemed to work in almost all cases. Obviously I'm using
this.blah
in thousands of places, very commonly with spaces in front, and almost all of them work. The only exception is the "greater than" symbol, used for comparisons. Less than (and everything else) seems to work fine.So given it only gives an error with the exact combination
> this
I feel like it's a bug.What did you expect to happen?
No errors
What actually happened? Please copy-paste the actual, raw output from ESLint.
283:41 error Unexpected space(s) before "this" @typescript-eslint/keyword-spacing
Steps to reproduce this issue:
The text was updated successfully, but these errors were encountered: