add error message to use of eval(); and enable strict mode on the parser
This commit is contained in:
parent
1890fb5bd3
commit
5b75b11628
@ -16,7 +16,8 @@ exports.messages = {
|
||||
readOnly: "$1 is read-only",
|
||||
modulesIllegalExportName: "Illegal export $1",
|
||||
unknownForHead: "Unknown node type $1 in ForStatement",
|
||||
didYouMean: "Did you mean $1?"
|
||||
didYouMean: "Did you mean $1?",
|
||||
evalInStrictMode: "eval is not allowed in strict mode"
|
||||
};
|
||||
|
||||
exports.get = function (key) {
|
||||
|
||||
@ -368,7 +368,7 @@ File.prototype.parse = function (code) {
|
||||
var opts = this.opts;
|
||||
|
||||
opts.allowImportExportEverywhere = this.isLoose("es6.modules");
|
||||
//opts.strictMode = this.transformers.useStrict.canRun();
|
||||
opts.strictMode = this.transformers.useStrict.canRun();
|
||||
|
||||
return parse(opts, code, function (tree) {
|
||||
self.transform(tree);
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
var useStrict = require("../../helpers/use-strict");
|
||||
var messages = require("../../../messages");
|
||||
var t = require("../../../types");
|
||||
|
||||
exports.Program = function (program) {
|
||||
@ -17,3 +18,9 @@ exports.FunctionExpression = function () {
|
||||
exports.ThisExpression = function () {
|
||||
return t.identifier("undefined");
|
||||
};
|
||||
|
||||
exports.CallExpression = function (node, parent, scope, file) {
|
||||
if (t.isIdentifier(node.callee, { name: "eval" })) {
|
||||
throw file.errorWithNode(node, messages.get("evalInStrictMode"));
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user