Typescript-eslint: [key-spacing] key-spacing of interfaces and other TS-specific key-value pairs

Created on 3 Sep 2019  路  3Comments  路  Source: typescript-eslint/typescript-eslint

Repro

{
  "rules": {
    "key-spacing": ["error", { "align": "value" }]
  }
}
interface Foo {
  foo: string;
  barBazQuux: string;
}

Expected Result

Should be highlighted as an error and auto fixed into:

interface Foo {
  foo:        string;
  barBazQuux: string;
}

Actual Result

ESLint ignores interfaces.

Additional Info

Time for @typescript-eslint/key-spacing?

Versions

| package | version |
| ---------------------------------- | ------- |
| @typescript-eslint/eslint-plugin | 2.0.0 |
| @typescript-eslint/parser | 2.0.0 |
| TypeScript | 3.6.2 |
| ESLint | 5.16.0 |
| node | 12.9.0 |
| yarn | 1.17.3 |

new base rule extension good first issue eslint-plugin

Most helpful comment

key-spacing for enums would be great option too.

All 3 comments

Is that the desired result that we want - the key-spacing rule specifically states "object literal properties".

In vanilla JS, do you do the same thing with classes?

In TS would you want the same functionality with enums? object type literals?

I want to be able to auto-align every key-value pair, similar to what ESLint's key-spacing does.

Properly aligned code is easier to navigate with eyes.

key-spacing for enums would be great option too.

Was this page helpful?
0 / 5 - 0 ratings