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

sort-prop-types throws an error for {sortShapeProp: true} if shape is not object literal #1668

Closed
justinanastos opened this issue Jan 31, 2018 · 1 comment

Comments

@justinanastos
Copy link
Contributor

justinanastos commented Jan 31, 2018

Example and use case:

import ChildComponent from './child-component';

SomeComponent.propTypes = {
  childProps: PropTypes.shape(
    ChildComponent.propTypes,
  ),
};

This will cause the following error to be thrown:

TypeError: Cannot read property 'reduce' of undefined
    at checkSorted ([localpath]/node_modules/eslint-plugin-react/lib/rules/sort-prop-types.js:80:20)
    at CallExpression ([localpath]/node_modules/eslint-plugin-react/lib/rules/sort-prop-types.js:166:9)
    at listeners.(anonymous function).forEach.listener ([localpath]/node_modules/eslint/lib/util/safe-emitter.js:47:58)
    at Array.forEach (<anonymous>)
    at Object.emit ([localpath]/node_modules/eslint/lib/util/safe-emitter.js:47:38)
    at NodeEventGenerator.applySelector ([localpath]/node_modules/eslint/lib/util/node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors ([localpath]/node_modules/eslint/lib/util/node-event-generator.js:280:22)
    at NodeEventGenerator.enterNode ([localpath]/node_modules/eslint/lib/util/node-event-generator.js:294:14)
    at CodePathAnalyzer.enterNode ([localpath]/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:608:23)
    at Traverser.enter [as _enter] ([localpath]/node_modules/eslint/lib/linter.js:1006:32)
    at Traverser._traverse ([localpath]/node_modules/eslint/lib/util/traverser.js:132:14)
    at Traverser._traverse ([localpath]/node_modules/eslint/lib/util/traverser.js:147:30)
    at Traverser._traverse ([localpath]/node_modules/eslint/lib/util/traverser.js:144:34)
    at Traverser._traverse ([localpath]/node_modules/eslint/lib/util/traverser.js:147:30)
    at Traverser._traverse ([localpath]/node_modules/eslint/lib/util/traverser.js:147:30)
    at Traverser._traverse ([localpath]/node_modules/eslint/lib/util/traverser.js:144:34)
@ljharb
Copy link
Member

ljharb commented Jan 31, 2018

Closed in #1669.

@ljharb ljharb closed this as completed Jan 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants