mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
This commit is contained in:
parent
b3f0e529cf
commit
d4bfb633bb
7 changed files with 2192 additions and 73 deletions
|
|
@ -2106,6 +2106,7 @@ function getEffectiveConfig(ruleList, config, aliasToRuleNames) {
|
||||||
return key.toUpperCase() === "DEFAULT";
|
return key.toUpperCase() === "DEFAULT";
|
||||||
});
|
});
|
||||||
var ruleDefault = defaultKey.length === 0 || !!config[defaultKey[0]];
|
var ruleDefault = defaultKey.length === 0 || !!config[defaultKey[0]];
|
||||||
|
/** @type {Configuration} */
|
||||||
var effectiveConfig = {};
|
var effectiveConfig = {};
|
||||||
var _iterator14 = _createForOfIteratorHelper(ruleList),
|
var _iterator14 = _createForOfIteratorHelper(ruleList),
|
||||||
_step14;
|
_step14;
|
||||||
|
|
@ -3191,10 +3192,10 @@ module.exports = markdownlint;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration object for linting rules. For a detailed schema, see
|
* Configuration object for linting rules. For the JSON schema, see
|
||||||
* {@link ../schema/markdownlint-config-schema.json}.
|
* {@link ../schema/markdownlint-config-schema.json}.
|
||||||
*
|
*
|
||||||
* @typedef {Object.<string, RuleConfiguration>} Configuration
|
* @typedef {import("./configuration").Configuration} Configuration
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
1268
lib/configuration.d.ts
vendored
Normal file
1268
lib/configuration.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load diff
6
lib/markdownlint.d.ts
vendored
6
lib/markdownlint.d.ts
vendored
|
|
@ -358,12 +358,10 @@ type FixInfo = {
|
||||||
*/
|
*/
|
||||||
type LintContentCallback = (error: Error | null, result?: LintError[]) => void;
|
type LintContentCallback = (error: Error | null, result?: LintError[]) => void;
|
||||||
/**
|
/**
|
||||||
* Configuration object for linting rules. For a detailed schema, see
|
* Configuration object for linting rules. For the JSON schema, see
|
||||||
* {@link ../schema/markdownlint-config-schema.json}.
|
* {@link ../schema/markdownlint-config-schema.json}.
|
||||||
*/
|
*/
|
||||||
type Configuration = {
|
type Configuration = import("./configuration").Configuration;
|
||||||
[x: string]: RuleConfiguration;
|
|
||||||
};
|
|
||||||
/**
|
/**
|
||||||
* Rule configuration.
|
* Rule configuration.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -317,6 +317,7 @@ function getEffectiveConfig(ruleList, config, aliasToRuleNames) {
|
||||||
(key) => key.toUpperCase() === "DEFAULT"
|
(key) => key.toUpperCase() === "DEFAULT"
|
||||||
);
|
);
|
||||||
const ruleDefault = (defaultKey.length === 0) || !!config[defaultKey[0]];
|
const ruleDefault = (defaultKey.length === 0) || !!config[defaultKey[0]];
|
||||||
|
/** @type {Configuration} */
|
||||||
const effectiveConfig = {};
|
const effectiveConfig = {};
|
||||||
for (const rule of ruleList) {
|
for (const rule of ruleList) {
|
||||||
const ruleName = rule.names[0].toUpperCase();
|
const ruleName = rule.names[0].toUpperCase();
|
||||||
|
|
@ -1436,10 +1437,10 @@ module.exports = markdownlint;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration object for linting rules. For a detailed schema, see
|
* Configuration object for linting rules. For the JSON schema, see
|
||||||
* {@link ../schema/markdownlint-config-schema.json}.
|
* {@link ../schema/markdownlint-config-schema.json}.
|
||||||
*
|
*
|
||||||
* @typedef {Object.<string, RuleConfiguration>} Configuration
|
* @typedef {import("./configuration").Configuration} Configuration
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
"build-config": "npm run build-config-schema && npm run build-config-example",
|
"build-config": "npm run build-config-schema && npm run build-config-example",
|
||||||
"build-config-example": "node schema/build-config-example.js",
|
"build-config-example": "node schema/build-config-example.js",
|
||||||
"build-config-schema": "node schema/build-config-schema.js",
|
"build-config-schema": "node schema/build-config-schema.js",
|
||||||
"build-declaration": "tsc --allowJs --declaration --emitDeclarationOnly --module commonjs --resolveJsonModule --target es2015 lib/markdownlint.js && node scripts delete 'lib/{c,md,r}*.d.ts' 'micromark/*.d.cts' 'helpers/*.d.{cts,ts}'",
|
"build-declaration": "tsc --allowJs --declaration --emitDeclarationOnly --module commonjs --resolveJsonModule --target es2015 lib/markdownlint.js && node scripts delete 'lib/{cache,constants,md,r}*.d.ts' 'micromark/*.d.cts' 'helpers/*.d.{cts,ts}'",
|
||||||
"build-demo": "node scripts copy node_modules/markdown-it/dist/markdown-it.min.js demo/markdown-it.min.js && node scripts copy node_modules/markdownlint-micromark/micromark-browser.js demo/micromark-browser.js && node scripts copy node_modules/markdownlint-micromark/micromark-html-browser.js demo/micromark-html-browser.js && cd demo && webpack --no-stats",
|
"build-demo": "node scripts copy node_modules/markdown-it/dist/markdown-it.min.js demo/markdown-it.min.js && node scripts copy node_modules/markdownlint-micromark/micromark-browser.js demo/micromark-browser.js && node scripts copy node_modules/markdownlint-micromark/micromark-html-browser.js demo/micromark-html-browser.js && cd demo && webpack --no-stats",
|
||||||
"build-docs": "node doc-build/build-rules.mjs",
|
"build-docs": "node doc-build/build-rules.mjs",
|
||||||
"build-example": "npm install --no-save --ignore-scripts grunt grunt-cli gulp through2",
|
"build-example": "npm install --no-save --ignore-scripts grunt grunt-cli gulp through2",
|
||||||
|
|
@ -85,6 +85,7 @@
|
||||||
"gemoji": "8.1.0",
|
"gemoji": "8.1.0",
|
||||||
"globby": "13.2.2",
|
"globby": "13.2.2",
|
||||||
"js-yaml": "4.1.0",
|
"js-yaml": "4.1.0",
|
||||||
|
"json-schema-to-typescript": "13.1.1",
|
||||||
"markdown-it-for-inline": "0.1.1",
|
"markdown-it-for-inline": "0.1.1",
|
||||||
"markdown-it-sub": "1.0.0",
|
"markdown-it-sub": "1.0.0",
|
||||||
"markdown-it-sup": "1.0.0",
|
"markdown-it-sup": "1.0.0",
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,9 @@
|
||||||
|
|
||||||
const fs = require("node:fs");
|
const fs = require("node:fs");
|
||||||
const path = require("node:path");
|
const path = require("node:path");
|
||||||
|
/** @type {import("../lib/markdownlint").Rule[]} */
|
||||||
const rules = require("../lib/rules");
|
const rules = require("../lib/rules");
|
||||||
|
const jsonSchemaToTypeScript = require("json-schema-to-typescript");
|
||||||
|
|
||||||
// Schema scaffolding
|
// Schema scaffolding
|
||||||
const schema = {
|
const schema = {
|
||||||
|
|
@ -548,10 +550,12 @@ for (const rule of rules) {
|
||||||
scheme.type = [ "boolean", "object" ];
|
scheme.type = [ "boolean", "object" ];
|
||||||
scheme.additionalProperties = false;
|
scheme.additionalProperties = false;
|
||||||
}
|
}
|
||||||
for (const [ index, name ] of rule.names.entries()) {
|
for (const name of rule.names) {
|
||||||
schema.properties[name] = (index === 0) ? scheme : {
|
schema.properties[name] = scheme;
|
||||||
"$ref": `#/properties/${rule.names[0]}`
|
// Using $ref causes rule aliases not to get JSDoc comments
|
||||||
};
|
// schema.properties[name] = (index === 0) ? scheme : {
|
||||||
|
// "$ref": `#/properties/${rule.names[0]}`
|
||||||
|
// };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -568,3 +572,18 @@ for (const [ tag, tagTags ] of Object.entries(tags)) {
|
||||||
// Write schema
|
// Write schema
|
||||||
const schemaFile = path.join(__dirname, "markdownlint-config-schema.json");
|
const schemaFile = path.join(__dirname, "markdownlint-config-schema.json");
|
||||||
fs.writeFileSync(schemaFile, JSON.stringify(schema, null, " "));
|
fs.writeFileSync(schemaFile, JSON.stringify(schema, null, " "));
|
||||||
|
|
||||||
|
// Write TypeScript declaration
|
||||||
|
// See https://github.com/bcherny/json-schema-to-typescript/issues/356 for why
|
||||||
|
// additionalProperties is deleted
|
||||||
|
const schemaDeclaration =
|
||||||
|
path.join(__dirname, "..", "lib", "configuration.d.ts");
|
||||||
|
// @ts-ignore
|
||||||
|
delete schema.additionalProperties;
|
||||||
|
schema.title = "Configuration";
|
||||||
|
jsonSchemaToTypeScript.compile(
|
||||||
|
// @ts-ignore
|
||||||
|
schema,
|
||||||
|
"UNUSED"
|
||||||
|
// eslint-disable-next-line unicorn/prefer-top-level-await
|
||||||
|
).then((declaration) => fs.writeFileSync(schemaDeclaration, declaration));
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue