index.js 1.1 KB

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