Skip to content

Commit

Permalink
Suggest-a-spec (#709)
Browse files Browse the repository at this point in the history
I am often forgetting to set the level for CSS specs. This does an OK
job of suggesting something better in those cases. We might extend this
further to catch typos and the like.
  • Loading branch information
ddbeck committed Mar 23, 2024
1 parent 7b31c0c commit 2cc5c83
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions scripts/specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ function testIsOK() {
};
testIsOK();


/**
* Print an array of potential spec URLs.
*/
function suggestSpecs(bad: URL): void {
const searchBy = bad.pathname.replaceAll("/", "");
const suggestions = specUrls.filter((specUrl) => specUrl.toString().includes(searchBy)).map(u => `- ${u}`);
if (suggestions.length > 0) {
console.warn("Did you mean one of these?");
console.warn(`${suggestions.join('\n')}`);
console.warn();
}
}

let checked = 0;
let errors = 0;

Expand All @@ -69,6 +83,7 @@ for (const [id, data] of Object.entries(features)) {
const url = new URL(spec);
if (!isOK(url)) {
console.error(`URL for ${id} not in web-specs: ${url.toString()}`);
suggestSpecs(url);
errors++;
}
checked++;
Expand Down

0 comments on commit 2cc5c83

Please sign in to comment.