Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to allow multiple spaces between colon and value

Globally I'd like to force {key: value} except in a few places where the following will be valid:

schema = {
    id:          Joi.string(),
    title:       Joi.string(),
    description: Joi.string(),
    start:       Joi.date().iso(),
    end:         Joi.date().iso(),
    creator:     Joi.object(),
    archived:    Joi.boolean(),
    _actions:    Joi.array()
};

Looking through the docs (http://eslint.org/docs/rules/key-spacing.html) I can't see if there's a combination of align and beforeColon, afterColon that works.

My config file rule is:

"key-spacing": [2, {"beforeColon": false, "afterColon": true}]

I've trying to override it for a given file with:

/* eslint key-spacing: ????? */

Is this rule possible?

like image 358
Adrian Lynch Avatar asked Jan 23 '26 18:01

Adrian Lynch


1 Answers

Set the mode option to minimum to require one or more spaces:

"key-spacing": [2, {"beforeColon": false, "afterColon": true, "mode": "minimum"}]
like image 101
Tamlyn Avatar answered Jan 26 '26 09:01

Tamlyn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!