Files
med-notes/.pnpm-store/v10/files/27/4fac17b7631d0641a60f261d7fcc6640d9660d5ae11b5789d9ac49e7c450e4934ec10d1f163d7a2dc3ca9e4065581cc86766ea9e2e2be89d36ec542014b6dd
2025-05-09 05:30:08 +02:00

47 lines
956 B
Plaintext

/**
* @fileoverview Rule to flag nested ternary expressions
* @author Ian Christian Myers
*/
"use strict";
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../shared/types').Rule} */
module.exports = {
meta: {
type: "suggestion",
docs: {
description: "Disallow nested ternary expressions",
recommended: false,
frozen: true,
url: "https://eslint.org/docs/latest/rules/no-nested-ternary",
},
schema: [],
messages: {
noNestedTernary: "Do not nest ternary expressions.",
},
},
create(context) {
return {
ConditionalExpression(node) {
if (
node.alternate.type === "ConditionalExpression" ||
node.consequent.type === "ConditionalExpression"
) {
context.report({
node,
messageId: "noNestedTernary",
});
}
},
};
},
};