eslint-plugin-markdown-preferences 0.33.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +9 -2
- package/lib/index.js +91 -37
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -412,6 +412,13 @@ type MarkdownPreferencesOrderedListMarkerStyle = [] | [{
|
|
|
412
412
|
}];
|
|
413
413
|
type MarkdownPreferencesPaddedCustomContainers = [] | [{
|
|
414
414
|
padding?: ("always" | "never");
|
|
415
|
+
overrides?: [{
|
|
416
|
+
info?: (string | [string, ...(string)[]]);
|
|
417
|
+
padding?: ("always" | "never");
|
|
418
|
+
}, ...({
|
|
419
|
+
info?: (string | [string, ...(string)[]]);
|
|
420
|
+
padding?: ("always" | "never");
|
|
421
|
+
})[]];
|
|
415
422
|
}];
|
|
416
423
|
type MarkdownPreferencesPaddingLineBetweenBlocks = {
|
|
417
424
|
prev: (("blockquote" | "code" | "heading" | "html" | "list" | "paragraph" | "thematic-break" | "table" | "link-definition" | "footnote-definition" | "frontmatter" | "custom-container" | "math" | "import-code-snippet" | "*") | [("blockquote" | "code" | "heading" | "html" | "list" | "paragraph" | "thematic-break" | "table" | "link-definition" | "footnote-definition" | "frontmatter" | "custom-container" | "math" | "import-code-snippet" | "*"), ...(("blockquote" | "code" | "heading" | "html" | "list" | "paragraph" | "thematic-break" | "table" | "link-definition" | "footnote-definition" | "frontmatter" | "custom-container" | "math" | "import-code-snippet" | "*"))[]] | {
|
|
@@ -538,7 +545,7 @@ declare namespace meta_d_exports {
|
|
|
538
545
|
export { name, version };
|
|
539
546
|
}
|
|
540
547
|
declare const name: "eslint-plugin-markdown-preferences";
|
|
541
|
-
declare const version: "0.
|
|
548
|
+
declare const version: "0.34.0";
|
|
542
549
|
//#endregion
|
|
543
550
|
//#region src/language/ast-types.d.ts
|
|
544
551
|
type Node = mdast.Node;
|
|
@@ -580,7 +587,7 @@ interface CustomContainer extends ExtendChildren<mdast.Parent, CustomContainer |
|
|
|
580
587
|
/**
|
|
581
588
|
* Info string (e.g., "warning" in ::: warning ... :::).
|
|
582
589
|
*/
|
|
583
|
-
info: string
|
|
590
|
+
info: string;
|
|
584
591
|
/**
|
|
585
592
|
* Children of custom container.
|
|
586
593
|
*/
|
package/lib/index.js
CHANGED
|
@@ -828,7 +828,7 @@ function getOtherMarker(unavailableMarker) {
|
|
|
828
828
|
/**
|
|
829
829
|
* Parse rule options.
|
|
830
830
|
*/
|
|
831
|
-
function parseOptions$
|
|
831
|
+
function parseOptions$7(options) {
|
|
832
832
|
const primary = options.primary || "-";
|
|
833
833
|
const secondary = options.secondary || getOtherMarker(primary);
|
|
834
834
|
if (primary === secondary) throw new Error(`\`primary\` and \`secondary\` cannot be the same (primary: "${primary}", secondary: "${secondary}").`);
|
|
@@ -896,7 +896,7 @@ var bullet_list_marker_style_default = createRule("bullet-list-marker-style", {
|
|
|
896
896
|
},
|
|
897
897
|
create(context) {
|
|
898
898
|
const sourceCode = context.sourceCode;
|
|
899
|
-
const options = parseOptions$
|
|
899
|
+
const options = parseOptions$7(context.options[0] || {});
|
|
900
900
|
let containerStack = {
|
|
901
901
|
node: sourceCode.ast,
|
|
902
902
|
level: 1,
|
|
@@ -1509,7 +1509,7 @@ var custom_container_marker_spacing_default = createRule("custom-container-marke
|
|
|
1509
1509
|
/**
|
|
1510
1510
|
* Parse options with defaults.
|
|
1511
1511
|
*/
|
|
1512
|
-
function parseOptions$
|
|
1512
|
+
function parseOptions$6(options) {
|
|
1513
1513
|
const linkDefinitionPlacement = {
|
|
1514
1514
|
referencedFromSingleSection: options?.linkDefinitionPlacement?.referencedFromSingleSection || "document-last",
|
|
1515
1515
|
referencedFromMultipleSections: options?.linkDefinitionPlacement?.referencedFromMultipleSections || "document-last"
|
|
@@ -1583,7 +1583,7 @@ var definitions_last_default = createRule("definitions-last", {
|
|
|
1583
1583
|
},
|
|
1584
1584
|
create(context) {
|
|
1585
1585
|
const sourceCode = context.sourceCode;
|
|
1586
|
-
const options = parseOptions$
|
|
1586
|
+
const options = parseOptions$6(context.options[0]);
|
|
1587
1587
|
/**
|
|
1588
1588
|
* Determine whether a node can be placed as the last node of the document or a section.
|
|
1589
1589
|
*/
|
|
@@ -5594,7 +5594,7 @@ function parseMathClosingSequenceFromText(text) {
|
|
|
5594
5594
|
/**
|
|
5595
5595
|
* Parse options.
|
|
5596
5596
|
*/
|
|
5597
|
-
function parseOptions$
|
|
5597
|
+
function parseOptions$5(options) {
|
|
5598
5598
|
const listItems = options?.listItems;
|
|
5599
5599
|
return { listItems: {
|
|
5600
5600
|
first: listItems?.first ?? 1,
|
|
@@ -5647,7 +5647,7 @@ var indent_default = createRule("indent", {
|
|
|
5647
5647
|
},
|
|
5648
5648
|
create(context) {
|
|
5649
5649
|
const sourceCode = context.sourceCode;
|
|
5650
|
-
const options = parseOptions$
|
|
5650
|
+
const options = parseOptions$5(context.options[0]);
|
|
5651
5651
|
class AbsBlockStack {
|
|
5652
5652
|
violations = [];
|
|
5653
5653
|
getCurrentBlockquote() {
|
|
@@ -6817,11 +6817,11 @@ var link_bracket_newline_default = createRule("link-bracket-newline", {
|
|
|
6817
6817
|
},
|
|
6818
6818
|
create(context) {
|
|
6819
6819
|
const sourceCode = context.sourceCode;
|
|
6820
|
-
const optionProvider = parseOptions$
|
|
6820
|
+
const optionProvider = parseOptions$8(context.options[0]);
|
|
6821
6821
|
/**
|
|
6822
6822
|
* Parse the options.
|
|
6823
6823
|
*/
|
|
6824
|
-
function parseOptions$
|
|
6824
|
+
function parseOptions$8(option) {
|
|
6825
6825
|
const newline = option?.newline ?? "never";
|
|
6826
6826
|
const multiline = option?.multiline ?? false;
|
|
6827
6827
|
return (bracketsRange) => {
|
|
@@ -6952,7 +6952,7 @@ var link_bracket_newline_default = createRule("link-bracket-newline", {
|
|
|
6952
6952
|
/**
|
|
6953
6953
|
* The basic option for links and images.
|
|
6954
6954
|
*/
|
|
6955
|
-
function parseOptions$
|
|
6955
|
+
function parseOptions$4(option) {
|
|
6956
6956
|
const space = option?.space ?? "never";
|
|
6957
6957
|
const imagesInLinks = option?.imagesInLinks;
|
|
6958
6958
|
return {
|
|
@@ -7002,7 +7002,7 @@ var link_bracket_spacing_default = createRule("link-bracket-spacing", {
|
|
|
7002
7002
|
},
|
|
7003
7003
|
create(context) {
|
|
7004
7004
|
const sourceCode = context.sourceCode;
|
|
7005
|
-
const options = parseOptions$
|
|
7005
|
+
const options = parseOptions$4(context.options[0]);
|
|
7006
7006
|
/**
|
|
7007
7007
|
* Verify the space after the opening bracket and before the closing bracket.
|
|
7008
7008
|
*/
|
|
@@ -7295,11 +7295,11 @@ var link_paren_newline_default = createRule("link-paren-newline", {
|
|
|
7295
7295
|
},
|
|
7296
7296
|
create(context) {
|
|
7297
7297
|
const sourceCode = context.sourceCode;
|
|
7298
|
-
const optionProvider = parseOptions$
|
|
7298
|
+
const optionProvider = parseOptions$8(context.options[0]);
|
|
7299
7299
|
/**
|
|
7300
7300
|
* Parse the options.
|
|
7301
7301
|
*/
|
|
7302
|
-
function parseOptions$
|
|
7302
|
+
function parseOptions$8(option) {
|
|
7303
7303
|
const newline = option?.newline ?? "never";
|
|
7304
7304
|
const multiline = option?.multiline ?? false;
|
|
7305
7305
|
return (openingParenIndex, closingParenIndex) => {
|
|
@@ -8905,7 +8905,7 @@ function markerToKind(marker) {
|
|
|
8905
8905
|
/**
|
|
8906
8906
|
* Parse rule options.
|
|
8907
8907
|
*/
|
|
8908
|
-
function parseOptions$
|
|
8908
|
+
function parseOptions$3(options) {
|
|
8909
8909
|
const prefer = markerToKind(options.prefer) || ".";
|
|
8910
8910
|
const overrides = (options.overrides ?? []).map((override) => {
|
|
8911
8911
|
const preferForOverride = markerToKind(override.prefer) || ".";
|
|
@@ -8966,7 +8966,7 @@ var ordered_list_marker_style_default = createRule("ordered-list-marker-style",
|
|
|
8966
8966
|
},
|
|
8967
8967
|
create(context) {
|
|
8968
8968
|
const sourceCode = context.sourceCode;
|
|
8969
|
-
const options = parseOptions$
|
|
8969
|
+
const options = parseOptions$3(context.options[0] || {});
|
|
8970
8970
|
let containerStack = {
|
|
8971
8971
|
node: sourceCode.ast,
|
|
8972
8972
|
level: 1,
|
|
@@ -9056,6 +9056,38 @@ var ordered_list_marker_style_default = createRule("ordered-list-marker-style",
|
|
|
9056
9056
|
|
|
9057
9057
|
//#endregion
|
|
9058
9058
|
//#region src/rules/padded-custom-containers.ts
|
|
9059
|
+
/**
|
|
9060
|
+
* Parse the given options.
|
|
9061
|
+
*/
|
|
9062
|
+
function parseOptions$2(options) {
|
|
9063
|
+
const padding = options?.padding || "never";
|
|
9064
|
+
const overrides = (options?.overrides || []).map((override) => {
|
|
9065
|
+
return {
|
|
9066
|
+
test: normalizeTest(override.info),
|
|
9067
|
+
padding: override.padding || padding
|
|
9068
|
+
};
|
|
9069
|
+
}).reverse();
|
|
9070
|
+
/**
|
|
9071
|
+
* Get the padding setting for the given container.
|
|
9072
|
+
*/
|
|
9073
|
+
function getPaddingForContainer(node) {
|
|
9074
|
+
for (const override of overrides) if (override.test(node)) return override.padding;
|
|
9075
|
+
return padding;
|
|
9076
|
+
}
|
|
9077
|
+
return { getPaddingForContainer };
|
|
9078
|
+
/**
|
|
9079
|
+
* Normalize the given info option.
|
|
9080
|
+
*/
|
|
9081
|
+
function normalizeTest(infoOption) {
|
|
9082
|
+
if (infoOption == null) return () => false;
|
|
9083
|
+
if (Array.isArray(infoOption)) {
|
|
9084
|
+
const tests = infoOption.map(normalizeTest);
|
|
9085
|
+
return (n) => tests.some((t) => t(n));
|
|
9086
|
+
}
|
|
9087
|
+
const test = toRegExp(infoOption);
|
|
9088
|
+
return (n) => test.test(n.info);
|
|
9089
|
+
}
|
|
9090
|
+
}
|
|
9059
9091
|
var padded_custom_containers_default = createRule("padded-custom-containers", {
|
|
9060
9092
|
meta: {
|
|
9061
9093
|
type: "layout",
|
|
@@ -9068,11 +9100,34 @@ var padded_custom_containers_default = createRule("padded-custom-containers", {
|
|
|
9068
9100
|
hasSuggestions: false,
|
|
9069
9101
|
schema: [{
|
|
9070
9102
|
type: "object",
|
|
9071
|
-
properties: {
|
|
9072
|
-
|
|
9073
|
-
|
|
9074
|
-
|
|
9075
|
-
|
|
9103
|
+
properties: {
|
|
9104
|
+
padding: {
|
|
9105
|
+
type: "string",
|
|
9106
|
+
enum: ["always", "never"],
|
|
9107
|
+
default: "never"
|
|
9108
|
+
},
|
|
9109
|
+
overrides: {
|
|
9110
|
+
type: "array",
|
|
9111
|
+
items: {
|
|
9112
|
+
type: "object",
|
|
9113
|
+
properties: {
|
|
9114
|
+
info: { anyOf: [{ type: "string" }, {
|
|
9115
|
+
type: "array",
|
|
9116
|
+
items: { type: "string" },
|
|
9117
|
+
minItems: 1,
|
|
9118
|
+
uniqueItems: true
|
|
9119
|
+
}] },
|
|
9120
|
+
padding: {
|
|
9121
|
+
type: "string",
|
|
9122
|
+
enum: ["always", "never"]
|
|
9123
|
+
}
|
|
9124
|
+
},
|
|
9125
|
+
additionalProperties: false
|
|
9126
|
+
},
|
|
9127
|
+
uniqueItems: true,
|
|
9128
|
+
minItems: 1
|
|
9129
|
+
}
|
|
9130
|
+
},
|
|
9076
9131
|
additionalProperties: false
|
|
9077
9132
|
}],
|
|
9078
9133
|
messages: {
|
|
@@ -9084,9 +9139,10 @@ var padded_custom_containers_default = createRule("padded-custom-containers", {
|
|
|
9084
9139
|
},
|
|
9085
9140
|
create(context) {
|
|
9086
9141
|
const sourceCode = context.sourceCode;
|
|
9087
|
-
const
|
|
9142
|
+
const options = parseOptions$2(context.options[0]);
|
|
9088
9143
|
return { customContainer(node) {
|
|
9089
9144
|
if (node.children.length === 0) return;
|
|
9145
|
+
const padding = options.getPaddingForContainer(node);
|
|
9090
9146
|
const parsed = parseCustomContainer(sourceCode, node);
|
|
9091
9147
|
if (!parsed) return;
|
|
9092
9148
|
const { openingSequence, closingSequence } = parsed;
|
|
@@ -9117,30 +9173,28 @@ var padded_custom_containers_default = createRule("padded-custom-containers", {
|
|
|
9117
9173
|
});
|
|
9118
9174
|
} else if (padding === "never") {
|
|
9119
9175
|
if (paddingAfterOpeningLines > 0) {
|
|
9120
|
-
const
|
|
9176
|
+
const lines = getParsedLines(sourceCode);
|
|
9177
|
+
const reportLines = [];
|
|
9178
|
+
for (let lineNumber = openingSequence.loc.end.line + 1; lineNumber < firstChildLoc.start.line; lineNumber++) reportLines.push(lines.get(lineNumber));
|
|
9179
|
+
const removeRange = [reportLines[0].range[0], reportLines[reportLines.length - 1].range[1]];
|
|
9121
9180
|
context.report({
|
|
9122
9181
|
messageId: "unexpectedPaddingAfterOpeningMarker",
|
|
9123
|
-
loc: getSourceLocationFromRange(sourceCode, node,
|
|
9124
|
-
|
|
9125
|
-
|
|
9126
|
-
for (let lineNumber = openingSequence.loc.end.line + 1; lineNumber < firstChildLoc.start.line; lineNumber++) {
|
|
9127
|
-
const line = lines.get(lineNumber);
|
|
9128
|
-
yield fixer.removeRange(line.range);
|
|
9129
|
-
}
|
|
9182
|
+
loc: getSourceLocationFromRange(sourceCode, node, removeRange),
|
|
9183
|
+
fix(fixer) {
|
|
9184
|
+
return fixer.removeRange(removeRange);
|
|
9130
9185
|
}
|
|
9131
9186
|
});
|
|
9132
9187
|
}
|
|
9133
9188
|
if (closingSequence && paddingBeforeClosingLines !== null && paddingBeforeClosingLines > 0) {
|
|
9134
|
-
const
|
|
9189
|
+
const lines = getParsedLines(sourceCode);
|
|
9190
|
+
const reportLines = [];
|
|
9191
|
+
for (let lineNumber = lastChildLoc.end.line + 1; lineNumber < closingSequence.loc.start.line; lineNumber++) reportLines.push(lines.get(lineNumber));
|
|
9192
|
+
const removeRange = [reportLines[0].range[0], reportLines[reportLines.length - 1].range[1]];
|
|
9135
9193
|
context.report({
|
|
9136
9194
|
messageId: "unexpectedPaddingBeforeClosingMarker",
|
|
9137
|
-
loc: getSourceLocationFromRange(sourceCode, node,
|
|
9138
|
-
|
|
9139
|
-
|
|
9140
|
-
for (let lineNumber = lastChildLoc.end.line + 1; lineNumber < closingSequence.loc.start.line; lineNumber++) {
|
|
9141
|
-
const line = lines.get(lineNumber);
|
|
9142
|
-
yield fixer.removeRange(line.range);
|
|
9143
|
-
}
|
|
9195
|
+
loc: getSourceLocationFromRange(sourceCode, node, removeRange),
|
|
9196
|
+
fix(fixer) {
|
|
9197
|
+
return fixer.removeRange(removeRange);
|
|
9144
9198
|
}
|
|
9145
9199
|
});
|
|
9146
9200
|
}
|
|
@@ -11937,7 +11991,7 @@ var meta_exports = /* @__PURE__ */ __export({
|
|
|
11937
11991
|
version: () => version
|
|
11938
11992
|
});
|
|
11939
11993
|
const name = "eslint-plugin-markdown-preferences";
|
|
11940
|
-
const version = "0.
|
|
11994
|
+
const version = "0.34.0";
|
|
11941
11995
|
|
|
11942
11996
|
//#endregion
|
|
11943
11997
|
//#region src/language/extensions/micromark-custom-container.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-markdown-preferences",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"description": "ESLint plugin that enforces our markdown preferences",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"@changesets/changelog-github": "^0.5.1",
|
|
80
80
|
"@changesets/cli": "^2.28.1",
|
|
81
81
|
"@changesets/get-release-plan": "^4.0.8",
|
|
82
|
-
"@eslint/core": "^0.
|
|
82
|
+
"@eslint/core": "^0.16.0",
|
|
83
83
|
"@eslint/markdown": "^7.2.0",
|
|
84
84
|
"@ota-meshi/eslint-plugin": "^0.18.0",
|
|
85
85
|
"@shikijs/vitepress-twoslash": "^3.0.0",
|