I want to override the rule @typescript/type-annotation-spacing
which determines how many spaces to put before and after :
in type annotations.
I would like to override it to have a space before and after :
, but the default it to just have one after.
The documentation describes several options for this rule, but it does not give any example of the full syntax for overriding this in the eslintrc.*
file.
This rule has an object option:
"before": false, (default for colon) disallows spaces before the colon/arrow.
"before": true, (default for arrow) requires a space before the colon/arrow.
"after": true, (default) requires a space after the colon/arrow.
"after": false, disallows spaces after the colon/arrow.
"overrides", overrides the default options for type annotations with colon (e.g. const foo: string) and function types with arrow (e.g. type Foo = () => {}).
I tried adding this to my eslintrc
file
"rules": {
"@typescript-eslint/type-annotation-spacing": {
before: true,
after: true,
severity: "warn"
}
}
but then I get this error:
Configuration for rule "@typescript-eslint/type-annotation-spacing" is invalid:
Severity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '{ before: true, after: true, severity: "warn" }').
I tried several other variations, but they all result in a similar error.
What is the correct syntax for this?