mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Remove helpers.deepFreeze and call Object.freeze only on things that need it for ~11% time reduction measured via profile-fixture.mjs on Apple Silicon M1.
This commit is contained in:
parent
b6471fba31
commit
936c876810
5 changed files with 110 additions and 97 deletions
|
|
@ -1200,6 +1200,39 @@ test("customRulesAsyncThrowsInSyncContext", (t) => {
|
|||
);
|
||||
});
|
||||
|
||||
test("customRulesParamsAreFrozen", (t) => {
|
||||
const options = {
|
||||
"customRules": [
|
||||
{
|
||||
"names": [ "name" ],
|
||||
"description": "description",
|
||||
"tags": [ "tag" ],
|
||||
"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")) {
|
||||
pending.push(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"files": [
|
||||
"CONTRIBUTING.md",
|
||||
"README.md",
|
||||
"doc/CustomRules.md",
|
||||
"doc/Rules.md"
|
||||
]
|
||||
};
|
||||
return markdownlint.promises.markdownlint(options).then(() => null);
|
||||
});
|
||||
|
||||
test("customRulesParamsAreStable", (t) => {
|
||||
t.plan(4);
|
||||
const config1 = { "value1": 10 };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue