-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
It must be possible for ES6 defaultProps be equal to function execution #2104
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
The rule definitely shouldn't crash - but |
Can you update to v7.12.1 and see if it's still crashing? |
Also, do you know what rule it's crashing on? |
@ljharb this is an IIFE though, so it should still work out? Pretty rare case though and not something we can lint for IMO (shouldn't crash of course though). |
Ah, I didn't even see that - yes, the IIFE should work fine wrt React. |
I'm also getting this with latest
Setting this in .eslintrc.yaml is my work-around ST:
|
@jethrolarson by any chance, can you share the code that it's erroring on? |
Stack trace doesn't say where the actual problem is, so I'm not sure. Code is proprietary so I can't just share the project. |
The OP's test code doesn't crash on master. @jethrolarson I understand. if you edit |
@ljharb just throwing it out there - would it be impossible for eslint to set an uncaught exception handler that would make it easier for people to locate the source of crashes? We've been getting a lot of reports like this recently. (also sorry for having caused some of them with my changes) |
I suppose we could; it'd be pretty intrusive to other plugins tho. It seems more like something eslint itself should be handing. |
File with error (i think): HeroTeaserList.propTypes = Object.assign({
heroIndex: PropTypes.number,
preview: PropTypes.bool,
}, componentApi, teaserListProps); in another file export const componentConfiguration = {
childComponentMapping: objectOf(string),
componentConfig: object,
componentInstanceId: string,
componentType: string,
dataType: string,
filter: shape(TemplateFilter),
filterVersionSetUuid: string,
teasers: arrayOf(shape(TeaserContent)),
title: string,
titleOverride: node,
uuid: string.isRequired,
visibleCount: number,
epgUuid: string,
readOnly: bool,
};
export const componentApi = Object.assign({
getComponent: func.isRequired,
onNavigation: func,
onConfigurationChange: func,
}, componentConfiguration); another file
|
Perfect, I'm able to repro. |
@ljharb yeah that's what I meant there; just thought you might know why that could be unrealistic. I'll look around their issue tracker. 👍 |
In the class below:
the defaultProps are equal to a anonymous function return value.
In this case, the eslint-plugin-react doesn't run, and throws the following error:
TypeError: Cannot read property 'split' of undefined at Object.isPropWrapperFunction (~/project/node_modules/eslint-plugin-react/lib/util/propWrapper.js:12:26) at resolveNodeValue (~/project/node_modules/eslint-plugin-react/lib/util/defaultProps.js:30:23) at Object.ClassProperty (~/project/node_modules/eslint-plugin-react/lib/util/defaultProps.js:222:26) at updatedRuleInstructions.(anonymous function) (~/project/node_modules/eslint-plugin-react/lib/util/Components.js:752:46) at listeners.(anonymous function).forEach.listener (~/project/node_modules/eslint/lib/util/safe-emitter.js:45:58)
I'm using the following versions:
"eslint": "5.10.0"
"eslint-plugin-react": "7.11.1".
If in the same class I put the defaultProps equal do an object it runs as expected.
Thanks
The text was updated successfully, but these errors were encountered: