Skip to content

Commit

Permalink
Make jshint happ(ier).
Browse files Browse the repository at this point in the history
  • Loading branch information
eventualbuddha committed Apr 10, 2014
1 parent 5827a04 commit 2ba3cdf
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 18 deletions.
2 changes: 2 additions & 0 deletions dist/commonjs/lgtm/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"use strict";
/* jshint esnext:true */

var config = {};

config.defer = function() {
Expand Down
8 changes: 5 additions & 3 deletions dist/commonjs/lgtm/helpers/core.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"use strict";
var ValidatorBuilder = require("../validator_builder");
/* jshint esnext:true */


function present(value) {
if (typeof value === 'string') {
Expand All @@ -26,13 +28,13 @@ function checkEmail(value, options) {
}

// http://stackoverflow.com/a/46181/11236
var regexp = /^(([^<>()\[\]\\.,;:\s@\"]+(\.[^<>()\[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
var regexp = /^(([^<>()\[\]\\.,;:\s@\"]+(\.[^<>()\[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return regexp.test(value);
}

function checkMinLength(minLength) {
if (minLength === null || minLength === undefined) {
throw new Error('must specify a min length')
throw new Error('must specify a min length');
}

return function(value) {
Expand All @@ -46,7 +48,7 @@ function checkMinLength(minLength) {

function checkMaxLength(maxLength) {
if (maxLength === null || maxLength === undefined) {
throw new Error('must specify a max length')
throw new Error('must specify a max length');
}

return function(value) {
Expand Down
4 changes: 3 additions & 1 deletion dist/commonjs/lgtm/object_validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ var keys = __dependency1__.keys;
var forEach = __dependency1__.forEach;
var get = __dependency1__.get;
var uniq = __dependency1__.uniq;
/* jshint esnext:true */


function ObjectValidator() {
this._validations = {};
Expand Down Expand Up @@ -42,7 +44,7 @@ ObjectValidator.prototype = {
for (var i = 0; i < dependentAttributes.length; i++) {
var attr = dependentAttributes[i];
if (!contains(dependentsForParent, attr)) {
dependentsForParent.push(attr)
dependentsForParent.push(attr);
}
}
},
Expand Down
2 changes: 2 additions & 0 deletions dist/commonjs/lgtm/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"use strict";
var config = require("./config");
/* jshint esnext:true */


/**
* Iteration
Expand Down
2 changes: 2 additions & 0 deletions dist/commonjs/lgtm/validator_builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ var ObjectValidator = require("./object_validator");
var __dependency1__ = require("./utils");
var getProperties = __dependency1__.getProperties;
var all = __dependency1__.all;
/* jshint esnext:true */


function ValidatorBuilder() {
this._validator = new ObjectValidator();
Expand Down
31 changes: 26 additions & 5 deletions dist/lgtm-standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ exports.helpers = helpers;
exports.ObjectValidator = ObjectValidator;
},{"./lgtm/config":3,"./lgtm/helpers/core":4,"./lgtm/object_validator":5,"./lgtm/validator_builder":7}],3:[function(require,module,exports){
"use strict";
/* jshint esnext:true */

var config = {};

config.defer = function() {
Expand All @@ -76,6 +78,8 @@ module.exports = config;
},{}],4:[function(require,module,exports){
"use strict";
var ValidatorBuilder = require("../validator_builder");
/* jshint esnext:true */


function present(value) {
if (typeof value === 'string') {
Expand All @@ -85,19 +89,30 @@ function present(value) {
return value !== '' && value !== null && value !== undefined;
}

function checkEmail(value) {
function checkEmail(value, options) {
if (typeof value === 'string') {
value = value.trim();
}

if (!options) {
options = {};
}

if (options.strictCharacters) {
var strictCharactersRegexp = /^[\x20-\x7F]*$/;
if (!strictCharactersRegexp.test(value)) {
return false;
}
}

// http://stackoverflow.com/a/46181/11236
var regexp = /^(([^<>()\[\]\\.,;:\s@\"]+(\.[^<>()\[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
var regexp = /^(([^<>()\[\]\\.,;:\s@\"]+(\.[^<>()\[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return regexp.test(value);
}

function checkMinLength(minLength) {
if (minLength === null || minLength === undefined) {
throw new Error('must specify a min length')
throw new Error('must specify a min length');
}

return function(value) {
Expand All @@ -111,7 +126,7 @@ function checkMinLength(minLength) {

function checkMaxLength(maxLength) {
if (maxLength === null || maxLength === undefined) {
throw new Error('must specify a max length')
throw new Error('must specify a max length');
}

return function(value) {
Expand Down Expand Up @@ -162,6 +177,8 @@ var keys = __dependency1__.keys;
var forEach = __dependency1__.forEach;
var get = __dependency1__.get;
var uniq = __dependency1__.uniq;
/* jshint esnext:true */


function ObjectValidator() {
this._validations = {};
Expand Down Expand Up @@ -196,7 +213,7 @@ ObjectValidator.prototype = {
for (var i = 0; i < dependentAttributes.length; i++) {
var attr = dependentAttributes[i];
if (!contains(dependentsForParent, attr)) {
dependentsForParent.push(attr)
dependentsForParent.push(attr);
}
}
},
Expand Down Expand Up @@ -320,6 +337,8 @@ module.exports = ObjectValidator;
},{"./config":3,"./utils":6}],6:[function(require,module,exports){
"use strict";
var config = require("./config");
/* jshint esnext:true */


/**
* Iteration
Expand Down Expand Up @@ -452,6 +471,8 @@ var ObjectValidator = require("./object_validator");
var __dependency1__ = require("./utils");
var getProperties = __dependency1__.getProperties;
var all = __dependency1__.all;
/* jshint esnext:true */


function ValidatorBuilder() {
this._validator = new ObjectValidator();
Expand Down
31 changes: 26 additions & 5 deletions dist/lgtm.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ exports.helpers = helpers;
exports.ObjectValidator = ObjectValidator;
},{"./lgtm/config":2,"./lgtm/helpers/core":3,"./lgtm/object_validator":4,"./lgtm/validator_builder":6}],2:[function(require,module,exports){
"use strict";
/* jshint esnext:true */

var config = {};

config.defer = function() {
Expand All @@ -59,6 +61,8 @@ module.exports = config;
},{}],3:[function(require,module,exports){
"use strict";
var ValidatorBuilder = require("../validator_builder");
/* jshint esnext:true */


function present(value) {
if (typeof value === 'string') {
Expand All @@ -68,19 +72,30 @@ function present(value) {
return value !== '' && value !== null && value !== undefined;
}

function checkEmail(value) {
function checkEmail(value, options) {
if (typeof value === 'string') {
value = value.trim();
}

if (!options) {
options = {};
}

if (options.strictCharacters) {
var strictCharactersRegexp = /^[\x20-\x7F]*$/;
if (!strictCharactersRegexp.test(value)) {
return false;
}
}

// http://stackoverflow.com/a/46181/11236
var regexp = /^(([^<>()\[\]\\.,;:\s@\"]+(\.[^<>()\[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
var regexp = /^(([^<>()\[\]\\.,;:\s@\"]+(\.[^<>()\[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return regexp.test(value);
}

function checkMinLength(minLength) {
if (minLength === null || minLength === undefined) {
throw new Error('must specify a min length')
throw new Error('must specify a min length');
}

return function(value) {
Expand All @@ -94,7 +109,7 @@ function checkMinLength(minLength) {

function checkMaxLength(maxLength) {
if (maxLength === null || maxLength === undefined) {
throw new Error('must specify a max length')
throw new Error('must specify a max length');
}

return function(value) {
Expand Down Expand Up @@ -145,6 +160,8 @@ var keys = __dependency1__.keys;
var forEach = __dependency1__.forEach;
var get = __dependency1__.get;
var uniq = __dependency1__.uniq;
/* jshint esnext:true */


function ObjectValidator() {
this._validations = {};
Expand Down Expand Up @@ -179,7 +196,7 @@ ObjectValidator.prototype = {
for (var i = 0; i < dependentAttributes.length; i++) {
var attr = dependentAttributes[i];
if (!contains(dependentsForParent, attr)) {
dependentsForParent.push(attr)
dependentsForParent.push(attr);
}
}
},
Expand Down Expand Up @@ -303,6 +320,8 @@ module.exports = ObjectValidator;
},{"./config":2,"./utils":5}],5:[function(require,module,exports){
"use strict";
var config = require("./config");
/* jshint esnext:true */


/**
* Iteration
Expand Down Expand Up @@ -435,6 +454,8 @@ var ObjectValidator = require("./object_validator");
var __dependency1__ = require("./utils");
var getProperties = __dependency1__.getProperties;
var all = __dependency1__.all;
/* jshint esnext:true */


function ValidatorBuilder() {
this._validator = new ObjectValidator();
Expand Down
2 changes: 2 additions & 0 deletions src/lgtm/config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* jshint esnext:true */

var config = {};

config.defer = function() {
Expand Down
8 changes: 5 additions & 3 deletions src/lgtm/helpers/core.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* jshint esnext:true */

import ValidatorBuilder from '../validator_builder';

function present(value) {
Expand Down Expand Up @@ -25,13 +27,13 @@ function checkEmail(value, options) {
}

// http://stackoverflow.com/a/46181/11236
var regexp = /^(([^<>()\[\]\\.,;:\s@\"]+(\.[^<>()\[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
var regexp = /^(([^<>()\[\]\\.,;:\s@\"]+(\.[^<>()\[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return regexp.test(value);
}

function checkMinLength(minLength) {
if (minLength === null || minLength === undefined) {
throw new Error('must specify a min length')
throw new Error('must specify a min length');
}

return function(value) {
Expand All @@ -45,7 +47,7 @@ function checkMinLength(minLength) {

function checkMaxLength(maxLength) {
if (maxLength === null || maxLength === undefined) {
throw new Error('must specify a max length')
throw new Error('must specify a max length');
}

return function(value) {
Expand Down
4 changes: 3 additions & 1 deletion src/lgtm/object_validator.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* jshint esnext:true */

import config from './config';
import { all, resolve, contains, keys, forEach, get, uniq } from './utils';

Expand Down Expand Up @@ -34,7 +36,7 @@ ObjectValidator.prototype = {
for (var i = 0; i < dependentAttributes.length; i++) {
var attr = dependentAttributes[i];
if (!contains(dependentsForParent, attr)) {
dependentsForParent.push(attr)
dependentsForParent.push(attr);
}
}
},
Expand Down
2 changes: 2 additions & 0 deletions src/lgtm/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* jshint esnext:true */

import config from './config';

/**
Expand Down
2 changes: 2 additions & 0 deletions src/lgtm/validator_builder.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* jshint esnext:true */

import ObjectValidator from './object_validator';
import { getProperties, all } from './utils';

Expand Down

0 comments on commit 2ba3cdf

Please sign in to comment.