Skip to content

require-prop-types raises an error when a validator is present #713

Closed
@danielsamuels

Description

@danielsamuels

Tell us about your environment

  • ESLint version: 4.19.1
  • eslint-plugin-vue version: 4.4.0
  • Node version: node v8.9.4, yarn 1.4.1

Please show your full configuration:

{
  "parserOptions": {
    "ecmaVersion": 6,
    "sourceType": "module"
  },
  "env": {
    "browser": true,
    "commonjs": true,
    "jquery": true
  },
  "extends": [
    "plugin:vue/recommended",
    "eslint:recommended"
  ]
}

What did you do?

<script>
export default {
    props: {
        deviceId: {
            validator: value => value === null || typeof value === Number,
            required: true,
        }
    },
};
</script>

What did you expect to happen?
According to the documentation it should be possible to define a validator in place of a type and have the rule pass. This is not the case.

What actually happened?

[ESLint: test.vue]

     Error       4,9: Prop "deviceId" should define at least its type. (vue/require-prop-types)

✗ 1 error, 0 warnings

Double-click on lines to jump to location, [F4] for next, [shift-F4] for previous.

[Finished in 1.0s]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions