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-input-placeholder.js
More file actions
36 lines (35 loc) · 998 Bytes
/
template-no-input-placeholder.js
File metadata and controls
36 lines (35 loc) · 998 Bytes
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
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
type: 'suggestion',
docs: {
description: 'disallow placeholder attribute on input elements',
category: 'Best Practices',
strictGjs: true,
strictGts: true,
url: 'https://github.com/ember-cli/eslint-plugin-ember/tree/master/docs/rules/template-no-input-placeholder.md',
},
fixable: null,
schema: [],
messages: {
noPlaceholder:
'Do not use placeholder attribute. Use a label instead for better accessibility.',
},
},
create(context) {
return {
GlimmerElementNode(node) {
if (node.tag === 'input' && node.attributes) {
for (const attr of node.attributes) {
if (attr.type === 'GlimmerAttrNode' && attr.name === 'placeholder') {
context.report({
node: attr,
messageId: 'noPlaceholder',
});
}
}
}
},
};
},
};