-
-
Notifications
You must be signed in to change notification settings - Fork 31
Description
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.toml
key = "value"
another_key = "another value"
path = "C:\\Users\\User" # This string contains an escape sequenceAfter 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.toml
key = 'value'
another_key = 'another value'
path = "C:\\Users\\User" # This string should remain double-quoted because of the escape sequenceAdditional 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.
Thank you for your consideration