Skip to content

Latest commit

 

History

History
81 lines (59 loc) · 1.28 KB

require-optimization.md

File metadata and controls

81 lines (59 loc) · 1.28 KB

Enforce Inferno components to have a shouldComponentUpdate method (inferno/require-optimization)

Rule Details

Examples of incorrect code for this rule:

class YourComponent extends Inferno.Component {

}
createClass({
});

Examples of correct code for this rule:

class YourComponent extends Inferno.Component {
  shouldComponentUpdate () {
    return false;
  }
}
createClass({
  shouldComponentUpdate: function () {
    return false;
  }
});
createClass({
  mixins: [PureRenderMixin]
});
@infernoMixin.decorate(PureRenderMixin)
createClass({

});

Rule Options

...
"inferno/require-optimization": [<enabled>, { allowDecorators: [<allowDecorator>] }]
...
  • enabled: for enabling the rule. 0=off, 1=warn, 2=error. Defaults to 0.
  • allowDecorators: optional array of decorators names to allow validation.

allowDecorators

Sets the allowed names of decorators. If the variable is present in the chain of decorators, it validates

Examples of correct code for this rule:

// ['pureRender']
@pureRender
class Hello extends Inferno.Component {}

Example

...
"inferno/require-optimization": [2, {allowDecorators: ['customDecorators']}]
...