|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * @fileoverview Rule to flag nested ternary expressions
|
|---|
| 3 | * @author Ian Christian Myers
|
|---|
| 4 | */
|
|---|
| 5 |
|
|---|
| 6 | "use strict";
|
|---|
| 7 |
|
|---|
| 8 | //------------------------------------------------------------------------------
|
|---|
| 9 | // Rule Definition
|
|---|
| 10 | //------------------------------------------------------------------------------
|
|---|
| 11 |
|
|---|
| 12 | /** @type {import('../shared/types').Rule} */
|
|---|
| 13 | module.exports = {
|
|---|
| 14 | meta: {
|
|---|
| 15 | type: "suggestion",
|
|---|
| 16 |
|
|---|
| 17 | docs: {
|
|---|
| 18 | description: "Disallow nested ternary expressions",
|
|---|
| 19 | recommended: false,
|
|---|
| 20 | url: "https://eslint.org/docs/latest/rules/no-nested-ternary"
|
|---|
| 21 | },
|
|---|
| 22 |
|
|---|
| 23 | schema: [],
|
|---|
| 24 |
|
|---|
| 25 | messages: {
|
|---|
| 26 | noNestedTernary: "Do not nest ternary expressions."
|
|---|
| 27 | }
|
|---|
| 28 | },
|
|---|
| 29 |
|
|---|
| 30 | create(context) {
|
|---|
| 31 |
|
|---|
| 32 | return {
|
|---|
| 33 | ConditionalExpression(node) {
|
|---|
| 34 | if (node.alternate.type === "ConditionalExpression" ||
|
|---|
| 35 | node.consequent.type === "ConditionalExpression") {
|
|---|
| 36 | context.report({
|
|---|
| 37 | node,
|
|---|
| 38 | messageId: "noNestedTernary"
|
|---|
| 39 | });
|
|---|
| 40 | }
|
|---|
| 41 | }
|
|---|
| 42 | };
|
|---|
| 43 | }
|
|---|
| 44 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.