eslint-plugin-markdown-preferences 0.36.0 → 0.36.1
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 +1 -1
- package/lib/index.js +28 -15
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -545,7 +545,7 @@ declare namespace meta_d_exports {
|
|
|
545
545
|
export { name, version };
|
|
546
546
|
}
|
|
547
547
|
declare const name: "eslint-plugin-markdown-preferences";
|
|
548
|
-
declare const version: "0.36.
|
|
548
|
+
declare const version: "0.36.1";
|
|
549
549
|
//#endregion
|
|
550
550
|
//#region src/language/ast-types.d.ts
|
|
551
551
|
type Node = mdast.Node;
|
package/lib/index.js
CHANGED
|
@@ -40,7 +40,7 @@ function createRule(ruleName, rule) {
|
|
|
40
40
|
|
|
41
41
|
//#endregion
|
|
42
42
|
//#region src/utils/ast.ts
|
|
43
|
-
const RE_HTML_COMMENT = /<!--(.*?)-->/
|
|
43
|
+
const RE_HTML_COMMENT = /<!--(.*?)-->/gu;
|
|
44
44
|
/**
|
|
45
45
|
* Get the parent of a node.
|
|
46
46
|
*/
|
|
@@ -138,17 +138,25 @@ function getThematicBreakMarker(sourceCode, node) {
|
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
140
|
/**
|
|
141
|
-
*
|
|
141
|
+
* Get all HTML comments in a node.
|
|
142
142
|
*/
|
|
143
|
-
function
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
*
|
|
148
|
-
*/
|
|
149
|
-
function
|
|
150
|
-
|
|
151
|
-
|
|
143
|
+
function getHTMLComments(sourceCode, node) {
|
|
144
|
+
const [startIndex] = sourceCode.getRange(node);
|
|
145
|
+
return [...iterate()];
|
|
146
|
+
/**
|
|
147
|
+
* An iterator which iterates HTML comments.
|
|
148
|
+
*/
|
|
149
|
+
function* iterate() {
|
|
150
|
+
let match;
|
|
151
|
+
while (match = RE_HTML_COMMENT.exec(node.value)) {
|
|
152
|
+
const start = startIndex + match.index;
|
|
153
|
+
const end = start + match[0].length;
|
|
154
|
+
yield {
|
|
155
|
+
value: match[1],
|
|
156
|
+
range: [start, end]
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
}
|
|
152
160
|
}
|
|
153
161
|
|
|
154
162
|
//#endregion
|
|
@@ -9503,9 +9511,14 @@ var padding_line_between_blocks_default = createRule("padding-line-between-block
|
|
|
9503
9511
|
* Check if the previous block is ignored
|
|
9504
9512
|
*/
|
|
9505
9513
|
function isIgnore(prevBlock) {
|
|
9506
|
-
if (
|
|
9507
|
-
const
|
|
9508
|
-
|
|
9514
|
+
if (prevBlock.type === "html") {
|
|
9515
|
+
const comments = getHTMLComments(sourceCode, prevBlock);
|
|
9516
|
+
const loc = sourceCode.getLoc(prevBlock);
|
|
9517
|
+
for (const comment of comments) {
|
|
9518
|
+
const value = comment.value;
|
|
9519
|
+
if (!/^\s*(?:eslint|markdownlint)-disable-next-line\b/u.test(value)) continue;
|
|
9520
|
+
if (sourceCode.getLocFromIndex(comment.range[1]).line === loc.end.line) return true;
|
|
9521
|
+
}
|
|
9509
9522
|
}
|
|
9510
9523
|
return false;
|
|
9511
9524
|
}
|
|
@@ -12213,7 +12226,7 @@ var meta_exports = /* @__PURE__ */ __export({
|
|
|
12213
12226
|
version: () => version
|
|
12214
12227
|
});
|
|
12215
12228
|
const name = "eslint-plugin-markdown-preferences";
|
|
12216
|
-
const version = "0.36.
|
|
12229
|
+
const version = "0.36.1";
|
|
12217
12230
|
|
|
12218
12231
|
//#endregion
|
|
12219
12232
|
//#region src/language/extensions/micromark-custom-container.ts
|