Skip to content

Commit

Permalink
ESLint syntax clean up - up to: fields/types/relationship/Relationshi…
Browse files Browse the repository at this point in the history
…pType.js
  • Loading branch information
Vito Belgiorno-Zegna committed Mar 16, 2015
1 parent 2267490 commit c4f820e
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 36 deletions.
8 changes: 4 additions & 4 deletions fields/types/localfiles/LocalFilesField.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var _ = require('underscore'),
$ = require('jquery'),
$ = require('jquery'),
bytes = require('bytes'),
React = require('react'),
Field = require('../Field');
Expand Down Expand Up @@ -63,7 +63,7 @@ module.exports = Field.create({

removeItem: function (i) {
var thumbs = this.state.items;
var thumb = thumbs[i];
var thumb = thumbs[i];

if (thumb.props.isQueued) {
thumbs[i] = null;
Expand Down Expand Up @@ -164,11 +164,11 @@ module.exports = Field.create({
});
if (remove.length) value = 'remove:' + remove.join(',');

return <input ref='action' className='field-action' type='hidden' value={value} name={this.props.paths.action} /> ;
return <input ref='action' className='field-action' type='hidden' value={value} name={this.props.paths.action} />;
},

renderUploadsField: function () {
return <input ref='uploads' className='field-uploads' type='hidden' name={this.props.paths.uploads} /> ;
return <input ref='uploads' className='field-uploads' type='hidden' name={this.props.paths.uploads} />;
},

renderUI: function () {
Expand Down
12 changes: 6 additions & 6 deletions fields/types/localfiles/LocalFilesType.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var fs = require('fs-extra'),

function localfiles(list, path, options) {
prepost.mixin(this)
.register("pre:move", "post:move");
.register('pre:move', 'post:move');
this._underscoreMethods = ['format', 'uploadFiles'];
this._fixedSize = 'full';

Expand All @@ -48,11 +48,11 @@ function localfiles(list, path, options) {

// Allow hook into before and after
if (options.pre && options.pre.move) {
this.pre("move", options.pre.move);
this.pre('move', options.pre.move);
}

if (options.post && options.post.move) {
this.post("move", options.post.move);
this.post('move', options.post.move);
}

}
Expand Down Expand Up @@ -86,7 +86,7 @@ localfiles.prototype.addToSchema = function() {
exists: this._path.append('.exists'),
upload: this._path.append('_upload'),
action: this._path.append('_action'),
order: this._path.append('_order'),
order: this._path.append('_order')
};

var schemaPaths = new mongoose.Schema({
Expand Down Expand Up @@ -315,15 +315,15 @@ localfiles.prototype.uploadFiles = function(item, files, update, callback) {

};

field.hooks("pre:move", function(fn, next) {
field.hooks('pre:move', function(fn, next) {
fn(item, file, next);
}, function(err) {
if (err) return processedFile(err);

doMove(function(err, fileData) {
if (err) return processedFile(err);

field.hooks("post:move", function(fn, next) {
field.hooks('post:move', function(fn, next) {
fn(item, file, fileData, next);
}, function(err) {
return processedFile(err, fileData);
Expand Down
2 changes: 1 addition & 1 deletion fields/types/location/LocationField.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ module.exports = Field.create({
geoChanged: function(i, event) {
var value = this.props.value;
if (!value.geo) {
value.geo = ['',''];
value.geo = ['', ''];
}
value.geo[i] = event.target.value;
this.props.onChange({
Expand Down
12 changes: 6 additions & 6 deletions fields/types/location/LocationType.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,25 +435,25 @@ location.prototype.googleLookup = function(item, region, update, callback) {
var location = {};

_.each(result.address_components, function(val){
if ( _.indexOf(val.types,'street_number') >= 0 ) {
if ( _.indexOf(val.types, 'street_number') >= 0 ) {
location.street1 = location.street1 || [];
location.street1.push(val.long_name);
}
if ( _.indexOf(val.types,'route') >= 0 ) {
if ( _.indexOf(val.types, 'route') >= 0 ) {
location.street1 = location.street1 || [];
location.street1.push(val.short_name);
}
// in some cases, you get suburb, city as locality - so only use the first
if ( _.indexOf(val.types,'locality') >= 0 && !location.suburb) {
if ( _.indexOf(val.types, 'locality') >= 0 && !location.suburb) {
location.suburb = val.long_name;
}
if ( _.indexOf(val.types,'administrative_area_level_1') >= 0 ) {
if ( _.indexOf(val.types, 'administrative_area_level_1') >= 0 ) {
location.state = val.short_name;
}
if ( _.indexOf(val.types,'country') >= 0 ) {
if ( _.indexOf(val.types, 'country') >= 0 ) {
location.country = val.long_name;
}
if ( _.indexOf(val.types,'postal_code') >= 0 ) {
if ( _.indexOf(val.types, 'postal_code') >= 0 ) {
location.postcode = val.short_name;
}
});
Expand Down
6 changes: 3 additions & 3 deletions fields/types/markdown/MarkdownField.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var toggleHeading = function(e, level) {
}

// Set the cursor
e.setSelection(cursor,cursor + chunk.length);
e.setSelection(cursor, cursor + chunk.length);
};

var renderMarkdown = function(component) {
Expand Down Expand Up @@ -120,8 +120,8 @@ module.exports = Field.create({
};

return (
<div className="md-editor">
<textarea name={this.props.paths.md} style={styles} defaultValue={this.props.value.md} ref="markdownTextarea" className="form-control markdown code"></textarea>
<div className='md-editor'>
<textarea name={this.props.paths.md} style={styles} defaultValue={this.props.value.md} ref='markdownTextarea' className='form-control markdown code'></textarea>
</div>
);
}
Expand Down
8 changes: 4 additions & 4 deletions fields/types/money/test/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ exports.testFieldType = function(List) {

it('should properly format', function () {
testItem.money = 1234;
demand(testItem._.money.format()).be("$1,234.00");
demand(testItem._.money.format()).be('$1,234.00');
testItem.money = -244;
demand(testItem._.money.format()).be("-$244.00");
demand(testItem._.money.format()).be('-$244.00');
});

it('should ignore formatting if the format option is false', function () {
testItem.money = 1234;
demand(testItem._.money.format()).be("$1,234.00");
demand(testItem._.money.format()).be('$1,234.00');
testItem.money = -244;
demand(testItem._.money.format()).be("-$244.00");
demand(testItem._.money.format()).be('-$244.00');
});
};
2 changes: 1 addition & 1 deletion fields/types/numberarray/NumberArrayType.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ numberarray.prototype.validateInput = function(data, required, item) {
return false;
}
if (Array.isArray(value) && !value.length) {
return false
return false;
}
}

Expand Down
16 changes: 8 additions & 8 deletions fields/types/password/PasswordField.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = Field.create({
},

renderValue: function() {
return <div className="field-value">{this.props.value ? "password set" : "password not set"}</div>;
return <div className='field-value'>{this.props.value ? 'password set' : 'password not set'}</div>;
},

renderField: function() {
Expand All @@ -52,21 +52,21 @@ module.exports = Field.create({

renderFields: function() {
return (
<div className="form-row">
<div className="col-sm-6">
<input type="password" name={this.props.path} placeholder='New password' ref="password" value={this.state.password} onChange={this.valueChanged.bind(this, 'password')} autoComplete="off" className="form-control" />
<div className='form-row'>
<div className='col-sm-6'>
<input type='password' name={this.props.path} placeholder='New password' ref='password' value={this.state.password} onChange={this.valueChanged.bind(this, 'password')} autoComplete='off' className='form-control' />
</div>
<div className="col-sm-6">
<input type="password" name={this.props.paths.confirm} placeholder='Confirm new password' ref="confirm" value={this.state.confirm} onChange={this.valueChanged.bind(this, 'confirm')} autoComplete="off" className="form-control" />
<div className='col-sm-6'>
<input type='password' name={this.props.paths.confirm} placeholder='Confirm new password' ref='confirm' value={this.state.confirm} onChange={this.valueChanged.bind(this, 'confirm')} autoComplete='off' className='form-control' />
</div>
</div>
);
},

renderChangeButton: function() {
var label = this.state.passwordIsSet ? "Change Password" : "Set Password";
var label = this.state.passwordIsSet ? 'Change Password' : 'Set Password';
return (
<button type="button" className="btn btn-default" onClick={this.showChangeUI}>{label}</button>
<button type='button' className='btn btn-default' onClick={this.showChangeUI}>{label}</button>
);
}

Expand Down
6 changes: 4 additions & 2 deletions fields/types/password/PasswordType.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@ password.prototype.addToSchema = function() {
var item = this;

bcrypt.genSalt(field.workFactor, function(err, salt) {
if (err)
if (err) {
return next(err);
}

bcrypt.hash(item.get(field.path), salt, function () {}, function(err, hash) {
if (err)
if (err) {
return next(err);
}

// override the cleartext password with the hashed one
item.set(field.path, hash);
Expand Down
2 changes: 1 addition & 1 deletion fields/types/relationship/RelationshipType.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ relationship.prototype.addFilters = function(query, item) {
}
query.where(path);
_.each(filters, function(value, method) {
if ('string' === typeof value && value.substr(0,1) === ':') {
if ('string' === typeof value && value.substr(0, 1) === ':') {
if (!item) {
return;
}
Expand Down

0 comments on commit c4f820e

Please sign in to comment.