JS.VUE.NO.BOOLEAN.DEFAULT

Disallow boolean defaults

The rule prevents Boolean props from having a default value.

Rule Details

The rule is to enforce the HTML standard of always defaulting boolean attributes to false.

{'vue/no-boolean-default': ['error']}

Copy
<script>
export default {
  props: {
    foo: {
      type: Boolean,
      default: true
    },
    bar: {
      type: Boolean
    }
  }
}
</script>

Options

  • 'no-default' (default) allows a prop definition object, but enforces that the default property not be defined.
  • 'default-false' enforces that the default can be set but must be set to false.
Copy
  "vue/no-boolean-default": ["error", "no-default|default-false"]

The content on this page is adapted from the ESLint User Guide. Copyright © OpenJS Foundation and other contributors, www.openjsf.org. All rights reserved. https://eslint.org/docs/rules/