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.

prefer-called-with.js 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _utils = require("./utils");
  7. var _default = (0, _utils.createRule)({
  8. name: __filename,
  9. meta: {
  10. docs: {
  11. category: 'Best Practices',
  12. description: 'Suggest using `toBeCalledWith()` or `toHaveBeenCalledWith()`',
  13. recommended: false
  14. },
  15. messages: {
  16. preferCalledWith: 'Prefer {{name}}With(/* expected args */)'
  17. },
  18. type: 'suggestion',
  19. schema: []
  20. },
  21. defaultOptions: [],
  22. create(context) {
  23. return {
  24. CallExpression(node) {
  25. if (!(0, _utils.isExpectCall)(node)) {
  26. return;
  27. }
  28. const {
  29. modifier,
  30. matcher
  31. } = (0, _utils.parseExpectCall)(node); // Could check resolves/rejects here but not a likely idiom.
  32. if (matcher && !modifier) {
  33. if (['toBeCalled', 'toHaveBeenCalled'].includes(matcher.name)) {
  34. context.report({
  35. data: {
  36. name: matcher.name
  37. },
  38. // todo: rename to 'matcherName'
  39. messageId: 'preferCalledWith',
  40. node: matcher.node.property
  41. });
  42. }
  43. }
  44. }
  45. };
  46. }
  47. });
  48. exports.default = _default;