index.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. "use strict";
  2. exports.__esModule = true;
  3. var _getIterator2 = require("babel-runtime/core-js/get-iterator");
  4. var _getIterator3 = _interopRequireDefault(_getIterator2);
  5. exports.default = function (_ref) {
  6. var messages = _ref.messages;
  7. return {
  8. visitor: {
  9. Scope: function Scope(_ref2) {
  10. var scope = _ref2.scope;
  11. for (var name in scope.bindings) {
  12. var binding = scope.bindings[name];
  13. if (binding.kind !== "const" && binding.kind !== "module") continue;
  14. for (var _iterator = binding.constantViolations, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) {
  15. var _ref3;
  16. if (_isArray) {
  17. if (_i >= _iterator.length) break;
  18. _ref3 = _iterator[_i++];
  19. } else {
  20. _i = _iterator.next();
  21. if (_i.done) break;
  22. _ref3 = _i.value;
  23. }
  24. var violation = _ref3;
  25. throw violation.buildCodeFrameError(messages.get("readOnly", name));
  26. }
  27. }
  28. }
  29. }
  30. };
  31. };
  32. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  33. module.exports = exports["default"];