Created
May 10, 2023 13:06
Revisions
-
orjan created this gist
May 10, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ import file from "./result.json" assert { type: "json" }; const entries = file.entries.map(entry => { //const children = Array.from(extractChildren(entry.children)); const children = entry.children.map(child => child.name); return { name: entry.name, children: children, errors: evaluateErrors(entry.name, children) }; }); function evaluateErrors(name, children) { const errors = []; const module = /src\/modules\/([a-z\-]+)/.exec(name)?.[1] ?? null; let child; for (child of children) { if (module && child.startsWith("/src/modules/") && child.endsWith(".vue") && !child.startsWith("/src/modules/"+module+"/")) { errors.push(child); } } return errors; } function extractChildren(children) { const stack = [...children]; const result = new Set(); let current; while (current = stack.pop()) { stack.push(...current.children); result.add(current.name); } return result; } const errorComponents = entries.filter(entry => entry.errors.length > 0); for (let error of errorComponents) { console.log(error.name); for (let e of error.errors) { console.log(" - ", e); } console.log(); }