Skip to content

TypeError: Cannot read property 'type' of null at props with type [,,] #930

Closed
@tianjianchn

Description

@tianjianchn

Tell us about your environment

  • ESLint version: 5.16.0 and 6
  • eslint-plugin-vue version: 5.2.2 and 5.2.3
  • Node version: 10.15.0

Please show your full configuration:

{
  "extends": [
    "plugin:vue/recommended"
  ],
  "plugins": [
    "vue"
  ],
}

What did you do?

<template>
  
</template>

<script>
export default {
  props: {
    name: [String,,]
  }
}
</script>

<style>

</style>

What did you expect to happen?
Just report the error, but not eslint exception

What actually happened?

when runing ./node_modules/.bin/eslint null-type-error.vue, eslint throws exception, see below.

TypeError: Cannot read property 'type' of null
Occurred while linting /xxxx/eslint-plugin-vue-bug/null-type-error.vue:6
    at isForbiddenType (/xxxx/eslint-plugin-vue-bug/node_modules/eslint-plugin-vue/lib/rules/require-prop-type-constructor.js:22:61)
    at node.elements.filter.prop (/xxxx/eslint-plugin-vue-bug/node_modules/eslint-plugin-vue/lib/rules/require-prop-type-constructor.js:61:27)
    at Array.filter (<anonymous>)
    at checkPropertyNode (/xxxx/eslint-plugin-vue-bug/node_modules/eslint-plugin-vue/lib/rules/require-prop-type-constructor.js:61:12)
    at utils.executeOnVueComponent (/xxxx/eslint-plugin-vue-bug/node_modules/eslint-plugin-vue/lib/rules/require-prop-type-constructor.js:79:11)
    at ExportDefaultDeclaration:exit (/xxxx/eslint-plugin-vue-bug/node_modules/eslint-plugin-vue/lib/utils/index.js:666:9)
    at listeners.(anonymous function).forEach.listener (/xxxx/eslint-plugin-vue-bug/node_modules/eslint/lib/util/safe-emitter.js:45:58)
    at Array.forEach (<anonymous>)
    at Object.emit (/xxxx/eslint-plugin-vue-bug/node_modules/eslint/lib/util/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/xxxx/eslint-plugin-vue-bug/node_modules/eslint/lib/util/node-event-generator.js:251:26)

in file node_modules/eslint-plugin-vue/lib/rules/require-prop-type-constructor.js

      } else if (node.type === 'ArrayExpression') {
        node.elements
          .filter(prop => isForbiddenType(prop)) // <------ prop maybe null here when prop type is [,,]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions