-
-
Notifications
You must be signed in to change notification settings - Fork 212
Expand file tree
/
Copy pathtemplate-no-block-params-for-html-elements.js
More file actions
45 lines (40 loc) · 1.22 KB
/
template-no-block-params-for-html-elements.js
File metadata and controls
45 lines (40 loc) · 1.22 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
40
41
42
43
44
45
const { isNativeElement } = require('../utils/is-native-element');
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'disallow block params on HTML elements',
category: 'Best Practices',
url: 'https://github.com/ember-cli/eslint-plugin-ember/tree/master/docs/rules/template-no-block-params-for-html-elements.md',
},
fixable: null,
schema: [],
messages: {
noBlockParamsForHtmlElements:
'Block params can only be used with components, not HTML elements.',
},
originallyFrom: {
name: 'ember-template-lint',
rule: 'lib/rules/no-block-params-for-html-elements.js',
docs: 'docs/rule/no-block-params-for-html-elements.md',
tests: 'test/unit/rules/no-block-params-for-html-elements-test.js',
},
},
create(context) {
const sourceCode = context.sourceCode;
return {
GlimmerElementNode(node) {
if (!isNativeElement(node, sourceCode)) {
return;
}
if (node.blockParams && node.blockParams.length > 0) {
context.report({
node,
messageId: 'noBlockParamsForHtmlElements',
});
}
},
};
},
};