vue/no-loss-of-precision
Disallow numeric literals that lose precision.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
warning |
None | No | None |
Applies to: Vue SFC templates and blocks, with script context where the rule requires it.
Bad
The integer cannot be represented precisely as a JavaScript number.
<template>
<p>{{ 9007199254740993 }}</p>
</template>
Good
A precomputed precise binding avoids an imprecise template literal.
<template>
<p>{{ preciseValue }}</p>
</template>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vue/no-loss-of-precision": "warn"
}
},
});
Then run vp run lint.