Vize

Property quotes

Choose when script object keys need quotes. Use the preserve mode to retain authored quoted keys, or the other modes to make quoting follow the object structure.

Keep shared options in vue.formatter in vite.config.*; the CLI and editor read the same settings. See Configuration.

Configure property quotes

Set vue.formatter.quoteProps in your existing Vite+ configuration to choose how script object keys are quoted:

import { defineConfig } from "@vizejs/vite-plugin/vite-plus";

export default defineConfig({}).withVue({
  formatter: { quoteProps: "preserve" },
});

The existing modes are:

  • "as-needed" (default): quote keys that require quotes.
  • "consistent": quote all keys in an object when one requires quotes; remove optional quotes when none require them.
  • "preserve": keep whether each key was authored with quotes.

For example, preserve formats {"name":1,plain:2} as { "name": 1, plain: 2 }. as-needed and consistent both format that object as { name: 1, plain: 2 }. When an object contains "needs-dash", consistent quotes its sibling keys as well.

The singleQuote setting still chooses the quote character. quoteProps controls which keys have quotes; it does not keep the original quote character.

Use with props and emits quote lint

The opinionated lint preset enables script/consistent-props-emits-key-quotes. That rule applies only to props and emits declarations, so let lint own that narrow policy and configure formatters to preserve authored quotes. In Vite+, a root formatter setting is shared with Oxfmt and the Vize Vue formatter:

import { defineConfig } from "@vizejs/vite-plugin/vite-plus";

export default defineConfig({
  fmt: { quoteProps: "preserve" },
}).withVue({
  linter: { preset: "opinionated" },
});

Prettier uses the equivalent setting in its own configuration. This also flows through prettier-plugin-vize:

{
  "quoteProps": "preserve"
}

Using preserve prevents format-on-save from undoing the lint-compliant quotes without imposing consistent quoting on unrelated objects.

The CLI and editor read the same vue.formatter settings from vite.config.*. Use vize fmt --quote-props preserve for a direct CLI override. The native Node API accepts the same three strings as formatSfc's quoteProps option. See Configuration for discovery and migration from removed dedicated configuration files.