Skip to content

Commit

Permalink
fix some linter errors (freeCodeCamp#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
jspaine authored and kenjiO committed May 18, 2017
1 parent a13bb7b commit e7a8518
Show file tree
Hide file tree
Showing 32 changed files with 105 additions and 115 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"_": true,
"console": true,
"expect": true,
"google": true,
"initDb": true,
"module": true,
"process": true,
Expand Down
2 changes: 1 addition & 1 deletion client/components/form/FieldGroup.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import {shallow, mount} from 'enzyme'
import {shallow} from 'enzyme'
import {
Checkbox,
ControlLabel,
Expand Down
1 change: 0 additions & 1 deletion client/modules/driver/components/DriverAssignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {loadSettings} from '../../settings/reducer'
import {loadVolunteers} from '../../volunteer/reducer'

import {Page, PageBody} from '../../../components/page'
import {Box, BoxBody, BoxHeader} from '../../../components/box'
import SelectCustomersTable from './driver-assignment/SelectCustomersTable'
import AssignDriverForm from './driver-assignment/AssignDriverForm'
import SelectCustomersMap from './driver-assignment/SelectCustomersMap'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ const SelectCustomersTable = ({
filter,
handleFilterChange,
loading,
error,
style
error
}) =>
<Box
className="assignmentBox"
Expand Down
24 changes: 13 additions & 11 deletions client/modules/food/components/Inventory.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ import React from 'react'
import FoodCategories from './inventory/FoodCategories'
import FoodItems from './inventory/FoodItems'

export default ({ store }) => (
<section className="content">
<div className="row">
<div className="col-xs-12 col-md-3 col-lg-2">
<FoodCategories />
</div>
<div className="col-xs-12 col-md-9 col-lg-10">
<FoodItems />
</div>
</div>
</section>
const Inventory = () => (
<section className="content">
<div className="row">
<div className="col-xs-12 col-md-3 col-lg-2">
<FoodCategories />
</div>
<div className="col-xs-12 col-md-9 col-lg-10">
<FoodItems />
</div>
</div>
</section>
)

export default Inventory
6 changes: 0 additions & 6 deletions client/modules/food/components/Packing.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,6 @@ function getPackedCustomersAndItems(scheduledCustomers, scheduledItems) {
return {customers, items}
}

// get a list of ids of checked customers
function getCustomerIds(customers) {
return customers.filter(customer => customer.isChecked)
.map(customer => customer.id)
}

// get customers list after toggling selected on matching id
function selectCustomer(customers, id) {
return customers.map(customer => {
Expand Down
4 changes: 2 additions & 2 deletions client/modules/food/components/inventory/Category.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Category extends React.Component {
this.setState({ showEdit: true })
}

onClickSubmitEdit = e => {
onClickSubmitEdit = () => {
this.setState({ showEdit: false })
this.props.onItemEdit(this.props.id, this.state.editedName)
}
Expand Down Expand Up @@ -53,7 +53,7 @@ class Category extends React.Component {
)
}
}

}

export default Category
10 changes: 5 additions & 5 deletions client/modules/food/components/inventory/FoodItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ class FoodItems extends React.Component {
/**
* Used by react-bootstrap-table to get the food item edit buttons
*/
getEditButton = (cell, row, formatExtraData, rowIdx) => (
getEditButton = (cell, row) => (
<button onClick={() => { this.openModal(row._id) }} className="btn btn-primary btn-flat btn-xs"><i className="fa fa-pencil"></i>Edit</button>
)

/**
* Used by react-bootstrap-table to get the food item delete buttons
*/
getDeleteButton = (cell, row, formatExtraData, rowIdx) => (
getDeleteButton = (cell, row) => (
<button
onClick={() => { this.props.deleteFoodItem(row.categoryId, row._id) }}
className="btn btn-danger btn-flat btn-xs">
Expand Down Expand Up @@ -142,9 +142,9 @@ class FoodItems extends React.Component {
} else {
// The user entered an existing food name and autosuggest provided the object for that food
this.setState({ modalInputFields: { ...this.state.modalInputFields,
name: value ? value.name : "",
categoryId: value ? value.categoryId : ""
} }, this.validate)
name: value ? value.name : "",
categoryId: value ? value.categoryId : ""
} }, this.validate)
}
},
foodQuantity: e =>
Expand Down
14 changes: 7 additions & 7 deletions client/modules/food/components/inventory/NewCategory.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ class NewCategory extends React.Component {
constructor(props) {
super(props)
this.state = {
inputFieldValue: "",
categoryExists: false,
validInput: false
inputFieldValue: "",
categoryExists: false,
validInput: false
}
}

Expand All @@ -20,10 +20,10 @@ class NewCategory extends React.Component {
}

validate = () => {
const trimmedInput = this.state.inputFieldValue.trim()
const categoryExists = this.props.doesCategoryExist(trimmedInput)
const validInput = (trimmedInput !== "") && !categoryExists
this.setState({validInput, categoryExists})
const trimmedInput = this.state.inputFieldValue.trim()
const categoryExists = this.props.doesCategoryExist(trimmedInput)
const validInput = (trimmedInput !== "") && !categoryExists
this.setState({validInput, categoryExists})
}

render = () => (
Expand Down
3 changes: 1 addition & 2 deletions client/modules/media/components/Media.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ const mapStateToProps = state => ({

const mapDispatchToProps = dispatch => ({
loadMedia: () => dispatch(loadMedia()),
saveMedia: file => dispatch(saveMedia(file)),
push: (route, params, options) => dispatch(stateGo(route, params, options))
saveMedia: file => dispatch(saveMedia(file))
})

class Media extends Component {
Expand Down
2 changes: 1 addition & 1 deletion client/modules/questionnaire/Questionnaire.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {connect} from 'react-redux'
import {compose} from 'recompose'
import {DragDropContext} from 'react-dnd'
import HTML5Backend from 'react-dnd-html5-backend'
import {get, head, sortBy} from 'lodash'
import {sortBy} from 'lodash'
import {Button, Col} from 'react-bootstrap'

import selectors from '../../store/selectors'
Expand Down
1 change: 0 additions & 1 deletion client/modules/questionnaire/components/FieldView.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const FieldView = ({
connectDropTarget,
isDragging,
isOver,
idx,
field,
onSelect
}) => connectDragSource(
Expand Down
1 change: 0 additions & 1 deletion client/modules/questionnaire/components/SectionView.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const SectionView = ({
connectDropTarget,
isDragging,
isOver,
idx,
section,
onEdit,
onDelete
Expand Down
22 changes: 16 additions & 6 deletions client/modules/settings/components/SettingsForm.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import React from 'react'
import PropTypes from 'prop-types'
import {compose, setPropTypes} from 'recompose'
import {reduxForm} from 'redux-form'
import {Link} from 'react-router-dom'
import {Button, Clearfix, Col, Row} from 'react-bootstrap'

import {RFFieldGroup} from '../../../components/form'

const SettingsForm = ({onSubmit, handleSubmit}) =>
const enhance = compose(
setPropTypes({
onSubmit: PropTypes.func.isRequired,
initialValues: PropTypes.object
}),
reduxForm({
form: 'settingsForm',
validate,
warn
})
)

const SettingsForm = ({handleSubmit}) =>
<div>
<Row>
<Col lg={3}>
Expand Down Expand Up @@ -112,11 +126,7 @@ const SettingsForm = ({onSubmit, handleSubmit}) =>
</div>
</div>

export default reduxForm({
form: 'settingsForm',
validate,
warn
})(SettingsForm)
export default enhance(SettingsForm)

function validate(values) {
let errors = {}
Expand Down
3 changes: 1 addition & 2 deletions client/modules/volunteer/VolunteerRouter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react'
import {Switch, Route} from 'react-router-dom'
import {connect} from 'react-redux'
import {Route} from 'react-router-dom'

import VolunteerList from './components/VolunteerList'
import VolunteerView from './components/VolunteerView'
Expand Down
7 changes: 2 additions & 5 deletions client/modules/volunteer/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,8 @@ export const createSelectors = path => {
const getAll = createSelector(
state => get(state, path).ids,
getEntities,
(volunteers, entities) => {
console.log('volunteers, entities', volunteers, entities)

return denormalize({volunteers}, {volunteers: arrayOfVolunteers}, entities).volunteers
}
(volunteers, entities) =>
denormalize({volunteers}, {volunteers: arrayOfVolunteers}, entities).volunteers
)
return {
getAll,
Expand Down
12 changes: 6 additions & 6 deletions client/store/middleware/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ export default store => next => action => {
error => {
let errorMessage = ""
if (error.error && error.error.errors) {
errorMessage = Object.entries(error.error.errors).reduce((acc, val) => {
return acc + " " + val[1].message + "\n"
}, "")
errorMessage = Object.entries(error.error.errors).reduce((acc, val) => {
return acc + " " + val[1].message + "\n"
}, "")
} else if (error.message) {
errorMessage = error.message
} else if (error.errmsg) {
Expand All @@ -98,9 +98,9 @@ export default store => next => action => {
}

return next(actionWith({
type: failureType,
error: errorMessage
}))}
type: failureType,
error: errorMessage
}))}
)
}

Expand Down
10 changes: 5 additions & 5 deletions server/config/mailer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ if (config.sendpulse) {
"text" : striptags(bodyHTML, [], '\n'),
"subject" : subject,
"from" : {
"name" : sp_config.name,
"email" : sp_config.email
"name" : sp_config.name,
"email" : sp_config.email
},
"to" : [ {
"name" : recepientName,
"email" : recepientEmail
"to" : [ {
"name" : recepientName,
"email" : recepientEmail
} ]
}

Expand Down
2 changes: 2 additions & 0 deletions server/config/passport.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ export default function() {
if (config.oauth) {
googleStrategy()
} else if (process.env.NODE_ENV !== 'test') {
/* eslint-disable no-console */
console.log()
console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
console.log('!!! Google oauth API keys not set. Google login is disabled !!!')
console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
console.log()
/* eslint-enable no-console */
}
}
1 change: 0 additions & 1 deletion server/controllers/customer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import mailer from '../lib/mailer'
import Customer from '../models/customer'
import Volunteer from '../models/volunteer'
import User from '../models/user'
import mongoose from 'mongoose'

export default {
/**
Expand Down
12 changes: 5 additions & 7 deletions server/controllers/donation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ import Settings from '../models/settings'
/**
* Module dependencies
*/
var mongoose = require('mongoose'),
var //mongoose = require('mongoose'),
errorHandler = require('./errors'),
// Donation = mongoose.model('Donation'),
// Donor = mongoose.model('Donor'),
// Settings = mongoose.model('Settings'),
async = require('async'),
mailHelper = require('sendgrid').mail,
config = require('../config/index'),
fs = require('fs')
config = require('../config/index')

/**
* Create a donation
Expand Down Expand Up @@ -46,7 +44,7 @@ exports.sendEmail = function(req, res, next) {
if (err) return next(err)

Settings.findOne({}, function(err, settings) {
if (err)
if (err) // eslint-disable-next-line no-console
console.log(err)

donation.tconfig = settings
Expand All @@ -65,8 +63,8 @@ exports.sendEmail = function(req, res, next) {

sg.API(request, function(error, response) {
if (error) {
console.log(error)
console.log(response.body.errors)
// eslint-disable-next-line no-console
console.log(error, response.body.errors)
}
})
})
Expand Down
14 changes: 7 additions & 7 deletions server/controllers/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ exports.getErrorMessage = function(err) {

if (err.code) {
switch (err.code) {
case 11000:
case 11001:
message = getUniqueErrorMessage(err)
break
default:
message = 'Something went wrong'
case 11000:
case 11001:
message = getUniqueErrorMessage(err)
break
default:
message = 'Something went wrong'
}
} else {
for (var errName in err.errors) {
Expand All @@ -39,4 +39,4 @@ exports.getErrorMessage = function(err) {
}

return message
}
}
Loading

0 comments on commit e7a8518

Please sign in to comment.