sindresorhus/eslint-plugin-unicorn

Rule proposal: consistent class member order

クローズ

#1,110 opened on 2021/02/18

 (5 件のコメント) (2 件のリアクション) (0 人の担当者)JavaScript (468 件のフォーク)user submission
help wantednew rule

Repository metrics

Stars
 (5,022 個のスター)
PR merge metrics
 (平均マージ 1d 16h) (30d で 399 merged PRs)

説明

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
   }
}

コントリビューターガイド