github-pages-deploy-action/node_modules/eslint/lib/rules/no-nested-ternary.js

45 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-03-07 11:45:40 +08:00
/**
* @fileoverview Rule to flag nested ternary expressions
* @author Ian Christian Myers
*/
"use strict";
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
module.exports = {
meta: {
type: "suggestion",
docs: {
description: "disallow nested ternary expressions",
category: "Stylistic Issues",
recommended: false,
url: "https://eslint.org/docs/rules/no-nested-ternary"
},
2020-05-15 05:33:08 +08:00
schema: [],
messages: {
noNestedTernary: "Do not nest ternary expressions."
}
2020-03-07 11:45:40 +08:00
},
create(context) {
return {
ConditionalExpression(node) {
if (node.alternate.type === "ConditionalExpression" ||
node.consequent.type === "ConditionalExpression") {
2020-05-15 05:33:08 +08:00
context.report({
node,
messageId: "noNestedTernary"
});
2020-03-07 11:45:40 +08:00
}
}
};
}
};