You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[prettier-plugin-toml] Support for single quotes formatting #488
Currently, prettier-plugin-toml does not seem to support an option to format TOML files using single quotes instead of double quotes. While Prettier itself offers a --single-quote option for many other supported languages like JavaScript and YAML, this functionality is not available for TOML files.
I would like prettier-plugin-toml to respect Prettier's --single-quote flag (and the corresponding .prettierrc option). When this option is enabled, running npx prettier --write file.toml --single-quote should convert double quotes to single quotes for strings where it is semantically safe to do so.
In TOML, double-quoted strings support escape sequences, whereas single-quoted strings are literal strings and do not. Therefore, the conversion should only happen for strings where no escape sequences are used, to avoid changing the string's meaning.
For example:
Current behavior:
# input.tomlkey = "value"another_key = "another value"path = "C:\\Users\\User"# This string contains an escape sequence
After running npx prettier --write input.toml --single-quote, the file remains unchanged.
Desired behavior:
After running npx prettier --write input.toml --single-quote, the input.toml file should be formatted as:
# input.tomlkey = 'value'another_key = 'another value'path = "C:\\Users\\User"# This string should remain double-quoted because of the escape sequence
Additional context
The ability to enforce a consistent quote style is a core feature of Prettier for many languages. Bringing this functionality to prettier-plugin-toml would improve consistency for projects that use TOML alongside other languages formatted by Prettier. It would also allow developers to adhere to their preferred coding style across the entire codebase.
Activity
test(prettier-plugin-toml): cover inherited prettier core options