compat-x-flag-transform.js 478 B

1234567891011121314151617181920212223
  1. /**
  2. * The MIT License (MIT)
  3. * Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
  4. */
  5. 'use strict';
  6. /**
  7. * A regexp-tree plugin to remove `x` flag `/foo/x` to `/foo/`.
  8. *
  9. * Note: other features of `x` flags (whitespace, comments) are
  10. * already removed at parsing stage.
  11. */
  12. module.exports = {
  13. RegExp: function RegExp(_ref) {
  14. var node = _ref.node;
  15. if (node.flags.includes('x')) {
  16. node.flags = node.flags.replace('x', '');
  17. }
  18. }
  19. };