react-scripts
Version:
Configuration and scripts for Create React App.
35 lines (28 loc) • 876 B
JavaScript
/**
* @fileoverview Rule to flag nested ternary expressions
* @author Ian Christian Myers
*/
;
//------------------------------------------------------------------------------
// 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, "Do not nest ternary expressions.");
}
}
};
}
};