Unless I'm missing something, there is no way to enforce whitespace after a property key in an object literal:
const b = {
a : 1, // bad
b: 2 // good
};
I think this is covered in ESLint by key-spacing
This would be best as an enhancement to the whitespace rule. We should probably update that rule to mirror how typedef-whitespace works since #971.
Looking forward
This is pretty old, and a strange feature since we already have a rule disallowing trailing whitespace. Going to close, feel free to re-open/make a new issue if you disagree.
@johnwiseheart, how can the rule requested by @jamiewinder be enforced with currently available rules?
@adanski @jamiewinder Looks like this cannot be done by the built-in rules alone. whitespace.check-type checks only for space after colon, and typedef-whitespace, although more configurable, works only for type definitions.
So I wrote whitespace-before-colon rule which complements those rules, and which checks spaces before colons in object literals and destructuring assignments.
This would be best as an enhancement to the
whitespacerule. We should probably update that rule to mirror howtypedef-whitespaceworks since #971.
I'd like to have this feature. @xemlock's solution was declined, but any progress on @adidahiya's proposed solution?
@NoBrainer See #4534, at this point basically all formatting-related features/enhancements will be declined.
Most helpful comment
@johnwiseheart, how can the rule requested by @jamiewinder be enforced with currently available rules?