Skip to content

Commit

Permalink
allow "Repeat n times" (#567)
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot authored Dec 14, 2023
1 parent 4510c82 commit e7ae26b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lint/rules/algorithm-line-style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,13 @@ export default function (
if (stepSeq.items.length === 1 && initialText === 'Repeat,') {
return;
}
if (/ times:$/.test(finalText)) {
return;
}
if (!/^Repeat, (?:while|until) /.test(initialText)) {
report({
ruleId,
message: `expected "Repeat" to start with "Repeat, while " or "Repeat, until "`,
message: `expected "Repeat" to look like "Repeat _n_ times:", "Repeat, while ..." or "Repeat, until ..."`,
...locate(first.location.start.offset),
});
}
Expand Down
2 changes: 2 additions & 0 deletions test/lint-algorithms.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ describe('linting algorithms', () => {
1. Substep.
1. Repeat,
1. Substep.
1. Repeat _x_ times:
1. Substep.
1. Repeat, while foo,
1. Substep.
1. Repeat, until foo,
Expand Down

0 comments on commit e7ae26b

Please sign in to comment.