mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Add $id to configuration schema, switch to version-specific repository links.
This commit is contained in:
parent
24ee072442
commit
316b0989c3
6 changed files with 36 additions and 33 deletions
|
@ -204,8 +204,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show library version
|
// Show library version
|
||||||
document.getElementById("version").textContent =
|
var version = markdownlint.getVersion();
|
||||||
"(v" + markdownlint.getVersion() + ")";
|
document.getElementById("version").textContent = "(v" + version + ")";
|
||||||
|
|
||||||
// Add event listeners
|
// Add event listeners
|
||||||
document.body.addEventListener("dragover", onDragOver);
|
document.body.addEventListener("dragover", onDragOver);
|
||||||
|
@ -227,7 +227,7 @@
|
||||||
"Content gets parsed and displayed in the upper-right box; rule violations (if any) show up in the lower-right box.",
|
"Content gets parsed and displayed in the upper-right box; rule violations (if any) show up in the lower-right box.",
|
||||||
"Click a violation for information about it or click its line number to highlighted it in the lower-left box.",
|
"Click a violation for information about it or click its line number to highlighted it in the lower-left box.",
|
||||||
"",
|
"",
|
||||||
"> *Note*: [All rules](https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md) are enabled except [MD013/line-length](https://github.com/DavidAnson/markdownlint/blob/main/doc/md013.md).",
|
"> *Note*: [All rules](https://github.com/DavidAnson/markdownlint/blob/v" + version + "/doc/Rules.md) are enabled except [MD013/line-length](https://github.com/DavidAnson/markdownlint/blob/v" + version + "/doc/md013.md).",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"#### Resources",
|
"#### Resources",
|
||||||
|
|
|
@ -62,9 +62,9 @@ See also: [`markdownlint` built-in rule implementations][lib].
|
||||||
*None* - The entire body of code is tested to 100% coverage by the core
|
*None* - The entire body of code is tested to 100% coverage by the core
|
||||||
`markdownlint` project, so there are no additional tests here.
|
`markdownlint` project, so there are no additional tests here.
|
||||||
|
|
||||||
[custom-rules]: https://github.com/DavidAnson/markdownlint/blob/main/doc/CustomRules.md
|
[custom-rules]: https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/CustomRules.md
|
||||||
[jsdoc]: https://en.m.wikipedia.org/wiki/JSDoc
|
[jsdoc]: https://en.m.wikipedia.org/wiki/JSDoc
|
||||||
[lib]: https://github.com/DavidAnson/markdownlint/tree/main/lib
|
[lib]: https://github.com/DavidAnson/markdownlint/tree/v0.32.1/lib
|
||||||
[markdown]: https://en.wikipedia.org/wiki/Markdown
|
[markdown]: https://en.wikipedia.org/wiki/Markdown
|
||||||
[markdownlint]: https://github.com/DavidAnson/markdownlint
|
[markdownlint]: https://github.com/DavidAnson/markdownlint
|
||||||
[rules]: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md
|
[rules]: https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/Rules.md
|
||||||
|
|
8
lib/configuration.d.ts
vendored
8
lib/configuration.d.ts
vendored
|
@ -6,6 +6,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export interface Configuration {
|
export interface Configuration {
|
||||||
|
/**
|
||||||
|
* JSON Schema URI (expected by some editors)
|
||||||
|
*/
|
||||||
|
$schema?: string;
|
||||||
/**
|
/**
|
||||||
* Default state for all rules
|
* Default state for all rules
|
||||||
*/
|
*/
|
||||||
|
@ -14,10 +18,6 @@ export interface Configuration {
|
||||||
* Path to configuration file to extend
|
* Path to configuration file to extend
|
||||||
*/
|
*/
|
||||||
extends?: string | null;
|
extends?: string | null;
|
||||||
/**
|
|
||||||
* JSON Schema URI (used by some editors)
|
|
||||||
*/
|
|
||||||
$schema?: string;
|
|
||||||
/**
|
/**
|
||||||
* MD001/heading-increment : Heading levels should only increment by one level at a time : https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/md001.md
|
* MD001/heading-increment : Heading levels should only increment by one level at a time : https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/md001.md
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -7,13 +7,22 @@ const path = require("node:path");
|
||||||
/** @type {import("../lib/markdownlint").Rule[]} */
|
/** @type {import("../lib/markdownlint").Rule[]} */
|
||||||
const rules = require("../lib/rules");
|
const rules = require("../lib/rules");
|
||||||
const jsonSchemaToTypeScript = require("json-schema-to-typescript");
|
const jsonSchemaToTypeScript = require("json-schema-to-typescript");
|
||||||
|
const { version } = require("../lib/constants");
|
||||||
|
|
||||||
|
const schemaUri = `https://raw.githubusercontent.com/DavidAnson/markdownlint/v${version}/schema/markdownlint-config-schema.json`;
|
||||||
|
|
||||||
// Schema scaffolding
|
// Schema scaffolding
|
||||||
const schema = {
|
const schema = {
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||||
|
"$id": schemaUri,
|
||||||
"title": "markdownlint configuration schema",
|
"title": "markdownlint configuration schema",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"$schema": {
|
||||||
|
"description": "JSON Schema URI (expected by some editors)",
|
||||||
|
"type": "string",
|
||||||
|
"default": schemaUri
|
||||||
|
},
|
||||||
"default": {
|
"default": {
|
||||||
"description": "Default state for all rules",
|
"description": "Default state for all rules",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
@ -26,12 +35,6 @@ const schema = {
|
||||||
"null"
|
"null"
|
||||||
],
|
],
|
||||||
"default": null
|
"default": null
|
||||||
},
|
|
||||||
"$schema": {
|
|
||||||
"description": "JSON Schema URI (used by some editors)",
|
|
||||||
"type": "string",
|
|
||||||
"default": "https://raw.githubusercontent.com/DavidAnson/markdownlint" +
|
|
||||||
"/main/schema/markdownlint-config-schema.json"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": {
|
"additionalProperties": {
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
{
|
{
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||||
|
"$id": "https://raw.githubusercontent.com/DavidAnson/markdownlint/v0.32.1/schema/markdownlint-config-schema.json",
|
||||||
"title": "markdownlint configuration schema",
|
"title": "markdownlint configuration schema",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"$schema": {
|
||||||
|
"description": "JSON Schema URI (expected by some editors)",
|
||||||
|
"type": "string",
|
||||||
|
"default": "https://raw.githubusercontent.com/DavidAnson/markdownlint/v0.32.1/schema/markdownlint-config-schema.json"
|
||||||
|
},
|
||||||
"default": {
|
"default": {
|
||||||
"description": "Default state for all rules",
|
"description": "Default state for all rules",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
@ -16,11 +22,6 @@
|
||||||
],
|
],
|
||||||
"default": null
|
"default": null
|
||||||
},
|
},
|
||||||
"$schema": {
|
|
||||||
"description": "JSON Schema URI (used by some editors)",
|
|
||||||
"type": "string",
|
|
||||||
"default": "https://raw.githubusercontent.com/DavidAnson/markdownlint/main/schema/markdownlint-config-schema.json"
|
|
||||||
},
|
|
||||||
"MD001": {
|
"MD001": {
|
||||||
"description": "MD001/heading-increment : Heading levels should only increment by one level at a time : https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/md001.md",
|
"description": "MD001/heading-increment : Heading levels should only increment by one level at a time : https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/md001.md",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
|
|
@ -20,10 +20,9 @@ const configSchema = require("../schema/markdownlint-config-schema.json");
|
||||||
|
|
||||||
const deprecatedRuleNames = new Set(constants.deprecatedRuleNames);
|
const deprecatedRuleNames = new Set(constants.deprecatedRuleNames);
|
||||||
const jsonSchemaVersion = "http://json-schema.org/draft-07/schema#";
|
const jsonSchemaVersion = "http://json-schema.org/draft-07/schema#";
|
||||||
const configSchemaUri = "https://example.com/configSchema";
|
|
||||||
const configSchemaStrictUri = "https://example.com/configSchemaStrict";
|
|
||||||
const configSchemaStrict = {
|
const configSchemaStrict = {
|
||||||
...configSchema,
|
...configSchema,
|
||||||
|
"$id": `${configSchema.$id}-strict`,
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -918,8 +917,8 @@ test("validateJsonUsingConfigSchemaStrict", async(t) => {
|
||||||
t.plan(171);
|
t.plan(171);
|
||||||
const { addSchema, validate } =
|
const { addSchema, validate } =
|
||||||
await import("@hyperjump/json-schema/draft-07");
|
await import("@hyperjump/json-schema/draft-07");
|
||||||
addSchema(configSchemaStrict, configSchemaStrictUri);
|
addSchema(configSchemaStrict);
|
||||||
const validateConfigSchema = await validate(configSchemaStrictUri);
|
const validateConfigSchema = await validate(configSchemaStrict.$id);
|
||||||
const configRe =
|
const configRe =
|
||||||
/^[\s\S]*<!-- markdownlint-configure-file ([\s\S]*) -->[\s\S]*$/;
|
/^[\s\S]*<!-- markdownlint-configure-file ([\s\S]*) -->[\s\S]*$/;
|
||||||
const ignoreFiles = new Set([
|
const ignoreFiles = new Set([
|
||||||
|
@ -956,8 +955,8 @@ test("validateConfigSchemaAllowsUnknownProperties", async(t) => {
|
||||||
t.plan(4);
|
t.plan(4);
|
||||||
const { addSchema, validate } =
|
const { addSchema, validate } =
|
||||||
await import("@hyperjump/json-schema/draft-07");
|
await import("@hyperjump/json-schema/draft-07");
|
||||||
addSchema(configSchema, configSchemaUri);
|
addSchema(configSchema);
|
||||||
addSchema(configSchemaStrict, configSchemaStrictUri);
|
addSchema(configSchemaStrict);
|
||||||
const testCases = [
|
const testCases = [
|
||||||
{
|
{
|
||||||
"property": true
|
"property": true
|
||||||
|
@ -971,14 +970,14 @@ test("validateConfigSchemaAllowsUnknownProperties", async(t) => {
|
||||||
for (const testCase of testCases) {
|
for (const testCase of testCases) {
|
||||||
const defaultResult =
|
const defaultResult =
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
await validate(configSchemaUri, testCase, "BASIC");
|
await validate(configSchema.$id, testCase, "BASIC");
|
||||||
t.true(
|
t.true(
|
||||||
defaultResult.valid,
|
defaultResult.valid,
|
||||||
"Unknown property blocked by default: " + JSON.stringify(testCase)
|
"Unknown property blocked by default: " + JSON.stringify(testCase)
|
||||||
);
|
);
|
||||||
const strictResult =
|
const strictResult =
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
await validate(configSchemaStrictUri, testCase, "BASIC");
|
await validate(configSchemaStrict.$id, testCase, "BASIC");
|
||||||
t.false(
|
t.false(
|
||||||
strictResult.valid,
|
strictResult.valid,
|
||||||
"Unknown property allowed when strict: " + JSON.stringify(testCase)
|
"Unknown property allowed when strict: " + JSON.stringify(testCase)
|
||||||
|
@ -990,8 +989,8 @@ test("validateConfigSchemaAppliesToUnknownProperties", async(t) => {
|
||||||
t.plan(4);
|
t.plan(4);
|
||||||
const { addSchema, validate } =
|
const { addSchema, validate } =
|
||||||
await import("@hyperjump/json-schema/draft-07");
|
await import("@hyperjump/json-schema/draft-07");
|
||||||
addSchema(configSchema, configSchemaUri);
|
addSchema(configSchema);
|
||||||
const validateConfigSchema = await validate(configSchemaUri);
|
const validateConfigSchema = await validate(configSchema.$id);
|
||||||
for (const allowed of [ true, {} ]) {
|
for (const allowed of [ true, {} ]) {
|
||||||
t.true(
|
t.true(
|
||||||
validateConfigSchema({ "property": allowed }, "BASIC").valid,
|
validateConfigSchema({ "property": allowed }, "BASIC").valid,
|
||||||
|
@ -1024,8 +1023,8 @@ test("validateConfigExampleJson", async(t) => {
|
||||||
"utf8"
|
"utf8"
|
||||||
);
|
);
|
||||||
const jsonObject = JSON.parse(stripJsonComments(dataJson));
|
const jsonObject = JSON.parse(stripJsonComments(dataJson));
|
||||||
addSchema(configSchemaStrict, configSchemaStrictUri);
|
addSchema(configSchemaStrict);
|
||||||
const result = await validate(configSchemaStrictUri, jsonObject, "BASIC");
|
const result = await validate(configSchemaStrict.$id, jsonObject, "BASIC");
|
||||||
t.true(
|
t.true(
|
||||||
result.valid,
|
result.valid,
|
||||||
`${fileJson}\n${JSON.stringify(result, null, 2)}`
|
`${fileJson}\n${JSON.stringify(result, null, 2)}`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue