-
Notifications
You must be signed in to change notification settings - Fork 8
/
jsx-for-single-child.js
34 lines (27 loc) · 973 Bytes
/
jsx-for-single-child.js
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
/**
* @fileoverview For tag must contain single child
* @author Vivek Kumar Bansal
* @copyright 2016 Vivek Kumar Bansal. All rights reserved.
*/
"use strict";
var utils = require("../utils");
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
module.exports = function(context) {
function isForComponent(node) {
return utils.isTag("For", node);
}
//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
return {
JSXOpeningElement: function(node) {
if (!isForComponent(node)) return node;
if (!utils.hasSingleChild(node)) {
context.report(node, "'For' tag must have single child.");
}
}
};
};
module.exports.schema = [];