Skip to content

Commit 16547b0

Browse files
committed
fix(template-no-block-params-for-html-elements): include mathml-tag-names
Extends the allowlist with MathML tag names. NullVoxPopuli confirmed the plugin can use ESM-only packages since the supported Node range (>=20.19) has require(esm). Adds an invalid test for `<mfrac as |num|>` and an invalid test for `<circle as |r|>` (SVG, via svg-tags).
1 parent 6308771 commit 16547b0

4 files changed

Lines changed: 28 additions & 1 deletion

File tree

lib/rules/template-no-block-params-for-html-elements.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
const htmlTags = require('html-tags');
22
const svgTags = require('svg-tags');
3+
const { mathmlTagNames } = require('mathml-tag-names');
34

4-
const ELEMENT_TAGS = new Set([...htmlTags, ...svgTags]);
5+
const ELEMENT_TAGS = new Set([...htmlTags, ...svgTags, ...mathmlTagNames]);
56

67
/** @type {import('eslint').Rule.RuleModule} */
78
module.exports = {

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"html-tags": "^3.3.1",
7474
"lodash.camelcase": "^4.3.0",
7575
"lodash.kebabcase": "^4.1.1",
76+
"mathml-tag-names": "^4.0.0",
7677
"requireindex": "^1.2.0",
7778
"snake-case": "^3.0.3",
7879
"svg-tags": "^1.0.0"

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/lib/rules/template-no-block-params-for-html-elements.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,27 @@ ruleTester.run('template-no-block-params-for-html-elements', rule, {
5555
},
5656
],
5757
},
58+
{
59+
// SVG element — in svg-tags allowlist.
60+
code: '<template><circle as |r|>{{r}}</circle></template>',
61+
output: null,
62+
errors: [
63+
{
64+
message: 'Block params can only be used with components, not HTML elements.',
65+
type: 'GlimmerElementNode',
66+
},
67+
],
68+
},
69+
{
70+
// MathML element — in mathml-tag-names allowlist.
71+
code: '<template><mfrac as |num|>{{num}}</mfrac></template>',
72+
output: null,
73+
errors: [
74+
{
75+
message: 'Block params can only be used with components, not HTML elements.',
76+
type: 'GlimmerElementNode',
77+
},
78+
],
79+
},
5880
],
5981
});

0 commit comments

Comments
 (0)