palantir / tslint-react

:orange_book: Lint rules related to React & JSX for TSLint.
Apache License 2.0
749 stars 76 forks source link

New rule: no-bind #44

Closed huashiyiqike closed 7 years ago

huashiyiqike commented 7 years ago

To circumvent re-rendering by creating a new function each time when binding this to functions

https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md

"jsx-no-bind": [<enabled>, {
  "ignoreRefs": <boolean> || false,
  "allowArrowFunctions": <boolean> || false,
  "allowBind": <boolean> || false
}]
tp commented 7 years ago

I found that the performance impact may not even be the real issue this would be helpful with, but rather TypeScript's lenient typing of bind (bind(this: Function, thisArg: any, ...argArray: any[]): any;), which results in parameter-mismatches not being caught.

huashiyiqike commented 7 years ago

@tp Great point! I didn't notice that, here is the link https://basarat.gitbooks.io/typescript/content/docs/tips/bind.html

adidahiya commented 7 years ago

will be available in v2.6.0