This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MyComponent extends React.Component { | |
| constructor(props) { | |
| super(props); | |
| if (props.foo) { /* | |
| * Now the assignment to this.state has a different parent. | |
| * If you didn't expect to see an if condition here, | |
| * the rule may crash. | |
| */ | |
| this.state = { /* some state */ }; | |
| } else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MyComponent extends React.Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = { /* some state */ }; // <-- state initialization | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class BaseHandler { | |
| constructor() { | |
| this.handler = this._handler.bind(this); | |
| } | |
| _handler(req, res, next) { | |
| let result; | |
| try { | |
| result = this._execute.apply(this, [req, res, next]); | |
| } catch (e) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function createBaseHandler(handler) { | |
| return function BaseHandler(req, res, next) { | |
| let result; | |
| try { | |
| result = handler(req, res, next); | |
| } catch (e) { | |
| res.status(500); | |
| res.end(); | |
| return; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Component(props) { | |
| return ( | |
| <button | |
| onClick={() => { | |
| console.log('inline functions bad'); // JSX props should not use arrow functions (react/jsx-no-bind) | |
| }} | |
| type="button" | |
| /> | |
| ); | |
| } |