Skip to content

Commit

Permalink
lint: forbid trailing whitespace within <p>
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot committed Aug 18, 2020
1 parent 814c4c9 commit 6c7e250
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lint/collect-spelling-diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ let matchers = [
message:
'clauses should be referenced using <emu-xref> tags rather than hardcoding clause numbers',
},
{
pattern: /(?<=[^ \n]) +<\/p>/gu,
message: '<p> tags should not contain trailing whitespace',
},
];

export function collectSpellingDiagnostics(
Expand Down
17 changes: 17 additions & 0 deletions test/lint-spelling.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,19 @@ windows:${M}\r
);
});

it('<p> trailing whitespace', async function () {
await assertLint(
positioned`
<p>This is an example:${M} </p>
`,
{
ruleId: 'spelling',
nodeType: 'html',
message: '<p> tags should not contain trailing whitespace',
}
);
});

it('negative', async function () {
await assertLintFree(`
<p>
Expand Down Expand Up @@ -240,6 +253,10 @@ windows:${M}\r
</tr></table>
<p>See clause <emu-xref href="#example"></emu-xref>.</p>
<p>
Paragraphs with the open/close tags on their own line are OK.
</p>
`);
});
});

0 comments on commit 6c7e250

Please sign in to comment.