4 ms·
YAMLLint is nice for this use case. https://github.com/adrienverge/yamllint https://github.com/adrienverge/yamllint It can be configured to require strict str
by tedmiston 7y ago
YAMLLint is nice for this use case.
https://github.com/adrienverge/yamllint https://github.com/adrienverge/yamllint
It can be configured to require strict string quoting.
https://yamllint.readthedocs.io/en/stable/rules.html#module-yamllint.rules.quoted_strings https://yamllint.readthedocs.io/en/stable/rules.html#module-...
And to explicitly restrict bools to only `true` and `false`.
https://yamllint.readthedocs.io/en/stable/rules.html#module-yamllint.rules.truthy https://yamllint.readthedocs.io/en/stable/rules.html#module-...
- BiteCode_dev 7y agoIf you need a linter for you conf file, something is wrong.
- cuddlecake 7y agoIs there some correlation between wrongness of conf files, and the usage of a linter?
- grogenaut 7y agoWe have schemas for some of our configs which is a level beyond linting. Trying to spread this more and more. Removes some classes of load errors with services. Trying to get to almost jsonschema level without the complexity of specification and reuse with the actual code
- brunoborges 7y agoJSON Spec for YAML files is neither ideal as there is no standard way to indicate, within the YAML file itself, which JSON schema to be read by parsers and editors to validate the document. Sorry, but YAML is a disaster and YAML Lint and JSON Schema are weak attempts to improve it. I'd be happy if YAML evolved to a true schema support, use of brackets or some other tip so white space wouldn't be meaningful, and silly things removed like three hundred ways to define Boolean values.
- carlisle_ 7y agoOr you're just conceding that software is imperfect and trying to make it as error free as possible is the objective.
- beart 7y agoWhy? Everything should be linted and validated. If it's in the repository, then it's "code".
- AnonymousPlanet 7y agoIf it's a config file, chances are it's not in your repo but at the customer's site. Are you going to ship the linter to production too?
- solarkraft 7y agoShouldn't the customer either be competent at configuring the system themselves or let somebody else do it (who will then ensure that the config is valid)? Edit: I suppose you mean that the config format should be "user friendly". I guess it should, but I have personally had far fewer problems with YAML than with TOML.
- nunez 7y agoI disagree. XML and JSON both have linters, and correctly so ; they are complex.
- viklove 7y agoXML is way worse. An errant tab can totally screw over your config with no warnings. I've never needed a linter or had much trouble with JSON, explicit delimiters go a along way.
- Thiez 7y agoWhat? How? Tabs don't affect how xml is parsed. In fact it's rather tricky to have significant whitespace in an xml document.