A linter for TOML files that can detect multiple errors using by tree-sitter parser
pip install git+https://github.com/yaegassy/toml-lint
# or
pipx install git+https://github.com/yaegassy/toml-lint
TODO: Publishing to PyPI
Currently, there is no library or linter that detects multiple errors in toml files. For example, tomllib/tomli
's loads function raises an exception and stops when it detects one error.
Therefore, I have created a linter that utilizes the "tree-sitter" parser to detect tree-error-nodes and executes the loads
function from tomllib/tomli
for each tree-error-node.
Furthermore, since there are errors that cannot be detected solely by the errors from the "tree-sitter" parser, I also execute the loads
function from tomllib/tomli
at the file level and combine the results.
$ toml-lint --help
usage: toml-lint [-h] [--version] [--stdin-filename STDIN_FILENAME] [filename]
A linter for TOML files that can detect multiple errors using by tree-sitter parser
positional arguments:
filename filename to be processed
options:
-h, --help show this help message and exit
--version print version
--stdin-filename STDIN_FILENAME
name of the file when passing it through stdin
Examples:
- **FILE**: toml-lint input.toml
- **STDIN**: cat input.toml | toml-lint --stdin-filename input.toml -
TOML file with multiple errors:
[tool.ruff]
select = [
I" # <- There is one missing double quote.
]
[tool.black]
line-length = 79" # <- There are unnecessary double quotes present.
[tool.mypy]
ignore_missing_imports = True # <- The correct form is "true" in lowercase.
Execution result:
$ toml-lint input.toml
input.toml:3:3 error: Invalid value
input.toml:7:17 error: Expected newline or end of document after a statement
input.toml:10:26 error: Invalid value
Vim/Neovim:
toml-lint-editor-demo.mp4
MIT