forked from ember-cli/eslint-plugin-ember
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate-no-attribute-splat-on-html-element.js
More file actions
39 lines (38 loc) · 1.12 KB
/
template-no-attribute-splat-on-html-element.js
File metadata and controls
39 lines (38 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
type: 'suggestion',
docs: {
description: 'disallow ...attributes on HTML elements',
category: 'Best Practices',
strictGjs: true,
strictGts: true,
url: 'https://github.com/ember-cli/eslint-plugin-ember/tree/master/docs/rules/template-no-attribute-splat-on-html-element.md',
},
fixable: null,
schema: [],
messages: {
noAttributeSplat:
'Do not use ...attributes on HTML elements. Use it only on component elements.',
},
},
create(context) {
return {
GlimmerElementNode(node) {
// Check if it's an HTML element (starts with lowercase letter)
if (node.tag && node.tag.length > 0 && node.tag[0] === node.tag[0].toLowerCase()) {
if (node.attributes) {
for (const attr of node.attributes) {
if (attr.name === '...attributes') {
context.report({
node: attr,
messageId: 'noAttributeSplat',
});
}
}
}
}
},
};
},
};