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-identical-title.js 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _experimentalUtils = require("@typescript-eslint/experimental-utils");
  7. var _utils = require("./utils");
  8. const newDescribeContext = () => ({
  9. describeTitles: [],
  10. testTitles: []
  11. });
  12. var _default = (0, _utils.createRule)({
  13. name: __filename,
  14. meta: {
  15. docs: {
  16. category: 'Best Practices',
  17. description: 'Disallow identical titles',
  18. recommended: 'error'
  19. },
  20. messages: {
  21. multipleTestTitle: 'Test title is used multiple times in the same describe block.',
  22. multipleDescribeTitle: 'Describe block title is used multiple times in the same describe block.'
  23. },
  24. schema: [],
  25. type: 'suggestion'
  26. },
  27. defaultOptions: [],
  28. create(context) {
  29. const contexts = [newDescribeContext()];
  30. return {
  31. CallExpression(node) {
  32. const currentLayer = contexts[contexts.length - 1];
  33. if ((0, _utils.isDescribeCall)(node)) {
  34. contexts.push(newDescribeContext());
  35. }
  36. if (node.callee.type === _experimentalUtils.AST_NODE_TYPES.TaggedTemplateExpression) {
  37. return;
  38. }
  39. const [argument] = node.arguments;
  40. if (!argument || !(0, _utils.isStringNode)(argument)) {
  41. return;
  42. }
  43. const title = (0, _utils.getStringValue)(argument);
  44. if ((0, _utils.isTestCaseCall)(node)) {
  45. if (currentLayer.testTitles.includes(title)) {
  46. context.report({
  47. messageId: 'multipleTestTitle',
  48. node: argument
  49. });
  50. }
  51. currentLayer.testTitles.push(title);
  52. }
  53. if (!(0, _utils.isDescribeCall)(node)) {
  54. return;
  55. }
  56. if (currentLayer.describeTitles.includes(title)) {
  57. context.report({
  58. messageId: 'multipleDescribeTitle',
  59. node: argument
  60. });
  61. }
  62. currentLayer.describeTitles.push(title);
  63. },
  64. 'CallExpression:exit'(node) {
  65. if ((0, _utils.isDescribeCall)(node)) {
  66. contexts.pop();
  67. }
  68. }
  69. };
  70. }
  71. });
  72. exports.default = _default;