Skip to content

Commit ac83a20

Browse files
Lint: Improve logic for validating algorithm steps. (#727)
* Lint: Improve logic for validating algorithm steps. Previously, the test ensuring that algorithm steps end in '.' or ':' looked at the Bikeshed source. This didn't handle word wrapping. While we prefer not to word wrap, that shouldn't cause this test to fail. Make the test analyse the DOM instead. * Fix some unrelated lint failures introduced in f08f9f7
1 parent f08f9f7 commit ac83a20

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

index.bs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6066,7 +6066,7 @@ partial interface MLGraphBuilder {
60666066
The <dfn method for=MLGraphBuilder>where(|condition|, |trueValue|, |falseValue|)</dfn> method steps are:
60676067
</summary>
60686068
1. If [=this=].{{MLGraphBuilder/[[hasBuilt]]}} is true, then [=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
6069-
1. If [=MLGraphBuilder/validating operand=] with [=this=] and any of |condition|, |input|, and |other| returns false, then [=exception/throw=] a {{TypeError}}.
6069+
1. If [=MLGraphBuilder/validating operand=] with [=this=] and any of |condition|, |trueValue|, and |falseValue| returns false, then [=exception/throw=] a {{TypeError}}.
60706070
1. If |condition|'s [=MLOperand/dataType=] is not equal to {{MLOperandDataType/"uint8"}}, then [=exception/throw=] a {{TypeError}}.
60716071
1. If |trueValue|'s [=MLOperand/dataType=] is not equal to |falseValue|'s [=MLOperand/dataType=], then [=exception/throw=] a {{TypeError}}.
60726072
1. Let |descriptor| be a new {{MLOperandDescriptor}}.

tools/lint.mjs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -258,18 +258,15 @@ for (const pre of root.querySelectorAll('pre.highlight:not(.idl)')) {
258258
}
259259

260260
// Ensure algorithm steps end in '.' or ':'.
261-
for (const match of source.matchAll(/^ *\d+\. .*$/mg)) {
262-
let str = match[0].trim();
261+
for (const p of root.querySelectorAll('.algorithm li > p')) {
262+
let str = p.innerText;
263263

264-
// Strip asterisks from things like "1. *Make graph connections.*"
265-
const match2 = str.match(/^(\d+\. )\*(.*)\*$/);
266-
if (match2) {
267-
str = match2[1] + match2[2];
268-
}
264+
// Strip "[Issue #123]" suffix.
265+
str = str.replace(/\s+\[Issue #\d+\]/, '');
269266

270-
const match3 = str.match(/[^.:]$/);
271-
if (match3) {
272-
error(`Algorithm steps should end with '.' or ':': ${format(match3)}`);
267+
const match = str.match(/[^.:]$/);
268+
if (match) {
269+
error(`Algorithm steps should end with '.' or ':': ${format(match)}`);
273270
}
274271
}
275272

0 commit comments

Comments
 (0)