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-multi-assign.js 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * @fileoverview Rule to check use of chained assignment expressions
  3. * @author Stewart Rand
  4. */
  5. "use strict";
  6. //------------------------------------------------------------------------------
  7. // Rule Definition
  8. //------------------------------------------------------------------------------
  9. module.exports = {
  10. meta: {
  11. type: "suggestion",
  12. docs: {
  13. description: "disallow use of chained assignment expressions",
  14. category: "Stylistic Issues",
  15. recommended: false,
  16. url: "https://eslint.org/docs/rules/no-multi-assign"
  17. },
  18. schema: [{
  19. type: "object",
  20. properties: {
  21. ignoreNonDeclaration: {
  22. type: "boolean",
  23. default: false
  24. }
  25. },
  26. additionalProperties: false
  27. }],
  28. messages: {
  29. unexpectedChain: "Unexpected chained assignment."
  30. }
  31. },
  32. create(context) {
  33. //--------------------------------------------------------------------------
  34. // Public
  35. //--------------------------------------------------------------------------
  36. const options = context.options[0] || {
  37. ignoreNonDeclaration: false
  38. };
  39. const targetParent = options.ignoreNonDeclaration ? ["VariableDeclarator"] : ["AssignmentExpression", "VariableDeclarator"];
  40. return {
  41. AssignmentExpression(node) {
  42. if (targetParent.indexOf(node.parent.type) !== -1) {
  43. context.report({
  44. node,
  45. messageId: "unexpectedChain"
  46. });
  47. }
  48. }
  49. };
  50. }
  51. };