mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Add typings for Rule object to all Rule samples and examples.
This commit is contained in:
parent
cdc30b1279
commit
c287e49eac
11 changed files with 34 additions and 9 deletions
|
@ -54,6 +54,14 @@
|
|||
"object-property-newline": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"test/rules/**/*.js"
|
||||
],
|
||||
"rules": {
|
||||
"jsdoc/valid-types": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"**/*.mjs"
|
||||
|
|
|
@ -28,6 +28,7 @@ the parsed input and a function to log any violations.
|
|||
A simple rule implementation looks like:
|
||||
|
||||
```javascript
|
||||
/** @type import("markdownlint").Rule */
|
||||
module.exports = {
|
||||
"names": [ "any-blockquote" ],
|
||||
"description": "Rule that reports an error for any blockquote",
|
||||
|
|
|
@ -109,7 +109,7 @@ markdownlint(options, assertLintResultsCallback);
|
|||
assertLintResultsCallback(null, await markdownlint.promises.markdownlint(options));
|
||||
})();
|
||||
|
||||
const testRule = {
|
||||
const testRule: markdownlint.Rule = {
|
||||
"names": [ "test-rule" ],
|
||||
"description": "Test rule",
|
||||
"information": new URL("https://example.com/rule-information"),
|
||||
|
|
|
@ -24,6 +24,7 @@ be useful to custom rule authors and may avoid duplicating code.
|
|||
```javascript
|
||||
const { forEachLine, getLineMetadata } = require("markdownlint-rule-helpers");
|
||||
|
||||
/** @type import("markdownlint").Rule */
|
||||
module.exports = {
|
||||
"names": [ "every-n-lines" ],
|
||||
"description": "Rule that reports an error every N lines",
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
|
||||
const { filterTokens } = require("markdownlint-rule-helpers");
|
||||
|
||||
/** @typedef {import("../../lib/markdownlint").MarkdownItToken} MarkdownItToken */
|
||||
/** @typedef {(MarkdownItToken) => void} FilterTokensCallback */
|
||||
|
||||
/** @type import("../../lib/markdownlint").Rule */
|
||||
module.exports = {
|
||||
"names": [ "any-blockquote" ],
|
||||
"description": "Rule that reports an error for any blockquote",
|
||||
|
@ -13,13 +17,18 @@ module.exports = {
|
|||
),
|
||||
"tags": [ "test" ],
|
||||
"function": (params, onError) => {
|
||||
filterTokens(params, "blockquote_open", (blockquote) => {
|
||||
filterTokens(
|
||||
params,
|
||||
"blockquote_open",
|
||||
/** @type FilterTokensCallback */
|
||||
(blockquote) => {
|
||||
const lines = blockquote.map[1] - blockquote.map[0];
|
||||
onError({
|
||||
"lineNumber": blockquote.lineNumber,
|
||||
"detail": "Blockquote spans " + lines + " line(s).",
|
||||
"context": blockquote.line.substr(0, 7)
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
const { forEachLine, getLineMetadata } = require("markdownlint-rule-helpers");
|
||||
|
||||
/** @type import("../../lib/markdownlint").Rule */
|
||||
module.exports = {
|
||||
"names": [ "every-n-lines" ],
|
||||
"description": "Rule that reports an error every N lines",
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/** @type import("../../lib/markdownlint").Rule */
|
||||
module.exports = {
|
||||
"names": [ "first-line" ],
|
||||
"description": "Rule that reports an error for the first line",
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/** @type import("../../lib/markdownlint").Rule */
|
||||
module.exports = {
|
||||
"names": [ "letters-E-X", "letter-E-letter-X", "contains-ex" ],
|
||||
"description": "Rule that reports an error for lines with the letters 'EX'",
|
||||
|
|
|
@ -24,6 +24,7 @@ function cleanJsdocRulesFromEslintConfig(config) {
|
|||
return cleanedConfig;
|
||||
}
|
||||
|
||||
/** @type import("../../lib/markdownlint").Rule */
|
||||
module.exports = {
|
||||
"names": [ "lint-javascript" ],
|
||||
"description": "Rule that lints JavaScript code",
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/** @type import("../../../lib/markdownlint").Rule */
|
||||
module.exports = {
|
||||
"names": [ "sample-rule" ],
|
||||
"description": "Sample rule",
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
const { filterTokens } = require("markdownlint-rule-helpers");
|
||||
const { parse, printParseErrorCode } = require("jsonc-parser");
|
||||
|
||||
/** @type import("../../lib/markdownlint").Rule */
|
||||
module.exports = {
|
||||
"names": [ "validate-json" ],
|
||||
"description": "Rule that validates JSON code",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue