JS.VUE.REQUIRE.DIRECT.EXPORT

Require the component to be directly exported

Rule Details

This rule aims to require that the component object be directly exported.

{'vue/require-direct-export': ['error']}

Copy
<script>
/* GOOD */
export default {
  name: 'ComponentA',
  data() {
    return {
      state: 1
    }
  }
}
</script>

{'vue/require-direct-export': ['error']}

Copy
<script>
const ComponentA = {
  name: 'ComponentA',
  data() {
    return {
      state: 1
    }
  }
}

/* BAD */
export default ComponentA
</script>

Options

Copy
{
  "vue/require-direct-export": ["error", {
    "disallowFunctionalComponentFunction": false
  }]
}
  • "disallowFunctionalComponentFunction" ... If true, disallow functional component functions, available in Vue 3.x. default false

"disallowFunctionalComponentFunction": false

{'vue/require-direct-export': ['error', {disallowFunctionalComponentFunction: false}]}

Copy
<script>
/* GOOD */
export default props => h('div', props.msg)
</script>

"disallowFunctionalComponentFunction": true

{'vue/require-direct-export': ['error', {disallowFunctionalComponentFunction: true}]}

Copy
<script>
/* BAD */
export default props => h('div', props.msg)
</script>

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/