Skip to content
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

TypeError: Cannot read property 'name' of undefined (plus infinite loop?) #1928

Closed
kaiyoma opened this issue Aug 14, 2018 · 6 comments
Closed

Comments

@kaiyoma
Copy link

kaiyoma commented Aug 14, 2018

Today I tried upgrading to the newest eslint and the newest eslint-config-airbnb. Now when I try linting my codebase, I seem to get this error over and over in an infinite loop:

TypeError: Cannot read property 'name' of undefined
    at markPropTypesAsDeclared (...\node_modules\eslint-plugin-react\lib\util\propTypes.js:475:51)
    at Object.MemberExpression (...\node_modules\eslint-plugin-react\lib\util\propTypes.js:644:9)
    at updatedRuleInstructions.(anonymous function) (...\node_modules\eslint-plugin-react\lib\util\Components.js:706:43)
    at listeners.(anonymous function).forEach.listener (...\node_modules\eslint\lib\util\safe-emitter.js:45:58)
    at Array.forEach (<anonymous>)
    at Object.emit (...\node_modules\eslint\lib\util\safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (...\node_modules\eslint\lib\util\node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (...\node_modules\eslint\lib\util\node-event-generator.js:280:22)
    at NodeEventGenerator.enterNode (...\node_modules\eslint\lib\util\node-event-generator.js:294:14)
    at CodePathAnalyzer.enterNode (...\node_modules\eslint\lib\code-path-analysis\code-path-analyzer.js:632:23)

I'm not sure what code is causing this because the filename isn't being printed out. Let me know if you need more info and I'll gladly help out.

@kaiyoma
Copy link
Author

kaiyoma commented Aug 14, 2018

Sorry, I should also mention that I also upgraded eslint-plugin-react (from 7.10.0 to 7.11.0).

@alexzherdev
Copy link
Contributor

@kaiyoma sorry for causing this. Is there a place in your code where you do something like

Component.propTypes.foo = ...

?

@kaiyoma
Copy link
Author

kaiyoma commented Aug 14, 2018

Not that exactly, but I think I found the file causing the issue. We have a very thin wrapper around a third-party component and the linter throws that same error every time I lint this file:

import RcSlider from 'rc-slider';
import React from 'react';

import './styles.less';

const Slider = props => (
  <div className='wrapped-slider'>
    <RcSlider {...props} />
  </div>
);

// Uses the same props as `rc-slider`: https://www.npmjs.com/package/rc-slider
Slider.propTypes = RcSlider.propTypes;

Slider.defaultProps = {
  tipFormatter: null,
};

export default Slider;

@alexzherdev
Copy link
Contributor

Thanks, that’s very helpful. Will try to fix ASAP.
@ljharb this is caused by a part of the refactoring where I had to combine code from the two rules, and apparently I didn’t code it defensively enough. Looks like we also don’t have tests for this case.
Is this serious enough to require a patch?

@alexzherdev
Copy link
Contributor

It looks like this is only failing with ESLint 5. @kaiyoma if necessary, you can try reverting to ESLint 4 in the meantime.

@ljharb
Copy link
Member

ljharb commented Aug 14, 2018

@alexzherdev yes, i think a patch would be ideal. Happy to review a PR asap.

alexzherdev added a commit to alexzherdev/eslint-plugin-react that referenced this issue Aug 14, 2018
alexzherdev added a commit to alexzherdev/eslint-plugin-react that referenced this issue Aug 14, 2018
alexzherdev added a commit to alexzherdev/eslint-plugin-react that referenced this issue Aug 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants