babel-plugin-check-es2015-constants
Advanced tools
Comparing version 7.0.0-alpha.15 to 7.0.0-alpha.16
@@ -6,4 +6,9 @@ "use strict"; | ||
exports.default = function (_ref) { | ||
var messages = _ref.messages; | ||
var messages = _ref.messages, | ||
t = _ref.types; | ||
function statementBeforeExpression(statement, expression) { | ||
return t.sequenceExpression([t.callExpression(t.functionExpression(null, [], t.blockStatement([statement])), []), expression]); | ||
} | ||
return { | ||
@@ -17,18 +22,16 @@ visitor: { | ||
if (binding.kind !== "const" && binding.kind !== "module") continue; | ||
var _arr = binding.constantViolations; | ||
for (var _iterator = binding.constantViolations, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
var _ref3; | ||
for (var _i = 0; _i < _arr.length; _i++) { | ||
var violation = _arr[_i]; | ||
var throwNode = t.throwStatement(t.newExpression(t.identifier("Error"), [t.stringLiteral(messages.get("readOnly", name))])); | ||
if (_isArray) { | ||
if (_i >= _iterator.length) break; | ||
_ref3 = _iterator[_i++]; | ||
} else { | ||
_i = _iterator.next(); | ||
if (_i.done) break; | ||
_ref3 = _i.value; | ||
if (violation.isAssignmentExpression()) { | ||
violation.get("right").replaceWith(statementBeforeExpression(throwNode, violation.get("right").node)); | ||
} else if (violation.parentPath.isUpdateExpression()) { | ||
violation.parentPath.replaceWith(statementBeforeExpression(throwNode, violation.parent)); | ||
} else if (violation.parentPath.isForXStatement()) { | ||
violation.parentPath.ensureBlock(); | ||
violation.parentPath.node.body.body.unshift(throwNode); | ||
} | ||
var violation = _ref3; | ||
throw violation.buildCodeFrameError(messages.get("readOnly", name)); | ||
} | ||
@@ -35,0 +38,0 @@ } |
{ | ||
"name": "babel-plugin-check-es2015-constants", | ||
"version": "7.0.0-alpha.15", | ||
"version": "7.0.0-alpha.16", | ||
"description": "Compile ES2015 constants to ES5", | ||
@@ -12,4 +12,4 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-check-es2015-constants", | ||
"devDependencies": { | ||
"babel-helper-plugin-test-runner": "7.0.0-alpha.15" | ||
"babel-helper-plugin-test-runner": "7.0.0-alpha.16" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2759
32