Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

no-nested-ternary.js 1.1KB

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