sindresorhus/eslint-plugin-unicorn

Rule proposal: Consistent decorator position for exports

Chiusa

#2038 aperta il 3 feb 2023

 (11 commenti) (0 reazioni) (0 assegnatari)JavaScript (468 fork)user submission
help wantednew rule

Metriche repository

Star
 (5022 stelle)
Metriche merge PR
 (Merge medio 4h 30m) (26 PR mergiate in 30 g)

Descrizione

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

Guida contributor