Skip to content

Add instance-variables to eslint react/sort-comp rule #375

@mattrunyon

Description

@mattrunyon

Currently, our eslint config requires instance variables to be defined after the constructor and lifecycle handlers like below.

constructor() {
  this.myProp = doSomething();
}

onComponentDidMount() {
  doSomethingElse();
}

myProp;

If we add instance-variables to the order before lifecycle, then this should require instance variables be defined before the constructor and after static members like below. This only applies to jsx/tsx files.

myProp;

constructor() {
  this.myProp = doSomething();
}

onComponentDidMount() {
  doSomethingElse();
}

It will require some manual fixing as the rule doesn't have auto-fix.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions