Rule enhancement: More granular control in space-unary-ops
See original GitHub issueCurrent state
This rule allows us to configure whether we expect spaces between unary operators for either word operators (delete
, void
, typeof
etc.) and non-word (+
, -
, ++
, !
, etc.).
Problem
Some might prefer different spacing rules for individual non-word operators. For me personally, I prefer to have the negation operator !
always separated from its operand, but I never separate ++
or --
from its operand.
Proposal
Extend the rule’s configuration so that we can configure the spacing rules for individual operators. One example might be to add an object as third argument where the object’s key would be the operator and the key’s value would be the rule to apply:
{
'space-unary-ops': [1, {
words: false,
nonwords: false,
'!': true // Overrides spacing rule for ! to always have space
}]
}
The configuration scheme above is just an idea. The goal is to allow more fine-grained control over where the spaces are expected and where they are not.
Thanks!
<bountysource-plugin>
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:14 (10 by maintainers)
Thanks to everyone who worked on this! Great work!
Hello, what if, we want to enforce usage:
instead of
my config
Second case should end up with error. At least that is what I expected. Thank you.