type/no-implied-eval
Disallow string-based dynamic code execution APIs.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
warning |
nuxt, opinionated |
No | None |
Applies to: Type information in Vue SFC scripts and templates, for the constructs shown below.
This rule reads type information from your TypeScript project (tsconfig.json), so the configuration sets typeAware: true. typeAware does not turn on opt-in rules by itself.
Bad
setTimeout receives a string, which is executed as dynamic code.
<script setup lang="ts">
function logVoid(): void {}
setTimeout("logVoid()", 10);
</script>
Good
setTimeout receives a function, so no string is evaluated.
<script setup lang="ts">
setTimeout(() => {}, 10);
</script>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"type/no-implied-eval": "warn"
},
"typeAware": true
},
});
Then run vp run lint.