UNPKG

647 BJavaScriptView Raw
1/**
2 * @fileoverview Rule to flag nested ternary expressions
3 * @author Ian Christian Myers
4 */
5
6//------------------------------------------------------------------------------
7// Rule Definition
8//------------------------------------------------------------------------------
9
10module.exports = function(context) {
11
12 "use strict";
13
14 return {
15 "ConditionalExpression": function(node) {
16 if (node.alternate.type === "ConditionalExpression" ||
17 node.consequent.type === "ConditionalExpression") {
18 context.report(node, "Do not nest ternary expressions");
19 }
20 }
21 };
22};
\No newline at end of file