Skip to content

Commit 1d2db15

Browse files
committed
Fix: Remove empty categories from the result page
Fix webhintio#869
1 parent e33e4aa commit 1d2db15

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/server/routes/scanner.js

+19-3
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@ const processHintResults = async (scanResult) => {
105105
version: scanResult.webhintVersion
106106
});
107107

108-
result.removeCategory('other');
109-
result.removeCategory('development');
110-
111108
result.showError = hints.every((hint) => {
112109
return hint.messages.length === 1 && hint.messages[0].message === 'Error in webhint analyzing this hint';
113110
});
@@ -125,6 +122,25 @@ const processHintResults = async (scanResult) => {
125122
}
126123
});
127124

125+
const categoriesToRemove = [];
126+
127+
for (const category of result.categories) {
128+
const passedCount = category.passed ? category.passed.length : 0;
129+
const hintsCount = category.hints ? category.hints.length : 0;
130+
131+
/*
132+
* If there is no hints in the category, add the category
133+
* to the list of categories to remove.
134+
*/
135+
if (passedCount + hintsCount === 0) {
136+
categoriesToRemove.push(category.name.toLowerCase());
137+
}
138+
}
139+
140+
for (const category of categoriesToRemove) {
141+
result.removeCategory(category);
142+
}
143+
128144
result.id = scanResult.id;
129145
result.permalink = `${webhintUrl}scanner/${scanResult.id}`;
130146

src/webhint-theme/source/js/scanner-submit.js

-2
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,6 @@
205205
updateAsPass(category);
206206
}
207207

208-
filterNewUpdates(category);
209-
210208
category.hintsToUpdate = filterNewUpdates(category);
211209

212210
updateErrorItems(category);

0 commit comments

Comments
 (0)