-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
async instance methods broken in 6.8.0 #991
Comments
Can you elaborate on how it breaks? That change should only have affected component detection on functions. |
Thanks for the lightning fast response there! Oh sorry, of course. In the async method, the linter now think it is its own component. Therefore, I get linting errors like these:
on code like this: class SomeClass extends Component {
async onAddToCart({ selectedCoverage, quantity }) {
// no jsx, just dispatcher calls etc
}
render() {
return <CartWhatever onAddToCart={this.onAddToCart} />
}
} |
Thanks, that definitely seems like a bug. @taion mind submitting a PR to fix this? |
Can't reproduce. See test cases added in #992. |
And in fact the PR should be expected to do the exact opposite, since the only added cases blacklist component detection. |
Thanks for the quick feedback guys :) I'll see if I can reproduce this outside of my application. |
Seems I can't reproduce this either outside of my own code. I'll close this until I have something to contribute. |
I'm having the same issue: class CertSettings extends React.Component {
static propTypes = {
onSave: React.PropTypes.func.isRequired,
errors: React.PropTypes.array,
};
handleSubmit = async ({ certificate: certificates, key: keys }) => {
if (!certificates || !certificates.length || !keys || !keys.length) {
return;
}
const { onSave } = this.props;
await onSave(crtContents, keyContents);
};
// ...
} Results in the following linting errors:
|
@bharley does it have the same problem if you don't destructure in the signature? (on a side note, there's zero reason you need an async function there, since you only have one |
@ljharb: It does not have a problem with that, no. I trimmed down the function to show the relevant parts. It does look silly though... You know what, that got me thinking... I played around with the code to it reproduce. This has issues: export class Example extends React.Component {
static propTypes = {
certificates: React.PropTypes.array,
onSave: React.PropTypes.func.isRequired,
onDelete: React.PropTypes.func.isRequired,
deleteFingerprint: React.PropTypes.string.isRequired,
};
handleDeleteConfirm = () => {
const { deleteFingerprint } = this.props;
this.props.onDelete(deleteFingerprint);
};
handleSubmit = async ({ certificate: certificates, key: keys }) => {
if (!certificates || !certificates.length || !keys || !keys.length) {
return;
}
const { onSave } = this.props;
await onSave(certificates, keys);
};
} but this doesn't export class Example extends React.Component {
static propTypes = {
certificates: React.PropTypes.array,
onSave: React.PropTypes.func.isRequired,
onDelete: React.PropTypes.func.isRequired,
deleteFingerprint: React.PropTypes.string.isRequired,
};
handleSubmit = async ({ certificate: certificates, key: keys }) => {
if (!certificates || !certificates.length || !keys || !keys.length) {
return;
}
const { onSave } = this.props;
await onSave(certificates, keys);
};
} |
…sx-eslint#991)" This reverts commit bad47d6.
We have a few async functions as instance methods in our component classes. An example is:
In #989 you introduced a check for whether a component was async or not. This broke code like this for us - which it shouldn't. Suggest that #989 is removed or rewritten to support this kind of syntax. Worked perfectly on 6.7.1 :)
The text was updated successfully, but these errors were encountered: