Skip to content
This repository has been archived by the owner on Oct 14, 2020. It is now read-only.

Commit

Permalink
switched from jshint to eslint, fixed linting errors. Adresses #312
Browse files Browse the repository at this point in the history
  • Loading branch information
coder13 committed May 13, 2016
1 parent 9abbb16 commit e27a821
Show file tree
Hide file tree
Showing 14 changed files with 144 additions and 57 deletions.
3 changes: 1 addition & 2 deletions .jshintignore → .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
tests/node_modules
node_modules
tests
packages
client/components
both/lib
Expand Down
66 changes: 66 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
parserOptions: {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"env": {
"node": true,
"es6": true
},
"globals": {},
"rules": {
"semi": 2,
"no-unused-expressions": 2,
"no-loop-func": 2,
"curly": [2, "all"],
"no-eval": 0,
"no-undef": 0,
"indent": [2, 2, {
"SwitchCase": 1
}
],
"no-trailing-spaces": 2,
"operator-linebreak": [2, "after"],
"wrap-iife": 2,
"comma-style": [2, "last"],
"keyword-spacing": [2, {
"overrides": {
"if": {
"after": false
},
"for": {
"after": false
},
"while": {
"after": false
},
"switch": {
"after": false
},
"catch": {
"after": false
}
}
}
],
"eol-last": 2,
"linebreak-style": [2, "unix"],
"no-with": 2,
"brace-style": 2,
"space-before-function-paren": [2, "never"],
"key-spacing": [2, {
"beforeColon": false,
"afterColon": true
}
],
"space-unary-ops": [2, {
"words": false,
"nonwords": false
}
]
},
"plugins": ["meteor"]
}
10 changes: 0 additions & 10 deletions .jshintrc

This file was deleted.

19 changes: 15 additions & 4 deletions both/collections/competition.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,12 @@ DEFAULT_STAFF_ROLES = {
dataEntry: true,
};

Competitions = new Mongo.Collection("competitions", { transform: function(doc) { return new Competition(doc); } });
Competitions = new Mongo.Collection("competitions", {
transform: function(doc) {
return new Competition(doc);
}
});

Schema.competition = new SimpleSchema({
competitionName: {
type: String,
Expand Down Expand Up @@ -307,7 +312,9 @@ Schema.competition = new SimpleSchema({
let obj = validationObject(this, ['calendarStartMinutes']);

let events = ScheduleEvents.find({competitionId: obj.id}).fetch();
if(_.any(events, function(event) { return event.startMinutes < obj.calendarStartMinutes; })) {
if(_.any(events, function(event) {
return event.startMinutes < obj.calendarStartMinutes;
})) {
return "earlierExistingEvents";
}
},
Expand All @@ -326,7 +333,9 @@ Schema.competition = new SimpleSchema({
}

let events = ScheduleEvents.find({competitionId: obj.id}).fetch();
if(_.any(events, function(event) { return event.endMinutes() > obj.calendarEndMinutes; })) {
if(_.any(events, function(event) {
return event.endMinutes() > obj.calendarEndMinutes;
})) {
return "laterExistingEvents";
}
},
Expand All @@ -352,7 +361,9 @@ Schema.competition = new SimpleSchema({
let obj = validationObject(this, ['numberOfDays']);

let events = ScheduleEvents.find({competitionId: obj.id}).fetch();
if(_.any(events, function(event) { return event.nthDay >= obj.numberOfDays; })) {
if(_.any(events, function(event) {
return event.nthDay >= obj.numberOfDays;
})) {
return "laterDayExistingEvents";
}
},
Expand Down
6 changes: 5 additions & 1 deletion both/collections/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ _.extend(Group.prototype, {
},
});

Groups = new Mongo.Collection("groups", { transform: function(doc) { return new Group(doc); } });
Groups = new Mongo.Collection("groups", {
transform: function(doc) {
return new Group(doc);
}
});

Schema.group = new SimpleSchema({
competitionId: {
Expand Down
38 changes: 21 additions & 17 deletions both/collections/round.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ _.extend(Round.prototype, {

resultSortOrder() {
switch(this.format().sortBy) {
case "best":
return {sortableBestValue: 1};
case "average":
return {sortableAverageValue: 1, sortableBestValue: 1};
default:
throw new Error(`Unknown format sortBy '${sortBy}'`);
case "best":
return {sortableBestValue: 1};
case "average":
return {sortableAverageValue: 1, sortableBestValue: 1};
default:
throw new Error(`Unknown format sortBy '${sortBy}'`);
}
},

Expand Down Expand Up @@ -109,16 +109,16 @@ _.extend(Round.prototype, {
if(previousResult) {
let tiedBest = wca.compareSolveTimes(result.solves[result.bestIndex], previousResult.solves[previousResult.bestIndex]) === 0;
switch(this.format().sortBy) {
case "best":
tied = tiedBest;
break;
case "average":
let tiedAverage = wca.compareSolveTimes(result.average, previousResult.average) === 0;
tied = tiedAverage && tiedBest;
break;
default:
// uh-oh, unrecognized roundFormat, give up
assert(false);
case "best":
tied = tiedBest;
break;
case "average":
let tiedAverage = wca.compareSolveTimes(result.average, previousResult.average) === 0;
tied = tiedAverage && tiedBest;
break;
default:
// uh-oh, unrecognized roundFormat, give up
assert(false);
}
}
if(!tied) {
Expand Down Expand Up @@ -284,7 +284,11 @@ _.extend(Round.prototype, {
},
});

Rounds = new Mongo.Collection("rounds", { transform: function(doc) { return new Round(doc); } });
Rounds = new Mongo.Collection("rounds", {
transform: function(doc) {
return new Round(doc);
}
});

Schema.round = new SimpleSchema({
competitionId: {
Expand Down
6 changes: 5 additions & 1 deletion both/collections/roundProgress.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ _.extend(RoundProgress.prototype, {
}
});

RoundProgresses = new Mongo.Collection("roundProgresses", { transform: function(doc) { return new RoundProgress(doc); } });
RoundProgresses = new Mongo.Collection("roundProgresses", {
transform: function(doc) {
return new RoundProgress(doc);
}
});

Schema.roundProgress = new SimpleSchema({
roundId: {
Expand Down
10 changes: 7 additions & 3 deletions both/collections/scheduleEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ _.extend(ScheduleEvent.prototype, {
}
});

ScheduleEvents = new Mongo.Collection("scheduleEvents", { transform: function(doc) { return new ScheduleEvent(doc); } });
ScheduleEvents = new Mongo.Collection("scheduleEvents", {
transform: function(doc) {
return new ScheduleEvent(doc);
}
});

Schema.scheduleEvent = new SimpleSchema({
competitionId: {
Expand Down Expand Up @@ -84,8 +88,8 @@ Schema.scheduleEvent = new SimpleSchema({

Schema.scheduleEvent.messages({
tooLateDay: "Event scheduled on day after competition ended.",
tooEarly: "Event scheduled before competition day starts.",
tooLate: "Event scheduled after competition day ends.",
tooEarly: "Event scheduled before competition day starts.",
tooLate: "Event scheduled after competition day ends.",
});

ScheduleEvents.attachSchema(Schema.scheduleEvent);
Expand Down
1 change: 1 addition & 0 deletions client/competition.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ Template.competition.helpers({
return $.fullCalendar.formatRange(moment(comp.startDate).utc(), moment(comp.endDate()).utc(), "LL");
},
});

4 changes: 3 additions & 1 deletion client/dataEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ Template.roundDataEntry.rendered = function() {
displayKey: function(result) {
return result.registration.uniqueName;
},
source: substringMatcher(function() { return results; }, 'registration.uniqueName'),
source: substringMatcher(function() {
return results;
}, 'registration.uniqueName'),
});
};

Expand Down
4 changes: 2 additions & 2 deletions client/editEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ Template.editEvents.events({
// While it looks weird to method chain collapse, I couldn't get it to work
// via passing hide:true. You can't just call collapse('hide') because when
// you manually call collapse() it defaults to toggling the element.
$('#editEventsList .collapse').collapse({toggle:false}).collapse('hide');
$('#editEventsList .collapse').collapse({toggle: false}).collapse('hide');
},
'click #expandAllEvents': function() {
$('#editEventsList .collapse').collapse({toggle:false}).collapse('show');
$('#editEventsList .collapse').collapse({toggle: false}).collapse('show');
},
});

Expand Down
4 changes: 3 additions & 1 deletion client/editSchedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ Template.editSchedule.helpers({
},
sortedRounds: function() {
let allRounds = Rounds.find({ competitionId: this.competitionId }).fetch();
return _.sortBy(allRounds, function(round) { return round.displayTitle(); });
return _.sortBy(allRounds, function(round) {
return round.displayTitle();
});
},
eventToEdit: function() {
return eventToEditReact.get();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"homepage": "https://live.cubing.net",
"scripts": {
"lint": "(jshint --exclude-path .jshintignore --config .jshintrc . && jscs .)",
"lint": "eslint .",
"test": "meteor test --once --driver-package dispatch:mocha-phantomjs",
"validate": "npm ls"
},
Expand Down
28 changes: 14 additions & 14 deletions server/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,15 +323,15 @@ Meteor.methods({
_.extend(result, statistics);
let id = Results.insert(
result, {
// meteor-collection2 is *killing* us here when we are inserting
// a bunch of stuff at once. Turning off all the validation it
// does for us gives a huge speed boost.
validate: false,
filter: false,
autoConvert: false,
removeEmptyStrings: false,
getAutoValues: false,
});
// meteor-collection2 is *killing* us here when we are inserting
// a bunch of stuff at once. Turning off all the validation it
// does for us gives a huge speed boost.
validate: false,
filter: false,
autoConvert: false,
removeEmptyStrings: false,
getAutoValues: false,
});
});

if(softCutoff) {
Expand Down Expand Up @@ -377,11 +377,11 @@ Meteor.methods({
let registration = registrationByWcaJsonId[jsonId];
let registrationId = Registrations.update(
registration._id, {
$set: {
registeredEvents: _.keys(registration.registeredEvents),
checkedIn: registration.checkedIn,
}
});
$set: {
registeredEvents: _.keys(registration.registeredEvents),
checkedIn: registration.checkedIn,
}
});
}
}

Expand Down

0 comments on commit e27a821

Please sign in to comment.