fix: Windows json sort diff

Signed-off-by: Innei <i@innei.in>
This commit is contained in:
Innei 2024-10-05 16:36:57 +08:00
parent 9b1de775d2
commit 74bf02bdd3
1 changed files with 4 additions and 1 deletions

View File

@ -36,7 +36,10 @@ export default {
const sortedJson = sortObjectKeys(json)
const sortedText = `${JSON.stringify(sortedJson, null, 2)}\n`
if (text.trim() !== sortedText.trim()) {
const noWhiteSpaceDiff = (a, b) =>
a.replaceAll(/\s/g, "") === b.replaceAll(/\s/g, "")
if (!noWhiteSpaceDiff(text, sortedText)) {
context.report({
node,
message: "JSON keys are not sorted recursively",