Skip to content

Commit 0ef88a7

Browse files
committed
fix(template-no-arguments-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 invalid tests for `<mfrac @numerator="x">` and `<circle @r="5" />` (SVG, via svg-tags).
1 parent fbc68ce commit 0ef88a7

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

lib/rules/template-no-arguments-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-arguments-for-html-elements.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,29 @@ ruleTester.run('template-no-arguments-for-html-elements', rule, {
6161
},
6262
],
6363
},
64+
{
65+
// SVG element — in svg-tags allowlist.
66+
code: '<template><circle @r="5" /></template>',
67+
output: null,
68+
errors: [
69+
{
70+
message:
71+
'@arguments can only be used on components, not HTML elements. Use regular attributes instead.',
72+
type: 'GlimmerAttrNode',
73+
},
74+
],
75+
},
76+
{
77+
// MathML element — in mathml-tag-names allowlist.
78+
code: '<template><mfrac @numerator="x" /></template>',
79+
output: null,
80+
errors: [
81+
{
82+
message:
83+
'@arguments can only be used on components, not HTML elements. Use regular attributes instead.',
84+
type: 'GlimmerAttrNode',
85+
},
86+
],
87+
},
6488
],
6589
});

0 commit comments

Comments
 (0)