Skip to content

Commit cd8954b

Browse files
authored
Fix: Remove empty categories from the result page
Fix #869
1 parent e33e4aa commit cd8954b

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"dependencies": {
3-
"@hint/formatter-html": "^4.1.12",
4-
"@hint/utils": "^7.0.0",
3+
"@hint/formatter-html": "^4.1.13",
4+
"@hint/utils": "^7.0.1",
55
"@hint/utils-i18n": "^1.0.0",
66
"algoliasearch": "^3.35.1",
77
"applicationinsights": "^1.6.0",
@@ -20,7 +20,7 @@
2020
},
2121
"devDependencies": {
2222
"@hint/artwork": "^2.2.1",
23-
"@hint/configuration-all": "^2.0.2",
23+
"@hint/configuration-all": "^2.0.3",
2424
"cross-env": "^6.0.3",
2525
"eslint": "^6.7.2",
2626
"gulp": "^4.0.2",

src/server/routes/scanner.js

Lines changed: 19 additions & 3 deletions
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

Lines changed: 0 additions & 2 deletions
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)