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

Commit e27a821

Browse files
committed
switched from jshint to eslint, fixed linting errors. Adresses #312
1 parent 9abbb16 commit e27a821

14 files changed

+144
-57
lines changed

.jshintignore .eslintignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
tests/node_modules
2-
node_modules
1+
tests
32
packages
43
client/components
54
both/lib

.eslintrc

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
parserOptions: {
3+
"ecmaVersion": 6,
4+
"sourceType": "module",
5+
"ecmaFeatures": {
6+
"jsx": true
7+
}
8+
},
9+
"env": {
10+
"node": true,
11+
"es6": true
12+
},
13+
"globals": {},
14+
"rules": {
15+
"semi": 2,
16+
"no-unused-expressions": 2,
17+
"no-loop-func": 2,
18+
"curly": [2, "all"],
19+
"no-eval": 0,
20+
"no-undef": 0,
21+
"indent": [2, 2, {
22+
"SwitchCase": 1
23+
}
24+
],
25+
"no-trailing-spaces": 2,
26+
"operator-linebreak": [2, "after"],
27+
"wrap-iife": 2,
28+
"comma-style": [2, "last"],
29+
"keyword-spacing": [2, {
30+
"overrides": {
31+
"if": {
32+
"after": false
33+
},
34+
"for": {
35+
"after": false
36+
},
37+
"while": {
38+
"after": false
39+
},
40+
"switch": {
41+
"after": false
42+
},
43+
"catch": {
44+
"after": false
45+
}
46+
}
47+
}
48+
],
49+
"eol-last": 2,
50+
"linebreak-style": [2, "unix"],
51+
"no-with": 2,
52+
"brace-style": 2,
53+
"space-before-function-paren": [2, "never"],
54+
"key-spacing": [2, {
55+
"beforeColon": false,
56+
"afterColon": true
57+
}
58+
],
59+
"space-unary-ops": [2, {
60+
"words": false,
61+
"nonwords": false
62+
}
63+
]
64+
},
65+
"plugins": ["meteor"]
66+
}

.jshintrc

-10
This file was deleted.

both/collections/competition.js

+15-4
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,12 @@ DEFAULT_STAFF_ROLES = {
277277
dataEntry: true,
278278
};
279279

280-
Competitions = new Mongo.Collection("competitions", { transform: function(doc) { return new Competition(doc); } });
280+
Competitions = new Mongo.Collection("competitions", {
281+
transform: function(doc) {
282+
return new Competition(doc);
283+
}
284+
});
285+
281286
Schema.competition = new SimpleSchema({
282287
competitionName: {
283288
type: String,
@@ -307,7 +312,9 @@ Schema.competition = new SimpleSchema({
307312
let obj = validationObject(this, ['calendarStartMinutes']);
308313

309314
let events = ScheduleEvents.find({competitionId: obj.id}).fetch();
310-
if(_.any(events, function(event) { return event.startMinutes < obj.calendarStartMinutes; })) {
315+
if(_.any(events, function(event) {
316+
return event.startMinutes < obj.calendarStartMinutes;
317+
})) {
311318
return "earlierExistingEvents";
312319
}
313320
},
@@ -326,7 +333,9 @@ Schema.competition = new SimpleSchema({
326333
}
327334

328335
let events = ScheduleEvents.find({competitionId: obj.id}).fetch();
329-
if(_.any(events, function(event) { return event.endMinutes() > obj.calendarEndMinutes; })) {
336+
if(_.any(events, function(event) {
337+
return event.endMinutes() > obj.calendarEndMinutes;
338+
})) {
330339
return "laterExistingEvents";
331340
}
332341
},
@@ -352,7 +361,9 @@ Schema.competition = new SimpleSchema({
352361
let obj = validationObject(this, ['numberOfDays']);
353362

354363
let events = ScheduleEvents.find({competitionId: obj.id}).fetch();
355-
if(_.any(events, function(event) { return event.nthDay >= obj.numberOfDays; })) {
364+
if(_.any(events, function(event) {
365+
return event.nthDay >= obj.numberOfDays;
366+
})) {
356367
return "laterDayExistingEvents";
357368
}
358369
},

both/collections/group.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ _.extend(Group.prototype, {
99
},
1010
});
1111

12-
Groups = new Mongo.Collection("groups", { transform: function(doc) { return new Group(doc); } });
12+
Groups = new Mongo.Collection("groups", {
13+
transform: function(doc) {
14+
return new Group(doc);
15+
}
16+
});
1317

1418
Schema.group = new SimpleSchema({
1519
competitionId: {

both/collections/round.js

+21-17
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ _.extend(Round.prototype, {
4141

4242
resultSortOrder() {
4343
switch(this.format().sortBy) {
44-
case "best":
45-
return {sortableBestValue: 1};
46-
case "average":
47-
return {sortableAverageValue: 1, sortableBestValue: 1};
48-
default:
49-
throw new Error(`Unknown format sortBy '${sortBy}'`);
44+
case "best":
45+
return {sortableBestValue: 1};
46+
case "average":
47+
return {sortableAverageValue: 1, sortableBestValue: 1};
48+
default:
49+
throw new Error(`Unknown format sortBy '${sortBy}'`);
5050
}
5151
},
5252

@@ -109,16 +109,16 @@ _.extend(Round.prototype, {
109109
if(previousResult) {
110110
let tiedBest = wca.compareSolveTimes(result.solves[result.bestIndex], previousResult.solves[previousResult.bestIndex]) === 0;
111111
switch(this.format().sortBy) {
112-
case "best":
113-
tied = tiedBest;
114-
break;
115-
case "average":
116-
let tiedAverage = wca.compareSolveTimes(result.average, previousResult.average) === 0;
117-
tied = tiedAverage && tiedBest;
118-
break;
119-
default:
120-
// uh-oh, unrecognized roundFormat, give up
121-
assert(false);
112+
case "best":
113+
tied = tiedBest;
114+
break;
115+
case "average":
116+
let tiedAverage = wca.compareSolveTimes(result.average, previousResult.average) === 0;
117+
tied = tiedAverage && tiedBest;
118+
break;
119+
default:
120+
// uh-oh, unrecognized roundFormat, give up
121+
assert(false);
122122
}
123123
}
124124
if(!tied) {
@@ -284,7 +284,11 @@ _.extend(Round.prototype, {
284284
},
285285
});
286286

287-
Rounds = new Mongo.Collection("rounds", { transform: function(doc) { return new Round(doc); } });
287+
Rounds = new Mongo.Collection("rounds", {
288+
transform: function(doc) {
289+
return new Round(doc);
290+
}
291+
});
288292

289293
Schema.round = new SimpleSchema({
290294
competitionId: {

both/collections/roundProgress.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ _.extend(RoundProgress.prototype, {
1515
}
1616
});
1717

18-
RoundProgresses = new Mongo.Collection("roundProgresses", { transform: function(doc) { return new RoundProgress(doc); } });
18+
RoundProgresses = new Mongo.Collection("roundProgresses", {
19+
transform: function(doc) {
20+
return new RoundProgress(doc);
21+
}
22+
});
1923

2024
Schema.roundProgress = new SimpleSchema({
2125
roundId: {

both/collections/scheduleEvent.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ _.extend(ScheduleEvent.prototype, {
1717
}
1818
});
1919

20-
ScheduleEvents = new Mongo.Collection("scheduleEvents", { transform: function(doc) { return new ScheduleEvent(doc); } });
20+
ScheduleEvents = new Mongo.Collection("scheduleEvents", {
21+
transform: function(doc) {
22+
return new ScheduleEvent(doc);
23+
}
24+
});
2125

2226
Schema.scheduleEvent = new SimpleSchema({
2327
competitionId: {
@@ -84,8 +88,8 @@ Schema.scheduleEvent = new SimpleSchema({
8488

8589
Schema.scheduleEvent.messages({
8690
tooLateDay: "Event scheduled on day after competition ended.",
87-
tooEarly: "Event scheduled before competition day starts.",
88-
tooLate: "Event scheduled after competition day ends.",
91+
tooEarly: "Event scheduled before competition day starts.",
92+
tooLate: "Event scheduled after competition day ends.",
8993
});
9094

9195
ScheduleEvents.attachSchema(Schema.scheduleEvent);

client/competition.js

+1
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ Template.competition.helpers({
1616
return $.fullCalendar.formatRange(moment(comp.startDate).utc(), moment(comp.endDate()).utc(), "LL");
1717
},
1818
});
19+

client/dataEntry.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ Template.roundDataEntry.rendered = function() {
114114
displayKey: function(result) {
115115
return result.registration.uniqueName;
116116
},
117-
source: substringMatcher(function() { return results; }, 'registration.uniqueName'),
117+
source: substringMatcher(function() {
118+
return results;
119+
}, 'registration.uniqueName'),
118120
});
119121
};
120122

client/editEvents.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ Template.editEvents.events({
5858
// While it looks weird to method chain collapse, I couldn't get it to work
5959
// via passing hide:true. You can't just call collapse('hide') because when
6060
// you manually call collapse() it defaults to toggling the element.
61-
$('#editEventsList .collapse').collapse({toggle:false}).collapse('hide');
61+
$('#editEventsList .collapse').collapse({toggle: false}).collapse('hide');
6262
},
6363
'click #expandAllEvents': function() {
64-
$('#editEventsList .collapse').collapse({toggle:false}).collapse('show');
64+
$('#editEventsList .collapse').collapse({toggle: false}).collapse('show');
6565
},
6666
});
6767

client/editSchedule.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ Template.editSchedule.helpers({
66
},
77
sortedRounds: function() {
88
let allRounds = Rounds.find({ competitionId: this.competitionId }).fetch();
9-
return _.sortBy(allRounds, function(round) { return round.displayTitle(); });
9+
return _.sortBy(allRounds, function(round) {
10+
return round.displayTitle();
11+
});
1012
},
1113
eventToEdit: function() {
1214
return eventToEditReact.get();

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
},
4040
"homepage": "https://live.cubing.net",
4141
"scripts": {
42-
"lint": "(jshint --exclude-path .jshintignore --config .jshintrc . && jscs .)",
42+
"lint": "eslint .",
4343
"test": "meteor test --once --driver-package dispatch:mocha-phantomjs",
4444
"validate": "npm ls"
4545
},

server/methods.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -323,15 +323,15 @@ Meteor.methods({
323323
_.extend(result, statistics);
324324
let id = Results.insert(
325325
result, {
326-
// meteor-collection2 is *killing* us here when we are inserting
327-
// a bunch of stuff at once. Turning off all the validation it
328-
// does for us gives a huge speed boost.
329-
validate: false,
330-
filter: false,
331-
autoConvert: false,
332-
removeEmptyStrings: false,
333-
getAutoValues: false,
334-
});
326+
// meteor-collection2 is *killing* us here when we are inserting
327+
// a bunch of stuff at once. Turning off all the validation it
328+
// does for us gives a huge speed boost.
329+
validate: false,
330+
filter: false,
331+
autoConvert: false,
332+
removeEmptyStrings: false,
333+
getAutoValues: false,
334+
});
335335
});
336336

337337
if(softCutoff) {
@@ -377,11 +377,11 @@ Meteor.methods({
377377
let registration = registrationByWcaJsonId[jsonId];
378378
let registrationId = Registrations.update(
379379
registration._id, {
380-
$set: {
381-
registeredEvents: _.keys(registration.registeredEvents),
382-
checkedIn: registration.checkedIn,
383-
}
384-
});
380+
$set: {
381+
registeredEvents: _.keys(registration.registeredEvents),
382+
checkedIn: registration.checkedIn,
383+
}
384+
});
385385
}
386386
}
387387

0 commit comments

Comments
 (0)