script/no-export-in-script-setup
Disallow export statements inside <script setup>.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
error |
essential, happy-path, ecosystem, nuxt, opinionated |
No | None |
Applies to: JS/TS scripts in Vue SFCs; examples show the relevant Options API or script setup form.
Bad
export const count attempts to expose a module export from <script setup>, where runtime exports are prohibited.
<script setup lang="ts">
export const count = 1;
</script>
Good
Removing export keeps count as a setup binding rather than a module export.
<script setup lang="ts">
const count = 1;
</script>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"script/no-export-in-script-setup": "error"
}
},
});
Then run vp run lint.