Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 834c4e9

Browse files
committed
JSLint's browser option is true if no environment is defined
1 parent 9511095 commit 834c4e9

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/extensions/default/JSLint/main.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ define(function (require, exports, module) {
4646
CodeInspection.requestRun(Strings.JSLINT_NAME);
4747
});
4848

49+
// Predefined environments understood by JSLint.
50+
var ENVIRONMENTS = ["browser", "node", "couch", "rhino"];
51+
4952
/**
5053
* Run JSLint on the current document. Reports results to the main UI. Displays
5154
* a gold star when no errors are found.
@@ -75,6 +78,15 @@ define(function (require, exports, module) {
7578
options.indent = PreferencesManager.get("spaceUnits");
7679
}
7780

81+
// If the user has not defined the environment, we use browser by default.
82+
var hasEnvironment = _.some(ENVIRONMENTS, function (env) {
83+
return options[env] !== undefined;
84+
});
85+
86+
if (!hasEnvironment) {
87+
options.browser = true;
88+
}
89+
7890
var jslintResult = JSLINT(text, options);
7991

8092
if (!jslintResult) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
function foo() {
22
"use strict";
3+
var body = document.body;
34
}

0 commit comments

Comments
 (0)