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.

require-to-throw-message.js 1.4KB

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: 'Require a message for `toThrow()`',
  13. recommended: false
  14. },
  15. messages: {
  16. addErrorMessage: 'Add an error message to {{ matcherName }}()'
  17. },
  18. type: 'suggestion',
  19. schema: []
  20. },
  21. defaultOptions: [],
  22. create(context) {
  23. return {
  24. CallExpression(node) {
  25. var _matcher$arguments;
  26. if (!(0, _utils.isExpectCall)(node)) {
  27. return;
  28. }
  29. const {
  30. matcher,
  31. modifier
  32. } = (0, _utils.parseExpectCall)(node);
  33. if ((matcher === null || matcher === void 0 ? void 0 : (_matcher$arguments = matcher.arguments) === null || _matcher$arguments === void 0 ? void 0 : _matcher$arguments.length) === 0 && ['toThrow', 'toThrowError'].includes(matcher.name) && (!modifier || !(modifier.name === _utils.ModifierName.not || modifier.negation))) {
  34. // Look for `toThrow` calls with no arguments.
  35. context.report({
  36. messageId: 'addErrorMessage',
  37. data: {
  38. matcherName: matcher.name
  39. },
  40. node: matcher.node.property
  41. });
  42. }
  43. }
  44. };
  45. }
  46. });
  47. exports.default = _default;