Skip to content

Commit

Permalink
Fixes #139. Adds other directories to jshint
Browse files Browse the repository at this point in the history
  • Loading branch information
mjstahl committed Oct 5, 2018
1 parent b9660b9 commit a816ef4
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 51 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"release:patch": "npm version patch && npm publish",
"release:minor": "npm version minor && npm publish",
"release:major": "npm version major && npm publish",
"jshint": "jshint ./*.js --config",
"jshint": "jshint ./*.js reflections/**/*.js types/*.js --config",
"build": "node build.js",
"http-server": "http-server -p 3000 --silent",
"ci": "npm run build && npm run test && node test-saucelabs.js",
Expand Down
1 change: 0 additions & 1 deletion reflections/get-set/get-set-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var QUnit = require('steal-qunit');
var canSymbol = require('can-symbol');
var shapeReflections = require("../shape/shape");
var getSetReflections = require("./get-set");

QUnit.module('can-reflect: get-set reflections: key');
Expand Down
48 changes: 24 additions & 24 deletions reflections/shape/shape.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if(typeof Map === "function") {
} else {
// IE-remove-start
var isEven = function isEven(num) {
return !(num % 2);
return num % 2 === 0;
};

// A simple map that stores items in an array.
Expand Down Expand Up @@ -121,6 +121,22 @@ try{
};
}

function createSerializeMap(Type) {
var MapType = Type || ArrayMap;
return {
unwrap: new MapType(),
serialize: new MapType() ,
isSerializing: {
unwrap: new MapType(),
serialize: new MapType()
},
circularReferenceIsSerializing: {
unwrap: new MapType(),
serialize: new MapType()
}
};
}

function makeSerializer(methodName, symbolsToCheck){
// A local variable that is shared with all operations that occur withing a single
// outer call to serialize()
Expand All @@ -147,22 +163,6 @@ function makeSerializer(methodName, symbolsToCheck){
return this.result;
};

function createSerializeMap(Type) {
var MapType = Type || ArrayMap;
return {
unwrap: new MapType(),
serialize: new MapType() ,
isSerializing: {
unwrap: new MapType(),
serialize: new MapType()
},
circularReferenceIsSerializing: {
unwrap: new MapType(),
serialize: new MapType()
}
};
}

return function serializer(value, MapType){
if (isSerializedHelper(value)) {
return value;
Expand Down Expand Up @@ -301,11 +301,11 @@ function addPatch(patches, patch) {
}

function updateDeepList(target, source, isAssign) {
var sourceArray = this.toArray(source);
var sourceArray = this.toArray(source); // jshint ignore:line

var patches = [],
lastIndex = -1;
this.eachIndex(target, function(curVal, index){
this.eachIndex(target, function(curVal, index){ // jshint ignore:line
lastIndex = index;
// If target has more items than the source.
if(index >= sourceArray.length) {
Expand All @@ -326,7 +326,7 @@ function updateDeepList(target, source, isAssign) {
}

}
}, this);
}, this); // jshint ignore:line
// add items at the end
if(sourceArray.length > lastIndex) {
addPatch(patches, {index: lastIndex+1, deleteCount: 0, insert: sourceArray.slice(lastIndex+1)});
Expand Down Expand Up @@ -836,7 +836,7 @@ shapeReflections = {
return target;
},
assignDeepList: function(target, source) {
return updateDeepList.call(this,target, source, true);
return updateDeepList.call(this, target, source, true);
},
/**
* @function can-reflect.assignDeep assignDeep
Expand Down Expand Up @@ -900,7 +900,7 @@ shapeReflections = {
if(sourceKeyMap.get(key)) {
targetSetKeyValue.call(target, key, sourceGetKeyValue.call(source, key) );
}
})
});

return target;
},
Expand Down Expand Up @@ -1065,9 +1065,9 @@ shapeReflections = {
proto = Object.getPrototypeOf(obj);
} else {
// IE-remove-start
proto = obj.__proto__;
proto = obj.__proto__; // jshint ignore:line
// IE-remove-end
};
}
if(proto !== undefined) {
return key in proto;
} else {
Expand Down
2 changes: 1 addition & 1 deletion reflections/type/type-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ QUnit.test("isBuiltIn", function() {
if (document) {
ok(typeReflections.isBuiltIn(document.createElement('div')), "Elements");
}
var Foo = function() {}
var Foo = function() {};
var customObj = new Foo();
ok(!typeReflections.isBuiltIn(customObj), "Custom Object");
if (testHelpers.mapSupported) {
Expand Down
42 changes: 21 additions & 21 deletions reflections/type/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,27 @@ function isPrimitive(obj){
}
}

var coreHasOwn = Object.prototype.hasOwnProperty;
var funcToString = Function.prototype.toString;
var objectCtorString = funcToString.call(Object);

function isPlainObject(obj) {
// Must be an Object.
// Because of IE, we also have to check the presence of the constructor property.
// Make sure that DOM nodes and window objects don't pass through, as well
if (!obj || typeof obj !== 'object' ) {
return false;
}
var proto = Object.getPrototypeOf(obj);
if(proto === Object.prototype || proto === null) {
return true;
}
// partially inspired by lodash: https://github.com/lodash/lodash
var Constructor = coreHasOwn.call(proto, 'constructor') && proto.constructor;
return typeof Constructor === 'function' && Constructor instanceof Constructor &&
funcToString.call(Constructor) === objectCtorString;
}

/**
* @function can-reflect.isBuiltIn isBuiltIn
* @parent can-reflect/type
Expand Down Expand Up @@ -393,27 +414,6 @@ if(supportsSymbols) {
};
}

var coreHasOwn = Object.prototype.hasOwnProperty;
var funcToString = Function.prototype.toString;
var objectCtorString = funcToString.call(Object);

function isPlainObject(obj) {
// Must be an Object.
// Because of IE, we also have to check the presence of the constructor property.
// Make sure that DOM nodes and window objects don't pass through, as well
if (!obj || typeof obj !== 'object' ) {
return false;
}
var proto = Object.getPrototypeOf(obj);
if(proto === Object.prototype || proto === null) {
return true;
}
// partially inspired by lodash: https://github.com/lodash/lodash
var Constructor = coreHasOwn.call(proto, 'constructor') && proto.constructor;
return typeof Constructor === 'function' && Constructor instanceof Constructor &&
funcToString.call(Constructor) === objectCtorString;
}

module.exports = {
isConstructorLike: isConstructorLike,
isFunctionLike: isFunctionLike,
Expand Down
4 changes: 2 additions & 2 deletions types/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function keysPolyfill() {
var keys = [];
var currentIndex = 0;

this.forEach(function(val, key) {
this.forEach(function(val, key) { // jshint ignore:line
keys.push(key);
});

Expand All @@ -17,7 +17,7 @@ function keysPolyfill() {
done: (currentIndex++ === keys.length)
};
}
}
};
}

if (typeof Map !== "undefined") {
Expand Down
2 changes: 1 addition & 1 deletion types/set.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if (typeof Set !== "undefined") {
done: (currentIndex++ === arr.length)
};
}
}
};
};
}
}
Expand Down

0 comments on commit a816ef4

Please sign in to comment.