Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidAnson committed Nov 30, 2024
1 parent 772eb50 commit 9c5a877
Show file tree
Hide file tree
Showing 60 changed files with 82 additions and 23 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ function applyFixes(input, errors) { ... }
Invoking `applyFixes` with the results of a call to lint can be done like so:

```javascript
import markdownlint from "../lib/markdownlint.mjs";
import markdownlint from "markdownlint";

const fixResults = markdownlint.sync({ "strings": { "content": original } });
const fixed = markdownlint.applyFixes(original, fixResults.content);
Expand All @@ -809,7 +809,7 @@ const fixed = markdownlint.applyFixes(original, fixResults.content);
Invoke `markdownlint` and use the `result` object's `toString` method:

```javascript
import markdownlint from "../lib/markdownlint.mjs";
import markdownlint from "markdownlint";

const options = {
"files": [ "good.md", "bad.md" ],
Expand Down
2 changes: 1 addition & 1 deletion example/Gruntfile.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = function wrapper(grunt) {

grunt.registerMultiTask("markdownlint", function task() {
const done = this.async();
import("../lib/markdownlint.mjs").then(({ "default": markdownlint }) => {
import("markdownlint").then(({ "default": markdownlint }) => {
markdownlint(
{ "files": this.filesSrc },
function callback(err, result) {
Expand Down
2 changes: 1 addition & 1 deletion example/gulpfile.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const through2 = require("through2");
gulp.task("markdownlint", function task() {
return gulp.src("*.md", { "read": false })
.pipe(through2.obj(function obj(file, enc, next) {
import("../lib/markdownlint.mjs").then(({ "default": markdownlint }) => {
import("markdownlint").then(({ "default": markdownlint }) => {
markdownlint(
{ "files": [ file.relative ] },
function callback(err, result) {
Expand Down
2 changes: 1 addition & 1 deletion example/standalone.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check

import markdownlint from "../lib/markdownlint.mjs";
import markdownlint from "markdownlint";

const options = {
"files": [ "good.md", "bad.md" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md001.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { addErrorDetailIf } from "../helpers/helpers.cjs";
import { getHeadingLevel } from "../helpers/micromark-helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD001", "heading-increment" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md003.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { addErrorDetailIf } from "../helpers/helpers.cjs";
import { getHeadingLevel, getHeadingStyle } from "../helpers/micromark-helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD003", "heading-style" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md004.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const validStyles = new Set([
"plus",
"sublist"
]);

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD004", "ul-style" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md005.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { addError, addErrorDetailIf } from "../helpers/helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD005", "list-indent" ],
Expand Down
2 changes: 2 additions & 0 deletions lib/md007.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import { addErrorDetailIf } from "../helpers/helpers.cjs";
import { getParentOfType } from "../helpers/micromark-helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

/** @type {import("micromark-util-types").TokenType[]} */
const unorderedListTypes =
[ "blockQuotePrefix", "listItemPrefix", "listUnordered" ];
/** @type {import("micromark-util-types").TokenType[]} */
const unorderedParentTypes =
[ "blockQuote", "listOrdered", "listUnordered" ];

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD007", "ul-indent" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md009.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { addError } from "../helpers/helpers.cjs";
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD009", "no-trailing-spaces" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md010.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

const tabRe = /\t+/g;

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD010", "no-hard-tabs" ],
Expand Down
4 changes: 2 additions & 2 deletions lib/md011.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { addError, hasOverlap } from "../helpers/helpers.cjs";
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

const reversedLinkRe =
/(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)\](?!\()/g;
const reversedLinkRe = /(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)\](?!\()/g;

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD011", "no-reversed-links" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md012.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { addErrorDetailIf } from "../helpers/helpers.cjs";
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD012", "no-multiple-blanks" ],
Expand Down
4 changes: 4 additions & 0 deletions lib/md013.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ const longLineRePrefix = "^.{";
const longLineRePostfixRelaxed = "}.*\\s.*$";
const longLineRePostfixStrict = "}.+$";
const sternModeRe = /^(?:[#>\s]*\s)?\S*$/;

/** @typedef {import("micromark-extension-gfm-autolink-literal")} */
/** @typedef {import("micromark-extension-gfm-table")} */

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD013", "line-length" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md014.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { addErrorContext } from "../helpers/helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

const dollarCommandRe = /^(\s*)(\$\s+)/;

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD014", "commands-show-output" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md018.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { addErrorContext } from "../helpers/helpers.cjs";
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD018", "no-missing-space-atx" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md019-md021.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function validateHeadingSpaces(onError, heading, delta) {
);
}
}

/** @type {import("./markdownlint.mjs").Rule[]} */
export default [
{
Expand Down
1 change: 1 addition & 0 deletions lib/md020.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { addErrorContext } from "../helpers/helpers.cjs";
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD020", "no-missing-space-closed-atx" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md022.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const getLinesFunction = (linesParam) => {
const lines = (linesParam === undefined) ? defaultLines : Number(linesParam);
return () => lines;
};

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD022", "blanks-around-headings" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md023.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { addErrorContext } from "../helpers/helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD023", "heading-start-left" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md024.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { addErrorContext } from "../helpers/helpers.cjs";
import { getHeadingLevel, getHeadingText } from "../helpers/micromark-helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD024", "no-duplicate-heading" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md025.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { addErrorContext, frontMatterHasTitle } from "../helpers/helpers.cjs";
import { getHeadingLevel, getHeadingText } from "../helpers/micromark-helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD025", "single-title", "single-h1" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md026.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { addError, allPunctuationNoQuestion, endOfLineGemojiCodeRe,
endOfLineHtmlEntityRe, escapeForRegExp } from "../helpers/helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD026", "no-trailing-punctuation" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md027.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { addErrorContext } from "../helpers/helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD027", "no-multiple-space-blockquote" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md028.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { addError } from "../helpers/helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

const ignoreTypes = new Set([ "lineEnding", "listItemIndent", "linePrefix" ]);

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD028", "no-blanks-blockquote" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md029.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const listStyleExamples = {
function getOrderedListItemValue(listItemPrefix) {
return Number(getDescendantsByType(listItemPrefix, [ "listItemValue" ])[0].text);
}

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD029", "ol-prefix" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md030.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { addErrorDetailIf } from "../helpers/helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD030", "list-marker-space" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md031.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function addError(onError, lines, lineNumber, top) {
fixInfo
);
}

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD031", "blanks-around-fences" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md032.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { filterByTypesCached } from "./cache.mjs";
const isList = (token) => (
(token.type === "listOrdered") || (token.type === "listUnordered")
);

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD032", "blanks-around-lists" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md033.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { addError, nextLinesRe } from "../helpers/helpers.cjs";
import { getHtmlTagInfo } from "../helpers/micromark-helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD033", "no-inline-html" ],
Expand Down
3 changes: 3 additions & 0 deletions lib/md034.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import { addErrorContext } from "../helpers/helpers.cjs";
import { filterByPredicate, getHtmlTagInfo, inHtmlFlow } from "../helpers/micromark-helpers.cjs";

/** @typedef {import("micromark-extension-gfm-autolink-literal")} */

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD034", "no-bare-urls" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md035.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { addErrorDetailIf } from "../helpers/helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD035", "hr-style" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md036.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const emphasisTypes = [
[ "emphasis", "emphasisText" ],
[ "strong", "strongText" ]
];

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD036", "no-emphasis-as-heading" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md037.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { addError } from "../helpers/helpers.cjs";
import { filterByPredicate, inHtmlFlow } from "../helpers/micromark-helpers.cjs";

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD037", "no-space-in-emphasis" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md038.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const trimCodeText = (text, start, end) => {
}
return text;
};

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD038", "no-space-in-code" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md039.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function addLabelSpaceError(onError, label, labelText, isStart) {
function validLink(label, labelText, definitions) {
return (label.parent?.children.length !== 1) || definitions.has(labelText.text.trim());
}

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD039", "no-space-in-links" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md040.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { addError, addErrorContext } from "../helpers/helpers.cjs";
import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD040", "fenced-code-language" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md041.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { addErrorContext, frontMatterHasTitle } from "../helpers/helpers.cjs";
import { filterByTypes, getHeadingLevel, getHtmlTagInfo, isHtmlFlowComment, nonContentTokens } from "../helpers/micromark-helpers.cjs";

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD041", "first-line-heading", "first-line-h1" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md042.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { addErrorContext } from "../helpers/helpers.cjs";
import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
import { getReferenceLinkImageData, filterByTypesCached } from "./cache.mjs";

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD042", "no-empty-links" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md043.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { addErrorContext, addErrorDetailIf } from "../helpers/helpers.cjs";
import { getHeadingLevel, getHeadingText } from "../helpers/micromark-helpers.cjs";
import { filterByTypesCached } from "./cache.mjs";

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD043", "required-headings" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md044.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { parse } from "../helpers/micromark-parse.mjs";
const ignoredChildTypes = new Set(
[ "codeFencedFence", "definition", "reference", "resource" ]
);

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD044", "proper-names" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md045.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getHtmlTagInfo, getDescendantsByType } from "../helpers/micromark-helpe
import { filterByTypesCached } from "./cache.mjs";

const altRe = getHtmlAttributeRe("alt");

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD045", "no-alt-text" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md046.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const tokenTypeToStyle = {
"codeFenced": "fenced",
"codeIndented": "indented"
};

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD046", "code-block-style" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md047.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @ts-check

import { addError, isBlankLine } from "../helpers/helpers.cjs";

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD047", "single-trailing-newline" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md048.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function fencedCodeBlockStyleFor(markup) {
return "backtick";
}
};

/** @type {import("./markdownlint.mjs").Rule} */
export default {
"names": [ "MD048", "code-fence-style" ],
Expand Down
1 change: 1 addition & 0 deletions lib/md049-md050.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const impl =
}
}
};

/** @type {import("./markdownlint.mjs").Rule[]} */
export default [
{
Expand Down
Loading

0 comments on commit 9c5a877

Please sign in to comment.