@@ -48,6 +48,9 @@ ruleTester.run("no-eval", rule, {
4848 { code : "function foo() { this.eval('foo'); }" , parserOptions : { ecmaFeatures : { impliedStrict : true } } } ,
4949 "var obj = {foo: function() { this.eval('foo'); }}" ,
5050 "var obj = {}; obj.foo = function() { this.eval('foo'); }" ,
51+ { code : "() => { this.eval('foo') }" , parserOptions : { ecmaVersion : 6 , sourceType : "module" } } ,
52+ { code : "function f() { 'use strict'; () => { this.eval('foo') } }" , parserOptions : { ecmaVersion : 6 } } ,
53+ { code : "(function f() { 'use strict'; () => { this.eval('foo') } })" , parserOptions : { ecmaVersion : 6 } } ,
5154 { code : "class A { foo() { this.eval(); } }" , parserOptions : { ecmaVersion : 6 } } ,
5255 { code : "class A { static foo() { this.eval(); } }" , parserOptions : { ecmaVersion : 6 } } ,
5356 { code : "class A { field = this.eval(); }" , parserOptions : { ecmaVersion : 2022 } } ,
@@ -95,6 +98,10 @@ ruleTester.run("no-eval", rule, {
9598 { code : "var EVAL = eval; EVAL('foo')" , errors : [ { messageId : "unexpected" , type : "Identifier" , column : 12 , endColumn : 16 } ] } ,
9699 { code : "var EVAL = this.eval; EVAL('foo')" , errors : [ { messageId : "unexpected" , type : "MemberExpression" , column : 17 , endColumn : 21 } ] } ,
97100 { code : "'use strict'; var EVAL = this.eval; EVAL('foo')" , errors : [ { messageId : "unexpected" , type : "MemberExpression" , column : 31 , endColumn : 35 } ] } ,
101+ { code : "() => { this.eval('foo'); }" , parserOptions : { ecmaVersion : 6 } , errors : [ { messageId : "unexpected" , type : "CallExpression" , column : 14 , endColumn : 18 } ] } ,
102+ { code : "() => { 'use strict'; this.eval('foo'); }" , parserOptions : { ecmaVersion : 6 } , errors : [ { messageId : "unexpected" , type : "CallExpression" , column : 28 , endColumn : 32 } ] } ,
103+ { code : "'use strict'; () => { this.eval('foo'); }" , parserOptions : { ecmaVersion : 6 } , errors : [ { messageId : "unexpected" , type : "CallExpression" , column : 28 , endColumn : 32 } ] } ,
104+ { code : "() => { 'use strict'; () => { this.eval('foo'); } }" , parserOptions : { ecmaVersion : 6 } , errors : [ { messageId : "unexpected" , type : "CallExpression" , column : 36 , endColumn : 40 } ] } ,
98105 { code : "(function(exe){ exe('foo') })(eval);" , errors : [ { messageId : "unexpected" , type : "Identifier" , column : 31 , endColumn : 35 } ] } ,
99106 { code : "window.eval('foo')" , env : { browser : true } , errors : [ { messageId : "unexpected" , type : "CallExpression" , column : 8 , endColumn : 12 } ] } ,
100107 { code : "window.window.eval('foo')" , env : { browser : true } , errors : [ { messageId : "unexpected" , type : "CallExpression" , column : 15 , endColumn : 19 } ] } ,
0 commit comments