Skip to content

Latest commit

 

History

History
65 lines (47 loc) · 1.2 KB

prefer-es6-class.md

File metadata and controls

65 lines (47 loc) · 1.2 KB

Enforce ES5 or ES6 class for Inferno Components (inferno/prefer-es6-class)

Inferno offers you two ways to create traditional components: using the ES5 inferno-create-class module or the new ES6 class system.

Rule Details

This rule allows you to enforce one way or another.

Rule Options

...
"inferno/prefer-es6-class": [<enabled>, <mode>]
...

always mode

Will enforce ES6 classes for Inferno Components. This is the default mode.

Examples of incorrect code for this rule:

var Hello = createClass({
  render: function() {
    return <div>Hello {this.props.name}</div>;
  }
});

Examples of correct code for this rule:

class Hello extends Inferno.Component {
  render() {
    return <div>Hello {this.props.name}</div>;
  }
}

never mode

Will enforce ES5 classes for Inferno Components.

Examples of incorrect code for this rule:

class Hello extends Inferno.Component {
  render() {
    return <div>Hello {this.props.name}</div>;
  }
}

Examples of correct code for this rule:

var Hello = createClass({
  render: function() {
    return <div>Hello {this.props.name}</div>;
  }
});