google_forms/node_modules/eslint/lib/rules/no-nested-ternary.js

45 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2024-08-09 12:04:48 +00:00
/**
* @fileoverview Rule to flag nested ternary expressions
* @author Ian Christian Myers
*/
"use strict";
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
2024-08-21 06:34:30 +00:00
/** @type {import('../shared/types').Rule} */
2024-08-09 12:04:48 +00:00
module.exports = {
meta: {
type: "suggestion",
docs: {
2024-08-21 06:34:30 +00:00
description: "Disallow nested ternary expressions",
2024-08-09 12:04:48 +00:00
recommended: false,
2024-08-21 06:34:30 +00:00
url: "https://eslint.org/docs/latest/rules/no-nested-ternary"
2024-08-09 12:04:48 +00:00
},
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"
});
}
}
};
}
};