cosmiconfig icon indicating copy to clipboard operation
cosmiconfig copied to clipboard

add support for TOML?

Open foray1010 opened this issue 7 years ago • 10 comments

Would you mind me adding support for TOML? Because TOML looks simpler and less error-prone

There is a good article explaining the reason why TOML is better than YAML https://arp242.net/weblog/yaml_probably_not_so_great_after_all.html

foray1010 avatar Jun 23 '18 01:06 foray1010

This is actually already doable via loaders. This functionality was recently added by davidtheclark in this pull request. If anything about it is unclear please let me know and I'll try to help out.

olsonpm avatar Jun 23 '18 02:06 olsonpm

@olsonpm cool! I wonder if we can make TOML supported by default instead of requiring additional setting because this library is required by so many useful tools (such as stylelint) and as far as I see they just use the default setting, it will be nice that TOML can also support by default!

foray1010 avatar Jun 23 '18 03:06 foray1010

I don't think we'll be adding more defaults. It's just too hard a line to draw on when to stop adding out-of-the-box supported languages and syntaxes - which is one of the reasons making it an option works well.

olsonpm avatar Jun 23 '18 03:06 olsonpm

Thanks @foray1010. I like the article: I find it convincing and I'll try using TOML more often :)

@olsonpm is right, though, that we won't be adding another default for TOML — not unless we see common reliance on it among cosmiconfig users. The "users" of cosmiconfig are not, however, the end users of tools like stylelint, but the authors of tools like stylelint. If stylelint users want TOML configuration, that's a feature request for stylelint; if lint-staged users want TOML configuration, that's a feature request for lint-staged. If stylelint and lint-staged and some other users then express that they'd like cosmiconfig to turn on TOML by default, we'd consider it.

because this library is required by so many useful tools (such as stylelint) and as far as I see they just use the default setting, it will be nice that TOML can also support by default!

Cosmiconfig should not be in control of this — that is, should not be making the decisions about adding more default configuration formats to libraries, unless those libraries want them.

So I'm happy to leave this issue open to see if library authors do want to add TOML to the defaults.

davidtheclark avatar Jun 24 '18 19:06 davidtheclark

Chiming in here just to say that I also think toml is superior to json and yaml. The Rust (cargo.toml) and Python (pyproject.toml) community seems to think so too.

dsifford avatar Jul 04 '18 19:07 dsifford

Chiming in with an additional point of data, since I'm in favor of this: Prettier has had TOML support since August 2018.

0az avatar Jan 31 '20 01:01 0az

Maybe you'd be interested in confinode, as adding TOML support is straightforward with it (see here).

sveyret avatar Feb 25 '20 12:02 sveyret

Just checking if there is any new opinions on this, I also need TOML and I'd reckon at this point it's caught some more traction enough to justify it as part of default loaders.

seivan avatar Apr 08 '21 23:04 seivan

Sounds like a good idea. What's the go-to lightweight parser for this?

The apparently most popular parser, @iarna/toml, which prettier also seems to use, does not support the latest version of the spec.

d-fischer avatar Nov 13 '22 22:11 d-fischer