Skip to content

vue/require-default-export Suspicious

What it does

Require components to be the default export.

Why is this bad?

Using SFCs (Single File Components) without a default export is not supported in Vue 3. Components should be exported as the default export.

Examples

Examples of incorrect code for this rule:

vue
<script>
const foo = "foo";
</script>

Examples of correct code for this rule:

vue
<script>
export default {
  data() {
    return {
      foo: "foo",
    };
  },
};
</script>

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny vue/require-default-export --vue-plugin
json
{
  "plugins": ["vue"],
  "rules": {
    "vue/require-default-export": "error"
  }
}

References

Released under the MIT License.