1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | "use strict";
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | module.exports = {
|
13 | meta: {
|
14 | docs: {
|
15 | description: "disallow nested ternary expressions",
|
16 | category: "Stylistic Issues",
|
17 | recommended: false,
|
18 | url: "https://eslint.org/docs/rules/no-nested-ternary"
|
19 | },
|
20 |
|
21 | schema: []
|
22 | },
|
23 |
|
24 | create(context) {
|
25 |
|
26 | return {
|
27 | ConditionalExpression(node) {
|
28 | if (node.alternate.type === "ConditionalExpression" ||
|
29 | node.consequent.type === "ConditionalExpression") {
|
30 | context.report({ node, message: "Do not nest ternary expressions." });
|
31 | }
|
32 | }
|
33 | };
|
34 | }
|
35 | };
|