Urara-Blog/node_modules/.pnpm-store/v3/files/45/17736aa9f68939a61a2f3d0744869dad598836619310b5f2eac7701aceaa70e6a0132ea0b48d0b4efeea80cc3971753a1e40d026c5d419e1289e3d16ec5d20
2022-08-14 01:14:53 +08:00

44 lines
1.1 KiB
Text

/**
* @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,
url: "https://eslint.org/docs/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"
});
}
}
};
}
};