mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Update customRulesParamsAreFrozen test to cover all parser variations.
This commit is contained in:
parent
d22c1f19ef
commit
a63972a666
1 changed files with 33 additions and 19 deletions
|
|
@ -1788,33 +1788,47 @@ test("customRulesAsyncThrowsInSyncContext", (t) => {
|
|||
});
|
||||
|
||||
test("customRulesParamsAreFrozen", (t) => {
|
||||
const assertParamsFrozen = (params) => {
|
||||
const pending = [ params ];
|
||||
let current = null;
|
||||
while ((current = pending.shift())) {
|
||||
t.true(Object.isFrozen(current) || (current === params));
|
||||
for (const name of Object.getOwnPropertyNames(current)) {
|
||||
const value = current[name];
|
||||
if (
|
||||
value &&
|
||||
(typeof value === "object") &&
|
||||
(name !== "parent")
|
||||
) {
|
||||
pending.push(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("../lib/markdownlint").Options */
|
||||
const options = {
|
||||
"customRules": [
|
||||
{
|
||||
"names": [ "name" ],
|
||||
"names": [ "none" ],
|
||||
"description": "description",
|
||||
"tags": [ "tag" ],
|
||||
"parser": "none",
|
||||
"function":
|
||||
(params) => {
|
||||
const pending = [ params ];
|
||||
let current = null;
|
||||
while ((current = pending.shift())) {
|
||||
t.true(Object.isFrozen(current) || (current === params));
|
||||
for (const name of Object.getOwnPropertyNames(current)) {
|
||||
const value = current[name];
|
||||
if (
|
||||
value &&
|
||||
(typeof value === "object") &&
|
||||
(name !== "parent")
|
||||
) {
|
||||
pending.push(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"function": assertParamsFrozen
|
||||
},
|
||||
{
|
||||
"names": [ "markdownit" ],
|
||||
"description": "description",
|
||||
"tags": [ "tag" ],
|
||||
"parser": "markdownit",
|
||||
"function": assertParamsFrozen
|
||||
},
|
||||
{
|
||||
"names": [ "micromark" ],
|
||||
"description": "description",
|
||||
"tags": [ "tag" ],
|
||||
"parser": "micromark",
|
||||
"function": assertParamsFrozen
|
||||
}
|
||||
],
|
||||
"files": [ "README.md" ]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue