This is my current eslint config. I am currently using the latest version of ESLint. I would like to be able to use these two rules in combination but they conflict. I also tried to write a custom rule but this also did not work.
// eslint.config.js
import parserTs from '@typescript-eslint/parser'
import stylistic from '@stylistic/eslint-plugin'
export default [
{
files: ["**/*.ts"],
plugins: {
'@stylistic': stylistic
},
languageOptions: {
parser: parserTs
},
rules: {
'@stylistic/type-annotation-spacing': ['error', {
"before": true,
"after": true
}],
'@stylistic/key-spacing': ['error', {
"beforeColon": false,
"afterColon": true,
"mode": "strict"
}]
}
}
];
How can I use key-spacing
only for keys/values and not for types?
As an example, this is how I want my code to be formatted:
const foo : string = 'Hello World!'
// ^ 1 Spaces
// ^ 1 Spaces
const bar = {
key: 'value'
// ^ 1 Space
// ^ No space
}