mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-21 21:30:47 +02: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
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
|
@ -30,11 +30,3 @@ jobs:
|
|||
run: npm install --no-package-lock
|
||||
- name: Run CI Tests
|
||||
run: npm run ci
|
||||
- name: Install markdownlint-micromark Dependencies
|
||||
run: npm run install-micromark
|
||||
- name: Build markdownlint-micromark
|
||||
run: npm run build-micromark
|
||||
- name: Install local markdownlint-micromark
|
||||
run: npm install --no-package-lock ./micromark
|
||||
- name: Test with local markdownlint-micromark
|
||||
run: npm test
|
||||
|
|
9
.gitignore
vendored
9
.gitignore
vendored
|
@ -1,14 +1,7 @@
|
|||
coverage
|
||||
demo/markdown-it.min.js
|
||||
demo/markdownlint-browser.js
|
||||
demo/markdownlint-browser.min.js
|
||||
demo/micromark-browser.js
|
||||
demo/micromark-html-browser.js
|
||||
micromark/micromark.cjs
|
||||
micromark/micromark.dev.cjs
|
||||
micromark/micromark-browser.js
|
||||
micromark/micromark-browser.dev.js
|
||||
micromark/micromark-html-browser.js
|
||||
micromark/micromark-html-browser.dev.js
|
||||
node_modules
|
||||
!test/node_modules
|
||||
npm-debug.log
|
||||
|
|
|
@ -5,13 +5,11 @@
|
|||
.vscode
|
||||
coverage
|
||||
demo/*
|
||||
!demo/markdownlint-browser.js
|
||||
doc-build
|
||||
eslint.config.mjs
|
||||
example
|
||||
micromark
|
||||
npm-debug.log
|
||||
schema/*.js
|
||||
schema/*.mjs
|
||||
scripts
|
||||
test
|
||||
test-repos
|
||||
|
|
20
README.md
20
README.md
|
@ -798,12 +798,10 @@ function applyFixes(input, errors) { ... }
|
|||
Invoking `applyFixes` with the results of a call to lint can be done like so:
|
||||
|
||||
```javascript
|
||||
const { "sync": markdownlintSync, applyFixes } = require("markdownlint");
|
||||
import markdownlint from "markdownlint";
|
||||
|
||||
function fixMarkdownlintViolations(content) {
|
||||
const fixResults = markdownlintSync({ strings: { content } });
|
||||
return applyFixes(content, fixResults.content);
|
||||
}
|
||||
const fixResults = markdownlint.sync({ "strings": { "content": original } });
|
||||
const fixed = markdownlint.applyFixes(original, fixResults.content);
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
@ -811,7 +809,7 @@ function fixMarkdownlintViolations(content) {
|
|||
Invoke `markdownlint` and use the `result` object's `toString` method:
|
||||
|
||||
```javascript
|
||||
const markdownlint = require("markdownlint");
|
||||
import markdownlint from "markdownlint";
|
||||
|
||||
const options = {
|
||||
"files": [ "good.md", "bad.md" ],
|
||||
|
@ -897,10 +895,10 @@ Output:
|
|||
```
|
||||
|
||||
Integration with the [gulp](https://gulpjs.com/) build system is
|
||||
straightforward: [`gulpfile.js`](example/gulpfile.js).
|
||||
straightforward: [`gulpfile.cjs`](example/gulpfile.cjs).
|
||||
|
||||
Integration with the [Grunt](https://gruntjs.com/) build system is similar:
|
||||
[`Gruntfile.js`](example/Gruntfile.js).
|
||||
[`Gruntfile.cjs`](example/Gruntfile.cjs).
|
||||
|
||||
## Browser
|
||||
|
||||
|
@ -912,11 +910,9 @@ Generate normal and minified scripts with:
|
|||
npm run build-demo
|
||||
```
|
||||
|
||||
Then reference `markdownlint` and `micromark` scripts:
|
||||
Then reference the `markdownlint` script:
|
||||
|
||||
```html
|
||||
<script src="demo/micromark-browser.js"></script>
|
||||
<script src="demo/micromark-html-browser.js"></script>
|
||||
<script src="demo/markdownlint-browser.min.js"></script>
|
||||
```
|
||||
|
||||
|
@ -928,7 +924,7 @@ const options = {
|
|||
"content": "Some Markdown to lint."
|
||||
}
|
||||
};
|
||||
const results = window.markdownlint.sync(options).toString();
|
||||
const results = window.markdownlint.markdownlint.sync(options).toString();
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
|
9
demo/browser-exports.mjs
Normal file
9
demo/browser-exports.mjs
Normal file
|
@ -0,0 +1,9 @@
|
|||
// @ts-check
|
||||
|
||||
export { default as markdownlint } from "../lib/markdownlint.mjs";
|
||||
export { compile, parse, postprocess, preprocess } from "micromark";
|
||||
export { directive, directiveHtml } from "micromark-extension-directive";
|
||||
export { gfmAutolinkLiteral, gfmAutolinkLiteralHtml } from "micromark-extension-gfm-autolink-literal";
|
||||
export { gfmFootnote, gfmFootnoteHtml } from "micromark-extension-gfm-footnote";
|
||||
export { gfmTable, gfmTableHtml } from "micromark-extension-gfm-table";
|
||||
export { math, mathHtml } from "micromark-extension-math";
|
|
@ -34,8 +34,6 @@
|
|||
</div>
|
||||
</div>
|
||||
<script src="markdown-it.min.js"></script>
|
||||
<script src="micromark-browser.js"></script>
|
||||
<script src="micromark-html-browser.js"></script>
|
||||
<script src="markdownlint-browser.min.js"></script>
|
||||
<script src="default.js"></script>
|
||||
</body>
|
||||
|
|
|
@ -3,9 +3,8 @@
|
|||
(function main() {
|
||||
// Dependencies
|
||||
var markdownit = globalThis.markdownit;
|
||||
var markdownlint = globalThis.markdownlint.library;
|
||||
var micromark = globalThis.micromarkBrowser;
|
||||
var micromarkHtml = globalThis.micromarkHtmlBrowser;
|
||||
var markdownlint = globalThis.markdownlint.markdownlint;
|
||||
var micromark = globalThis.markdownlint;
|
||||
|
||||
// DOM elements
|
||||
var markdown = document.getElementById("markdown");
|
||||
|
@ -70,15 +69,15 @@
|
|||
const compileOptions = {
|
||||
"allowDangerousHtml": true,
|
||||
"htmlExtensions": [
|
||||
micromarkHtml.directiveHtml({ "*": handleDirective }),
|
||||
micromarkHtml.gfmAutolinkLiteralHtml(),
|
||||
micromarkHtml.gfmFootnoteHtml(),
|
||||
micromarkHtml.gfmTableHtml(),
|
||||
micromarkHtml.mathHtml()
|
||||
micromark.directiveHtml({ "*": handleDirective }),
|
||||
micromark.gfmAutolinkLiteralHtml(),
|
||||
micromark.gfmFootnoteHtml(),
|
||||
micromark.gfmTableHtml(),
|
||||
micromark.mathHtml()
|
||||
]
|
||||
};
|
||||
try {
|
||||
return micromarkHtml.compile(compileOptions)(events);
|
||||
return micromark.compile(compileOptions)(events);
|
||||
} catch (error) {
|
||||
return `[Exception: "${error}"]`;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,8 +0,0 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
"library": require(".."),
|
||||
"helpers": require("../helpers")
|
||||
};
|
8
demo/module-stub.cjs
Normal file
8
demo/module-stub.cjs
Normal file
|
@ -0,0 +1,8 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
// @ts-ignore
|
||||
"createRequire": () => require
|
||||
};
|
|
@ -1,11 +1,14 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const webpack = require("webpack");
|
||||
const TerserPlugin = require("terser-webpack-plugin");
|
||||
import { createRequire } from "node:module";
|
||||
const require = createRequire(import.meta.url);
|
||||
import webpack from "webpack";
|
||||
import TerserPlugin from "terser-webpack-plugin";
|
||||
import { __dirname, importWithTypeJson } from "../test/esm-helpers.mjs";
|
||||
const libraryPackageJson = await importWithTypeJson(import.meta, "../package.json");
|
||||
const nodeModulePrefixRe = /^node:/u;
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-jsdoc
|
||||
function config(options) {
|
||||
const { entry, filename, mode, optimization, packageJson } = options;
|
||||
const { name, version, homepage, license } = packageJson;
|
||||
|
@ -13,8 +16,7 @@ function config(options) {
|
|||
"devtool": false,
|
||||
"entry": entry,
|
||||
"externals": {
|
||||
"markdown-it": "markdownit",
|
||||
"markdownlint-micromark": "micromarkBrowser"
|
||||
"markdown-it": "markdownit"
|
||||
},
|
||||
"mode": mode,
|
||||
"module": {
|
||||
|
@ -33,7 +35,7 @@ function config(options) {
|
|||
"name": name.replace(/(-\w)/g, (m) => m.slice(1).toUpperCase()),
|
||||
"type": "var"
|
||||
},
|
||||
"path": __dirname
|
||||
"path": __dirname(import.meta)
|
||||
},
|
||||
"plugins": [
|
||||
new webpack.NormalModuleReplacementPlugin(
|
||||
|
@ -52,7 +54,8 @@ function config(options) {
|
|||
"fs": false,
|
||||
"os": false,
|
||||
"path": false,
|
||||
"util": false
|
||||
"util": false,
|
||||
"module": require.resolve("./module-stub.cjs")
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -77,14 +80,10 @@ const modeProduction = {
|
|||
}
|
||||
};
|
||||
const entryLibrary = {
|
||||
"entry": "./markdownlint-exports.js",
|
||||
"packageJson": require("../package.json")
|
||||
"entry": "./browser-exports.mjs",
|
||||
"packageJson": libraryPackageJson
|
||||
};
|
||||
// const entryHelpers = {
|
||||
// "entry": "../helpers/helpers.js",
|
||||
// "packageJson": require("../helpers/package.json")
|
||||
// };
|
||||
module.exports = [
|
||||
export default [
|
||||
config({
|
||||
...entryLibrary,
|
||||
...modeDevelopment,
|
||||
|
@ -95,14 +94,4 @@ module.exports = [
|
|||
...modeProduction,
|
||||
"filename": "markdownlint-browser.min.js"
|
||||
})
|
||||
// config({
|
||||
// ...entryHelpers,
|
||||
// ...modeDevelopment,
|
||||
// "filename": "markdownlint-rule-helpers-browser.js"
|
||||
// }),
|
||||
// config({
|
||||
// ...entryHelpers,
|
||||
// ...modeProduction,
|
||||
// "filename": "markdownlint-rule-helpers-browser.min.js"
|
||||
// })
|
||||
];
|
|
@ -1,8 +1,8 @@
|
|||
import { readFile, writeFile } from "node:fs/promises";
|
||||
import { EOL } from "node:os";
|
||||
import { default as rules } from "../lib/rules.js";
|
||||
import { newLineRe } from "../helpers/helpers.js";
|
||||
import { deprecatedRuleNames, fixableRuleNames } from "../lib/constants.js";
|
||||
import { default as rules } from "../lib/rules.mjs";
|
||||
import { newLineRe } from "../helpers/helpers.cjs";
|
||||
import { deprecatedRuleNames, fixableRuleNames } from "../lib/constants.mjs";
|
||||
|
||||
const maxLineLength = 80;
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ A simple rule implementation using the `micromark` parser to report a violation
|
|||
for any use of blockquotes might look like:
|
||||
|
||||
```javascript
|
||||
/** @type import("markdownlint").Rule */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
module.exports = {
|
||||
"names": [ "any-blockquote-micromark" ],
|
||||
"description": "Rule that reports an error for any blockquote",
|
||||
|
@ -61,7 +61,7 @@ module.exports = {
|
|||
That same rule implemented using the `markdown-it` parser might look like:
|
||||
|
||||
```javascript
|
||||
/** @type import("markdownlint").Rule */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
module.exports = {
|
||||
"names": [ "any-blockquote-markdown-it" ],
|
||||
"description": "Rule that reports an error for any blockquote",
|
||||
|
@ -187,8 +187,8 @@ exception.
|
|||
[markdown-it-token]: https://markdown-it.github.io/markdown-it/#Token
|
||||
[markdownlint-rule]: https://www.npmjs.com/search?q=keywords:markdownlint-rule
|
||||
[micromark]: https://github.com/micromark/micromark
|
||||
[micromark-token]: ../lib/markdownlint.d.ts
|
||||
[micromark-token]: ../lib/markdownlint.d.mts
|
||||
[rule-helpers]: https://www.npmjs.com/package/markdownlint-rule-helpers
|
||||
[options-custom-rules]: ../README.md#optionscustomrules
|
||||
[test-rules]: ../test/rules
|
||||
[tokens]: ../test/snapshots/markdownlint-test-custom-rules.js.md
|
||||
[tokens]: ../test/snapshots/markdownlint-test-custom-rules.mjs.md
|
||||
|
|
|
@ -25,20 +25,11 @@ export default [
|
|||
"demo/markdown-it.min.js",
|
||||
"demo/markdownlint-browser.js",
|
||||
"demo/markdownlint-browser.min.js",
|
||||
"demo/micromark-browser.js",
|
||||
"demo/micromark-html-browser.js",
|
||||
"example/typescript/type-check.js",
|
||||
"micromark/micromark.cjs",
|
||||
"micromark/micromark.dev.cjs",
|
||||
"micromark/micromark-browser.js",
|
||||
"micromark/micromark-browser.dev.js",
|
||||
"test-repos/**"
|
||||
]
|
||||
},
|
||||
{
|
||||
"languageOptions": {
|
||||
"sourceType": "commonjs"
|
||||
},
|
||||
"linterOptions": {
|
||||
"reportUnusedDisableDirectives": true
|
||||
},
|
||||
|
@ -88,7 +79,6 @@ export default [
|
|||
"unicorn/no-null": "off",
|
||||
"unicorn/no-useless-undefined": "off",
|
||||
"unicorn/prefer-at": "off",
|
||||
"unicorn/prefer-module": "off",
|
||||
"unicorn/prefer-string-raw": "off",
|
||||
"unicorn/prefer-string-replace-all": "off",
|
||||
"unicorn/prefer-string-slice": "off",
|
||||
|
@ -107,15 +97,20 @@ export default [
|
|||
},
|
||||
{
|
||||
"files": [
|
||||
"**/*.mjs"
|
||||
"**/*.js",
|
||||
"**/*.cjs"
|
||||
],
|
||||
"languageOptions": {
|
||||
"sourceType": "module"
|
||||
"sourceType": "commonjs",
|
||||
"globals": {
|
||||
"module": "readonly",
|
||||
"require": "readonly"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"demo/*.js"
|
||||
"demo/default.js"
|
||||
],
|
||||
"languageOptions": {
|
||||
"globals": {
|
||||
|
@ -131,26 +126,42 @@ export default [
|
|||
"no-invalid-this": "off",
|
||||
"no-shadow": "off",
|
||||
"no-var": "off",
|
||||
"unicorn/prefer-module": "off",
|
||||
"unicorn/prefer-query-selector": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"example/*.js"
|
||||
"example/*.cjs"
|
||||
],
|
||||
"languageOptions": {
|
||||
"sourceType": "commonjs"
|
||||
},
|
||||
"rules": {
|
||||
"n/no-missing-require": "off",
|
||||
"no-console": "off",
|
||||
"no-invalid-this": "off",
|
||||
"no-invalid-this": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"example/standalone.mjs"
|
||||
],
|
||||
"rules": {
|
||||
"no-console": "off",
|
||||
"no-shadow": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"test/rules/**/*.js"
|
||||
"test/rules/**/*.js",
|
||||
"test/rules/**/*.cjs"
|
||||
],
|
||||
"languageOptions": {
|
||||
"sourceType": "commonjs"
|
||||
},
|
||||
"rules": {
|
||||
"jsdoc/valid-types": "off"
|
||||
"unicorn/prefer-module": "off"
|
||||
}
|
||||
}
|
||||
];
|
||||
|
|
28
example/Gruntfile.cjs
Normal file
28
example/Gruntfile.cjs
Normal file
|
@ -0,0 +1,28 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
module.exports = function wrapper(grunt) {
|
||||
grunt.initConfig({
|
||||
"markdownlint": {
|
||||
"example": {
|
||||
"src": [ "*.md" ]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
grunt.registerMultiTask("markdownlint", function task() {
|
||||
const done = this.async();
|
||||
import("markdownlint").then(({ "default": markdownlint }) => {
|
||||
markdownlint(
|
||||
{ "files": this.filesSrc },
|
||||
function callback(err, result) {
|
||||
const resultString = err || ((result || "").toString());
|
||||
if (resultString) {
|
||||
grunt.fail.warn("\n" + resultString + "\n");
|
||||
}
|
||||
done(!err || !resultString);
|
||||
});
|
||||
}).catch(done);
|
||||
});
|
||||
};
|
|
@ -1,28 +0,0 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const markdownlint = require("../lib/markdownlint");
|
||||
|
||||
module.exports = function wrapper(grunt) {
|
||||
grunt.initConfig({
|
||||
"markdownlint": {
|
||||
"example": {
|
||||
"src": [ "*.md" ]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
grunt.registerMultiTask("markdownlint", function task() {
|
||||
const done = this.async();
|
||||
markdownlint(
|
||||
{ "files": this.filesSrc },
|
||||
function callback(err, result) {
|
||||
const resultString = err || ((result || "").toString());
|
||||
if (resultString) {
|
||||
grunt.fail.warn("\n" + resultString + "\n");
|
||||
}
|
||||
done(!err || !resultString);
|
||||
});
|
||||
});
|
||||
};
|
24
example/gulpfile.cjs
Normal file
24
example/gulpfile.cjs
Normal file
|
@ -0,0 +1,24 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const gulp = require("gulp");
|
||||
const through2 = require("through2");
|
||||
|
||||
// Simple task wrapper
|
||||
gulp.task("markdownlint", function task() {
|
||||
return gulp.src("*.md", { "read": false })
|
||||
.pipe(through2.obj(function obj(file, enc, next) {
|
||||
import("markdownlint").then(({ "default": markdownlint }) => {
|
||||
markdownlint(
|
||||
{ "files": [ file.relative ] },
|
||||
function callback(err, result) {
|
||||
const resultString = (result || "").toString();
|
||||
if (resultString) {
|
||||
console.log(resultString);
|
||||
}
|
||||
next(err, file);
|
||||
});
|
||||
}).catch(next);
|
||||
}));
|
||||
});
|
|
@ -1,23 +0,0 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const gulp = require("gulp");
|
||||
const through2 = require("through2");
|
||||
const markdownlint = require("../lib/markdownlint");
|
||||
|
||||
// Simple task wrapper
|
||||
gulp.task("markdownlint", function task() {
|
||||
return gulp.src("*.md", { "read": false })
|
||||
.pipe(through2.obj(function obj(file, enc, next) {
|
||||
markdownlint(
|
||||
{ "files": [ file.relative ] },
|
||||
function callback(err, result) {
|
||||
const resultString = (result || "").toString();
|
||||
if (resultString) {
|
||||
console.log(resultString);
|
||||
}
|
||||
next(err, file);
|
||||
});
|
||||
}));
|
||||
});
|
|
@ -1,8 +1,6 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const markdownlint = require("../lib/markdownlint");
|
||||
import markdownlint from "markdownlint";
|
||||
|
||||
const options = {
|
||||
"files": [ "good.md", "bad.md" ],
|
||||
|
@ -19,6 +17,7 @@ console.log(result.toString());
|
|||
// Makes an asynchronous call
|
||||
markdownlint(options, function callback(err, result) {
|
||||
if (!err) {
|
||||
// @ts-ignore
|
||||
console.log(result.toString());
|
||||
}
|
||||
});
|
||||
|
@ -29,3 +28,9 @@ markdownlint(options, function callback(err, result) {
|
|||
console.dir(result, { "colors": true, "depth": null });
|
||||
}
|
||||
});
|
||||
|
||||
// Fixes all supported violations in Markdown content
|
||||
const original = "# Heading";
|
||||
const fixResults = markdownlint.sync({ "strings": { "content": original } });
|
||||
const fixed = markdownlint.applyFixes(original, fixResults.content);
|
||||
console.log(fixed);
|
|
@ -1,25 +1,27 @@
|
|||
// Attempt to validate all the type declarations in markdownlint.d.ts
|
||||
// Attempt to validate all the type declarations in markdownlint.d.mts
|
||||
|
||||
import markdownlint from "../..";
|
||||
import { default as markdownlint, Configuration, ConfigurationStrict, LintResults, Options, Rule, RuleParams, RuleOnError, RuleOnErrorInfo } from "../../lib/markdownlint.mjs";
|
||||
|
||||
const assert = require("assert");
|
||||
import assert from "assert";
|
||||
// @ts-expect-error TS7016: Could not find a declaration file for module 'markdown-it-sub'.
|
||||
import markdownItSub from "markdown-it-sub";
|
||||
const markdownlintJsonPath = "../../.markdownlint.json";
|
||||
|
||||
const version: string = markdownlint.getVersion();
|
||||
assert(/^\d+\.\d+\.\d+$/.test(version));
|
||||
|
||||
function assertConfiguration(config: markdownlint.Configuration) {
|
||||
function assertConfiguration(config: Configuration) {
|
||||
assert(!!config);
|
||||
assert.deepEqual(config["line-length"], { "strict": true, "code_blocks": false });
|
||||
// config assignment is covered by markdownlint.Options
|
||||
}
|
||||
|
||||
function assertConfigurationCallback(err: Error | null, config?: markdownlint.Configuration) {
|
||||
function assertConfigurationCallback(err: Error | null, config?: Configuration) {
|
||||
assert(!err);
|
||||
config && assertConfiguration(config);
|
||||
}
|
||||
|
||||
function assertLintResults(results: markdownlint.LintResults) {
|
||||
function assertLintResults(results: LintResults) {
|
||||
assert(!!results);
|
||||
assert.equal(results["string"].length, 1);
|
||||
assert.equal(results["string"][0].lineNumber, 1);
|
||||
|
@ -60,7 +62,7 @@ function assertLintResults(results: markdownlint.LintResults) {
|
|||
};
|
||||
}
|
||||
|
||||
function assertLintResultsCallback(err: Error | null, results?: markdownlint.LintResults) {
|
||||
function assertLintResultsCallback(err: Error | null, results?: LintResults) {
|
||||
assert(!err);
|
||||
results && assertLintResults(results);
|
||||
}
|
||||
|
@ -76,7 +78,7 @@ markdownlint.readConfig(markdownlintJsonPath, [ JSON.parse ], assertConfiguratio
|
|||
assertConfigurationCallback(null, await markdownlint.promises.readConfig(markdownlintJsonPath, [ JSON.parse ]))
|
||||
})();
|
||||
|
||||
let options: markdownlint.Options;
|
||||
let options: Options;
|
||||
options = {
|
||||
"files": [ "../bad.md" ],
|
||||
"strings": {
|
||||
|
@ -93,7 +95,7 @@ options = {
|
|||
"frontMatter": /---/,
|
||||
"handleRuleFailures": false,
|
||||
"noInlineConfig": false,
|
||||
"markdownItPlugins": [ [ require("markdown-it-sub") ] ]
|
||||
"markdownItPlugins": [ [ markdownItSub ] ]
|
||||
};
|
||||
|
||||
assertLintResults(markdownlint.sync(options));
|
||||
|
@ -109,16 +111,16 @@ markdownlint(options, assertLintResultsCallback);
|
|||
assertLintResultsCallback(null, await markdownlint.promises.markdownlint(options));
|
||||
})();
|
||||
|
||||
const testRule: markdownlint.Rule = {
|
||||
const testRule: Rule = {
|
||||
"names": [ "test-rule" ],
|
||||
"description": "Test rule",
|
||||
"information": new URL("https://example.com/rule-information"),
|
||||
"tags": [ "test-tag" ],
|
||||
"parser": "none",
|
||||
"function": function rule(params: markdownlint.RuleParams, onError: markdownlint.RuleOnError) {
|
||||
"function": function rule(params: RuleParams, onError: RuleOnError) {
|
||||
assert(!!params);
|
||||
assert(!!onError);
|
||||
let ruleParams: markdownlint.RuleParams;
|
||||
let ruleParams: RuleParams;
|
||||
ruleParams = {
|
||||
"name": "name",
|
||||
"parsers": {
|
||||
|
@ -140,7 +142,7 @@ const testRule: markdownlint.Rule = {
|
|||
"version": "1.2.3"
|
||||
};
|
||||
assert(ruleParams);
|
||||
let ruleOnErrorInfo: markdownlint.RuleOnErrorInfo;
|
||||
let ruleOnErrorInfo: RuleOnErrorInfo;
|
||||
ruleOnErrorInfo = {
|
||||
"lineNumber": 1,
|
||||
"detail": "detail",
|
||||
|
@ -196,7 +198,7 @@ assert.equal(
|
|||
"# Heading\n"
|
||||
);
|
||||
|
||||
const configuration: markdownlint.Configuration = {
|
||||
const configuration: Configuration = {
|
||||
"custom-rule": true,
|
||||
"no-hard-tabs": false,
|
||||
"heading-style": {
|
||||
|
@ -204,7 +206,7 @@ const configuration: markdownlint.Configuration = {
|
|||
}
|
||||
};
|
||||
assert(configuration);
|
||||
const configurationStrict: markdownlint.ConfigurationStrict = {
|
||||
const configurationStrict: ConfigurationStrict = {
|
||||
// "custom-rule": true,
|
||||
"no-hard-tabs": false,
|
||||
"heading-style": {
|
||||
|
|
|
@ -1 +1 @@
|
|||
test.js
|
||||
test.cjs
|
||||
|
|
|
@ -4,13 +4,17 @@
|
|||
|
||||
const micromark = require("./micromark-helpers.cjs");
|
||||
|
||||
const { newLineRe, nextLinesRe } = require("./shared.js");
|
||||
const { newLineRe, nextLinesRe } = require("./shared.cjs");
|
||||
|
||||
module.exports.newLineRe = newLineRe;
|
||||
module.exports.nextLinesRe = nextLinesRe;
|
||||
|
||||
/** @typedef {import("../lib/markdownlint.js").RuleOnError} RuleOnError */
|
||||
/** @typedef {import("../lib/markdownlint.js").RuleOnErrorFixInfo} RuleOnErrorFixInfo */
|
||||
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/52529
|
||||
/** @typedef {import("../lib/markdownlint.mjs").RuleOnError} RuleOnError */
|
||||
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/52529
|
||||
/** @typedef {import("../lib/markdownlint.mjs").RuleOnErrorFixInfo} RuleOnErrorFixInfo */
|
||||
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/52529
|
||||
/** @typedef {import("../lib/markdownlint.mjs").MicromarkToken} MicromarkToken */
|
||||
|
||||
// Regular expression for matching common front matter (YAML and TOML)
|
||||
module.exports.frontMatterRe =
|
||||
|
@ -336,8 +340,8 @@ const positionLessThanOrEqual = (lineA, columnA, lineB, columnB) => (
|
|||
/**
|
||||
* Returns whether two ranges (or MicromarkTokens) overlap anywhere.
|
||||
*
|
||||
* @param {FileRange|import("../lib/markdownlint.js").MicromarkToken} rangeA Range A.
|
||||
* @param {FileRange|import("../lib/markdownlint.js").MicromarkToken} rangeB Range B.
|
||||
* @param {FileRange|MicromarkToken} rangeA Range A.
|
||||
* @param {FileRange|MicromarkToken} rangeB Range B.
|
||||
* @returns {boolean} True iff the two ranges overlap.
|
||||
*/
|
||||
module.exports.hasOverlap = function hasOverlap(rangeA, rangeB) {
|
|
@ -2,10 +2,12 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { flatTokensSymbol, htmlFlowSymbol } = require("./shared.js");
|
||||
const { flatTokensSymbol, htmlFlowSymbol } = require("./shared.cjs");
|
||||
|
||||
/** @typedef {import("markdownlint-micromark").TokenType} TokenType */
|
||||
/** @typedef {import("../lib/markdownlint.js").MicromarkToken} Token */
|
||||
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/52529
|
||||
/** @typedef {import("micromark-util-types").TokenType} TokenType */
|
||||
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/52529
|
||||
/** @typedef {import("../lib/markdownlint.mjs").MicromarkToken} Token */
|
||||
|
||||
/**
|
||||
* Determines if a Micromark token is within an htmlFlow type.
|
||||
|
|
|
@ -1,18 +1,24 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { directive } from "micromark-extension-directive";
|
||||
import { gfmAutolinkLiteral } from "micromark-extension-gfm-autolink-literal";
|
||||
import { gfmFootnote } from "micromark-extension-gfm-footnote";
|
||||
import { gfmTable } from "micromark-extension-gfm-table";
|
||||
import { math } from "micromark-extension-math";
|
||||
import { parse as micromarkParse, postprocess as micromarkPostprocess, preprocess as micromarkPreprocess } from "micromark";
|
||||
// micromark-core-commonmark is not a dependency because this instance must match what's used by micromark
|
||||
// eslint-disable-next-line n/no-extraneous-import
|
||||
import { labelEnd } from "micromark-core-commonmark";
|
||||
import { isHtmlFlowComment } from "./micromark-helpers.cjs";
|
||||
import { flatTokensSymbol, htmlFlowSymbol, newLineRe } from "./shared.cjs";
|
||||
|
||||
const micromark = require("markdownlint-micromark");
|
||||
const { isHtmlFlowComment } = require("./micromark-helpers.cjs");
|
||||
const { flatTokensSymbol, htmlFlowSymbol, newLineRe } = require("./shared.js");
|
||||
|
||||
/** @typedef {import("markdownlint-micromark").Construct} Construct */
|
||||
/** @typedef {import("markdownlint-micromark").Event} Event */
|
||||
/** @typedef {import("markdownlint-micromark").ParseOptions} MicromarkParseOptions */
|
||||
/** @typedef {import("markdownlint-micromark").State} State */
|
||||
/** @typedef {import("markdownlint-micromark").Token} Token */
|
||||
/** @typedef {import("markdownlint-micromark").Tokenizer} Tokenizer */
|
||||
/** @typedef {import("../lib/markdownlint.js").MicromarkToken} MicromarkToken */
|
||||
/** @typedef {import("micromark-util-types").Event} Event */
|
||||
/** @typedef {import("micromark-util-types").ParseOptions} MicromarkParseOptions */
|
||||
/** @typedef {import("micromark-util-types").State} State */
|
||||
/** @typedef {import("micromark-util-types").Token} Token */
|
||||
/** @typedef {import("micromark-util-types").Tokenizer} Tokenizer */
|
||||
/** @typedef {import("./micromark-types.d.mts")} */
|
||||
/** @typedef {import("../lib/markdownlint.mjs").MicromarkToken} MicromarkToken */
|
||||
|
||||
/**
|
||||
* Parse options.
|
||||
|
@ -28,27 +34,23 @@ const { flatTokensSymbol, htmlFlowSymbol, newLineRe } = require("./shared.js");
|
|||
* @param {MicromarkParseOptions} [micromarkParseOptions] Options for micromark.
|
||||
* @returns {Event[]} Micromark events.
|
||||
*/
|
||||
function getEvents(
|
||||
export function getEvents(
|
||||
markdown,
|
||||
micromarkParseOptions = {}
|
||||
) {
|
||||
// Customize extensions list to add useful extensions
|
||||
const extensions = [
|
||||
micromark.directive(),
|
||||
micromark.gfmAutolinkLiteral(),
|
||||
micromark.gfmFootnote(),
|
||||
micromark.gfmTable(),
|
||||
micromark.math(),
|
||||
directive(),
|
||||
gfmAutolinkLiteral(),
|
||||
gfmFootnote(),
|
||||
gfmTable(),
|
||||
math(),
|
||||
...(micromarkParseOptions.extensions || [])
|
||||
];
|
||||
|
||||
// // Shim labelEnd to identify undefined link labels
|
||||
/** @type {Event[][]} */
|
||||
const artificialEventLists = [];
|
||||
/** @type {Construct} */
|
||||
const labelEnd =
|
||||
// @ts-ignore
|
||||
micromark.labelEnd;
|
||||
const tokenizeOriginal = labelEnd.tokenize;
|
||||
|
||||
/** @type {Tokenizer} */
|
||||
|
@ -162,9 +164,9 @@ function getEvents(
|
|||
// Use micromark to parse document into Events
|
||||
const encoding = undefined;
|
||||
const eol = true;
|
||||
const parseContext = micromark.parse({ ...micromarkParseOptions, extensions });
|
||||
const chunks = micromark.preprocess()(markdown, encoding, eol);
|
||||
const events = micromark.postprocess(parseContext.document().write(chunks));
|
||||
const parseContext = micromarkParse({ ...micromarkParseOptions, extensions });
|
||||
const chunks = micromarkPreprocess()(markdown, encoding, eol);
|
||||
const events = micromarkPostprocess(parseContext.document().write(chunks));
|
||||
|
||||
// Append artificial events and return all events
|
||||
// eslint-disable-next-line unicorn/prefer-spread
|
||||
|
@ -214,8 +216,7 @@ function parseInternal(
|
|||
};
|
||||
const history = [ root ];
|
||||
let current = root;
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type MicromarkParseOptions | null */
|
||||
/** @type {MicromarkParseOptions | null} */
|
||||
let reparseOptions = null;
|
||||
let lines = null;
|
||||
let skipHtmlFlowChildren = false;
|
||||
|
@ -303,11 +304,6 @@ function parseInternal(
|
|||
* @param {ParseOptions} [parseOptions] Options.
|
||||
* @returns {MicromarkToken[]} Micromark tokens.
|
||||
*/
|
||||
function parse(markdown, parseOptions) {
|
||||
export function parse(markdown, parseOptions) {
|
||||
return parseInternal(markdown, parseOptions);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getEvents,
|
||||
parse
|
||||
};
|
11
helpers/micromark-types.d.mts
Normal file
11
helpers/micromark-types.d.mts
Normal file
|
@ -0,0 +1,11 @@
|
|||
export {};
|
||||
|
||||
// Augment TokenTypeMap with markdownlint-specific types.
|
||||
declare module "micromark-util-types" {
|
||||
export interface TokenTypeMap {
|
||||
undefinedReference: "undefinedReference"
|
||||
undefinedReferenceCollapsed: "undefinedReferenceCollapsed"
|
||||
undefinedReferenceFull: "undefinedReferenceFull"
|
||||
undefinedReferenceShortcut: "undefinedReferenceShortcut"
|
||||
}
|
||||
}
|
|
@ -2,9 +2,9 @@
|
|||
"name": "markdownlint-rule-helpers",
|
||||
"version": "0.27.0",
|
||||
"description": "A collection of markdownlint helper functions for custom rules",
|
||||
"main": "./helpers.js",
|
||||
"main": "./helpers.cjs",
|
||||
"exports": {
|
||||
".": "./helpers.js",
|
||||
".": "./helpers.cjs",
|
||||
"./micromark": "./micromark-helpers.cjs"
|
||||
},
|
||||
"author": "David Anson (https://dlaa.me/)",
|
||||
|
@ -20,7 +20,12 @@
|
|||
"node": ">=18"
|
||||
},
|
||||
"dependencies": {
|
||||
"markdownlint-micromark": "0.1.2"
|
||||
"micromark": "4.0.0",
|
||||
"micromark-extension-directive": "3.0.2",
|
||||
"micromark-extension-gfm-autolink-literal": "2.1.0",
|
||||
"micromark-extension-gfm-footnote": "2.1.0",
|
||||
"micromark-extension-gfm-table": "2.1.0",
|
||||
"micromark-extension-math": "3.1.0"
|
||||
},
|
||||
"keywords": [
|
||||
"markdownlint",
|
||||
|
|
|
@ -7,7 +7,7 @@ const test = require("ava").default;
|
|||
const { "exports": packageExports, name } = require("../helpers/package.json");
|
||||
|
||||
const exportMappings = new Map([
|
||||
[ ".", "../helpers/helpers.js" ],
|
||||
[ ".", "../helpers/helpers.cjs" ],
|
||||
[ "./micromark", "../helpers/micromark-helpers.cjs" ]
|
||||
]);
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const helpers = require("../helpers");
|
||||
const { filterByTypes } = require("../helpers/micromark-helpers.cjs");
|
||||
import { getReferenceLinkImageData as helpersGetReferenceLinkImageData } from "../helpers/helpers.cjs";
|
||||
import { filterByTypes } from "../helpers/micromark-helpers.cjs";
|
||||
|
||||
/** @type {Map<string, object>} */
|
||||
const map = new Map();
|
||||
|
@ -12,10 +10,10 @@ let params = undefined;
|
|||
/**
|
||||
* Initializes (resets) the cache.
|
||||
*
|
||||
* @param {import("./markdownlint").RuleParams} [p] Rule parameters object.
|
||||
* @param {import("./markdownlint.mjs").RuleParams} [p] Rule parameters object.
|
||||
* @returns {void}
|
||||
*/
|
||||
function initialize(p) {
|
||||
export function initialize(p) {
|
||||
map.clear();
|
||||
params = p;
|
||||
}
|
||||
|
@ -39,11 +37,11 @@ function getCached(name, getValue) {
|
|||
/**
|
||||
* Filters a list of Micromark tokens by type and caches the result.
|
||||
*
|
||||
* @param {import("./markdownlint").MicromarkTokenType[]} types Types to allow.
|
||||
* @param {import("./markdownlint.mjs").MicromarkTokenType[]} types Types to allow.
|
||||
* @param {boolean} [htmlFlow] Whether to include htmlFlow content.
|
||||
* @returns {import("./markdownlint").MicromarkToken[]} Filtered tokens.
|
||||
* @returns {import("./markdownlint.mjs").MicromarkToken[]} Filtered tokens.
|
||||
*/
|
||||
function filterByTypesCached(types, htmlFlow) {
|
||||
export function filterByTypesCached(types, htmlFlow) {
|
||||
return getCached(
|
||||
// eslint-disable-next-line prefer-rest-params
|
||||
JSON.stringify(arguments),
|
||||
|
@ -56,15 +54,9 @@ function filterByTypesCached(types, htmlFlow) {
|
|||
*
|
||||
* @returns {Object} Reference link and image data object.
|
||||
*/
|
||||
function getReferenceLinkImageData() {
|
||||
export function getReferenceLinkImageData() {
|
||||
return getCached(
|
||||
getReferenceLinkImageData.name,
|
||||
() => helpers.getReferenceLinkImageData(params.parsers.micromark.tokens)
|
||||
() => helpersGetReferenceLinkImageData(params.parsers.micromark.tokens)
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
initialize,
|
||||
filterByTypesCached,
|
||||
getReferenceLinkImageData
|
||||
};
|
2
lib/configuration.d.ts
vendored
2
lib/configuration.d.ts
vendored
|
@ -1,4 +1,4 @@
|
|||
import { ConfigurationStrict } from "./configuration-strict";
|
||||
import type { ConfigurationStrict } from "./configuration-strict.d.ts";
|
||||
|
||||
export interface Configuration extends ConfigurationStrict {
|
||||
/**
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
module.exports.deprecatedRuleNames = [];
|
||||
module.exports.fixableRuleNames = [
|
||||
export const deprecatedRuleNames = [];
|
||||
export const fixableRuleNames = [
|
||||
"MD004", "MD005", "MD007", "MD009", "MD010", "MD011",
|
||||
"MD012", "MD014", "MD018", "MD019", "MD020", "MD021",
|
||||
"MD022", "MD023", "MD026", "MD027", "MD030", "MD031",
|
||||
|
@ -11,5 +9,5 @@ module.exports.fixableRuleNames = [
|
|||
"MD047", "MD049", "MD050", "MD051", "MD053", "MD054",
|
||||
"MD058"
|
||||
];
|
||||
module.exports.homepage = "https://github.com/DavidAnson/markdownlint";
|
||||
module.exports.version = "0.36.1";
|
||||
export const homepage = "https://github.com/DavidAnson/markdownlint";
|
||||
export const version = "0.36.1";
|
|
@ -4,6 +4,11 @@
|
|||
|
||||
const { newLineRe } = require("../helpers");
|
||||
|
||||
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/52529
|
||||
/** @typedef {import("./markdownlint.mjs").MarkdownItToken} MarkdownItToken */
|
||||
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/52529
|
||||
/** @typedef {import("./markdownlint.mjs").Plugin} Plugin */
|
||||
|
||||
/**
|
||||
* @callback InlineCodeSpanCallback
|
||||
* @param {string} code Code content.
|
||||
|
@ -67,7 +72,7 @@ function forEachInlineCodeSpan(input, handler) {
|
|||
/**
|
||||
* Freeze all freeze-able members of a token and its children.
|
||||
*
|
||||
* @param {import("./markdownlint").MarkdownItToken} token A markdown-it token.
|
||||
* @param {MarkdownItToken} token A markdown-it token.
|
||||
* @returns {void}
|
||||
*/
|
||||
function freezeToken(token) {
|
||||
|
@ -98,8 +103,7 @@ function freezeToken(token) {
|
|||
*/
|
||||
function annotateAndFreezeTokens(tokens, lines) {
|
||||
let trMap = null;
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").MarkdownItToken[] */
|
||||
/** @type {MarkdownItToken[]} */
|
||||
// @ts-ignore
|
||||
const markdownItTokens = tokens;
|
||||
for (const token of markdownItTokens) {
|
||||
|
@ -148,10 +152,10 @@ function annotateAndFreezeTokens(tokens, lines) {
|
|||
/**
|
||||
* Gets an array of markdown-it tokens for the input.
|
||||
*
|
||||
* @param {import("./markdownlint").Plugin[]} markdownItPlugins Additional plugins.
|
||||
* @param {Plugin[]} markdownItPlugins Additional plugins.
|
||||
* @param {string} content Markdown content.
|
||||
* @param {string[]} lines Lines of Markdown content.
|
||||
* @returns {import("../lib/markdownlint").MarkdownItToken} Array of markdown-it tokens.
|
||||
* @returns {MarkdownItToken} Array of markdown-it tokens.
|
||||
*/
|
||||
function getMarkdownItTokens(markdownItPlugins, content, lines) {
|
||||
const markdownit = require("markdown-it");
|
||||
|
|
|
@ -1,79 +1,12 @@
|
|||
export = markdownlint;
|
||||
/**
|
||||
* Lint specified Markdown files.
|
||||
*
|
||||
* @param {Options | null} options Configuration options.
|
||||
* @param {LintCallback} callback Callback (err, result) function.
|
||||
* @returns {void}
|
||||
*/
|
||||
declare function markdownlint(options: Options | null, callback: LintCallback): void;
|
||||
declare namespace markdownlint {
|
||||
export { markdownlintSync as sync, readConfig, readConfigSync, getVersion, promises, applyFix, applyFixes, RuleFunction, RuleParams, MarkdownParsers, ParserMarkdownIt, ParserMicromark, MarkdownItToken, MicromarkTokenType, MicromarkToken, RuleOnError, RuleOnErrorInfo, RuleOnErrorFixInfo, RuleOnErrorFixInfoNormalized, Rule, Options, Plugin, ToStringCallback, LintResults, LintError, FixInfo, LintContentCallback, LintCallback, Configuration, ConfigurationStrict, RuleConfiguration, ConfigurationParser, ReadConfigCallback, ResolveConfigExtendsCallback };
|
||||
}
|
||||
/**
|
||||
* Lint specified Markdown files synchronously.
|
||||
*
|
||||
* @param {Options | null} options Configuration options.
|
||||
* @returns {LintResults} Results object.
|
||||
*/
|
||||
declare function markdownlintSync(options: Options | null): LintResults;
|
||||
/**
|
||||
* Read specified configuration file.
|
||||
*
|
||||
* @param {string} file Configuration file name.
|
||||
* @param {ConfigurationParser[] | ReadConfigCallback} parsers Parsing
|
||||
* function(s).
|
||||
* @param {Object} [fs] File system implementation.
|
||||
* @param {ReadConfigCallback} [callback] Callback (err, result) function.
|
||||
* @returns {void}
|
||||
*/
|
||||
declare function readConfig(file: string, parsers: ConfigurationParser[] | ReadConfigCallback, fs?: any, callback?: ReadConfigCallback): void;
|
||||
/**
|
||||
* Read specified configuration file synchronously.
|
||||
*
|
||||
* @param {string} file Configuration file name.
|
||||
* @param {ConfigurationParser[]} [parsers] Parsing function(s).
|
||||
* @param {Object} [fs] File system implementation.
|
||||
* @returns {Configuration} Configuration object.
|
||||
* @throws An Error if processing fails.
|
||||
*/
|
||||
declare function readConfigSync(file: string, parsers?: ConfigurationParser[], fs?: any): Configuration;
|
||||
/**
|
||||
* Gets the (semantic) version of the library.
|
||||
*
|
||||
* @returns {string} SemVer string.
|
||||
*/
|
||||
declare function getVersion(): string;
|
||||
declare namespace promises {
|
||||
export { markdownlintPromise as markdownlint };
|
||||
export { extendConfigPromise as extendConfig };
|
||||
export { readConfigPromise as readConfig };
|
||||
}
|
||||
/**
|
||||
* Applies the specified fix to a Markdown content line.
|
||||
*
|
||||
* @param {string} line Line of Markdown content.
|
||||
* @param {RuleOnErrorFixInfo} fixInfo RuleOnErrorFixInfo instance.
|
||||
* @param {string} [lineEnding] Line ending to use.
|
||||
* @returns {string | null} Fixed content or null if deleted.
|
||||
*/
|
||||
declare function applyFix(line: string, fixInfo: RuleOnErrorFixInfo, lineEnding?: string): string | null;
|
||||
/**
|
||||
* Applies as many of the specified fixes as possible to Markdown content.
|
||||
*
|
||||
* @param {string} input Lines of Markdown content.
|
||||
* @param {RuleOnErrorInfo[]} errors RuleOnErrorInfo instances.
|
||||
* @returns {string} Fixed content.
|
||||
*/
|
||||
declare function applyFixes(input: string, errors: RuleOnErrorInfo[]): string;
|
||||
export default markdownlint;
|
||||
/**
|
||||
* Function to implement rule logic.
|
||||
*/
|
||||
type RuleFunction = (params: RuleParams, onError: RuleOnError) => void;
|
||||
export type RuleFunction = (params: RuleParams, onError: RuleOnError) => void;
|
||||
/**
|
||||
* Rule parameters.
|
||||
*/
|
||||
type RuleParams = {
|
||||
export type RuleParams = {
|
||||
/**
|
||||
* File/string name.
|
||||
*/
|
||||
|
@ -102,7 +35,7 @@ type RuleParams = {
|
|||
/**
|
||||
* Markdown parser data.
|
||||
*/
|
||||
type MarkdownParsers = {
|
||||
export type MarkdownParsers = {
|
||||
/**
|
||||
* Markdown parser data from markdown-it (only present when Rule.parser is "markdownit").
|
||||
*/
|
||||
|
@ -115,7 +48,7 @@ type MarkdownParsers = {
|
|||
/**
|
||||
* Markdown parser data from markdown-it.
|
||||
*/
|
||||
type ParserMarkdownIt = {
|
||||
export type ParserMarkdownIt = {
|
||||
/**
|
||||
* Token objects from markdown-it.
|
||||
*/
|
||||
|
@ -124,7 +57,7 @@ type ParserMarkdownIt = {
|
|||
/**
|
||||
* Markdown parser data from micromark.
|
||||
*/
|
||||
type ParserMicromark = {
|
||||
export type ParserMicromark = {
|
||||
/**
|
||||
* Token objects from micromark.
|
||||
*/
|
||||
|
@ -133,7 +66,7 @@ type ParserMicromark = {
|
|||
/**
|
||||
* markdown-it token.
|
||||
*/
|
||||
type MarkdownItToken = {
|
||||
export type MarkdownItToken = {
|
||||
/**
|
||||
* HTML attributes.
|
||||
*/
|
||||
|
@ -195,11 +128,11 @@ type MarkdownItToken = {
|
|||
*/
|
||||
line: string;
|
||||
};
|
||||
type MicromarkTokenType = import("markdownlint-micromark").TokenType;
|
||||
export type MicromarkTokenType = import("micromark-util-types").TokenType;
|
||||
/**
|
||||
* micromark token.
|
||||
*/
|
||||
type MicromarkToken = {
|
||||
export type MicromarkToken = {
|
||||
/**
|
||||
* Token type.
|
||||
*/
|
||||
|
@ -236,11 +169,11 @@ type MicromarkToken = {
|
|||
/**
|
||||
* Error-reporting callback.
|
||||
*/
|
||||
type RuleOnError = (onErrorInfo: RuleOnErrorInfo) => void;
|
||||
export type RuleOnError = (onErrorInfo: RuleOnErrorInfo) => void;
|
||||
/**
|
||||
* Fix information for RuleOnError callback.
|
||||
*/
|
||||
type RuleOnErrorInfo = {
|
||||
export type RuleOnErrorInfo = {
|
||||
/**
|
||||
* Line number (1-based).
|
||||
*/
|
||||
|
@ -269,7 +202,7 @@ type RuleOnErrorInfo = {
|
|||
/**
|
||||
* Fix information for RuleOnErrorInfo.
|
||||
*/
|
||||
type RuleOnErrorFixInfo = {
|
||||
export type RuleOnErrorFixInfo = {
|
||||
/**
|
||||
* Line number (1-based).
|
||||
*/
|
||||
|
@ -290,7 +223,7 @@ type RuleOnErrorFixInfo = {
|
|||
/**
|
||||
* RuleOnErrorInfo with all optional properties present.
|
||||
*/
|
||||
type RuleOnErrorFixInfoNormalized = {
|
||||
export type RuleOnErrorFixInfoNormalized = {
|
||||
/**
|
||||
* Line number (1-based).
|
||||
*/
|
||||
|
@ -311,7 +244,7 @@ type RuleOnErrorFixInfoNormalized = {
|
|||
/**
|
||||
* Rule definition.
|
||||
*/
|
||||
type Rule = {
|
||||
export type Rule = {
|
||||
/**
|
||||
* Rule name(s).
|
||||
*/
|
||||
|
@ -344,7 +277,7 @@ type Rule = {
|
|||
/**
|
||||
* Configuration options.
|
||||
*/
|
||||
type Options = {
|
||||
export type Options = {
|
||||
/**
|
||||
* Configuration object.
|
||||
*/
|
||||
|
@ -395,21 +328,21 @@ type Options = {
|
|||
/**
|
||||
* A markdown-it plugin.
|
||||
*/
|
||||
type Plugin = any[];
|
||||
export type Plugin = any[];
|
||||
/**
|
||||
* Function to pretty-print lint results.
|
||||
*/
|
||||
type ToStringCallback = (ruleAliases?: boolean) => string;
|
||||
export type ToStringCallback = (ruleAliases?: boolean) => string;
|
||||
/**
|
||||
* Lint results (for resultVersion 3).
|
||||
*/
|
||||
type LintResults = {
|
||||
export type LintResults = {
|
||||
[x: string]: LintError[];
|
||||
};
|
||||
/**
|
||||
* Lint error.
|
||||
*/
|
||||
type LintError = {
|
||||
export type LintError = {
|
||||
/**
|
||||
* Line number (1-based).
|
||||
*/
|
||||
|
@ -446,7 +379,7 @@ type LintError = {
|
|||
/**
|
||||
* Fix information.
|
||||
*/
|
||||
type FixInfo = {
|
||||
export type FixInfo = {
|
||||
/**
|
||||
* Line number (1-based).
|
||||
*/
|
||||
|
@ -467,37 +400,92 @@ type FixInfo = {
|
|||
/**
|
||||
* Called with the result of linting a string or document.
|
||||
*/
|
||||
type LintContentCallback = (error: Error | null, result?: LintError[]) => void;
|
||||
export type LintContentCallback = (error: Error | null, result?: LintError[]) => void;
|
||||
/**
|
||||
* Called with the result of the lint function.
|
||||
*/
|
||||
type LintCallback = (error: Error | null, results?: LintResults) => void;
|
||||
export type LintCallback = (error: Error | null, results?: LintResults) => void;
|
||||
/**
|
||||
* Configuration object for linting rules. For the JSON schema, see
|
||||
* {@link ../schema/markdownlint-config-schema.json}.
|
||||
*/
|
||||
type Configuration = import("./configuration").Configuration;
|
||||
export type Configuration = import("./configuration.d.ts").Configuration;
|
||||
/**
|
||||
* Configuration object for linting rules strictly. For the JSON schema, see
|
||||
* {@link ../schema/markdownlint-config-schema-strict.json}.
|
||||
*/
|
||||
type ConfigurationStrict = import("./configuration-strict").ConfigurationStrict;
|
||||
export type ConfigurationStrict = import("./configuration-strict.d.ts").ConfigurationStrict;
|
||||
/**
|
||||
* Rule configuration.
|
||||
*/
|
||||
type RuleConfiguration = boolean | any;
|
||||
export type RuleConfiguration = boolean | any;
|
||||
/**
|
||||
* Parses a configuration string and returns a configuration object.
|
||||
*/
|
||||
type ConfigurationParser = (text: string) => Configuration;
|
||||
export type ConfigurationParser = (text: string) => Configuration;
|
||||
/**
|
||||
* Called with the result of the readConfig function.
|
||||
*/
|
||||
type ReadConfigCallback = (err: Error | null, config?: Configuration) => void;
|
||||
export type ReadConfigCallback = (err: Error | null, config?: Configuration) => void;
|
||||
/**
|
||||
* Called with the result of the resolveConfigExtends function.
|
||||
*/
|
||||
type ResolveConfigExtendsCallback = (err: Error | null, path?: string) => void;
|
||||
export type ResolveConfigExtendsCallback = (err: Error | null, path?: string) => void;
|
||||
/**
|
||||
* Lint specified Markdown files.
|
||||
*
|
||||
* @param {Options | null} options Configuration options.
|
||||
* @param {LintCallback} callback Callback (err, result) function.
|
||||
* @returns {void}
|
||||
*/
|
||||
declare function markdownlint(options: Options | null, callback: LintCallback): void;
|
||||
declare namespace markdownlint {
|
||||
export { markdownlintSync as sync };
|
||||
export { readConfig };
|
||||
export { readConfigSync };
|
||||
export { getVersion };
|
||||
export namespace promises {
|
||||
export { markdownlintPromise as markdownlint };
|
||||
export { extendConfigPromise as extendConfig };
|
||||
export { readConfigPromise as readConfig };
|
||||
}
|
||||
export { applyFix };
|
||||
export { applyFixes };
|
||||
}
|
||||
/**
|
||||
* Lint specified Markdown files synchronously.
|
||||
*
|
||||
* @param {Options | null} options Configuration options.
|
||||
* @returns {LintResults} Results object.
|
||||
*/
|
||||
declare function markdownlintSync(options: Options | null): LintResults;
|
||||
/**
|
||||
* Read specified configuration file.
|
||||
*
|
||||
* @param {string} file Configuration file name.
|
||||
* @param {ConfigurationParser[] | ReadConfigCallback} parsers Parsing
|
||||
* function(s).
|
||||
* @param {Object} [fs] File system implementation.
|
||||
* @param {ReadConfigCallback} [callback] Callback (err, result) function.
|
||||
* @returns {void}
|
||||
*/
|
||||
declare function readConfig(file: string, parsers: ConfigurationParser[] | ReadConfigCallback, fs?: any, callback?: ReadConfigCallback): void;
|
||||
/**
|
||||
* Read specified configuration file synchronously.
|
||||
*
|
||||
* @param {string} file Configuration file name.
|
||||
* @param {ConfigurationParser[]} [parsers] Parsing function(s).
|
||||
* @param {Object} [fs] File system implementation.
|
||||
* @returns {Configuration} Configuration object.
|
||||
* @throws An Error if processing fails.
|
||||
*/
|
||||
declare function readConfigSync(file: string, parsers?: ConfigurationParser[], fs?: any): Configuration;
|
||||
/**
|
||||
* Gets the (semantic) version of the library.
|
||||
*
|
||||
* @returns {string} SemVer string.
|
||||
*/
|
||||
declare function getVersion(): string;
|
||||
/**
|
||||
* Lint specified Markdown files.
|
||||
*
|
||||
|
@ -524,3 +512,20 @@ declare function extendConfigPromise(config: Configuration, file: string, parser
|
|||
* @returns {Promise<Configuration>} Configuration object.
|
||||
*/
|
||||
declare function readConfigPromise(file: string, parsers?: ConfigurationParser[], fs?: any): Promise<Configuration>;
|
||||
/**
|
||||
* Applies the specified fix to a Markdown content line.
|
||||
*
|
||||
* @param {string} line Line of Markdown content.
|
||||
* @param {RuleOnErrorFixInfo} fixInfo RuleOnErrorFixInfo instance.
|
||||
* @param {string} [lineEnding] Line ending to use.
|
||||
* @returns {string | null} Fixed content or null if deleted.
|
||||
*/
|
||||
declare function applyFix(line: string, fixInfo: RuleOnErrorFixInfo, lineEnding?: string): string | null;
|
||||
/**
|
||||
* Applies as many of the specified fixes as possible to Markdown content.
|
||||
*
|
||||
* @param {string} input Lines of Markdown content.
|
||||
* @param {RuleOnErrorInfo[]} errors RuleOnErrorInfo instances.
|
||||
* @returns {string} Fixed content.
|
||||
*/
|
||||
declare function applyFixes(input: string, errors: RuleOnErrorInfo[]): string;
|
|
@ -1,19 +1,16 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const path = require("node:path");
|
||||
const { promisify } = require("node:util");
|
||||
const micromark = require("../helpers/micromark-parse.cjs");
|
||||
const { version } = require("./constants");
|
||||
const rules = require("./rules");
|
||||
const helpers = require("../helpers");
|
||||
const cache = require("./cache");
|
||||
|
||||
// @ts-ignore
|
||||
// eslint-disable-next-line camelcase, no-inline-comments, no-undef
|
||||
const dynamicRequire = (typeof __non_webpack_require__ === "undefined") ? require : /* c8 ignore next */ __non_webpack_require__;
|
||||
// Capture native require implementation for dynamic loading of modules
|
||||
import * as nodeFs from "node:fs";
|
||||
import { createRequire } from "node:module";
|
||||
const dynamicRequire = createRequire(import.meta.url);
|
||||
import * as os from "node:os";
|
||||
import path from "node:path";
|
||||
import { promisify } from "node:util";
|
||||
import { initialize as cacheInitialize } from "./cache.mjs";
|
||||
import { version } from "./constants.mjs";
|
||||
import rules from "./rules.mjs";
|
||||
import { parse as micromarkParse } from "../helpers/micromark-parse.mjs";
|
||||
import * as helpers from "../helpers/helpers.cjs";
|
||||
|
||||
/**
|
||||
* Validate the list of rules for structure and reuse.
|
||||
|
@ -497,7 +494,7 @@ function lintContent(
|
|||
);
|
||||
const customRulesPresent = (ruleList.length !== rules.length);
|
||||
// Parse content into parser tokens
|
||||
const micromarkTokens = micromark.parse(
|
||||
const micromarkTokens = micromarkParse(
|
||||
content,
|
||||
{ "freezeTokens": customRulesPresent }
|
||||
);
|
||||
|
@ -507,7 +504,7 @@ function lintContent(
|
|||
// Parse content into lines and get markdown-it tokens
|
||||
const lines = content.split(helpers.newLineRe);
|
||||
const markdownitTokens = needMarkdownItTokens ?
|
||||
require("./markdownit.cjs").getMarkdownItTokens(markdownItPlugins, preClearedContent, lines) :
|
||||
dynamicRequire("./markdownit.cjs").getMarkdownItTokens(markdownItPlugins, preClearedContent, lines) :
|
||||
[];
|
||||
// Create (frozen) parameters for rules
|
||||
/** @type {MarkdownParsers} */
|
||||
|
@ -533,7 +530,7 @@ function lintContent(
|
|||
"lines": Object.freeze(lines),
|
||||
"frontMatterLines": Object.freeze(frontMatterLines)
|
||||
};
|
||||
cache.initialize({
|
||||
cacheInitialize({
|
||||
...paramsBase,
|
||||
"parsers": parsersMicromark,
|
||||
"config": null
|
||||
|
@ -751,7 +748,7 @@ function lintContent(
|
|||
} catch (error) {
|
||||
callbackError(error);
|
||||
} finally {
|
||||
cache.initialize();
|
||||
cacheInitialize();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -866,7 +863,7 @@ function lintInput(options, synchronous, callback) {
|
|||
3 :
|
||||
options.resultVersion;
|
||||
const markdownItPlugins = options.markdownItPlugins || [];
|
||||
const fs = options.fs || require("node:fs");
|
||||
const fs = options.fs || nodeFs;
|
||||
const aliasToRuleNames = mapAliasToRuleNames(ruleList);
|
||||
const results = newResults(ruleList);
|
||||
let done = false;
|
||||
|
@ -1068,7 +1065,7 @@ function extendConfig(config, file, parsers, fs, callback) {
|
|||
if (configExtends) {
|
||||
return resolveConfigExtends(
|
||||
file,
|
||||
helpers.expandTildePath(configExtends, require("node:os")),
|
||||
helpers.expandTildePath(configExtends, os),
|
||||
fs,
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
(_, resolvedExtends) => readConfig(
|
||||
|
@ -1132,10 +1129,10 @@ function readConfig(file, parsers, fs, callback) {
|
|||
}
|
||||
}
|
||||
if (!fs) {
|
||||
fs = require("node:fs");
|
||||
fs = nodeFs;
|
||||
}
|
||||
// Read file
|
||||
file = helpers.expandTildePath(file, require("node:os"));
|
||||
file = helpers.expandTildePath(file, os);
|
||||
fs.readFile(file, "utf8", (err, content) => {
|
||||
if (err) {
|
||||
// @ts-ignore
|
||||
|
@ -1180,10 +1177,9 @@ function readConfigPromise(file, parsers, fs) {
|
|||
*/
|
||||
function readConfigSync(file, parsers, fs) {
|
||||
if (!fs) {
|
||||
fs = require("node:fs");
|
||||
fs = nodeFs;
|
||||
}
|
||||
// Read file
|
||||
const os = require("node:os");
|
||||
file = helpers.expandTildePath(file, os);
|
||||
const content = fs.readFileSync(file, "utf8");
|
||||
// Try to parse file
|
||||
|
@ -1248,7 +1244,7 @@ function applyFix(line, fixInfo, lineEnding = "\n") {
|
|||
* @returns {string} Fixed content.
|
||||
*/
|
||||
function applyFixes(input, errors) {
|
||||
const lineEnding = helpers.getPreferredLineEnding(input, require("node:os"));
|
||||
const lineEnding = helpers.getPreferredLineEnding(input, os);
|
||||
const lines = input.split(helpers.newLineRe);
|
||||
// Normalize fixInfo objects
|
||||
let fixInfos = errors
|
||||
|
@ -1267,8 +1263,7 @@ function applyFixes(input, errors) {
|
|||
);
|
||||
});
|
||||
// Remove duplicate entries (needed for following collapse step)
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type RuleOnErrorFixInfo */
|
||||
/** @type {RuleOnErrorFixInfo} */
|
||||
let lastFixInfo = {};
|
||||
fixInfos = fixInfos.filter((fixInfo) => {
|
||||
const unique = (
|
||||
|
@ -1342,7 +1337,7 @@ markdownlint.promises = {
|
|||
};
|
||||
markdownlint.applyFix = applyFix;
|
||||
markdownlint.applyFixes = applyFixes;
|
||||
module.exports = markdownlint;
|
||||
export default markdownlint;
|
||||
|
||||
// Type declarations
|
||||
|
||||
|
@ -1414,7 +1409,7 @@ module.exports = markdownlint;
|
|||
* @property {string} line Line content.
|
||||
*/
|
||||
|
||||
/** @typedef {import("markdownlint-micromark").TokenType} MicromarkTokenType */
|
||||
/** @typedef {import("micromark-util-types").TokenType} MicromarkTokenType */
|
||||
|
||||
/**
|
||||
* micromark token.
|
||||
|
@ -1567,14 +1562,14 @@ module.exports = markdownlint;
|
|||
* Configuration object for linting rules. For the JSON schema, see
|
||||
* {@link ../schema/markdownlint-config-schema.json}.
|
||||
*
|
||||
* @typedef {import("./configuration").Configuration} Configuration
|
||||
* @typedef {import("./configuration.d.ts").Configuration} Configuration
|
||||
*/
|
||||
|
||||
/**
|
||||
* Configuration object for linting rules strictly. For the JSON schema, see
|
||||
* {@link ../schema/markdownlint-config-schema-strict.json}.
|
||||
*
|
||||
* @typedef {import("./configuration-strict").ConfigurationStrict} ConfigurationStrict
|
||||
* @typedef {import("./configuration-strict.d.ts").ConfigurationStrict} ConfigurationStrict
|
||||
*/
|
||||
|
||||
/**
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { getHeadingLevel } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { getHeadingLevel } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD001", "heading-increment" ],
|
||||
"description": "Heading levels should only increment by one level at a time",
|
||||
"tags": [ "headings" ],
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { getHeadingLevel, getHeadingStyle } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { getHeadingLevel, getHeadingStyle } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD003", "heading-style" ],
|
||||
"description": "Heading style",
|
||||
"tags": [ "headings" ],
|
|
@ -1,10 +1,8 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { getDescendantsByType, getParentOfType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { getDescendantsByType, getParentOfType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const markerToStyle = {
|
||||
"-": "dash",
|
||||
|
@ -29,9 +27,8 @@ const validStyles = new Set([
|
|||
"sublist"
|
||||
]);
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD004", "ul-style" ],
|
||||
"description": "Unordered list style",
|
||||
"tags": [ "bullet", "ul" ],
|
|
@ -1,13 +1,10 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addError, addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addError, addErrorDetailIf } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD005", "list-indent" ],
|
||||
"description": "Inconsistent indentation for list items at the same level",
|
||||
"tags": [ "bullet", "ul", "indentation" ],
|
|
@ -1,23 +1,18 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { getParentOfType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { getParentOfType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("markdownlint-micromark").TokenType[] */
|
||||
/** @type {import("micromark-util-types").TokenType[]} */
|
||||
const unorderedListTypes =
|
||||
[ "blockQuotePrefix", "listItemPrefix", "listUnordered" ];
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("markdownlint-micromark").TokenType[] */
|
||||
/** @type {import("micromark-util-types").TokenType[]} */
|
||||
const unorderedParentTypes =
|
||||
[ "blockQuote", "listOrdered", "listUnordered" ];
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD007", "ul-indent" ],
|
||||
"description": "Unordered list indentation",
|
||||
"tags": [ "bullet", "ul", "indentation" ],
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addError } from "../helpers/helpers.cjs";
|
||||
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addError } = require("../helpers");
|
||||
const { addRangeToSet } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD009", "no-trailing-spaces" ],
|
||||
"description": "Trailing spaces",
|
||||
"tags": [ "whitespace" ],
|
|
@ -1,16 +1,13 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addError, hasOverlap } = require("../helpers");
|
||||
const { getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addError, hasOverlap } from "../helpers/helpers.cjs";
|
||||
import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const tabRe = /\t+/g;
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD010", "no-hard-tabs" ],
|
||||
"description": "Hard tabs",
|
||||
"tags": [ "whitespace", "hard_tab" ],
|
||||
|
@ -26,8 +23,7 @@ module.exports = {
|
|||
const spaceMultiplier = (spacesPerTab === undefined) ?
|
||||
1 :
|
||||
Math.max(0, Number(spacesPerTab));
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("../helpers/micromark-helpers.cjs").TokenType[] */
|
||||
/** @type {import("../helpers/micromark-helpers.cjs").TokenType[]} */
|
||||
const exclusionTypes = [];
|
||||
if (includeCode) {
|
||||
if (ignoreCodeLanguages.size > 0) {
|
||||
|
@ -60,7 +56,7 @@ module.exports = {
|
|||
const lineNumber = lineIndex + 1;
|
||||
const column = match.index + 1;
|
||||
const length = match[0].length;
|
||||
/** @type {import("../helpers").FileRange} */
|
||||
/** @type {import("../helpers/helpers.cjs").FileRange} */
|
||||
const range = { "startLine": lineNumber, "startColumn": column, "endLine": lineNumber, "endColumn": column + length - 1 };
|
||||
if (!codeRanges.some((codeRange) => hasOverlap(codeRange, range))) {
|
||||
addError(
|
|
@ -1,17 +1,13 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addError, hasOverlap } from "../helpers/helpers.cjs";
|
||||
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addError, hasOverlap } = require("../helpers");
|
||||
const { addRangeToSet } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
const reversedLinkRe = /(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)\](?!\()/g;
|
||||
|
||||
const reversedLinkRe =
|
||||
/(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)\](?!\()/g;
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD011", "no-reversed-links" ],
|
||||
"description": "Reversed link syntax",
|
||||
"tags": [ "links" ],
|
||||
|
@ -34,7 +30,7 @@ module.exports = {
|
|||
) {
|
||||
const column = match.index + preChar.length + 1;
|
||||
const length = match[0].length - preChar.length;
|
||||
/** @type {import("../helpers").FileRange} */
|
||||
/** @type {import("../helpers/helpers.cjs").FileRange} */
|
||||
const range = { "startLine": lineNumber, "startColumn": column, "endLine": lineNumber, "endColumn": column + length - 1 };
|
||||
if (!codeTexts.some((codeText) => hasOverlap(codeText, range))) {
|
||||
addError(
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { addRangeToSet } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD012", "no-multiple-blanks" ],
|
||||
"description": "Multiple consecutive blank lines",
|
||||
"tags": [ "whitespace", "blank_lines" ],
|
|
@ -1,20 +1,19 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { getReferenceLinkImageData } = require("./cache");
|
||||
const { addRangeToSet, getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached, getReferenceLinkImageData } from "./cache.mjs";
|
||||
import { addRangeToSet, getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
|
||||
const longLineRePrefix = "^.{";
|
||||
const longLineRePostfixRelaxed = "}.*\\s.*$";
|
||||
const longLineRePostfixStrict = "}.+$";
|
||||
const sternModeRe = /^(?:[#>\s]*\s)?\S*$/;
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @typedef {import("micromark-extension-gfm-autolink-literal")} */
|
||||
/** @typedef {import("micromark-extension-gfm-table")} */
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD013", "line-length" ],
|
||||
"description": "Line length",
|
||||
"tags": [ "line_length" ],
|
|
@ -1,15 +1,12 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const dollarCommandRe = /^(\s*)(\$\s+)/;
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD014", "commands-show-output" ],
|
||||
"description": "Dollar signs used before commands without showing output",
|
||||
"tags": [ "code" ],
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { addRangeToSet } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD018", "no-missing-space-atx" ],
|
||||
"description": "No space after hash on atx style heading",
|
||||
"tags": [ "headings", "atx", "spaces" ],
|
|
@ -1,16 +1,14 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorContext } = require("../helpers/helpers");
|
||||
const { getHeadingStyle } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { getHeadingStyle } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/**
|
||||
* Validate heading sequence and whitespace length at start or end.
|
||||
*
|
||||
* @param {import("./markdownlint").RuleOnError} onError Error-reporting callback.
|
||||
* @param {import("./markdownlint").MicromarkToken} heading ATX heading token.
|
||||
* @param {import("./markdownlint.mjs").RuleOnError} onError Error-reporting callback.
|
||||
* @param {import("./markdownlint.mjs").MicromarkToken} heading ATX heading token.
|
||||
* @param {number} delta Direction to scan.
|
||||
* @returns {void}
|
||||
*/
|
||||
|
@ -47,9 +45,8 @@ function validateHeadingSpaces(onError, heading, delta) {
|
|||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule[] */
|
||||
module.exports = [
|
||||
/** @type {import("./markdownlint.mjs").Rule[]} */
|
||||
export default [
|
||||
{
|
||||
"names": [ "MD019", "no-multiple-space-atx" ],
|
||||
"description": "Multiple spaces after hash on atx style heading",
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { addRangeToSet } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD020", "no-missing-space-closed-atx" ],
|
||||
"description": "No space inside hashes on closed atx style heading",
|
||||
"tags": [ "headings", "atx_closed", "spaces" ],
|
|
@ -1,10 +1,8 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorDetailIf, isBlankLine } = require("../helpers");
|
||||
const { getBlockQuotePrefixText, getHeadingLevel } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorDetailIf, isBlankLine } from "../helpers/helpers.cjs";
|
||||
import { getBlockQuotePrefixText, getHeadingLevel } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const defaultLines = 1;
|
||||
|
||||
|
@ -21,9 +19,8 @@ const getLinesFunction = (linesParam) => {
|
|||
return () => lines;
|
||||
};
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD022", "blanks-around-headings" ],
|
||||
"description": "Headings should be surrounded by blank lines",
|
||||
"tags": [ "headings", "blank_lines" ],
|
|
@ -1,13 +1,10 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD023", "heading-start-left" ],
|
||||
"description": "Headings must start at the beginning of the line",
|
||||
"tags": [ "headings", "spaces" ],
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { getHeadingLevel, getHeadingText } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { getHeadingLevel, getHeadingText } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD024", "no-duplicate-heading" ],
|
||||
"description": "Multiple headings with the same content",
|
||||
"tags": [ "headings" ],
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorContext, frontMatterHasTitle } from "../helpers/helpers.cjs";
|
||||
import { getHeadingLevel, getHeadingText } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorContext, frontMatterHasTitle } = require("../helpers");
|
||||
const { getHeadingLevel, getHeadingText } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD025", "single-title", "single-h1" ],
|
||||
"description": "Multiple top-level headings in the same document",
|
||||
"tags": [ "headings" ],
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addError, allPunctuationNoQuestion, endOfLineGemojiCodeRe,
|
||||
endOfLineHtmlEntityRe, escapeForRegExp } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addError, allPunctuationNoQuestion, endOfLineGemojiCodeRe,
|
||||
endOfLineHtmlEntityRe, escapeForRegExp } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD026", "no-trailing-punctuation" ],
|
||||
"description": "Trailing punctuation in heading",
|
||||
"tags": [ "headings" ],
|
|
@ -1,13 +1,10 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD027", "no-multiple-space-blockquote" ],
|
||||
"description": "Multiple spaces after blockquote symbol",
|
||||
"tags": [ "blockquote", "whitespace", "indentation" ],
|
|
@ -1,15 +1,12 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addError } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addError } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const ignoreTypes = new Set([ "lineEnding", "listItemIndent", "linePrefix" ]);
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD028", "no-blanks-blockquote" ],
|
||||
"description": "Blank line inside blockquote",
|
||||
"tags": [ "blockquote", "whitespace" ],
|
|
@ -1,10 +1,8 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const listStyleExamples = {
|
||||
"one": "1/1/1",
|
||||
|
@ -22,9 +20,8 @@ function getOrderedListItemValue(listItemPrefix) {
|
|||
return Number(getDescendantsByType(listItemPrefix, [ "listItemValue" ])[0].text);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD029", "ol-prefix" ],
|
||||
"description": "Ordered list item prefix",
|
||||
"tags": [ "ol" ],
|
|
@ -1,13 +1,10 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD030", "list-marker-space" ],
|
||||
"description": "Spaces after list markers",
|
||||
"tags": [ "ol", "ul", "whitespace" ],
|
|
@ -1,10 +1,8 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorContext, isBlankLine } = require("../helpers");
|
||||
const { getParentOfType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorContext, isBlankLine } from "../helpers/helpers.cjs";
|
||||
import { getParentOfType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const codeFencePrefixRe = /^(.*?)[`~]/;
|
||||
|
||||
|
@ -14,7 +12,7 @@ const codeFencePrefixRe = /^(.*?)[`~]/;
|
|||
/**
|
||||
* Adds an error for the top or bottom of a code fence.
|
||||
*
|
||||
* @param {import("./markdownlint").RuleOnError} onError Error-reporting callback.
|
||||
* @param {import("./markdownlint.mjs").RuleOnError} onError Error-reporting callback.
|
||||
* @param {ReadonlyStringArray} lines Lines of Markdown content.
|
||||
* @param {number} lineNumber Line number.
|
||||
* @param {boolean} top True iff top fence.
|
||||
|
@ -24,7 +22,7 @@ function addError(onError, lines, lineNumber, top) {
|
|||
const line = lines[lineNumber - 1];
|
||||
const [ , prefix ] = line.match(codeFencePrefixRe) || [];
|
||||
const fixInfo = (prefix === undefined) ?
|
||||
null :
|
||||
undefined :
|
||||
{
|
||||
"lineNumber": lineNumber + (top ? 0 : 1),
|
||||
"insertText": `${prefix.replace(/[^>]/g, " ").trim()}\n`
|
||||
|
@ -40,9 +38,8 @@ function addError(onError, lines, lineNumber, top) {
|
|||
);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD031", "blanks-around-fences" ],
|
||||
"description": "Fenced code blocks should be surrounded by blank lines",
|
||||
"tags": [ "code", "blank_lines" ],
|
|
@ -1,18 +1,15 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorContext, isBlankLine } = require("../helpers");
|
||||
const { filterByPredicate, getBlockQuotePrefixText, nonContentTokens } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorContext, isBlankLine } from "../helpers/helpers.cjs";
|
||||
import { filterByPredicate, getBlockQuotePrefixText, nonContentTokens } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const isList = (token) => (
|
||||
(token.type === "listOrdered") || (token.type === "listUnordered")
|
||||
);
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD032", "blanks-around-lists" ],
|
||||
"description": "Lists should be surrounded by blank lines",
|
||||
"tags": [ "bullet", "ul", "ol", "blank_lines" ],
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addError, nextLinesRe } from "../helpers/helpers.cjs";
|
||||
import { getHtmlTagInfo } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addError, nextLinesRe } = require("../helpers");
|
||||
const { getHtmlTagInfo } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD033", "no-inline-html" ],
|
||||
"description": "Inline HTML",
|
||||
"tags": [ "html" ],
|
|
@ -1,13 +1,12 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { filterByPredicate, getHtmlTagInfo, inHtmlFlow } from "../helpers/micromark-helpers.cjs";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { filterByPredicate, getHtmlTagInfo, inHtmlFlow } = require("../helpers/micromark-helpers.cjs");
|
||||
/** @typedef {import("micromark-extension-gfm-autolink-literal")} */
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD034", "no-bare-urls" ],
|
||||
"description": "Bare URL used",
|
||||
"tags": [ "links", "url" ],
|
|
@ -1,13 +1,10 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD035", "hr-style" ],
|
||||
"description": "Horizontal rule style",
|
||||
"tags": [ "hr" ],
|
|
@ -1,10 +1,8 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorContext, allPunctuation } = require("../helpers");
|
||||
const { getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorContext, allPunctuation } from "../helpers/helpers.cjs";
|
||||
import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/** @typedef {import("../helpers/micromark-helpers.cjs").TokenType} TokenType */
|
||||
/** @type {TokenType[][]} */
|
||||
|
@ -13,9 +11,8 @@ const emphasisTypes = [
|
|||
[ "strong", "strongText" ]
|
||||
];
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD036", "no-emphasis-as-heading" ],
|
||||
"description": "Emphasis used instead of a heading",
|
||||
"tags": [ "headings", "emphasis" ],
|
|
@ -1,13 +1,10 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addError } from "../helpers/helpers.cjs";
|
||||
import { filterByPredicate, inHtmlFlow } from "../helpers/micromark-helpers.cjs";
|
||||
|
||||
const { addError } = require("../helpers");
|
||||
const { filterByPredicate, inHtmlFlow } = require("../helpers/micromark-helpers.cjs");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD037", "no-space-in-emphasis" ],
|
||||
"description": "Spaces inside emphasis markers",
|
||||
"tags": [ "whitespace", "emphasis" ],
|
|
@ -1,10 +1,8 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const leftSpaceRe = /^\s(?:[^`]|$)/;
|
||||
const rightSpaceRe = /[^`]\s$/;
|
||||
|
@ -19,9 +17,8 @@ const trimCodeText = (text, start, end) => {
|
|||
return text;
|
||||
};
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD038", "no-space-in-code" ],
|
||||
"description": "Spaces inside code span elements",
|
||||
"tags": [ "whitespace", "code" ],
|
|
@ -1,14 +1,12 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { getReferenceLinkImageData, filterByTypesCached } = require("./cache");
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { getReferenceLinkImageData, filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/**
|
||||
* Adds an error for a label space issue.
|
||||
*
|
||||
* @param {import("./markdownlint").RuleOnError} onError Error-reporting callback.
|
||||
* @param {import("./markdownlint.mjs").RuleOnError} onError Error-reporting callback.
|
||||
* @param {import("../helpers/micromark-helpers.cjs").Token} label Label token.
|
||||
* @param {import("../helpers/micromark-helpers.cjs").Token} labelText LabelText token.
|
||||
* @param {boolean} isStart True iff error is at the start of the link.
|
||||
|
@ -49,9 +47,8 @@ function validLink(label, labelText, definitions) {
|
|||
return (label.parent?.children.length !== 1) || definitions.has(labelText.text.trim());
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD039", "no-space-in-links" ],
|
||||
"description": "Spaces inside link text",
|
||||
"tags": [ "whitespace", "links" ],
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addError, addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addError, addErrorContext } = require("../helpers");
|
||||
const { getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD040", "fenced-code-language" ],
|
||||
"description": "Fenced code blocks should have a language specified",
|
||||
"tags": [ "code", "language" ],
|
|
@ -1,14 +1,10 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorContext, frontMatterHasTitle } from "../helpers/helpers.cjs";
|
||||
import { filterByTypes, getHeadingLevel, getHtmlTagInfo, isHtmlFlowComment, nonContentTokens } from "../helpers/micromark-helpers.cjs";
|
||||
|
||||
const { addErrorContext, frontMatterHasTitle } = require("../helpers");
|
||||
const { filterByTypes, getHeadingLevel, getHtmlTagInfo, isHtmlFlowComment, nonContentTokens } =
|
||||
require("../helpers/micromark-helpers.cjs");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD041", "first-line-heading", "first-line-h1" ],
|
||||
"description": "First line in a file should be a top-level heading",
|
||||
"tags": [ "headings" ],
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
import { getReferenceLinkImageData, filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { getReferenceLinkImageData, filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD042", "no-empty-links" ],
|
||||
"description": "No empty links",
|
||||
"tags": [ "links" ],
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorContext, addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { getHeadingLevel, getHeadingText } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorContext, addErrorDetailIf } = require("../helpers");
|
||||
const { getHeadingLevel, getHeadingText } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD043", "required-headings" ],
|
||||
"description": "Required heading structure",
|
||||
"tags": [ "headings" ],
|
|
@ -1,18 +1,15 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorDetailIf, escapeForRegExp, hasOverlap } = require("../helpers");
|
||||
const { filterByPredicate, filterByTypes } = require("../helpers/micromark-helpers.cjs");
|
||||
const { parse } = require("../helpers/micromark-parse.cjs");
|
||||
import { addErrorDetailIf, escapeForRegExp, hasOverlap } from "../helpers/helpers.cjs";
|
||||
import { filterByPredicate, filterByTypes } from "../helpers/micromark-helpers.cjs";
|
||||
import { parse } from "../helpers/micromark-parse.mjs";
|
||||
|
||||
const ignoredChildTypes = new Set(
|
||||
[ "codeFencedFence", "definition", "reference", "resource" ]
|
||||
);
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD044", "proper-names" ],
|
||||
"description": "Proper names should have the correct capitalization",
|
||||
"tags": [ "spelling" ],
|
||||
|
@ -48,7 +45,7 @@ module.exports = {
|
|||
token.children.filter((t) => !ignoredChildTypes.has(t.type))
|
||||
)
|
||||
);
|
||||
/** @type {import("../helpers").FileRange[]} */
|
||||
/** @type {import("../helpers/helpers.cjs").FileRange[]} */
|
||||
const exclusions = [];
|
||||
const scannedTokens = new Set();
|
||||
for (const name of names) {
|
||||
|
@ -64,7 +61,7 @@ module.exports = {
|
|||
const column = token.startColumn + match.index + leftMatch.length;
|
||||
const length = nameMatch.length;
|
||||
const lineNumber = token.startLine;
|
||||
/** @type {import("../helpers").FileRange} */
|
||||
/** @type {import("../helpers/helpers.cjs").FileRange} */
|
||||
const nameRange = {
|
||||
"startLine": lineNumber,
|
||||
"startColumn": column,
|
||||
|
@ -75,7 +72,7 @@ module.exports = {
|
|||
!names.includes(nameMatch) &&
|
||||
!exclusions.some((exclusion) => hasOverlap(exclusion, nameRange))
|
||||
) {
|
||||
/** @type {import("../helpers").FileRange[]} */
|
||||
/** @type {import("../helpers/helpers.cjs").FileRange[]} */
|
||||
let autolinkRanges = [];
|
||||
if (!scannedTokens.has(token)) {
|
||||
autolinkRanges = filterByTypes(parse(token.text), [ "literalAutolink" ])
|
|
@ -1,16 +1,13 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addError, getHtmlAttributeRe, nextLinesRe } = require("../helpers");
|
||||
const { getHtmlTagInfo, getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addError, getHtmlAttributeRe, nextLinesRe } from "../helpers/helpers.cjs";
|
||||
import { getHtmlTagInfo, getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const altRe = getHtmlAttributeRe("alt");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD045", "no-alt-text" ],
|
||||
"description": "Images should have alternate text (alt text)",
|
||||
"tags": [ "accessibility", "images" ],
|
|
@ -1,18 +1,15 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const tokenTypeToStyle = {
|
||||
"codeFenced": "fenced",
|
||||
"codeIndented": "indented"
|
||||
};
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD046", "code-block-style" ],
|
||||
"description": "Code block style",
|
||||
"tags": [ "code" ],
|
|
@ -1,12 +1,9 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addError, isBlankLine } from "../helpers/helpers.cjs";
|
||||
|
||||
const { addError, isBlankLine } = require("../helpers");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD047", "single-trailing-newline" ],
|
||||
"description": "Files should end with a single newline character",
|
||||
"tags": [ "blank_lines" ],
|
|
@ -1,10 +1,8 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/**
|
||||
* Return the string representation of a fence markup character.
|
||||
|
@ -21,9 +19,8 @@ function fencedCodeBlockStyleFor(markup) {
|
|||
}
|
||||
};
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD048", "code-fence-style" ],
|
||||
"description": "Code fence style",
|
||||
"tags": [ "code" ],
|
|
@ -1,9 +1,7 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addError } = require("../helpers");
|
||||
const { filterByPredicate, getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
import { addError } from "../helpers/helpers.cjs";
|
||||
import { filterByPredicate, getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
|
||||
const intrawordRe = /^\w$/;
|
||||
|
||||
|
@ -23,10 +21,10 @@ function emphasisOrStrongStyleFor(markup) {
|
|||
};
|
||||
|
||||
/**
|
||||
* @param {import("./markdownlint").RuleParams} params Rule parameters.
|
||||
* @param {import("./markdownlint").RuleOnError} onError Error-reporting callback.
|
||||
* @param {import("markdownlint-micromark").TokenType} type Token type.
|
||||
* @param {import("markdownlint-micromark").TokenType} typeSequence Token sequence type.
|
||||
* @param {import("./markdownlint.mjs").RuleParams} params Rule parameters.
|
||||
* @param {import("./markdownlint.mjs").RuleOnError} onError Error-reporting callback.
|
||||
* @param {import("micromark-util-types").TokenType} type Token type.
|
||||
* @param {import("micromark-util-types").TokenType} typeSequence Token sequence type.
|
||||
* @param {"*" | "**"} asterisk Asterisk kind.
|
||||
* @param {"_" | "__"} underline Underline kind.
|
||||
* @param {"asterisk" | "consistent" | "underscore"} style Style string.
|
||||
|
@ -78,9 +76,8 @@ const impl =
|
|||
}
|
||||
};
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule[] */
|
||||
module.exports = [
|
||||
/** @type {import("./markdownlint.mjs").Rule[]} */
|
||||
export default [
|
||||
{
|
||||
"names": [ "MD049", "emphasis-style" ],
|
||||
"description": "Emphasis style",
|
|
@ -1,10 +1,8 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addError, getHtmlAttributeRe } = require("../helpers");
|
||||
const { filterByPredicate, filterByTypes, getHtmlTagInfo } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addError, getHtmlAttributeRe } from "../helpers/helpers.cjs";
|
||||
import { filterByPredicate, filterByTypes, getHtmlTagInfo } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
// Regular expression for identifying HTML anchor names
|
||||
const idRe = getHtmlAttributeRe("id");
|
||||
|
@ -60,9 +58,8 @@ function unescapeStringTokenText(token) {
|
|||
.join("");
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD051", "link-fragments" ],
|
||||
"description": "Link fragments should be valid",
|
||||
"tags": [ "links" ],
|
||||
|
@ -104,8 +101,7 @@ module.exports = {
|
|||
}
|
||||
|
||||
// Process link and definition fragments
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("../helpers/micromark-helpers.cjs").TokenType[][] */
|
||||
/** @type {import("../helpers/micromark-helpers.cjs").TokenType[][]} */
|
||||
const parentChilds = [
|
||||
[ "link", "resourceDestinationString" ],
|
||||
[ "definition", "definitionDestinationString" ]
|
|
@ -1,13 +1,10 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addError } from "../helpers/helpers.cjs";
|
||||
import { getReferenceLinkImageData } from "./cache.mjs";
|
||||
|
||||
const { addError } = require("../helpers");
|
||||
const { getReferenceLinkImageData } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD052", "reference-links-images" ],
|
||||
"description":
|
||||
"Reference links and images should use a label that is defined",
|
|
@ -1,15 +1,12 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addError, ellipsify } = require("../helpers");
|
||||
const { getReferenceLinkImageData } = require("./cache");
|
||||
import { addError, ellipsify } from "../helpers/helpers.cjs";
|
||||
import { getReferenceLinkImageData } from "./cache.mjs";
|
||||
|
||||
const linkReferenceDefinitionRe = /^ {0,3}\[([^\]]*[^\\])\]:/;
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD053", "link-image-reference-definitions" ],
|
||||
"description": "Link and image reference definitions should be needed",
|
||||
"tags": [ "images", "links" ],
|
|
@ -1,10 +1,8 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorContext, nextLinesRe } = require("../helpers");
|
||||
const { getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { getReferenceLinkImageData, filterByTypesCached } = require("./cache");
|
||||
import { addErrorContext, nextLinesRe } from "../helpers/helpers.cjs";
|
||||
import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
import { getReferenceLinkImageData, filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const backslashEscapeRe = /\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g;
|
||||
const removeBackslashEscapes = (text) => text.replace(backslashEscapeRe, "$1");
|
||||
|
@ -20,9 +18,8 @@ const autolinkAble = (destination) => {
|
|||
return !autolinkDisallowedRe.test(destination);
|
||||
};
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD054", "link-image-style" ],
|
||||
"description": "Link and image style",
|
||||
"tags": [ "images", "links" ],
|
|
@ -1,9 +1,7 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const whitespaceTypes = new Set([ "linePrefix", "whitespace" ]);
|
||||
const ignoreWhitespace = (tokens) => tokens.filter(
|
||||
|
@ -13,9 +11,10 @@ const firstOrNothing = (items) => items[0];
|
|||
const lastOrNothing = (items) => items[items.length - 1];
|
||||
const makeRange = (start, end) => [ start, end - start + 1 ];
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @typedef {import("micromark-extension-gfm-table")} */
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD055", "table-pipe-style" ],
|
||||
"description": "Table pipe style",
|
||||
"tags": [ "table" ],
|
|
@ -1,16 +1,15 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { getParentOfType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { getParentOfType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const makeRange = (start, end) => [ start, end - start + 1 ];
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @typedef {import("micromark-extension-gfm-table")} */
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD056", "table-column-count" ],
|
||||
"description": "Table column count",
|
||||
"tags": [ "table" ],
|
|
@ -1,14 +1,13 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorContext, isBlankLine } from "../helpers/helpers.cjs";
|
||||
import { getBlockQuotePrefixText } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorContext, isBlankLine } = require("../helpers");
|
||||
const { getBlockQuotePrefixText } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
/** @typedef {import("micromark-extension-gfm-table")} */
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD058", "blanks-around-tables" ],
|
||||
"description": "Tables should be surrounded by blank lines",
|
||||
"tags": [ "table" ],
|
74
lib/rules.js
74
lib/rules.js
|
@ -1,74 +0,0 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { homepage, version } = require("./constants");
|
||||
|
||||
// @ts-ignore
|
||||
const [ md019, md021 ] = require("./md019-md021");
|
||||
// @ts-ignore
|
||||
const [ md049, md050 ] = require("./md049-md050");
|
||||
|
||||
const rules = [
|
||||
require("./md001"),
|
||||
// md002: Deprecated and removed
|
||||
require("./md003"),
|
||||
require("./md004"),
|
||||
require("./md005"),
|
||||
// md006: Deprecated and removed
|
||||
require("./md007"),
|
||||
require("./md009"),
|
||||
require("./md010"),
|
||||
require("./md011"),
|
||||
require("./md012"),
|
||||
require("./md013"),
|
||||
require("./md014"),
|
||||
require("./md018"),
|
||||
md019,
|
||||
require("./md020"),
|
||||
md021,
|
||||
require("./md022"),
|
||||
require("./md023"),
|
||||
require("./md024"),
|
||||
require("./md025"),
|
||||
require("./md026"),
|
||||
require("./md027"),
|
||||
require("./md028"),
|
||||
require("./md029"),
|
||||
require("./md030"),
|
||||
require("./md031"),
|
||||
require("./md032"),
|
||||
require("./md033"),
|
||||
require("./md034"),
|
||||
require("./md035"),
|
||||
require("./md036"),
|
||||
require("./md037"),
|
||||
require("./md038"),
|
||||
require("./md039"),
|
||||
require("./md040"),
|
||||
require("./md041"),
|
||||
require("./md042"),
|
||||
require("./md043"),
|
||||
require("./md044"),
|
||||
require("./md045"),
|
||||
require("./md046"),
|
||||
require("./md047"),
|
||||
require("./md048"),
|
||||
md049,
|
||||
md050,
|
||||
require("./md051"),
|
||||
require("./md052"),
|
||||
require("./md053"),
|
||||
require("./md054"),
|
||||
require("./md055"),
|
||||
require("./md056"),
|
||||
// md057: See https://github.com/markdownlint/markdownlint
|
||||
require("./md058")
|
||||
];
|
||||
for (const rule of rules) {
|
||||
const name = rule.names[0].toLowerCase();
|
||||
// eslint-disable-next-line dot-notation
|
||||
rule["information"] =
|
||||
new URL(`${homepage}/blob/v${version}/doc/${name}.md`);
|
||||
}
|
||||
module.exports = rules;
|
118
lib/rules.mjs
Normal file
118
lib/rules.mjs
Normal file
|
@ -0,0 +1,118 @@
|
|||
// @ts-check
|
||||
|
||||
import { homepage, version } from "./constants.mjs";
|
||||
|
||||
import md001 from "./md001.mjs";
|
||||
import md003 from "./md003.mjs";
|
||||
import md004 from "./md004.mjs";
|
||||
import md005 from "./md005.mjs";
|
||||
import md007 from "./md007.mjs";
|
||||
import md009 from "./md009.mjs";
|
||||
import md010 from "./md010.mjs";
|
||||
import md011 from "./md011.mjs";
|
||||
import md012 from "./md012.mjs";
|
||||
import md013 from "./md013.mjs";
|
||||
import md014 from "./md014.mjs";
|
||||
import md018 from "./md018.mjs";
|
||||
import md019md021 from "./md019-md021.mjs";
|
||||
const [ md019, md021 ] = md019md021;
|
||||
import md020 from "./md020.mjs";
|
||||
import md022 from "./md022.mjs";
|
||||
import md023 from "./md023.mjs";
|
||||
import md024 from "./md024.mjs";
|
||||
import md025 from "./md025.mjs";
|
||||
import md026 from "./md026.mjs";
|
||||
import md027 from "./md027.mjs";
|
||||
import md028 from "./md028.mjs";
|
||||
import md029 from "./md029.mjs";
|
||||
import md030 from "./md030.mjs";
|
||||
import md031 from "./md031.mjs";
|
||||
import md032 from "./md032.mjs";
|
||||
import md033 from "./md033.mjs";
|
||||
import md034 from "./md034.mjs";
|
||||
import md035 from "./md035.mjs";
|
||||
import md036 from "./md036.mjs";
|
||||
import md037 from "./md037.mjs";
|
||||
import md038 from "./md038.mjs";
|
||||
import md039 from "./md039.mjs";
|
||||
import md040 from "./md040.mjs";
|
||||
import md041 from "./md041.mjs";
|
||||
import md042 from "./md042.mjs";
|
||||
import md043 from "./md043.mjs";
|
||||
import md044 from "./md044.mjs";
|
||||
import md045 from "./md045.mjs";
|
||||
import md046 from "./md046.mjs";
|
||||
import md047 from "./md047.mjs";
|
||||
import md048 from "./md048.mjs";
|
||||
import md049md050 from "./md049-md050.mjs";
|
||||
const [ md049, md050 ] = md049md050;
|
||||
import md051 from "./md051.mjs";
|
||||
import md052 from "./md052.mjs";
|
||||
import md053 from "./md053.mjs";
|
||||
import md054 from "./md054.mjs";
|
||||
import md055 from "./md055.mjs";
|
||||
import md056 from "./md056.mjs";
|
||||
import md058 from "./md058.mjs";
|
||||
|
||||
const rules = [
|
||||
md001,
|
||||
// md002: Deprecated and removed
|
||||
md003,
|
||||
md004,
|
||||
md005,
|
||||
// md006: Deprecated and removed
|
||||
md007,
|
||||
md009,
|
||||
md010,
|
||||
md011,
|
||||
md012,
|
||||
md013,
|
||||
md014,
|
||||
md018,
|
||||
md019,
|
||||
md020,
|
||||
md021,
|
||||
md022,
|
||||
md023,
|
||||
md024,
|
||||
md025,
|
||||
md026,
|
||||
md027,
|
||||
md028,
|
||||
md029,
|
||||
md030,
|
||||
md031,
|
||||
md032,
|
||||
md033,
|
||||
md034,
|
||||
md035,
|
||||
md036,
|
||||
md037,
|
||||
md038,
|
||||
md039,
|
||||
md040,
|
||||
md041,
|
||||
md042,
|
||||
md043,
|
||||
md044,
|
||||
md045,
|
||||
md046,
|
||||
md047,
|
||||
md048,
|
||||
md049,
|
||||
md050,
|
||||
md051,
|
||||
md052,
|
||||
md053,
|
||||
md054,
|
||||
md055,
|
||||
md056,
|
||||
// md057: See https://github.com/markdownlint/markdownlint
|
||||
md058
|
||||
];
|
||||
for (const rule of rules) {
|
||||
const name = rule.names[0].toLowerCase();
|
||||
// eslint-disable-next-line dot-notation
|
||||
rule["information"] = new URL(`${homepage}/blob/v${version}/doc/${name}.md`);
|
||||
}
|
||||
export default rules;
|
|
@ -1,6 +0,0 @@
|
|||
exports.mjs
|
||||
exports-html.mjs
|
||||
micromark.dev.cjs
|
||||
micromark-browser.dev.js
|
||||
micromark-html-browser.dev.js
|
||||
webpack.config.js
|
|
@ -1,2 +0,0 @@
|
|||
ignore-scripts=true
|
||||
package-lock=false
|
|
@ -1,21 +0,0 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) David Anson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
|
@ -1,10 +0,0 @@
|
|||
# markdownlint-micromark
|
||||
|
||||
> A trivial package that re-exports some [`micromark`][micromark] functionality
|
||||
> as a CommonJS module
|
||||
|
||||
This package is unlikely to be of any use beyond a specific scenario used by
|
||||
[`markdownlint`][markdownlint].
|
||||
|
||||
[markdownlint]: https://github.com/DavidAnson/markdownlint
|
||||
[micromark]: https://github.com/micromark/micromark
|
|
@ -1,40 +0,0 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
||||
"projectFolder": ".",
|
||||
"mainEntryPointFilePath": "<projectFolder>/types.d.ts",
|
||||
"bundledPackages": [ "*" ],
|
||||
"newlineKind": "os",
|
||||
"compiler": {
|
||||
"overrideTsconfig": {}
|
||||
},
|
||||
"apiReport": {
|
||||
"enabled": false
|
||||
},
|
||||
"docModel": {
|
||||
"enabled": false
|
||||
},
|
||||
"dtsRollup": {
|
||||
"enabled": true,
|
||||
"untrimmedFilePath": "<projectFolder>/micromark.d.cts"
|
||||
},
|
||||
"tsdocMetadata": {
|
||||
"enabled": false
|
||||
},
|
||||
"messages": {
|
||||
"compilerMessageReporting": {
|
||||
"default": {
|
||||
"logLevel": "warning"
|
||||
}
|
||||
},
|
||||
"extractorMessageReporting": {
|
||||
"default": {
|
||||
"logLevel": "warning"
|
||||
}
|
||||
},
|
||||
"tsdocMessageReporting": {
|
||||
"default": {
|
||||
"logLevel": "warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
// @ts-check
|
||||
|
||||
/* eslint-disable n/no-missing-import */
|
||||
|
||||
export { compile } from "micromark";
|
||||
export { directiveHtml } from "micromark-extension-directive";
|
||||
export { gfmAutolinkLiteralHtml } from "micromark-extension-gfm-autolink-literal";
|
||||
export { gfmFootnoteHtml } from "micromark-extension-gfm-footnote";
|
||||
export { gfmTableHtml } from "micromark-extension-gfm-table";
|
||||
export { mathHtml } from "micromark-extension-math";
|
|
@ -1,14 +0,0 @@
|
|||
// @ts-check
|
||||
|
||||
/* eslint-disable n/no-missing-import */
|
||||
|
||||
export { directive } from "micromark-extension-directive";
|
||||
export { gfmAutolinkLiteral } from "micromark-extension-gfm-autolink-literal";
|
||||
export { gfmFootnote } from "micromark-extension-gfm-footnote";
|
||||
export { gfmTable } from "micromark-extension-gfm-table";
|
||||
export { math } from "micromark-extension-math";
|
||||
export { parse } from "micromark";
|
||||
export { postprocess } from "micromark";
|
||||
export { preprocess } from "micromark";
|
||||
// micromark-core-commonmark is not a dev/dependency because this instance must match what's used by micromark
|
||||
export { labelEnd } from "micromark-core-commonmark";
|
File diff suppressed because it is too large
Load diff
|
@ -1,46 +0,0 @@
|
|||
{
|
||||
"name": "markdownlint-micromark",
|
||||
"version": "0.1.12",
|
||||
"description": "A trivial package that re-exports some micromark functionality as a CommonJS module",
|
||||
"type": "commonjs",
|
||||
"exports": "./micromark.cjs",
|
||||
"types": "./micromark.d.cts",
|
||||
"author": "David Anson (https://dlaa.me/)",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/DavidAnson/markdownlint",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/DavidAnson/markdownlint.git"
|
||||
},
|
||||
"bugs": "https://github.com/DavidAnson/markdownlint/issues",
|
||||
"funding": "https://github.com/sponsors/DavidAnson",
|
||||
"scripts": {
|
||||
"build": "webpack --stats minimal",
|
||||
"types": "api-extractor run --local"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"micromark-browser.js",
|
||||
"micromark-html-browser.js",
|
||||
"micromark.cjs",
|
||||
"micromark.d.cts",
|
||||
"package.json",
|
||||
"README.md"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@microsoft/api-extractor": "7.48.0",
|
||||
"micromark": "4.0.1",
|
||||
"micromark-extension-directive": "3.0.2",
|
||||
"micromark-extension-gfm-autolink-literal": "2.1.0",
|
||||
"micromark-extension-gfm-footnote": "2.1.0",
|
||||
"micromark-extension-gfm-table": "2.1.0",
|
||||
"micromark-extension-math": "3.1.0",
|
||||
"micromark-util-types": "2.0.1",
|
||||
"terser-webpack-plugin": "5.3.10",
|
||||
"webpack": "5.96.1",
|
||||
"webpack-cli": "5.1.4"
|
||||
}
|
||||
}
|
34
micromark/types.d.ts
vendored
34
micromark/types.d.ts
vendored
|
@ -1,34 +0,0 @@
|
|||
// Manually update due to api-extractor limitations including:
|
||||
// - https://github.com/microsoft/rushstack/issues/1709
|
||||
// - ERROR: Failed to fetch entity for import() type node: import('micromark-util-types').ParseContext
|
||||
// - Unwillingness to treat "katex" as one of bundledPackages
|
||||
//
|
||||
// 1. npm install
|
||||
// 2. Comment-out micromark-util-types/ParseContext in micromark/node_modules/micromark-extension-gfm-footnote/index.d.ts
|
||||
// 3. npm run types
|
||||
// 4. Remove "import type { KatexOptions } from 'katex';" in micromark/micromark.d.cts
|
||||
// 5. Replace "KatexOptions" with "Object" in micromark/micromark.d.cts
|
||||
// 6. Append "declare module 'micromark-util-types' { interface TokenTypeMap { ... } }" in micromark/micromark.d.cts from:
|
||||
// - micromark/node_modules/micromark-extension-directive/index.d.ts
|
||||
// - micromark/node_modules/micromark-extension-gfm-autolink-literal/index.d.ts
|
||||
// - micromark/node_modules/micromark-extension-gfm-footnote/index.d.ts
|
||||
// - micromark/node_modules/micromark-extension-gfm-table/index.d.ts
|
||||
// - micromark/node_modules/micromark-extension-math/index.d.ts
|
||||
// - export declare interface TokenTypeMap {
|
||||
// undefinedReference: 'undefinedReference'
|
||||
// undefinedReferenceCollapsed: 'undefinedReferenceCollapsed'
|
||||
// undefinedReferenceFull: 'undefinedReferenceFull'
|
||||
// undefinedReferenceShortcut: 'undefinedReferenceShortcut'
|
||||
// }
|
||||
// 7. Update version number in package.json and stage changes
|
||||
// 8. Test: npm run build, npm pack, npm install ./micromark/markdownlint-micromark-0.1.11.tgz, npm run ci, verify types like gfmFootnote* in getReferenceLinkImageData(...)
|
||||
// 9. Publish: git clean -dfx, npm install, npm run build, npm publish ., git push
|
||||
|
||||
export type { directive, directiveHtml } from "micromark-extension-directive";
|
||||
export type { gfmAutolinkLiteral, gfmAutolinkLiteralHtml } from "micromark-extension-gfm-autolink-literal";
|
||||
export type { gfmFootnote, gfmFootnoteHtml } from "micromark-extension-gfm-footnote";
|
||||
export type { gfmTable, gfmTableHtml } from "micromark-extension-gfm-table";
|
||||
export type { math, mathHtml } from "micromark-extension-math";
|
||||
export type { compile, parse, postprocess, preprocess } from "micromark";
|
||||
|
||||
export type { CompileData, Construct, Event, ParseOptions, State, Token, TokenType, TokenTypeMap, Tokenizer } from "micromark-util-types";
|
|
@ -1,127 +0,0 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const webpack = require("webpack");
|
||||
const TerserPlugin = require("terser-webpack-plugin");
|
||||
const { name, version, homepage } = require("./package.json");
|
||||
|
||||
const htmlEntry = "./exports-html.mjs";
|
||||
const htmlName = "micromarkHtmlBrowser";
|
||||
|
||||
const base = {
|
||||
"entry": "./exports.mjs",
|
||||
"output": {
|
||||
"path": __dirname
|
||||
},
|
||||
"plugins": [
|
||||
new webpack.BannerPlugin({
|
||||
"banner": `${name} ${version} ${homepage}`
|
||||
})
|
||||
]
|
||||
};
|
||||
|
||||
const commonjs = {
|
||||
...base,
|
||||
"output": {
|
||||
...base.output,
|
||||
"library": {
|
||||
"type": "commonjs"
|
||||
}
|
||||
},
|
||||
"target": "node"
|
||||
};
|
||||
|
||||
const web = {
|
||||
...base,
|
||||
"output": {
|
||||
...base.output,
|
||||
"library": {
|
||||
"name": "micromarkBrowser",
|
||||
"type": "var"
|
||||
}
|
||||
},
|
||||
"target": "web"
|
||||
};
|
||||
|
||||
const production = {
|
||||
"mode": "production",
|
||||
"optimization": {
|
||||
"minimizer": [
|
||||
new TerserPlugin({
|
||||
"extractComments": false,
|
||||
"terserOptions": {
|
||||
"compress": {
|
||||
"passes": 2
|
||||
}
|
||||
}
|
||||
})
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
const development = {
|
||||
"devtool": false,
|
||||
"mode": "development"
|
||||
};
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
...commonjs,
|
||||
...production,
|
||||
"output": {
|
||||
...commonjs.output,
|
||||
"filename": "micromark.cjs"
|
||||
}
|
||||
},
|
||||
{
|
||||
...commonjs,
|
||||
...development,
|
||||
"output": {
|
||||
...commonjs.output,
|
||||
"filename": "micromark.dev.cjs"
|
||||
}
|
||||
},
|
||||
{
|
||||
...web,
|
||||
...production,
|
||||
"output": {
|
||||
...web.output,
|
||||
"filename": "micromark-browser.js"
|
||||
}
|
||||
},
|
||||
{
|
||||
...web,
|
||||
...development,
|
||||
"output": {
|
||||
...web.output,
|
||||
"filename": "micromark-browser.dev.js"
|
||||
}
|
||||
},
|
||||
{
|
||||
...web,
|
||||
...production,
|
||||
"entry": htmlEntry,
|
||||
"output": {
|
||||
...web.output,
|
||||
"library": {
|
||||
...web.output.library,
|
||||
"name": htmlName
|
||||
},
|
||||
"filename": "micromark-html-browser.js"
|
||||
}
|
||||
},
|
||||
{
|
||||
...web,
|
||||
...development,
|
||||
"entry": htmlEntry,
|
||||
"output": {
|
||||
...web.output,
|
||||
"library": {
|
||||
...web.output.library,
|
||||
"name": htmlName
|
||||
},
|
||||
"filename": "micromark-html-browser.dev.js"
|
||||
}
|
||||
}
|
||||
];
|
43
package.json
43
package.json
|
@ -2,17 +2,16 @@
|
|||
"name": "markdownlint",
|
||||
"version": "0.36.1",
|
||||
"description": "A Node.js style checker and lint tool for Markdown/CommonMark files.",
|
||||
"type": "commonjs",
|
||||
"main": "./lib/markdownlint.js",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./lib/markdownlint.js",
|
||||
"./helpers": "./helpers/helpers.js",
|
||||
".": "./lib/markdownlint.mjs",
|
||||
"./helpers": "./helpers/helpers.cjs",
|
||||
"./style/all": "./style/all.json",
|
||||
"./style/cirosantilli": "./style/cirosantilli.json",
|
||||
"./style/prettier": "./style/prettier.json",
|
||||
"./style/relaxed": "./style/relaxed.json"
|
||||
},
|
||||
"types": "./lib/markdownlint.d.ts",
|
||||
"types": "./lib/markdownlint.d.mts",
|
||||
"author": "David Anson (https://dlaa.me/)",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/DavidAnson/markdownlint",
|
||||
|
@ -24,13 +23,12 @@
|
|||
"funding": "https://github.com/sponsors/DavidAnson",
|
||||
"scripts": {
|
||||
"build-config": "npm run build-config-schema && npm run build-config-example",
|
||||
"build-config-example": "node schema/build-config-example.js",
|
||||
"build-config-schema": "node schema/build-config-schema.js",
|
||||
"build-declaration": "tsc --allowJs --declaration --emitDeclarationOnly --module commonjs --outDir dts --resolveJsonModule --target es2015 lib/markdownlint.js && node scripts copy dts/lib/markdownlint.d.ts lib/markdownlint.d.ts && node scripts remove dts",
|
||||
"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-config-example": "node schema/build-config-example.mjs",
|
||||
"build-config-schema": "node schema/build-config-schema.mjs",
|
||||
"build-declaration": "tsc --allowJs --declaration --emitDeclarationOnly --module nodenext --outDir dts --target es2015 lib/markdownlint.mjs && node scripts/index.mjs copy dts/lib/markdownlint.d.mts lib/markdownlint.d.mts && node scripts/index.mjs remove dts",
|
||||
"build-demo": "node scripts/index.mjs copy node_modules/markdown-it/dist/markdown-it.min.js demo/markdown-it.min.js && cd demo && webpack --no-stats",
|
||||
"build-docs": "node doc-build/build-rules.mjs",
|
||||
"build-example": "npm install --no-save --ignore-scripts grunt grunt-cli gulp through2",
|
||||
"build-micromark": "cd micromark && npm run build",
|
||||
"ci": "npm-run-all --continue-on-error --parallel lint serial-config-docs serial-declaration-demo test-cover && git diff --exit-code",
|
||||
"clone-test-repos-apache-airflow": "cd test-repos && git clone https://github.com/apache/airflow apache-airflow --depth 1 --no-tags --quiet",
|
||||
"clone-test-repos-dotnet-docs": "cd test-repos && git clone https://github.com/dotnet/docs dotnet-docs --depth 1 --no-tags --quiet",
|
||||
|
@ -45,20 +43,17 @@
|
|||
"clone-test-repos-webpack-webpack-js-org": "cd test-repos && git clone https://github.com/webpack/webpack.js.org webpack-webpack-js-org --depth 1 --no-tags --quiet",
|
||||
"clone-test-repos": "mkdir test-repos && cd test-repos && npm run clone-test-repos-apache-airflow && npm run clone-test-repos-dotnet-docs && npm run clone-test-repos-electron-electron && npm run clone-test-repos-eslint-eslint && npm run clone-test-repos-mdn-content && npm run clone-test-repos-mkdocs-mkdocs && npm run clone-test-repos-mochajs-mocha && npm run clone-test-repos-pi-hole-docs && npm run clone-test-repos-v8-v8-dev && npm run clone-test-repos-webhintio-hint && npm run clone-test-repos-webpack-webpack-js-org",
|
||||
"declaration": "npm run build-declaration && npm run test-declaration",
|
||||
"example": "cd example && node standalone.js && grunt markdownlint --force && gulp markdownlint",
|
||||
"docker-npm-install": "docker run --rm --tty --name npm-install --volume $PWD:/home/workdir --workdir /home/workdir --user node node:latest npm install",
|
||||
"docker-npm-run-upgrade": "docker run --rm --tty --name npm-run-upgrade --volume $PWD:/home/workdir --workdir /home/workdir --user node node:latest npm run upgrade",
|
||||
"install-micromark": "cd micromark && npm install",
|
||||
"example": "cd example && node standalone.mjs && grunt markdownlint --force && gulp markdownlint",
|
||||
"lint": "eslint --max-warnings 0",
|
||||
"lint-test-repos": "ava --timeout=10m test/markdownlint-test-repos-*.js",
|
||||
"lint-test-repos": "ava --timeout=10m test/markdownlint-test-repos-*.mjs",
|
||||
"serial-config-docs": "npm run build-config && npm run build-docs",
|
||||
"serial-declaration-demo": "npm run build-declaration && npm-run-all --continue-on-error --parallel build-demo test-declaration",
|
||||
"test": "ava --timeout=30s test/markdownlint-test.js test/markdownlint-test-config.js test/markdownlint-test-custom-rules.js test/markdownlint-test-fixes.js test/markdownlint-test-helpers.js test/markdownlint-test-micromark.mjs test/markdownlint-test-result-object.js test/markdownlint-test-scenarios.js helpers/test.cjs",
|
||||
"test": "ava --timeout=30s test/markdownlint-test.mjs test/markdownlint-test-config.mjs test/markdownlint-test-custom-rules.mjs test/markdownlint-test-fixes.mjs test/markdownlint-test-helpers.mjs test/markdownlint-test-micromark.mjs test/markdownlint-test-result-object.mjs test/markdownlint-test-scenarios.mjs helpers/test.cjs",
|
||||
"test-cover": "c8 --100 npm test",
|
||||
"test-declaration": "cd example/typescript && tsc --module nodenext && tsc --module commonjs && node type-check.js",
|
||||
"test-extra": "ava --timeout=10m test/markdownlint-test-extra-parse.js test/markdownlint-test-extra-type.js",
|
||||
"update-snapshots": "ava --update-snapshots test/markdownlint-test-custom-rules.js test/markdownlint-test-micromark.mjs test/markdownlint-test-scenarios.js",
|
||||
"update-snapshots-test-repos": "ava --timeout=10m --update-snapshots test/markdownlint-test-repos-*.js",
|
||||
"test-declaration": "cd example/typescript && tsc --module commonjs && tsc --module nodenext && node type-check.js",
|
||||
"test-extra": "ava --timeout=10m test/markdownlint-test-extra-parse.mjs test/markdownlint-test-extra-type.mjs",
|
||||
"update-snapshots": "ava --update-snapshots test/markdownlint-test-custom-rules.mjs test/markdownlint-test-micromark.mjs test/markdownlint-test-scenarios.mjs",
|
||||
"update-snapshots-test-repos": "ava --timeout=10m --update-snapshots test/markdownlint-test-repos-*.mjs",
|
||||
"upgrade": "npx --yes npm-check-updates --upgrade"
|
||||
},
|
||||
"engines": {
|
||||
|
@ -66,7 +61,13 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"markdown-it": "14.1.0",
|
||||
"markdownlint-micromark": "0.1.12"
|
||||
"micromark": "4.0.0",
|
||||
"micromark-extension-directive": "3.0.2",
|
||||
"micromark-extension-gfm-autolink-literal": "2.1.0",
|
||||
"micromark-extension-gfm-footnote": "2.1.0",
|
||||
"micromark-extension-gfm-table": "2.1.0",
|
||||
"micromark-extension-math": "3.1.0",
|
||||
"micromark-util-types": "2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "9.15.0",
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const yaml = require("js-yaml");
|
||||
const configSchema = require("./markdownlint-config-schema.json");
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import yaml from "js-yaml";
|
||||
import { __dirname, importWithTypeJson } from "../test/esm-helpers.mjs";
|
||||
const configSchema = await importWithTypeJson(import.meta, "../schema/markdownlint-config-schema.json");
|
||||
|
||||
const configExample = {};
|
||||
for (const rule in configSchema.properties) {
|
||||
|
@ -35,8 +34,8 @@ const transformComments = (input, commentPrefix) => (
|
|||
);
|
||||
|
||||
const configStringJson = JSON.stringify(configExample, null, 2);
|
||||
fs.writeFileSync(
|
||||
path.join(__dirname, ".markdownlint.jsonc"),
|
||||
await fs.writeFile(
|
||||
path.join(__dirname(import.meta), ".markdownlint.jsonc"),
|
||||
transformComments(configStringJson, "//"),
|
||||
"utf8"
|
||||
);
|
||||
|
@ -49,8 +48,8 @@ const configStringYaml = yaml.dump(
|
|||
"quotingType": "\""
|
||||
}
|
||||
);
|
||||
fs.writeFileSync(
|
||||
path.join(__dirname, ".markdownlint.yaml"),
|
||||
await fs.writeFile(
|
||||
path.join(__dirname(import.meta), ".markdownlint.yaml"),
|
||||
transformComments(configStringYaml, "#"),
|
||||
"utf8"
|
||||
);
|
|
@ -1,13 +1,12 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
/** @type {import("../lib/markdownlint").Rule[]} */
|
||||
const rules = require("../lib/rules");
|
||||
const jsonSchemaToTypeScript = require("json-schema-to-typescript");
|
||||
const { version } = require("../lib/constants");
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
/** @type {import("../lib/markdownlint.mjs").Rule[]} */
|
||||
import rules from "../lib/rules.mjs";
|
||||
import jsonSchemaToTypeScript from "json-schema-to-typescript";
|
||||
import { version } from "../lib/constants.mjs";
|
||||
import { __dirname } from "../test/esm-helpers.mjs";
|
||||
|
||||
const schemaName = "markdownlint-config-schema.json";
|
||||
const schemaUri = `https://raw.githubusercontent.com/DavidAnson/markdownlint/v${version}/schema/${schemaName}`;
|
||||
|
@ -586,8 +585,8 @@ for (const [ tag, tagTags ] of Object.entries(tags)) {
|
|||
}
|
||||
|
||||
// Write schema
|
||||
const schemaFile = path.join(__dirname, schemaName);
|
||||
fs.writeFileSync(schemaFile, JSON.stringify(schema, null, " "));
|
||||
const schemaFile = path.join(__dirname(import.meta), schemaName);
|
||||
await fs.writeFile(schemaFile, JSON.stringify(schema, null, " "));
|
||||
|
||||
// Create and write strict schema
|
||||
const schemaStrict = {
|
||||
|
@ -595,15 +594,15 @@ const schemaStrict = {
|
|||
"$id": schemaStrictUri,
|
||||
"additionalProperties": false
|
||||
};
|
||||
const schemaFileStrict = path.join(__dirname, schemaStrictName);
|
||||
fs.writeFileSync(schemaFileStrict, JSON.stringify(schemaStrict, null, " "));
|
||||
const schemaFileStrict = path.join(__dirname(import.meta), schemaStrictName);
|
||||
await fs.writeFile(schemaFileStrict, JSON.stringify(schemaStrict, null, " "));
|
||||
|
||||
// Write TypeScript declaration file
|
||||
const declarationStrictName = path.join(__dirname, "..", "lib", "configuration-strict.d.ts");
|
||||
const declarationStrictName = path.join(__dirname(import.meta), "..", "lib", "configuration-strict.d.ts");
|
||||
schemaStrict.title = "ConfigurationStrict";
|
||||
jsonSchemaToTypeScript.compile(
|
||||
const declaration = await jsonSchemaToTypeScript.compile(
|
||||
// @ts-ignore
|
||||
schemaStrict,
|
||||
"UNUSED"
|
||||
// eslint-disable-next-line unicorn/prefer-top-level-await
|
||||
).then((declaration) => fs.writeFileSync(declarationStrictName, declaration));
|
||||
);
|
||||
await fs.writeFile(declarationStrictName, declaration);
|
|
@ -1,29 +0,0 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const fs = require("node:fs").promises;
|
||||
|
||||
const [ command, ...args ] = process.argv.slice(2);
|
||||
|
||||
// eslint-disable-next-line unicorn/prefer-top-level-await
|
||||
(async() => {
|
||||
if (command === "copy") {
|
||||
const [ src, dest ] = args;
|
||||
await fs.copyFile(src, dest);
|
||||
} else if (command === "delete") {
|
||||
const { globby } = await import("globby");
|
||||
await Promise.all(
|
||||
args.flatMap(
|
||||
(glob) => globby(glob)
|
||||
.then(
|
||||
(files) => files.map((file) => fs.unlink(file))
|
||||
)
|
||||
)
|
||||
);
|
||||
} else if (command === "remove") {
|
||||
await Promise.all(args.map((dir) => fs.rm(dir, { "recursive": true })));
|
||||
} else {
|
||||
throw new Error(`Unsupported command: ${command}`);
|
||||
}
|
||||
})();
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue