vue/no-export-in-script-setup 正确性
它的作用
禁止在 <script setup> 中使用 export
为什么这不好?
旧版本的 <script setup> RFC 使用 export 来定义在模板中使用的变量, 但新的 <script setup> RFC 已更新为不使用 export 来定义。 有关更多详情,请参见 Vue RFCs - 0040-script-setup。
示例
以下是此规则的错误代码示例:
vue
<script setup>
export let msg = "Hello!";
</script>以下是此规则的正确代码示例:
vue
<script setup>
let msg = "Hello!";
</script>如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"plugins": ["vue"],
"rules": {
"vue/no-export-in-script-setup": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
plugins: ["vue"],
rules: {
"vue/no-export-in-script-setup": "error",
},
});bash
oxlint --deny vue/no-export-in-script-setup --vue-plugin版本
此规则新增于 v1.20.0。
