Ohm-Management - Projektarbeit B-ME
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-sync.js 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * @fileoverview Rule to check for properties whose identifier ends with the string Sync
  3. * @author Matt DuVall<http://mattduvall.com/>
  4. */
  5. /* jshint node:true */
  6. "use strict";
  7. //------------------------------------------------------------------------------
  8. // Rule Definition
  9. //------------------------------------------------------------------------------
  10. module.exports = {
  11. meta: {
  12. type: "suggestion",
  13. docs: {
  14. description: "disallow synchronous methods",
  15. category: "Node.js and CommonJS",
  16. recommended: false,
  17. url: "https://eslint.org/docs/rules/no-sync"
  18. },
  19. schema: [
  20. {
  21. type: "object",
  22. properties: {
  23. allowAtRootLevel: {
  24. type: "boolean"
  25. }
  26. },
  27. additionalProperties: false
  28. }
  29. ]
  30. },
  31. create(context) {
  32. const selector = context.options[0] && context.options[0].allowAtRootLevel
  33. ? ":function MemberExpression[property.name=/.*Sync$/]"
  34. : "MemberExpression[property.name=/.*Sync$/]";
  35. return {
  36. [selector](node) {
  37. context.report({
  38. node,
  39. message: "Unexpected sync method: '{{propertyName}}'.",
  40. data: {
  41. propertyName: node.property.name
  42. }
  43. });
  44. }
  45. };
  46. }
  47. };