mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Convert markdownlint library to an ECMAScript module, replace markdownlint-micromark with micromark, stop publishing (large) markdownlint-browser.js, see https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c for guidance.
This commit is contained in:
parent
191226f070
commit
1e71f6f44e
140 changed files with 1087 additions and 10428 deletions
|
|
@ -1,36 +0,0 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const js = require("@eslint/js");
|
||||
const eslint = require("eslint");
|
||||
const linter = new eslint.Linter();
|
||||
const languageJavaScript = /js|javascript/i;
|
||||
|
||||
/** @type import("../../lib/markdownlint").Rule */
|
||||
module.exports = {
|
||||
"names": [ "lint-javascript" ],
|
||||
"description": "Rule that lints JavaScript code",
|
||||
"tags": [ "test", "lint", "javascript" ],
|
||||
"parser": "markdownit",
|
||||
"function": (params, onError) => {
|
||||
const fences = params.parsers.markdownit.tokens
|
||||
.filter((token) => token.type === "fence");
|
||||
for (const fence of fences) {
|
||||
if (languageJavaScript.test(fence.info)) {
|
||||
const results = linter.verify(fence.content, js.configs.recommended);
|
||||
for (const result of results) {
|
||||
const lineNumber = fence.lineNumber + result.line;
|
||||
onError({
|
||||
"lineNumber": lineNumber,
|
||||
"detail": result.message,
|
||||
"context": params.lines[lineNumber - 1]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
// Unsupported by this sample:
|
||||
// "code_block": language unknown
|
||||
// "code_inline": too brief
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue