Skip to content

Commit

Permalink
Add SpreadElement support to require-default-props
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickcr committed May 28, 2018
1 parent b3ed9d6 commit 632941c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/rules/require-default-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ module.exports = {
* @returns {Object[]} Array of PropType object representations, to be consumed by `addPropTypesToComponent`.
*/
function getPropTypesFromObjectExpression(objectExpression) {
const props = objectExpression.properties.filter(property => property.type !== 'ExperimentalSpreadProperty');
const props = objectExpression.properties.filter(property => property.type !== 'ExperimentalSpreadProperty' && property.type !== 'SpreadElement');

return props.map(property => ({
name: sourceCode.getText(property.key).replace(QUOTES_REGEX, ''),
Expand Down Expand Up @@ -184,7 +184,7 @@ module.exports = {
* from this ObjectExpression can't be resolved.
*/
function getDefaultPropsFromObjectExpression(objectExpression) {
const hasSpread = objectExpression.properties.find(property => property.type === 'ExperimentalSpreadProperty');
const hasSpread = objectExpression.properties.find(property => property.type === 'ExperimentalSpreadProperty' || property.type === 'SpreadElement');

if (hasSpread) {
return 'unresolved';
Expand Down Expand Up @@ -555,7 +555,7 @@ module.exports = {

// Search for the proptypes declaration
node.properties.forEach(property => {
if (property.type === 'ExperimentalSpreadProperty') {
if (property.type === 'ExperimentalSpreadProperty' || property.type === 'SpreadElement') {
return;
}

Expand Down

0 comments on commit 632941c

Please sign in to comment.