Skip to content

Exception thrown by require-default-prop when encountering spread operator #1040

Closed
@thedamon

Description

@thedamon

Tell us about your environment

  • ESLint version: 6.8.0
  • eslint-plugin-vue version: 6.1.2
  • Node version: 10.16.3

Package.json:

{
  "scripts": {
    "lint": "eslint . --ext .js,.vue"
  },
  "dependencies": {
    "babel-eslint": "^10.0.3",
    "eslint": "^6.8.0",
    "eslint-plugin-vue": "^6.1.2",
    "vue-eslint-parser": "^7.0.0"
  }
}

Please show your full configuration:

module.exports = {
  extends: ["plugin:vue/recommended"]
};

What did you do?

<script>
const commonProps = {
  background: String
};

export default {
  name: "test",
  props: {
    background: {
      ...commonProps.background,
      validator: data => {
        return ["bg-2", "bg"].includes(data);
      }
    }
  }
};
</script>

What did you expect to happen?
Tests to run successfully

What actually happened?

require-default-prop encountered an error parsing the file.

$ eslint . --ext .js,.vue
TypeError: Cannot read property 'type' of undefined
Occurred while linting /eslint-test/Test.vue:6
    at value.type.ObjectExpression.value.properties.find.p (eslint-plugin-vue/lib/rules/require-default-prop.js:116:17)
    at Array.find (<anonymous>)
    at isBooleanProp (eslint-plugin-vue/lib/rules/require-default-prop.js:115:26)
    at props.filter.prop (eslint-plugin-vue/lib/rules/require-default-prop.js:129:36)
    at Array.filter (<anonymous>)
    at excludeBooleanProps (eslint-plugin-vue/lib/rules/require-default-prop.js:129:20)
    at utils.executeOnVue (eslint-plugin-vue/lib/rules/require-default-prop.js:141:29)
    at ExportDefaultDeclaration:exit (eslint-plugin-vue/lib/utils/index.js:628:9)
    at listeners.(anonymous function).forEach.listener (eslint/lib/linter/safe-emitter.js:45:58)
    at Array.forEach (<anonymous>)
error Command failed with exit code 2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions