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 'type' of null at props with type [,,] #930

Closed
tianjianchn opened this issue Jul 18, 2019 · 1 comment · Fixed by #963
Closed

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

tianjianchn opened this issue Jul 18, 2019 · 1 comment · Fixed by #963

Comments

@tianjianchn
Copy link

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 [,,]
@ota-meshi ota-meshi added the bug label Jul 27, 2019
@ota-meshi
Copy link
Member

Thank you for this issue.

I reproduced this bug on the demo page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants