From 45e39c3ac881cbd98077e97a3d8788c817a2de53 Mon Sep 17 00:00:00 2001 From: Arlo Breault Date: Fri, 5 Jun 2015 16:11:41 -0700 Subject: [PATCH] Make generated parsers use strict mode * Issue #324 * JSHint complains about two possible strict violations. But are valid uses of `this`, so we suppress the warnings. --- .jshintrc | 31 +++++++++++----------- lib/compiler/passes/generate-javascript.js | 2 ++ lib/parser.js | 2 ++ 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/.jshintrc b/.jshintrc index 218394a..0fdd54e 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,17 +1,18 @@ { - "curly": true, - "eqeqeq": true, - "evil": true, - "forin": true, - "freeze": true, - "immed": true, - "latedef": "nofunc", - "laxbreak": true, - "loopfunc": true, - "newcap": false, - "noarg": true, - "noempty": true, - "nonew": true, - "trailing": true, - "-W082": false + "curly": true, + "eqeqeq": true, + "evil": true, + "forin": true, + "freeze": true, + "immed": true, + "latedef": "nofunc", + "laxbreak": true, + "loopfunc": true, + "newcap": false, + "noarg": true, + "noempty": true, + "nonew": true, + "trailing": true, + "validthis": true, + "-W082": false } diff --git a/lib/compiler/passes/generate-javascript.js b/lib/compiler/passes/generate-javascript.js index c38d4b8..1268774 100644 --- a/lib/compiler/passes/generate-javascript.js +++ b/lib/compiler/passes/generate-javascript.js @@ -761,6 +761,8 @@ function generateJavascript(ast, options) { parts.push([ '(function() {', + ' "use strict";', + '', ' /*', ' * Generated by PEG.js 0.8.0.', ' *', diff --git a/lib/parser.js b/lib/parser.js index d402a52..b6b677f 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -1,4 +1,6 @@ module.exports = (function() { + "use strict"; + /* * Generated by PEG.js 0.8.0. *