mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Add @stylistic/eslint-plugin to ESLint configuration.
This commit is contained in:
parent
fe02674ce0
commit
164bbac651
21 changed files with 103 additions and 78 deletions
|
|
@ -932,11 +932,13 @@ function lintInput(options, synchronous, callback) {
|
|||
const config = options.config || { "default": true };
|
||||
const configParsers = options.configParsers || null;
|
||||
const frontMatter = (options.frontMatter === undefined) ?
|
||||
helpers.frontMatterRe : options.frontMatter;
|
||||
helpers.frontMatterRe :
|
||||
options.frontMatter;
|
||||
const handleRuleFailures = !!options.handleRuleFailures;
|
||||
const noInlineConfig = !!options.noInlineConfig;
|
||||
const resultVersion = (options.resultVersion === undefined) ?
|
||||
3 : options.resultVersion;
|
||||
3 :
|
||||
options.resultVersion;
|
||||
const getMarkdownIt = () => {
|
||||
const markdownit = require("markdown-it");
|
||||
const md = markdownit({ "html": true });
|
||||
|
|
|
|||
|
|
@ -21,14 +21,14 @@ module.exports = {
|
|||
codeBlock.children,
|
||||
[ "codeFlowValue" ]
|
||||
);
|
||||
const dollarMatches = codeFlowValues.
|
||||
map((codeFlowValue) => ({
|
||||
const dollarMatches = codeFlowValues
|
||||
.map((codeFlowValue) => ({
|
||||
"result": codeFlowValue.text.match(dollarCommandRe),
|
||||
"startColumn": codeFlowValue.startColumn,
|
||||
"startLine": codeFlowValue.startLine,
|
||||
"text": codeFlowValue.text
|
||||
})).
|
||||
filter((dollarMatch) => dollarMatch.result);
|
||||
}))
|
||||
.filter((dollarMatch) => dollarMatch.result);
|
||||
if (dollarMatches.length === codeFlowValues.length) {
|
||||
for (const dollarMatch of dollarMatches) {
|
||||
// @ts-ignore
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ const { filterByTypesCached } = require("./cache");
|
|||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
"names": ["MD027", "no-multiple-space-blockquote"],
|
||||
"names": [ "MD027", "no-multiple-space-blockquote" ],
|
||||
"description": "Multiple spaces after blockquote symbol",
|
||||
"tags": ["blockquote", "whitespace", "indentation"],
|
||||
"tags": [ "blockquote", "whitespace", "indentation" ],
|
||||
"parser": "micromark",
|
||||
"function": function MD027(params, onError) {
|
||||
for (const token of filterByTypesCached([ "linePrefix" ])) {
|
||||
|
|
|
|||
10
lib/md031.js
10
lib/md031.js
|
|
@ -23,10 +23,12 @@ const codeFencePrefixRe = /^(.*?)[`~]/;
|
|||
function addError(onError, lines, lineNumber, top) {
|
||||
const line = lines[lineNumber - 1];
|
||||
const [ , prefix ] = line.match(codeFencePrefixRe) || [];
|
||||
const fixInfo = (prefix === undefined) ? null : {
|
||||
"lineNumber": lineNumber + (top ? 0 : 1),
|
||||
"insertText": `${prefix.replace(/[^>]/g, " ").trim()}\n`
|
||||
};
|
||||
const fixInfo = (prefix === undefined) ?
|
||||
null :
|
||||
{
|
||||
"lineNumber": lineNumber + (top ? 0 : 1),
|
||||
"insertText": `${prefix.replace(/[^>]/g, " ").trim()}\n`
|
||||
};
|
||||
addErrorContext(
|
||||
onError,
|
||||
lineNumber,
|
||||
|
|
|
|||
|
|
@ -21,8 +21,6 @@ module.exports = {
|
|||
if ((token.type === "literalAutolink") && !inHtmlFlow(token)) {
|
||||
// Detect and ignore https://github.com/micromark/micromark/issues/164
|
||||
const siblings = token.parent?.children;
|
||||
// Commented-out due to not being able to exercise in test/code coverage
|
||||
// || micromarkTokens;
|
||||
const index = siblings?.indexOf(token);
|
||||
// @ts-ignore
|
||||
const prev = siblings?.at(index - 1);
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ module.exports = {
|
|||
punctuation = String((punctuation === undefined) ? allPunctuation : punctuation);
|
||||
const punctuationRe = new RegExp("[" + punctuation + "]$");
|
||||
const paragraphTokens =
|
||||
filterByTypesCached([ "paragraph" ]).
|
||||
filter((token) =>
|
||||
filterByTypesCached([ "paragraph" ])
|
||||
.filter((token) =>
|
||||
(token.parent?.type === "content") && !token.parent?.parent && (token.children.length === 1)
|
||||
);
|
||||
for (const paragraphToken of paragraphTokens) {
|
||||
|
|
|
|||
14
lib/md039.js
14
lib/md039.js
|
|
@ -29,10 +29,12 @@ function addLabelSpaceError(onError, label, labelText, isStart) {
|
|||
isStart,
|
||||
!isStart,
|
||||
range,
|
||||
range ? {
|
||||
"editColumn": range[0],
|
||||
"deleteCount": range[1]
|
||||
} : undefined
|
||||
range ?
|
||||
{
|
||||
"editColumn": range[0],
|
||||
"deleteCount": range[1]
|
||||
} :
|
||||
undefined
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -57,8 +59,8 @@ module.exports = {
|
|||
"parser": "micromark",
|
||||
"function": function MD039(params, onError) {
|
||||
const { definitions } = getReferenceLinkImageData();
|
||||
const labels = filterByTypesCached([ "label" ]).
|
||||
filter((label) => label.parent?.type === "link");
|
||||
const labels = filterByTypesCached([ "label" ])
|
||||
.filter((label) => label.parent?.type === "link");
|
||||
for (const label of labels) {
|
||||
const labelTexts = filterByTypes(
|
||||
label.children,
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ module.exports = {
|
|||
"function": function MD041(params, onError) {
|
||||
const level = Number(params.config.level || 1);
|
||||
if (!frontMatterHasTitle(params.frontMatterLines, params.config.front_matter_title)) {
|
||||
params.parsers.micromark.tokens.
|
||||
filter((token) => !nonContentTokens.has(token.type) && !isHtmlFlowComment(token)).
|
||||
every((token) => {
|
||||
params.parsers.micromark.tokens
|
||||
.filter((token) => !nonContentTokens.has(token.type) && !isHtmlFlowComment(token))
|
||||
.every((token) => {
|
||||
let isError = true;
|
||||
if ((token.type === "atxHeading") || (token.type === "setextHeading")) {
|
||||
isError = (getHeadingLevel(token) !== level);
|
||||
|
|
|
|||
|
|
@ -53,4 +53,4 @@ module.exports = {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue