diff options
Diffstat (limited to 'tools/node_modules/eslint/lib/rules/no-nested-ternary.js')
-rw-r--r-- | tools/node_modules/eslint/lib/rules/no-nested-ternary.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/lib/rules/no-nested-ternary.js b/tools/node_modules/eslint/lib/rules/no-nested-ternary.js new file mode 100644 index 0000000000..4fe49fc9c0 --- /dev/null +++ b/tools/node_modules/eslint/lib/rules/no-nested-ternary.js @@ -0,0 +1,34 @@ +/** + * @fileoverview Rule to flag nested ternary expressions + * @author Ian Christian Myers + */ + +"use strict"; + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +module.exports = { + meta: { + docs: { + description: "disallow nested ternary expressions", + category: "Stylistic Issues", + recommended: false + }, + + schema: [] + }, + + create(context) { + + return { + ConditionalExpression(node) { + if (node.alternate.type === "ConditionalExpression" || + node.consequent.type === "ConditionalExpression") { + context.report({ node, message: "Do not nest ternary expressions." }); + } + } + }; + } +}; |