Skip to content

Commit

Permalink
Fix browser presence linter (mdn#21517)
Browse files Browse the repository at this point in the history
* Fix browser presence linter

* Clean up variables

* Fix IE filtering

* Revert "Fix IE filtering"

This reverts commit 0c511ec.
  • Loading branch information
queengooborg authored Dec 12, 2023
1 parent 71faf8e commit 16cf945
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions test/linter/test-browsers-presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ const { browsers } = bcd;
* @param {CompatStatement} data The data to test
* @param {string} category The category the data belongs to.
* @param {Logger} logger The logger to output errors to.
* @param {string} [path] The path of the data.
*/
const processData = (
data: CompatStatement,
category: string,
logger: Logger,
path = '',
): void => {
if (data.support) {
const support = data.support;
Expand Down Expand Up @@ -52,9 +50,9 @@ const processData = (
);
if (undefEntries.length > 0) {
logger.error(
chalk`{red → {bold ${path}} has the following browsers, which are not defined in BCD: {bold ${undefEntries.join(
chalk`Has the following browsers, which are not defined in BCD: {bold ${undefEntries.join(
', ',
)}}}`,
)}}`,
);
}

Expand All @@ -63,7 +61,7 @@ const processData = (
).filter((value) => !displayBrowsers.includes(value));
if (invalidEntries.length > 0) {
logger.error(
chalk`{bold ${path}} has the following browsers, which are invalid for {bold ${category}} compat data: {bold ${invalidEntries.join(
chalk`Has the following browsers, which are invalid for {bold ${category}} compat data: {bold ${invalidEntries.join(
', ',
)}}`,
);
Expand All @@ -74,7 +72,7 @@ const processData = (
);
if (missingEntries.length > 0) {
logger.error(
chalk`{bold ${path}} is missing the following browsers, which are required for {bold ${category}} compat data: {bold ${missingEntries.join(
chalk`Missing the following browsers, which are required for {bold ${category}} compat data: {bold ${missingEntries.join(
', ',
)}}`,
);
Expand All @@ -93,6 +91,6 @@ export default {
* @param {LinterData} root The data to test
*/
check: (logger: Logger, { data, path: { category } }: LinterData) => {
processData(data, category || '', logger);
processData(data, category, logger);
},
} as Linter;

0 comments on commit 16cf945

Please sign in to comment.