sindresorhus/eslint-plugin-unicorn

Rule proposal: consistent class member order

Chiusa

#1110 aperta il 18 feb 2021

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

Metriche repository

Star
 (5022 stelle)
Metriche merge PR
 (Merge medio 1g 16h) (399 PR mergiate in 30 g)

Descrizione

Enforce statements in this order

Originally posted by @fisker in https://github.com/sindresorhus/eslint-plugin-unicorn/issues/990#issuecomment-753474656

Can you open a separate issue for the class member order rule idea? Similar rule for TS: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/member-ordering.md

Originally posted by @sindresorhus in https://github.com/sindresorhus/eslint-plugin-unicorn/issues/990#issuecomment-755267134

Rule name class-body-order is the original idea, I'm open to better suggestions.

Fail

Cases not in order as example in Pass.

Pass

class Unicorn {
   #privateField = 1;

   publicField= 1;

   static staticField = 1;

   constructor() {}

   #privateMethod() {}

   publicMethod() {}

   static staticMethod() {}

   static {
     // static block
   }
}

Guida contributor