sindresorhus/eslint-plugin-unicorn

Rule proposal: Consistent decorator position for exports

Open

#2,038 opened on Feb 3, 2023

View on GitHub
 (11 comments) (0 reactions) (0 assignees)JavaScript (5,022 stars) (468 forks)user submission
help wantednew rule

Description

Description

Decorators can be placed in two positions when you export a class. Would be nice with a rule to enforce either for consistency.

https://twitter.com/leobalter/status/1621242353494425602

I haven't yet made up my mind which should be the default. Lets discuss.

Either:

export default @decorator class {}

or

@decorator export default class {}

My mind is split as I kinda feel that export should always come first, since it should immediately clear what's being exported. On the other hand, placing it first will allow stacking it above (the rule may want to enforce whether this is allowed too):

@decorator
export default class {}

I'm leaning towards the latter.

Fail

TODO

Pass

TODO

Additional Info

No response

Contributor guide