Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[dist] JSHint complaince for `prompt`

[dist] Added custom .jshintrc with `browser: false` and `devel: false` since this particular project is node-only
  • Loading branch information...
commit ae91bc72393def50c447928e98a5e3f1f523774a 1 parent b46a98e
@indexzero indexzero authored
Showing with 70 additions and 15 deletions.
  1. +54 −0 .jshintrc
  2. +16 −15 lib/prompt.js
View
54 .jshintrc
@@ -0,0 +1,54 @@
+{
+ "passfail": false,
+ "maxerr": 100,
+
+ "browser": false,
+ "node": true,
+ "rhino": false,
+ "couch": true,
+ "wsh": true,
+ "jquery": true,
+ "prototypejs": false,
+ "mootools": false,
+ "dojo": false,
+
+ "devel": false,
+
+ "es5": true,
+ "strict": false,
+ "globalstrict": false,
+
+ "asi": false,
+ "lastsemic": true,
+ "laxbreak": true,
+ "laxcomma": false,
+ "bitwise": false,
+ "boss": false,
+ "curly": true,
+ "eqeqeq": true,
+ "eqnull": false,
+ "evil": false,
+ "expr": false,
+ "forin": false,
+ "immed": false,
+ "latedef": false,
+ "loopfunc": true,
+ "noarg": true,
+ "regexp": true,
+ "regexdash": false,
+ "scripturl": true,
+ "shadow": true,
+ "supernew": true,
+ "undef": true,
+
+ "newcap": true,
+ "noempty": true,
+ "nonew": true,
+ "nomen": false,
+ "onevar": true,
+ "plusplus": false,
+ "sub": true,
+ "trailing": true,
+ "white": false,
+ "indent": 2
+}
View
31 lib/prompt.js
@@ -133,10 +133,10 @@ prompt.history = function (search) {
return null;
}
- return history.filter(function (name) {
+ return history.filter(function (pair) {
return typeof pair.property === 'string'
- ? pair.property === name
- : pair.property.name === name;
+ ? pair.property === search
+ : pair.property.name === search;
})[0];
};
@@ -191,7 +191,7 @@ prompt.get = function (schema, callback) {
var iterator = [],
result = {};
- if (typeof schema == 'string') {
+ if (typeof schema === 'string') {
//
// We can iterate over a single string.
//
@@ -205,11 +205,11 @@ prompt.get = function (schema, callback) {
// An array of strings and/or single-prop schema and/or no-prop schema.
//
iterator = schema.map(function (element) {
- if (typeof element == 'string') {
+ if (typeof element === 'string') {
return {
path: [element],
schema: prompt.properties[element.toLowerCase()] || {}
- }
+ };
}
else if (element.properties) {
return {
@@ -379,13 +379,13 @@ prompt.getInput = function (prop, callback) {
// TODO: Make overrides nestable
//
if (prompt.override && prompt.override[propName]) {
- return callback(null, prompt.override[propName])
+ return callback(null, prompt.override[propName]);
}
//
// Build a proper validation schema if we just have a string
//
- if (typeof prop == 'string') {
+ if (typeof prop === 'string') {
schema = {};
}
@@ -443,7 +443,7 @@ prompt.getInput = function (prop, callback) {
line = '';
}
- if (line && !(line === '')) {
+ if (line && line !== '') {
against[propName] = line;
}
@@ -557,24 +557,25 @@ prompt._remember = function (property, value) {
// Converts the schema into new format if it is in old format
//
function convert(schema) {
- var newSchema = false,
- newProps = Object.keys(validate.messages);
+ var newProps = Object.keys(validate.messages),
+ newSchema = false,
+ key;
newProps = newProps.concat(['description', 'dependencies']);
- for (var key in schema) {
+ for (key in schema) {
if (newProps.indexOf(key) > 0) {
newSchema = true;
break;
}
}
- if (!newSchema || schema.validator || schema.warning || schema.empty != null) {
+ if (!newSchema || schema.validator || schema.warning || typeof schema.empty !== 'undefined') {
schema.description = schema.message;
schema.message = schema.warning;
schema.pattern = schema.validator;
- if (schema.empty != null) {
+ if (typeof schema.empty !== 'undefined') {
schema.required = !(schema.empty);
}
@@ -584,4 +585,4 @@ function convert(schema) {
}
return schema;
-};
+}
Please sign in to comment.
Something went wrong with that request. Please try again.