Skip to content

Commit f71e9e8

Browse files
committed
Use eslint to standardize code style
1 parent 8326600 commit f71e9e8

7 files changed

+41
-31
lines changed

.eslintrc

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"rules": {
3+
"indent": [
4+
2,
5+
4
6+
],
7+
"quotes": [
8+
2,
9+
"single"
10+
],
11+
"linebreak-style": [
12+
2,
13+
"unix"
14+
],
15+
"semi": [
16+
2,
17+
"always"
18+
]
19+
},
20+
"env": {
21+
"browser": true
22+
},
23+
"globals": {
24+
"process": true,
25+
"module": true,
26+
"require": true
27+
},
28+
"extends": "eslint:recommended"
29+
}

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
"test": "test"
88
},
99
"scripts": {
10-
"test": "tape test/*.js",
10+
"test": "eslint togeojson.js && tape test/*.js",
1111
"cov": "istanbul cover test/index.js && coveralls < ./coverage/lcov.info",
1212
"browser": "browserify -t brfs test/index.js > test/bundle.js"
1313
},
1414
"devDependencies": {
1515
"brfs": "~0.2.1",
1616
"coveralls": "~2.10.0",
17+
"eslint": "^1.2.1",
1718
"glob": "^4.2.1",
1819
"istanbul": "~0.2.11",
1920
"tape": "~3.0.3"

test/data/gxmultitrack.kml.geojson

-6
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
},
1414
"properties": {
1515
"name": "\n12/04/2014 11:24 AM (départ)\n ",
16-
"styleUrl": "#start",
17-
"styleHash": "-13d91d2a",
1816
"description": "\n\n "
1917
}
2018
},
@@ -167,8 +165,6 @@
167165
},
168166
"properties": {
169167
"name": "\n12/04/2014 11:24 AM\n ",
170-
"styleUrl": "#track",
171-
"styleHash": "-4182fe62",
172168
"description": "\n\n ",
173169
"type": "\ncourse à pied\n ",
174170
"coordTimes": [
@@ -218,8 +214,6 @@
218214
},
219215
"properties": {
220216
"name": "\n12/04/2014 11:24 AM (fin)\n ",
221-
"styleUrl": "#end",
222-
"styleHash": "10d07b61",
223217
"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 "
224218
}
225219
}

test/data/multitrack.kml.geojson

+2-8
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
]
1313
},
1414
"properties": {
15-
"name": "8/8/2013 17:20 (Start)",
16-
"styleUrl": "#start",
17-
"styleHash": "4c07829a"
15+
"name": "8/8/2013 17:20 (Start)"
1816
}
1917
},
2018
{
@@ -106,8 +104,6 @@
106104
},
107105
"properties": {
108106
"name": "8/8/2013 17:20",
109-
"styleUrl": "#track",
110-
"styleHash": "-1fdecab8",
111107
"type": "walking",
112108
"coordTimes": [
113109
"2013-08-08T15:24:47.000Z",
@@ -141,9 +137,7 @@
141137
]
142138
},
143139
"properties": {
144-
"name": "8/8/2013 17:20 (End)",
145-
"styleUrl": "#end",
146-
"styleHash": "15ca312f"
140+
"name": "8/8/2013 17:20 (End)"
147141
}
148142
}
149143
]

test/data/simpledata.kml.geojson

-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
},
1313
"properties": {
1414
"name": "Easy trail",
15-
"styleUrl": "#trailhead-balloon-template",
16-
"styleHash": "ca0b0b",
1715
"TrailHeadName": "Pi in the sky",
1816
"TrailLength": "3.14159",
1917
"ElevationGain": "10"
@@ -30,8 +28,6 @@
3028
},
3129
"properties": {
3230
"name": "Difficult trail",
33-
"styleUrl": "#trailhead-balloon-template",
34-
"styleHash": "ca0b0b",
3531
"TrailHeadName": "Mount Everest",
3632
"TrailLength": "347.45",
3733
"ElevationGain": "10000"

test/data/style.kml.geojson

+1-5
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
},
1414
"properties": {
1515
"name": "Google Earth - New Polygon",
16-
"styleUrl": "#a",
17-
"styleHash": "-1d694122",
1816
"description": "Here is some descriptive text"
1917
}
2018
},
@@ -29,9 +27,7 @@
2927
]
3028
},
3129
"properties": {
32-
"name": "Google Earth - New Path",
33-
"styleUrl": "#b",
34-
"styleHash": "-5b6ad921"
30+
"name": "Google Earth - New Path"
3531
}
3632
}
3733
]

togeojson.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ var toGeoJSON = (function() {
5555
if (ele) {
5656
e = parseFloat(nodeVal(ele));
5757
if (!isNaN(e)) {
58-
ll.push(e);
58+
ll.push(e);
5959
}
6060
}
6161
return {
@@ -108,8 +108,8 @@ var toGeoJSON = (function() {
108108
}
109109
function kmlColor(v) {
110110
var color, opacity;
111-
v = v || "";
112-
if (v.substr(0, 1) === "#") { v = v.substr(1); }
111+
v = v || '';
112+
if (v.substr(0, 1) === '#') { v = v.substr(1); }
113113
if (v.length === 6 || v.length === 3) { color = v; }
114114
if (v.length === 8) {
115115
opacity = parseInt(v.substr(0, 2), 16) / 255;
@@ -123,7 +123,7 @@ var toGeoJSON = (function() {
123123
if (elems.length === 0) elems = get(root, 'gx:coord');
124124
for (var i = 0; i < elems.length; i++) coords.push(gxCoord(nodeVal(elems[i])));
125125
var timeElems = get(root, 'when');
126-
for (var i = 0; i < timeElems.length; i++) times.push(nodeVal(timeElems[i]));
126+
for (var j = 0; j < timeElems.length; j++) times.push(nodeVal(timeElems[j]));
127127
return {
128128
coords: coords,
129129
times: times
@@ -188,7 +188,7 @@ var toGeoJSON = (function() {
188188

189189
if (!geomsAndTimes.geoms.length) return [];
190190
if (name) properties.name = name;
191-
if (styleUrl && styleIndex["#"+styleUrl]) {
191+
if (styleUrl && styleIndex['#' + styleUrl]) {
192192
properties.styleUrl = styleUrl;
193193
properties.styleHash = styleIndex[styleUrl];
194194
}
@@ -215,8 +215,8 @@ var toGeoJSON = (function() {
215215
outline = nodeVal(get1(polyStyle, 'outline'));
216216
if (pcolor) properties.fill = pcolor;
217217
if (!isNaN(popacity)) properties['fill-opacity'] = popacity;
218-
if (fill) properties['fill-opacity'] = fill === "1" ? 1 : 0;
219-
if (outline) properties['stroke-opacity'] = outline === "1" ? 1 : 0;
218+
if (fill) properties['fill-opacity'] = fill === '1' ? 1 : 0;
219+
if (outline) properties['stroke-opacity'] = outline === '1' ? 1 : 0;
220220
}
221221
if (extendedData) {
222222
var datas = get(extendedData, 'Data'),

0 commit comments

Comments
 (0)