react/jsx-no-bind false positive?
See original GitHub issueExample snippet:
import React from 'react';
import PropTypes from 'prop-types';
class FalsePositive extends React.PureComponent {
static propTypes = {
list: PropTypes.arrayOf(PropTypes.node).isRequired,
};
render() {
return (
<div>
{this.props.list.map(this.wrap.bind(this, 'span'))}
</div>
);
}
wrap(Tag, item, i) {
return <Tag key={i}>{item}</Tag>;
}
}
export default FalsePositive;
this.wrap.bind
triggers the rule, even though the bound function isn’t the actual prop being passed, but is being used during the render to build the children, so it shouldn’t break purity.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
12 essential ESLint rules for React - LogRocket Blog
Introduction. ESLint has a comprehensive set of rules for JavaScript code that cover stylistic choices and prevent common bugs.
Read more >Files changed (103) - Renovate Bot Package Diff
[`destructuring-assignment`]: fix a false positive for local prop named `context` in SFC ([#2929][] @SyMind). 85. - * [`jsx-no-target-blank`]: Allow ...
Read more >eslint-config-canonical - npm
Rule CN AB GG SD XO
@babel/new‑cap ❌ 👻 👻 👻 👻
@babel/no‑invalid‑this 🚨 👻 👻 👻 👻
@babel/no‑unused‑expressions 🚨 👻 👻 👻 👻
Read more >SharePoint Framework (SPFx) v1.15 and the attack of ESLint!
lintCmd.enabled = false; // existing code... ... The react/jsx-no-bind rule states we shouldn't ever use arrow functions in our React ...
Read more >eslint-plugin-react - npm Package Health Analysis - Snyk
We found that eslint-plugin-react demonstrates a positive version release cadence with at least one new version released in the past 3 months.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ljharb
Thanks for replying! I think I know the direction I’m going with to fix this issue now. Will open a PR soon. 😄
It’s hard to evaluate without an actual PR; I’d love to look at the test case and docs changes in particular that you’re suggesting.