[GH-ISSUE #25] Suggestion: Add rules json schema #19

Closed
opened 2026-03-03 01:23:04 +03:00 by kerem · 3 comments
Owner

Originally created by @mizunashi-mana on GitHub (Jul 30, 2016).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/25

Such as:

var schema = require('markdownlint/rules-schema');

// use schema

From https://raw.githubusercontent.com/DavidAnson/vscode-markdownlint/master/config-schema.json

Originally created by @mizunashi-mana on GitHub (Jul 30, 2016). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/25 Such as: ``` js var schema = require('markdownlint/rules-schema'); // use schema ``` From https://raw.githubusercontent.com/DavidAnson/vscode-markdownlint/master/config-schema.json
kerem 2026-03-03 01:23:04 +03:00
Author
Owner

@DavidAnson commented on GitHub (Jul 30, 2016):

I created that schema because the VS Code extension vscode-markdownlint can use it to provide syntax highlighting in the editor (i.e., warning). How are you thinking to use the schema with markdownlint? Would you want to throw an exception if the user provides a config that isn't valid? My worry about that would be that it is too restrictive (i.e., error). For example, note that I use the unsupported comment key to add information to the sample styles: https://github.com/DavidAnson/markdownlint/blob/master/style/relaxed.json

I don't think I would want to block a valid user just because they had extra content in their JSON.

<!-- gh-comment-id:236382101 --> @DavidAnson commented on GitHub (Jul 30, 2016): I created that schema because the VS Code extension `vscode-markdownlint` can use it to provide syntax highlighting in the editor (i.e., warning). How are you thinking to use the schema with `markdownlint`? Would you want to throw an exception if the user provides a config that isn't valid? My worry about that would be that it is too restrictive (i.e., error). For example, note that I use the unsupported `comment` key to add information to the sample styles: https://github.com/DavidAnson/markdownlint/blob/master/style/relaxed.json I don't think I would want to block a valid user just because they had extra content in their JSON.
Author
Owner

@mizunashi-mana commented on GitHub (Jul 31, 2016):

For example, note that I use the unsupported comment key to add information to the sample styles: https://github.com/DavidAnson/markdownlint/blob/master/style/relaxed.json

In this case, json schema permits additional properties on default. So, this is not problem.
However, there might be problems in other cases.

Yet, I think the rules structure of markdownlint are more complexity than other linter config.
For markdownlint developers, we should provide validations.
json-schema is flexible and has many supports. For example, we can nest such as:

{
  "type": "object",
  "properties": {
     "rules": {
         "$ref": "rules.schema.json"
     }
  }
}

ref: https://spacetelescope.github.io/understanding-json-schema/structuring.html

And, related writers can choose best library that suits them from many libraries.

I think providing json schema, providing cost saving and flexible validations for markdownlint tool writers.

<!-- gh-comment-id:236424749 --> @mizunashi-mana commented on GitHub (Jul 31, 2016): > For example, note that I use the unsupported comment key to add information to the sample styles: https://github.com/DavidAnson/markdownlint/blob/master/style/relaxed.json In this case, json schema permits additional properties on default. So, this is not problem. However, there might be problems in other cases. Yet, I think the rules structure of `markdownlint` are more complexity than other linter config. For markdownlint developers, we should provide validations. json-schema is flexible and has many supports. For example, we can nest such as: ``` json { "type": "object", "properties": { "rules": { "$ref": "rules.schema.json" } } } ``` ref: https://spacetelescope.github.io/understanding-json-schema/structuring.html And, related writers can choose best library that suits them from many libraries. - https://github.com/geraintluff/tv4 - https://github.com/epoberezkin/ajv - https://github.com/tdegrunt/jsonschema - etc. I think providing json schema, providing cost saving and flexible validations for markdownlint tool writers.
Author
Owner

@DavidAnson commented on GitHub (Jul 31, 2016):

I think this could work as a new validateSchema option - if true, an exception is thrown for an invalid schema. I use tv4 in vscode-markdownlint, so it would be fairly straightforward to add.

However, I'm reluctant to introduce a new dependencies for something non-essential like this. :( (There's currently just one and it's the Markdown parser!) I'd worry less about using devDependencies, but I'm not sure that works for the scenario you have in mind.

I may need to think about this more.

<!-- gh-comment-id:236464076 --> @DavidAnson commented on GitHub (Jul 31, 2016): I think this could work as a new `validateSchema` option - if `true`, an exception is thrown for an invalid schema. I use `tv4` in `vscode-markdownlint`, so it would be fairly straightforward to add. However, I'm reluctant to introduce a new `dependencies` for something non-essential like this. :( (There's currently just one and it's the Markdown parser!) I'd worry less about using `devDependencies`, but I'm not sure that works for the scenario you have in mind. I may need to think about this more.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/markdownlint#19
No description provided.