Skip to content

Commit

Permalink
Fixed #1220: Add typed array option, implied by 'node' option
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Kovalyov <anton@kovalyov.net>
  • Loading branch information
Rob--W authored and valueof committed Aug 15, 2013
1 parent 27bd241 commit ae96e5c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 14 deletions.
6 changes: 6 additions & 0 deletions src/jshint.js
Expand Up @@ -128,6 +128,7 @@ var JSHINT = (function () {
// predefined
rhino : true, // if the Rhino environment globals should be predefined
shelljs : true, // if ShellJS globals should be predefined
typed : true, // if typed array globals should be predefined
undef : true, // if variables should be declared before used
scripturl : true, // if script-targeted URLs should be tolerated
shadow : true, // if variable shadowing should be tolerated
Expand Down Expand Up @@ -333,6 +334,9 @@ var JSHINT = (function () {
combine(predefined, vars.shelljs);
combine(predefined, vars.node);
}
if (state.option.typed) {
combine(predefined, vars.typed);
}

if (state.option.phantom) {
combine(predefined, vars.phantom);
Expand All @@ -344,6 +348,7 @@ var JSHINT = (function () {

if (state.option.node) {
combine(predefined, vars.node);
combine(predefined, vars.typed);
}

if (state.option.devel) {
Expand All @@ -356,6 +361,7 @@ var JSHINT = (function () {

if (state.option.browser) {
combine(predefined, vars.browser);
combine(predefined, vars.typed);
}

if (state.option.nonstandard) {
Expand Down
30 changes: 16 additions & 14 deletions src/vars.js
Expand Up @@ -45,8 +45,6 @@ exports.ecmaIdentifiers = {
// Global variables commonly provided by a web browser environment.

exports.browser = {
ArrayBuffer : false,
ArrayBufferView : false,
Audio : false,
Blob : false,
addEventListener : false,
Expand All @@ -59,16 +57,13 @@ exports.browser = {
close : false,
closed : false,
CustomEvent : false,
DataView : false,
DOMParser : false,
defaultStatus : false,
document : false,
Element : false,
ElementTimeControl : false,
event : false,
FileReader : false,
Float32Array : false,
Float64Array : false,
FormData : false,
focus : false,
frames : false,
Expand Down Expand Up @@ -128,9 +123,6 @@ exports.browser = {
HTMLUListElement : false,
HTMLVideoElement : false,
history : false,
Int16Array : false,
Int32Array : false,
Int8Array : false,
Image : false,
length : false,
localStorage : false,
Expand Down Expand Up @@ -328,10 +320,6 @@ exports.browser = {
SVGZoomAndPan : false,
TimeEvent : false,
top : false,
Uint16Array : false,
Uint32Array : false,
Uint8Array : false,
Uint8ClampedArray : false,
WebSocket : false,
window : false,
Worker : false,
Expand Down Expand Up @@ -386,7 +374,6 @@ exports.node = {
__filename : false,
__dirname : false,
Buffer : false,
DataView : false,
console : false,
exports : true, // In Node it is ok to exports = module.exports = foo();
GLOBAL : false,
Expand Down Expand Up @@ -460,6 +447,21 @@ exports.shelljs = {
tempdir : false
};

exports.typed = {
ArrayBuffer : false,
ArrayBufferView : false,
DataView : false,
Float32Array : false,
Float64Array : false,
Int16Array : false,
Int32Array : false,
Int8Array : false,
Uint16Array : false,
Uint32Array : false,
Uint8Array : false,
Uint8ClampedArray : false
};

exports.wsh = {
ActiveXObject : true,
Enumerator : true,
Expand All @@ -480,7 +482,7 @@ exports.dojo = {
dojo : false,
dijit : false,
dojox : false,
define : false,
define : false,
"require": false
};

Expand Down
23 changes: 23 additions & 0 deletions tests/unit/envs.js
Expand Up @@ -442,6 +442,29 @@ exports.shelljs = function (test) {
test.done();
};

exports.typed = function (test) {
var globals = [
"ArrayBuffer",
"ArrayBufferView",
"DataView",
"Float32Array",
"Float64Array",
"Int16Array",
"Int32Array",
"Int8Array",
"Uint16Array",
"Uint32Array",
"Uint8Array",
"Uint8ClampedArray"
];

globalsImplied(test, globals);
globalsKnown(test, globals, { browser: true });
globalsKnown(test, globals, { node: true });
globalsKnown(test, globals, { typed: true });

test.done();
};


exports.wsh = function (test) {
Expand Down

0 comments on commit ae96e5c

Please sign in to comment.