Skip to content

Rule proposal: prefer-class-fields #314

@MrHen

Description

@MrHen

Issuehunt badges

There is a superior pattern for class field declarations that can declutter constructors (often making them totally unnecessary.) The feature is still considered experimental but it works out of the box with babel.

Fail:

class Foo {
  constructor() {
    this.foo = 'foo';
  }
}

Pass:

class Foo {
  foo = 'foo';
}

IssueHunt Summary

frsgit frsgit has been rewarded.

Backers (Total: $30.00)

Submitted pull Requests


Tips

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions