-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
"no-unused-prop-types" inside async functions (include arrow) #1053
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
Comments
Some additional info which might help: this will error: onSubmit = async (e) => {
this.setState({loggingIn: true, success: false, message: null})
const {email, password} = this.state
const {login, setAuthenticated} = this.props // not detected by eslint
const {success, message} = await login(email, password)
this.setState({loggingIn: false, success, message})
setAuthenticated(success)
if (success) {
const {router, location: {state: {nextPathname} = {}}} = this.props
setTimeout(() => {
router.push(nextPathname || '/')
}, 1000)
}
} this will not error: onSubmit = async (e) => {
this.setState({loggingIn: true, success: false, message: null})
const {email, password} = this.state
// properly detected by eslint
const {login, setAuthenticated, router, location: {state: {nextPathname} = {}}} = this.props
const {success, message} = await login(email, password)
this.setState({loggingIn: false, success, message})
setAuthenticated(success)
if (success) {
setTimeout(() => {
router.push(nextPathname || '/')
}, 1000)
}
} The only difference between these snippets is how {
code: [
'export class Example extends Component {',
' static propTypes = {',
' failed: PropTypes.func.isRequired,',
' loadUserProfile: PropTypes.func.isRequired,',
' }',
' handleLogin = async () => {',
' const {failed, loadUserProfile} = this.props;',
' await failed();',
' await loadUserProfile();',
' };',
'}'
].join('\n'),
parser: 'babel-eslint'
}, |
export default class Users extends Component {
static propTypes = {
...
onLoad: PropTypes.func.isRequired,
};
async componentWillMount() {
await Promise.all([
this.props.onLoad(),
this.onSearch(),
]);
...
}
...
}
|
@TrevorSayre similar for me — using |
Hi!
I think there is a bug with async functions.
property: "no-unused-prop-types"
parser: "[email protected]"
where: "async functions"
example:
The text was updated successfully, but these errors were encountered: