Skip to content

Commit f8ac543

Browse files
committed
fix(template-require-iframe-title): address Copilot review — use strict, comment count, doc wrap, hbs parity
1 parent 1fd8b3b commit f8ac543

3 files changed

Lines changed: 49 additions & 4 deletions

File tree

docs/rules/template-require-iframe-title.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ This rule **forbids** the following:
3939
Whitespace-only `title` (`" "`) is flagged by default as an
4040
authoring-hygiene check: HTML and ACCNAME technically permit it (step 2I
4141
doesn't trim), but a whitespace-only accessible name is useless in
42-
practice. Suppress this specific strictness via `allowWhitespaceOnlyTitle:
43-
true` if your codebase needs it.
42+
practice. Suppress this specific strictness via
43+
`allowWhitespaceOnlyTitle: true` if your codebase needs it.
4444

4545
## Configuration
4646

lib/rules/template-require-iframe-title.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
// Non-string literal AST nodes (boolean/null/undefined/number) don't represent
24
// a meaningful author-provided title. Even though they would coerce to strings
35
// at runtime (e.g. `true` → "true", `42` → "42"), those strings do not describe
@@ -58,8 +60,8 @@ module.exports = {
5860
},
5961
],
6062
messages: {
61-
// Four messageIds (missingTitle, emptyTitle, invalidTitleLiteral,
62-
// duplicateTitle) for richer diagnostic detail.
63+
// Five messageIds (missingTitle, emptyTitle, invalidTitleLiteral,
64+
// duplicateTitleFirst, duplicateTitleOther) for richer diagnostic detail.
6365
missingTitle: '<iframe> elements must have a unique title property.',
6466
emptyTitle: '<iframe> elements must have a unique title property.',
6567
invalidTitleLiteral:

tests/lib/rules/template-require-iframe-title.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,5 +251,48 @@ hbsRuleTester.run('template-require-iframe-title', rule, {
251251
output: null,
252252
errors: [{ message: '<iframe> elements must have a unique title property.' }],
253253
},
254+
255+
// hbs parity with gjs for the other non-string mustache literals
256+
// (boolean true / null / undefined / number).
257+
{
258+
code: '<iframe title={{true}} />',
259+
output: null,
260+
errors: [
261+
{
262+
message:
263+
'<iframe title> must be a non-empty string. Got a boolean literal, which does not describe the frame contents.',
264+
},
265+
],
266+
},
267+
{
268+
code: '<iframe title={{null}} />',
269+
output: null,
270+
errors: [
271+
{
272+
message:
273+
'<iframe title> must be a non-empty string. Got a null literal, which does not describe the frame contents.',
274+
},
275+
],
276+
},
277+
{
278+
code: '<iframe title={{undefined}} />',
279+
output: null,
280+
errors: [
281+
{
282+
message:
283+
'<iframe title> must be a non-empty string. Got a undefined literal, which does not describe the frame contents.',
284+
},
285+
],
286+
},
287+
{
288+
code: '<iframe title={{42}} />',
289+
output: null,
290+
errors: [
291+
{
292+
message:
293+
'<iframe title> must be a non-empty string. Got a number literal, which does not describe the frame contents.',
294+
},
295+
],
296+
},
254297
],
255298
});

0 commit comments

Comments
 (0)