mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 17:26:22 +03:00
[GH-ISSUE #1397] .markdownlint.jsonc config json-schema.org schema: allow trailing commas #2526
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#2526
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 @jimmy-zhening-luo on GitHub (Oct 31, 2024).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/1397
Problem Statement
.markdownlint.jsoncfile inVSCode.$schemaas good practice:markdownlinthappily accepts a.jsoncconfig with trailing commas.Expected
VSCode does not show any warning about trailing commas.
Actual
VSCode shows warnings about trailing commas.
Mitigation
.markdownlint.jsonc, comment out$schemafield:jsoncfile unless told otherwise by a$schema. To allow commas unles told otherwise by a$schema, add this to your VSCode user or workspacesettings.json:Voila!
And, miraculously, VSCode still validates schema even without
$schema, either because of DavidAnson's extension is smartly doing some file association, or because VSCode Markdown Language Support is auto-magic (I haven't checked yet 😅, but I'm assuming the former because anyone fastidious enough to ship ajson-schema.orgschema would probably do that).Proposed Change
Create a
json-schema.orgschema for.markdownlint.jsoncwith{ "allowTrailingCommas": true }.Rationale
When a
$schemais specified in a JSONC object, VScode treats that schema as the source of truth. Additionally, per Microsoft/VSCode#102061 (comment-656541600), VSCode will never allow trailing commas in a JSONC file unless that source of truth says{ "allowTrailingCommas": true }.N.B. Because
markdownlintalso supports.markdownlint.jsonconfigs (I think), perhaps this require a split between the.jsonand.jsoncschemas, where the.jsoncschema allows trailing commas (per observed behavior frommarkdownlint'sjsoncconfig parser), whereas a.jsonschema of course should never allow trailing commas.@DavidAnson commented on GitHub (Nov 1, 2024):
First off, thank you for a very well-written and documented issue! It is a pleasure to get issues where people have done their homework. :)
That said, there is already a discussion of this topic which explains why I do NOT think modifying the schema file is appropriate: https://github.com/DavidAnson/markdownlint-cli2/pull/270
That said, I agree that parsers should allow trailing commas for flexibility and that's why markdownlint handles with or without:
github.com/DavidAnson/markdownlint-cli2@da711fa8b3/parsers/jsonc-parse.js (L14)@jimmy-zhening-luo commented on GitHub (Nov 1, 2024):
Thank you for taking the time to respond!
I agree with your reasoning for not changing it and am actually starting to come around myself. In the meantime, it's beneficial to me that you decided to have your config parser gracefully handle with or without trailing commas. I'll close this request now since given the prior art I missed and since I agree with the prior resolution.
Thanks again, I'm a big fan of your work, you've made writing/editing/coding in Markdown sane in a way I haven't seen done elsewhere.
@DavidAnson commented on GitHub (Nov 1, 2024):
Cheers! :)