Skip to content
This repository has been archived by the owner on May 24, 2019. It is now read-only.

Commit

Permalink
Merge pull request #182 from mozilla-services/181
Browse files Browse the repository at this point in the history
Use eslint for js validation #181
  • Loading branch information
jaredlockhart committed Nov 18, 2015
2 parents 67a6cc9 + f7b31bb commit aaa0239
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 25 deletions.
33 changes: 33 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"rules": {
"indent": [
2,
2
],
"quotes": [
2,
"double"
],
"linebreak-style": [
2,
"unix"
],
"semi": [
2,
"always"
]
},
"env": {
"es6": true,
"node": true,
"browser": true
},
"extends": "eslint:recommended",
"ecmaFeatures": {
"jsx": true,
"experimentalObjectRestSpread": true
},
"plugins": [
"react"
]
}
2 changes: 1 addition & 1 deletion leaderboard/static/js/cachedfetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
this.keys[key] = this.keys[key].then(function (data) {
return preprocessor(data);
});
};
}
}

return this.keys[key];
Expand Down
8 changes: 5 additions & 3 deletions leaderboard/static/js/leaderboard.react.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/*global React ReactDOM*/

var dispatcher = require("./dispatcher.js");
var cachedFetch = require("./cachedfetch.js");
var getUrlParameters = require('./parseurl.js').getUrlParameters;
var getUrlParameters = require("./parseurl.js").getUrlParameters;
var getLeadersKey = require("./leaderskey.js");

var LeaderMap = require("./leadermap.react.js").LeaderMap;
Expand Down Expand Up @@ -64,7 +66,7 @@ var Leaderboard = React.createClass({
for (var paramName in selection) {
var paramValue = selection[paramName];
if ((paramValue != null) && ((("" + paramValue).length) > 0)) {
newLocationParams.push(paramName + '=' + paramValue);
newLocationParams.push(paramName + "=" + paramValue);
}
}

Expand Down Expand Up @@ -145,4 +147,4 @@ module.exports = {
document.getElementById("leaderboard-container")
);
}
}
};
12 changes: 7 additions & 5 deletions leaderboard/static/js/leadermap.react.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/*global React L*/

var dispatcher = require("./dispatcher.js");
var cachedFetch = require("./cachedfetch.js");
var promisescript = require('promisescript');
var promisescript = require("promisescript");

// Style constants
var countryStyleEmpty = {
Expand Down Expand Up @@ -79,26 +81,26 @@ var LeaderMap = React.createClass({

layer.setStyle(countryStyleFilled);

layer.on("mouseover", (e) => {
layer.on("mouseover", () => {
layer.setStyle(countryStyleHover);
});

layer.on("mouseout", (e) => {
layer.on("mouseout", () => {
if (countryIso2 === this.props.selection.iso2) {
layer.setStyle(countryStyleSelected);
} else {
layer.setStyle(countryStyleFilled);
}
});

layer.on("click", (e) => {
layer.on("click", () => {
this.map.closePopup(this.popup);

dispatcher.fire("updateSelection", {
iso2: countryIso2
});
});
}
};

L.geoJson(
countriesGeo, {
Expand Down
8 changes: 5 additions & 3 deletions leaderboard/static/js/leaderprofile.react.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/*global React*/

var cachedFetch = require("./cachedfetch.js");
var dispatcher = require("./dispatcher.js");

Expand All @@ -20,7 +22,7 @@ var LeaderCountryRow = React.createClass({
<td><a href="" onClick={this.handleClick}>{countryName}</a></td>
<td>{this.props.rank.observations}</td>
</tr>
)
);
}
});

Expand Down Expand Up @@ -60,12 +62,12 @@ var LeaderProfile = React.createClass({
selection={this.props.selection}
rank={rank}
/>
)
);
})}
</tbody>
</table>
</div>
)
);
}
});

Expand Down
2 changes: 1 addition & 1 deletion leaderboard/static/js/leaderskey.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = function (selection) {
return "countryLeaders:" + selection.iso2 + ":" + selection.offset;
}
};
24 changes: 13 additions & 11 deletions leaderboard/static/js/leadertable.react.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/*global React*/

var dispatcher = require("./dispatcher.js");
var cachedFetch = require("./cachedfetch.js");
var getUrlParameters = require("./parseurl.js").getUrlParameters;
Expand All @@ -20,14 +22,14 @@ var LeadersButton = React.createClass({
return (
<button onClick={this.handleClick} className={classes}>{this.props.name}</button>
);
},
}
});

var LeadersHeader = React.createClass({
getInitialState: function () {
return {
countries: [],
}
countries: []
};
},

componentDidMount: function () {
Expand All @@ -54,13 +56,13 @@ var LeadersHeader = React.createClass({
<option key={countryIso2} value={countryIso2}>
{countries[countryIso2].name}
</option>
)
);
})}
</select>
</div>
</div>
);
},
}
});

var LeadersFooter = React.createClass({
Expand All @@ -86,7 +88,7 @@ var LeadersFooter = React.createClass({
</div>
</div>
);
},
}
});

var LeaderTableRow = React.createClass({
Expand All @@ -107,7 +109,7 @@ var LeaderTableRow = React.createClass({
<td><a href="" onClick={this.handleClick}>{this.props.leader.name}</a></td>
<td>{this.props.leader.observations}</td>
</tr>
)
);
}
});

Expand All @@ -130,12 +132,12 @@ var LeaderTableRows = React.createClass({
selection={this.props.selection}
leader={leader}
/>
)
);
})}
</tbody>
</table>
);
},
}
});

var LeaderTable = React.createClass({
Expand Down Expand Up @@ -179,8 +181,8 @@ var LeaderTable = React.createClass({
},

render: function() {
var start = 0,
stop = 0;
var start = 0;
var stop = 0;

if (this.state.leaders.length > 0) {
start = this.state.leaders[0].rank;
Expand Down
2 changes: 1 addition & 1 deletion leaderboard/static/js/parseurl.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ function getUrlParameters(url) {
module.exports = {
parseUrl: parseUrl,
getUrlParameters: getUrlParameters
}
};

0 comments on commit aaa0239

Please sign in to comment.