Skip to content

Latest commit

 

History

History
56 lines (40 loc) · 965 Bytes

align-enums.md

File metadata and controls

56 lines (40 loc) · 965 Bytes

alignment/align-enums

This rule is included in plugin:alignment/recommended preset.

🔧 The --fix option on the command line can automatically fix the problems reported by this rule.

Rule Details

Aligns the members of a TypeScript enum.

Examples of incorrect code:

/*eslint align-enums: "warn"*/

enum Direction {
  UP = "up",
  DOWN = "down",
  LEFT = "left",
  RIGHT = "right",
}

Examples of correct code:

/*eslint align-enums: "warn"*/

enum Direction {
  UP /*   */ = "up",
  DOWN /* */ = "down",
  LEFT /* */ = "left",
  RIGHT /**/ = "right",
}

Options

spacingCharacter

  • Type: string
  • Default: " "

The spacing character inserted between the comments. The Length of the character must be one.

/*eslint align-enums: ["warn", "always", { "spacingCharacter": "-" }]*/

// Valid
enum Direction {
  UP /*---*/ = "up",
  DOWN /*-*/ = "down",
  LEFT /*-*/ = "left",
  RIGHT /**/ = "right",
}