diff --git a/src/lint/collect-spelling-diagnostics.ts b/src/lint/collect-spelling-diagnostics.ts index da212124..f79dd30a 100644 --- a/src/lint/collect-spelling-diagnostics.ts +++ b/src/lint/collect-spelling-diagnostics.ts @@ -65,6 +65,14 @@ let matchers = [ pattern: /(?<=\S) +(?! |<\/(td|th|dd|dt)>)/gu, message: 'multiple consecutive spaces are not allowed', }, + { + pattern: /(?<=<[a-z]+( [a-z]+(="[^"\n]+")?)*>)(?) /gu, + message: 'tags should not contain leading whitespace', + }, + { + pattern: /(?<=[^ \n]) +<\/(?!td|th|dd|dt)/gu, + message: 'tags should not contain trailing whitespace', + }, ]; export function collectSpellingDiagnostics( diff --git a/test/lint-spelling.js b/test/lint-spelling.js index f647a76e..fcdf8ca7 100644 --- a/test/lint-spelling.js +++ b/test/lint-spelling.js @@ -211,6 +211,32 @@ windows:${M}\r ); }); + it('leading whitespace within tags', async function () { + await assertLint( + positioned` +
${M} This is an example.
+ `, + { + ruleId: 'spelling', + nodeType: 'html', + message: 'tags should not contain leading whitespace', + } + ); + }); + + it('trailing whitespace within tags', async function () { + await assertLint( + positioned` +This is an example:${M}
+ `, + { + ruleId: 'spelling', + nodeType: 'html', + message: 'tags should not contain trailing whitespace', + } + ); + }); + it('negative', async function () { await assertLintFree(`@@ -241,6 +267,9 @@ windows:${M}\r
+ Paragraphs with the open/close tags on their own line are OK. +
`); }); }); diff --git a/test/lint.js b/test/lint.js index fe33dbf4..b3a542bd 100644 --- a/test/lint.js +++ b/test/lint.js @@ -58,7 +58,7 @@ describe('linting whole program', function () { it('error in inline grammar', async function () { await assertLint( positioned` -