Skip to content

Commit

Permalink
Use eslint to standardize code style
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcw committed Aug 25, 2015
1 parent 8326600 commit f71e9e8
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 31 deletions.
29 changes: 29 additions & 0 deletions .eslintrc
@@ -0,0 +1,29 @@
{
"rules": {
"indent": [
2,
4
],
"quotes": [
2,
"single"
],
"linebreak-style": [
2,
"unix"
],
"semi": [
2,
"always"
]
},
"env": {
"browser": true
},
"globals": {
"process": true,
"module": true,
"require": true
},
"extends": "eslint:recommended"
}
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -7,13 +7,14 @@
"test": "test"
},
"scripts": {
"test": "tape test/*.js",
"test": "eslint togeojson.js && tape test/*.js",
"cov": "istanbul cover test/index.js && coveralls < ./coverage/lcov.info",
"browser": "browserify -t brfs test/index.js > test/bundle.js"
},
"devDependencies": {
"brfs": "~0.2.1",
"coveralls": "~2.10.0",
"eslint": "^1.2.1",
"glob": "^4.2.1",
"istanbul": "~0.2.11",
"tape": "~3.0.3"
Expand Down
6 changes: 0 additions & 6 deletions test/data/gxmultitrack.kml.geojson
Expand Up @@ -13,8 +13,6 @@
},
"properties": {
"name": "\n12/04/2014 11:24 AM (départ)\n ",
"styleUrl": "#start",
"styleHash": "-13d91d2a",
"description": "\n\n "
}
},
Expand Down Expand Up @@ -167,8 +165,6 @@
},
"properties": {
"name": "\n12/04/2014 11:24 AM\n ",
"styleUrl": "#track",
"styleHash": "-4182fe62",
"description": "\n\n ",
"type": "\ncourse à pied\n ",
"coordTimes": [
Expand Down Expand Up @@ -218,8 +214,6 @@
},
"properties": {
"name": "\n12/04/2014 11:24 AM (fin)\n ",
"styleUrl": "#end",
"styleHash": "10d07b61",
"description": "\nCréé par Google Mes parcours sur Android\n\nNom : 12/04/2014 11:24 AM\nType d'activité : course à pied\nDescription : -\nDistance totale : 10,43 km (6,5 mi)\nDurée totale : 1:13:38\nDurée du déplacement : 1:08:20\nVitesse moyenne : 8,49 km/h (5,3 mi/h)\nVitesse moyenne de déplacement : 9,16 km/h (5,7 mi/h)\nVitesse max. : 12,84 km/h (8,0 mi/h)\nVitesse moyenne : 7:04 min/km (11:22 min/mi)\nAllure moyenne : 6:33 min/km (10:33 min/mi)\nVitesse maximale : 4:40 min/km (7:31 min/mi)\nÉlévation max. : 1020 m (3347 pi)\nÉlévation min. : 678 m (2223 pi)\nDénivelé : 1095 m (3593 pi)\nInclinaison max. : 21 %\nInclinaison min. : -24 %\nDate d'enregistrement : 12/04/2014 11:24 AM\n\n "
}
}
Expand Down
10 changes: 2 additions & 8 deletions test/data/multitrack.kml.geojson
Expand Up @@ -12,9 +12,7 @@
]
},
"properties": {
"name": "8/8/2013 17:20 (Start)",
"styleUrl": "#start",
"styleHash": "4c07829a"
"name": "8/8/2013 17:20 (Start)"
}
},
{
Expand Down Expand Up @@ -106,8 +104,6 @@
},
"properties": {
"name": "8/8/2013 17:20",
"styleUrl": "#track",
"styleHash": "-1fdecab8",
"type": "walking",
"coordTimes": [
"2013-08-08T15:24:47.000Z",
Expand Down Expand Up @@ -141,9 +137,7 @@
]
},
"properties": {
"name": "8/8/2013 17:20 (End)",
"styleUrl": "#end",
"styleHash": "15ca312f"
"name": "8/8/2013 17:20 (End)"
}
}
]
Expand Down
4 changes: 0 additions & 4 deletions test/data/simpledata.kml.geojson
Expand Up @@ -12,8 +12,6 @@
},
"properties": {
"name": "Easy trail",
"styleUrl": "#trailhead-balloon-template",
"styleHash": "ca0b0b",
"TrailHeadName": "Pi in the sky",
"TrailLength": "3.14159",
"ElevationGain": "10"
Expand All @@ -30,8 +28,6 @@
},
"properties": {
"name": "Difficult trail",
"styleUrl": "#trailhead-balloon-template",
"styleHash": "ca0b0b",
"TrailHeadName": "Mount Everest",
"TrailLength": "347.45",
"ElevationGain": "10000"
Expand Down
6 changes: 1 addition & 5 deletions test/data/style.kml.geojson
Expand Up @@ -13,8 +13,6 @@
},
"properties": {
"name": "Google Earth - New Polygon",
"styleUrl": "#a",
"styleHash": "-1d694122",
"description": "Here is some descriptive text"
}
},
Expand All @@ -29,9 +27,7 @@
]
},
"properties": {
"name": "Google Earth - New Path",
"styleUrl": "#b",
"styleHash": "-5b6ad921"
"name": "Google Earth - New Path"
}
}
]
Expand Down
14 changes: 7 additions & 7 deletions togeojson.js
Expand Up @@ -55,7 +55,7 @@ var toGeoJSON = (function() {
if (ele) {
e = parseFloat(nodeVal(ele));
if (!isNaN(e)) {
ll.push(e);
ll.push(e);
}
}
return {
Expand Down Expand Up @@ -108,8 +108,8 @@ var toGeoJSON = (function() {
}
function kmlColor(v) {
var color, opacity;
v = v || "";
if (v.substr(0, 1) === "#") { v = v.substr(1); }
v = v || '';
if (v.substr(0, 1) === '#') { v = v.substr(1); }
if (v.length === 6 || v.length === 3) { color = v; }
if (v.length === 8) {
opacity = parseInt(v.substr(0, 2), 16) / 255;
Expand All @@ -123,7 +123,7 @@ var toGeoJSON = (function() {
if (elems.length === 0) elems = get(root, 'gx:coord');
for (var i = 0; i < elems.length; i++) coords.push(gxCoord(nodeVal(elems[i])));
var timeElems = get(root, 'when');
for (var i = 0; i < timeElems.length; i++) times.push(nodeVal(timeElems[i]));
for (var j = 0; j < timeElems.length; j++) times.push(nodeVal(timeElems[j]));
return {
coords: coords,
times: times
Expand Down Expand Up @@ -188,7 +188,7 @@ var toGeoJSON = (function() {

if (!geomsAndTimes.geoms.length) return [];
if (name) properties.name = name;
if (styleUrl && styleIndex["#"+styleUrl]) {
if (styleUrl && styleIndex['#' + styleUrl]) {
properties.styleUrl = styleUrl;
properties.styleHash = styleIndex[styleUrl];
}
Expand All @@ -215,8 +215,8 @@ var toGeoJSON = (function() {
outline = nodeVal(get1(polyStyle, 'outline'));
if (pcolor) properties.fill = pcolor;
if (!isNaN(popacity)) properties['fill-opacity'] = popacity;
if (fill) properties['fill-opacity'] = fill === "1" ? 1 : 0;
if (outline) properties['stroke-opacity'] = outline === "1" ? 1 : 0;
if (fill) properties['fill-opacity'] = fill === '1' ? 1 : 0;
if (outline) properties['stroke-opacity'] = outline === '1' ? 1 : 0;
}
if (extendedData) {
var datas = get(extendedData, 'Data'),
Expand Down

0 comments on commit f71e9e8

Please sign in to comment.