mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 01:05:55 +03:00
[GH-ISSUE #687] "Cannot read or parse config file" using .jsonc with comments #2357
Labels
No labels
bug
enhancement
enhancement
enhancement
fixed in next
fixed in next
fixed in next
new rule
new rule
new rule
pull-request
question
refactoring
refactoring
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/markdownlint#2357
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @aguynamedben on GitHub (Dec 21, 2022).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/687
Hi, I'm new to this library and think I've found a bug where parsing the .jsonc config file breaks if comments are present in the .jsonc file.
If .markdownlint.jsonc is:
I get
but if comments are removed from .markdownlint.jsonc, and it's
Things work as expected, without the JSON parsing error

Isn't the whole point of .jsonc to allow comments?
Versions:

@aguynamedben commented on GitHub (Dec 21, 2022):
Hmm... okay the problem seems to be the trailing commas. This works:
I still find the output surprising. Trailing commas cause a seemingly "bad lint result" instead of just a "couldn't lint because your config file isn't right!" message. Maybe an improvement would be to just stop altogether if the config file isn't parsed correctly. Right now it seems to attempt to continue and dump a bunch of output to stdout. I'd be less surprised if the parsing just stopped at the JSON parse problem.
@DavidAnson commented on GitHub (Dec 22, 2022):
As you note, the original example was invalid due to the trailing comma. For the unexpected CLI behavior, please open an issue in the corresponding repo if there isn't already something relevant: https://github.com/igorshubovych/markdownlint-cli