index.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. exports.requeueComputedKeyAndDecorators = requeueComputedKeyAndDecorators;
  7. {
  8. exports.skipAllButComputedKey = function skipAllButComputedKey(path) {
  9. path.skip();
  10. if (path.node.computed) {
  11. path.context.maybeQueue(path.get("key"));
  12. }
  13. };
  14. }
  15. function requeueComputedKeyAndDecorators(path) {
  16. const {
  17. context,
  18. node
  19. } = path;
  20. if (node.computed) {
  21. context.maybeQueue(path.get("key"));
  22. }
  23. if (node.decorators) {
  24. for (const decorator of path.get("decorators")) {
  25. context.maybeQueue(decorator);
  26. }
  27. }
  28. }
  29. const visitor = {
  30. FunctionParent(path) {
  31. if (path.isArrowFunctionExpression()) {
  32. return;
  33. } else {
  34. path.skip();
  35. if (path.isMethod()) {
  36. requeueComputedKeyAndDecorators(path);
  37. }
  38. }
  39. },
  40. Property(path) {
  41. if (path.isObjectProperty()) {
  42. return;
  43. }
  44. path.skip();
  45. requeueComputedKeyAndDecorators(path);
  46. }
  47. };
  48. var _default = visitor;
  49. exports.default = _default;
  50. //# sourceMappingURL=index.js.map