Classes are nice tools to use when programming with the object-oriented paradigm, as they hold internal state and give access to methods on the instances. In functional programming, having stateful objects is more harmful than helpful, and should be replaced by the use of pure functions.
class Polygon {
constructor(height, width) {
this.height = height;
this.width = width;
}
}function polygon(height, width) {
return {
height: height,
width: width
};
}For those who cannot use Function Components and/or Hooks, using class will trigger this rule to fail.
class Sup extends React.Component {
constructor() {
}
}To get it to pass, add a rule modication in your .eslintrc file. This will allow only classes that extend React.Component or React.
"fp-jxl/no-class": ["error", {
"allowExtendingReactComponent": true
}]