Skip to content

Latest commit

Β 

History

History
67 lines (44 loc) Β· 1.6 KB

File metadata and controls

67 lines (44 loc) Β· 1.6 KB

consistent-export-decorator-position

πŸ“ Enforce consistent decorator position on exported classes.

πŸ’Ό This rule is enabled in the following configs: βœ… recommended, β˜‘οΈ unopinionated.

πŸ”§ This rule is automatically fixable by the --fix CLI option.

Decorators can be placed before or after export and export default on class declarations. Pick one style for consistency.

This rule requires a parser that supports decorators, such as @typescript-eslint/parser.

Examples

// eslint unicorn/consistent-export-decorator-position: error

// ❌
export default @decorator class Foo {}

// ❌
@decorator export default class Foo {}

// βœ…
@decorator
export default class Foo {}

before

// eslint unicorn/consistent-export-decorator-position: ["error", "before"]

// ❌
@decorator
export default class Foo {}

// βœ…
@decorator export default class Foo {}

after

// eslint unicorn/consistent-export-decorator-position: ["error", "after"]

// ❌
@decorator
export default class Foo {}

// βœ…
export default @decorator class Foo {}

Options

Type: string
Default: 'above'

Available options:

  • 'above' - Require decorators on the line above the export.
  • 'before' - Require decorators before export on the same line.
  • 'after' - Require decorators after export or export default.