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-top-level-describe.js 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 test cases and hooks to be inside a `describe` block',
  13. recommended: false
  14. },
  15. messages: {
  16. unexpectedTestCase: 'All test cases must be wrapped in a describe block.',
  17. unexpectedHook: 'All hooks must be wrapped in a describe block.'
  18. },
  19. type: 'suggestion',
  20. schema: []
  21. },
  22. defaultOptions: [],
  23. create(context) {
  24. let numberOfDescribeBlocks = 0;
  25. return {
  26. CallExpression(node) {
  27. if ((0, _utils.isDescribeCall)(node)) {
  28. numberOfDescribeBlocks++;
  29. return;
  30. }
  31. if (numberOfDescribeBlocks === 0) {
  32. if ((0, _utils.isTestCaseCall)(node)) {
  33. context.report({
  34. node,
  35. messageId: 'unexpectedTestCase'
  36. });
  37. return;
  38. }
  39. if ((0, _utils.isHook)(node)) {
  40. context.report({
  41. node,
  42. messageId: 'unexpectedHook'
  43. });
  44. return;
  45. }
  46. }
  47. },
  48. 'CallExpression:exit'(node) {
  49. if ((0, _utils.isDescribeCall)(node)) {
  50. numberOfDescribeBlocks--;
  51. }
  52. }
  53. };
  54. }
  55. });
  56. exports.default = _default;