mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-31 01:09:22 +02:00
Enable curly and block-spacing eslint rules
This commit is contained in:
@@ -19,9 +19,11 @@
|
||||
"array-callback-return": "warn",
|
||||
"arrow-spacing": "warn",
|
||||
"block-scoped-var": "error",
|
||||
"block-spacing": ["warn", "always"],
|
||||
"brace-style": ["warn", "1tbs", { "allowSingleLine": true }],
|
||||
"class-methods-use-this": "error",
|
||||
"complexity": ["warn", 50],
|
||||
"curly": ["warn", "multi-line"],
|
||||
"default-case-last": "error",
|
||||
"default-param-last": "error",
|
||||
"dot-notation": "error",
|
||||
|
||||
@@ -8,8 +8,9 @@ export function actionDeleteMember(relationId, memberIndex) {
|
||||
|
||||
graph = graph.replace(relation);
|
||||
|
||||
if (relation.isDegenerate())
|
||||
if (relation.isDegenerate()) {
|
||||
graph = actionDeleteRelation(relation.id)(graph);
|
||||
}
|
||||
|
||||
return graph;
|
||||
};
|
||||
|
||||
@@ -80,8 +80,7 @@ export function actionDisconnect(nodeId, newNodeId) {
|
||||
|
||||
action.disabled = function(graph) {
|
||||
var connections = action.connections(graph);
|
||||
if (connections.length === 0)
|
||||
return 'not_connected';
|
||||
if (connections.length === 0) return 'not_connected';
|
||||
|
||||
var parentWays = graph.parentWays(graph.entity(nodeId));
|
||||
var seenRelationIds = {};
|
||||
@@ -105,8 +104,7 @@ export function actionDisconnect(nodeId, newNodeId) {
|
||||
});
|
||||
});
|
||||
|
||||
if (sharedRelation)
|
||||
return 'relation';
|
||||
if (sharedRelation) return 'relation';
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -256,11 +256,13 @@ export function behaviorSelect(context) {
|
||||
|
||||
var datum = pointerInfo.firstEvent.target.__data__;
|
||||
var entity = (datum && datum.properties && datum.properties.entity) || datum;
|
||||
if (context.graph().hasEntity(entity.id)) return {
|
||||
pointerId: pointerId,
|
||||
entityId: entity.id,
|
||||
selected: selectedIDs.indexOf(entity.id) !== -1
|
||||
};
|
||||
if (context.graph().hasEntity(entity.id)) {
|
||||
return {
|
||||
pointerId: pointerId,
|
||||
entityId: entity.id,
|
||||
selected: selectedIDs.indexOf(entity.id) !== -1
|
||||
};
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -213,8 +213,9 @@ export function coreDifference(base, head) {
|
||||
|
||||
if (extent &&
|
||||
(!h || !h.intersects(extent, head)) &&
|
||||
(!b || !b.intersects(extent, base)))
|
||||
(!b || !b.intersects(extent, base))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result[id] = h;
|
||||
|
||||
|
||||
@@ -143,8 +143,7 @@ coreGraph.prototype = {
|
||||
for (i = 0; i < entities.length; i++) {
|
||||
var entity = entities[i];
|
||||
|
||||
if (!entity.visible || (!force && base.entities[entity.id]))
|
||||
continue;
|
||||
if (!entity.visible || (!force && base.entities[entity.id])) continue;
|
||||
|
||||
// Merging data into the base graph
|
||||
base.entities[entity.id] = entity;
|
||||
|
||||
@@ -326,14 +326,18 @@ export function geoViewportEdge(point, dimensions) {
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
|
||||
if (point[0] > dimensions[0] - pad[1])
|
||||
if (point[0] > dimensions[0] - pad[1]) {
|
||||
x = -10;
|
||||
if (point[0] < pad[3])
|
||||
}
|
||||
if (point[0] < pad[3]) {
|
||||
x = 10;
|
||||
if (point[1] > dimensions[1] - pad[2])
|
||||
}
|
||||
if (point[1] > dimensions[1] - pad[2]) {
|
||||
y = -10;
|
||||
if (point[1] < pad[0])
|
||||
}
|
||||
if (point[1] < pad[0]) {
|
||||
y = 10;
|
||||
}
|
||||
|
||||
if (x || y) {
|
||||
return [x, y];
|
||||
|
||||
@@ -114,8 +114,7 @@ osmEntity.prototype = {
|
||||
|
||||
|
||||
copy: function(resolver, copies) {
|
||||
if (copies[this.id])
|
||||
return copies[this.id];
|
||||
if (copies[this.id]) return copies[this.id];
|
||||
|
||||
var copy = osmEntity(this, { id: undefined, user: undefined, version: undefined });
|
||||
copies[this.id] = copy;
|
||||
|
||||
@@ -441,8 +441,7 @@ export function osmIntersection(graph, startVertexId, maxDistance) {
|
||||
}
|
||||
|
||||
// stop looking if we find a "direct" restriction (matching FROM, VIA, TO)
|
||||
if (restrict && restrict.direct)
|
||||
break;
|
||||
if (restrict && restrict.direct) break;
|
||||
}
|
||||
|
||||
nextWays.push({ way: way, restrict: restrict });
|
||||
@@ -607,19 +606,25 @@ export function osmInferRestriction(graph, turn, projection) {
|
||||
var angle = (geoAngle(fromVertex, fromNode, projection) -
|
||||
geoAngle(toVertex, toNode, projection)) * 180 / Math.PI;
|
||||
|
||||
while (angle < 0)
|
||||
while (angle < 0) {
|
||||
angle += 360;
|
||||
}
|
||||
|
||||
if (fromNode === toNode)
|
||||
if (fromNode === toNode) {
|
||||
return 'no_u_turn';
|
||||
if ((angle < 23 || angle > 336) && fromOneWay && toOneWay)
|
||||
}
|
||||
if ((angle < 23 || angle > 336) && fromOneWay && toOneWay) {
|
||||
return 'no_u_turn'; // wider tolerance for u-turn if both ways are oneway
|
||||
if ((angle < 40 || angle > 319) && fromOneWay && toOneWay && turn.from.vertex !== turn.to.vertex)
|
||||
}
|
||||
if ((angle < 40 || angle > 319) && fromOneWay && toOneWay && turn.from.vertex !== turn.to.vertex) {
|
||||
return 'no_u_turn'; // even wider tolerance for u-turn if there is a via way (from !== to)
|
||||
if (angle < 158)
|
||||
}
|
||||
if (angle < 158) {
|
||||
return 'no_right_turn';
|
||||
if (angle > 202)
|
||||
}
|
||||
if (angle > 202) {
|
||||
return 'no_left_turn';
|
||||
}
|
||||
|
||||
return 'no_straight_on';
|
||||
}
|
||||
|
||||
@@ -225,16 +225,22 @@ function parseBicycleWay(tag) {
|
||||
|
||||
|
||||
function mapToLanesObj(lanesObj, data, key) {
|
||||
if (data.forward) data.forward.forEach(function(l, i) {
|
||||
if (!lanesObj.forward[i]) lanesObj.forward[i] = {};
|
||||
lanesObj.forward[i][key] = l;
|
||||
});
|
||||
if (data.backward) data.backward.forEach(function(l, i) {
|
||||
if (!lanesObj.backward[i]) lanesObj.backward[i] = {};
|
||||
lanesObj.backward[i][key] = l;
|
||||
});
|
||||
if (data.unspecified) data.unspecified.forEach(function(l, i) {
|
||||
if (!lanesObj.unspecified[i]) lanesObj.unspecified[i] = {};
|
||||
lanesObj.unspecified[i][key] = l;
|
||||
});
|
||||
if (data.forward) {
|
||||
data.forward.forEach(function(l, i) {
|
||||
if (!lanesObj.forward[i]) lanesObj.forward[i] = {};
|
||||
lanesObj.forward[i][key] = l;
|
||||
});
|
||||
}
|
||||
if (data.backward) {
|
||||
data.backward.forEach(function(l, i) {
|
||||
if (!lanesObj.backward[i]) lanesObj.backward[i] = {};
|
||||
lanesObj.backward[i][key] = l;
|
||||
});
|
||||
}
|
||||
if (data.unspecified) {
|
||||
data.unspecified.forEach(function(l, i) {
|
||||
if (!lanesObj.unspecified[i]) lanesObj.unspecified[i] = {};
|
||||
lanesObj.unspecified[i][key] = l;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,24 +40,31 @@ export function osmOldMultipolygonOuterMemberOfRelation(entity, graph) {
|
||||
// For fixing up rendering of multipolygons with tags on the outer member.
|
||||
// https://github.com/openstreetmap/iD/issues/613
|
||||
export function osmIsOldMultipolygonOuterMember(entity, graph) {
|
||||
if (entity.type !== 'way' || Object.keys(entity.tags).filter(osmIsInterestingTag).length === 0)
|
||||
if (entity.type !== 'way' ||
|
||||
Object.keys(entity.tags).filter(osmIsInterestingTag).length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var parents = graph.parentRelations(entity);
|
||||
if (parents.length !== 1)
|
||||
return false;
|
||||
if (parents.length !== 1) return false;
|
||||
|
||||
var parent = parents[0];
|
||||
if (!parent.isMultipolygon() || Object.keys(parent.tags).filter(osmIsInterestingTag).length > 1)
|
||||
if (!parent.isMultipolygon() ||
|
||||
Object.keys(parent.tags).filter(osmIsInterestingTag).length > 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var members = parent.members, member;
|
||||
for (var i = 0; i < members.length; i++) {
|
||||
member = members[i];
|
||||
if (member.id === entity.id && member.role && member.role !== 'outer')
|
||||
return false; // Not outer member
|
||||
if (member.id !== entity.id && (!member.role || member.role === 'outer'))
|
||||
return false; // Not a simple multipolygon
|
||||
if (member.id === entity.id && member.role && member.role !== 'outer') {
|
||||
// Not outer member
|
||||
return false;
|
||||
}
|
||||
if (member.id !== entity.id && (!member.role || member.role === 'outer')) {
|
||||
// Not a simple multipolygon
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return parent;
|
||||
@@ -65,33 +72,33 @@ export function osmIsOldMultipolygonOuterMember(entity, graph) {
|
||||
|
||||
|
||||
export function osmOldMultipolygonOuterMember(entity, graph) {
|
||||
if (entity.type !== 'way')
|
||||
return false;
|
||||
if (entity.type !== 'way') return false;
|
||||
|
||||
var parents = graph.parentRelations(entity);
|
||||
if (parents.length !== 1)
|
||||
return false;
|
||||
if (parents.length !== 1) return false;
|
||||
|
||||
var parent = parents[0];
|
||||
if (!parent.isMultipolygon() || Object.keys(parent.tags).filter(osmIsInterestingTag).length > 1)
|
||||
if (!parent.isMultipolygon() ||
|
||||
Object.keys(parent.tags).filter(osmIsInterestingTag).length > 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var members = parent.members, member, outerMember;
|
||||
for (var i = 0; i < members.length; i++) {
|
||||
member = members[i];
|
||||
if (!member.role || member.role === 'outer') {
|
||||
if (outerMember)
|
||||
return false; // Not a simple multipolygon
|
||||
if (outerMember) return false; // Not a simple multipolygon
|
||||
outerMember = member;
|
||||
}
|
||||
}
|
||||
|
||||
if (!outerMember)
|
||||
return false;
|
||||
if (!outerMember) return false;
|
||||
|
||||
var outerEntity = graph.hasEntity(outerMember.id);
|
||||
if (!outerEntity || !Object.keys(outerEntity.tags).filter(osmIsInterestingTag).length)
|
||||
if (!outerEntity ||
|
||||
!Object.keys(outerEntity.tags).filter(osmIsInterestingTag).length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return outerEntity;
|
||||
}
|
||||
|
||||
@@ -330,14 +330,16 @@ Object.assign(osmRelation.prototype, {
|
||||
|
||||
for (o = 0; o < outers.length; o++) {
|
||||
outer = outers[o];
|
||||
if (geoPolygonContainsPolygon(outer, inner))
|
||||
if (geoPolygonContainsPolygon(outer, inner)) {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
for (o = 0; o < outers.length; o++) {
|
||||
outer = outers[o];
|
||||
if (geoPolygonIntersectsPolygon(outer, inner, false))
|
||||
if (geoPolygonIntersectsPolygon(outer, inner, false)) {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -155,8 +155,10 @@ Object.assign(osmWay.prototype, {
|
||||
|
||||
// implied oneway tag..
|
||||
for (var key in this.tags) {
|
||||
if (key in osmOneWayTags && (this.tags[key] in osmOneWayTags[key]))
|
||||
if (key in osmOneWayTags &&
|
||||
(this.tags[key] in osmOneWayTags[key])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
@@ -232,10 +234,8 @@ Object.assign(osmWay.prototype, {
|
||||
},
|
||||
|
||||
isArea: function() {
|
||||
if (this.tags.area === 'yes')
|
||||
return true;
|
||||
if (!this.isClosed() || this.tags.area === 'no')
|
||||
return false;
|
||||
if (this.tags.area === 'yes') return true;
|
||||
if (!this.isClosed() || this.tags.area === 'no') return false;
|
||||
return this.tagSuggestingArea() !== null;
|
||||
},
|
||||
|
||||
|
||||
@@ -315,8 +315,7 @@ export function svgLabels(projection, context) {
|
||||
var preset = geometry === 'area' && presetManager.match(entity, graph);
|
||||
var icon = preset && !shouldSkipIcon(preset) && preset.icon;
|
||||
|
||||
if (!icon && !utilDisplayName(entity))
|
||||
continue;
|
||||
if (!icon && !utilDisplayName(entity)) continue;
|
||||
|
||||
for (k = 0; k < labelStack.length; k++) {
|
||||
var matchGeom = labelStack[k][0];
|
||||
|
||||
@@ -185,10 +185,11 @@ export function svgLines(projection, context) {
|
||||
var layer = this.parentNode.__data__;
|
||||
var data = pathdata[layer] || [];
|
||||
return data.filter(function(d) {
|
||||
if (isSelected)
|
||||
if (isSelected) {
|
||||
return context.selectedIDs().indexOf(d.id) !== -1;
|
||||
else
|
||||
} else {
|
||||
return context.selectedIDs().indexOf(d.id) === -1;
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -105,8 +105,7 @@ export function svgMidpoints(projection, context) {
|
||||
|
||||
|
||||
function midpointFilter(d) {
|
||||
if (midpoints[d.id])
|
||||
return true;
|
||||
if (midpoints[d.id]) return true;
|
||||
|
||||
for (var i = 0; i < d.parents.length; i++) {
|
||||
if (filter(d.parents[i])) {
|
||||
|
||||
@@ -91,16 +91,12 @@ export function uiFieldAddress(field, context) {
|
||||
|
||||
function isAddressable(d) {
|
||||
if (d.tags.name) {
|
||||
if (d.tags.admin_level === '8' && d.tags.boundary === 'administrative')
|
||||
return true;
|
||||
if (d.tags.border_type === 'city')
|
||||
return true;
|
||||
if (d.tags.place === 'city' || d.tags.place === 'town' || d.tags.place === 'village')
|
||||
return true;
|
||||
if (d.tags.admin_level === '8' && d.tags.boundary === 'administrative') return true;
|
||||
if (d.tags.border_type === 'city') return true;
|
||||
if (d.tags.place === 'city' || d.tags.place === 'town' || d.tags.place === 'village') return true;
|
||||
}
|
||||
|
||||
if (d.tags['addr:city'])
|
||||
return true;
|
||||
if (d.tags['addr:city']) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -534,8 +534,10 @@ export function uiFieldRestrictions(field, context) {
|
||||
for (var i = 0; i < datum.via.ways.length; i++) {
|
||||
var prev = names[names.length - 1];
|
||||
var curr = displayName(datum.via.ways[i], vgraph);
|
||||
if (!prev || curr !== prev) // collapse identical names
|
||||
if (!prev || curr !== prev) {
|
||||
// collapse identical names
|
||||
names.push(curr);
|
||||
}
|
||||
}
|
||||
|
||||
help
|
||||
|
||||
@@ -49,7 +49,8 @@ var helpStringReplacements;
|
||||
// with custom `replacements`
|
||||
export function helpHtml(id, replacements) {
|
||||
// only load these the first time
|
||||
if (!helpStringReplacements) helpStringReplacements = {
|
||||
if (!helpStringReplacements) {
|
||||
helpStringReplacements = {
|
||||
// insert icons corresponding to various UI elements
|
||||
point_icon: icon('#iD-icon-point', 'inline'),
|
||||
line_icon: icon('#iD-icon-line', 'inline'),
|
||||
@@ -144,7 +145,8 @@ export function helpHtml(id, replacements) {
|
||||
start_the_walkthrough: t.html('splash.walkthrough'),
|
||||
help: t.html('help.title'),
|
||||
ok: t.html('intro.ok')
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
var reps;
|
||||
if (replacements) {
|
||||
@@ -255,10 +257,11 @@ export function selectMenuItem(context, operation) {
|
||||
|
||||
export function transitionTime(point1, point2) {
|
||||
var distance = geoSphericalDistance(point1, point2);
|
||||
if (distance === 0)
|
||||
if (distance === 0) {
|
||||
return 0;
|
||||
else if (distance < 80)
|
||||
} else if (distance < 80) {
|
||||
return 500;
|
||||
else
|
||||
} else {
|
||||
return 1000;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,12 +211,13 @@ export function uiIntroLine(context, reveal) {
|
||||
reveal('.surface', continueLineText);
|
||||
|
||||
context.on('enter.intro', function(mode) {
|
||||
if (mode.id === 'draw-line')
|
||||
if (mode.id === 'draw-line') {
|
||||
return;
|
||||
else if (mode.id === 'select')
|
||||
} else if (mode.id === 'select') {
|
||||
return continueTo(chooseCategoryRoad);
|
||||
else
|
||||
} else {
|
||||
return chapter.restart();
|
||||
}
|
||||
});
|
||||
|
||||
function continueTo(nextStep) {
|
||||
|
||||
@@ -23,18 +23,12 @@ export function uiPresetIcon() {
|
||||
|
||||
|
||||
function getIcon(p, geom) {
|
||||
if (isSmall() && p.isFallback && p.isFallback())
|
||||
return 'iD-icon-' + p.id;
|
||||
else if (p.icon)
|
||||
return p.icon;
|
||||
else if (geom === 'line')
|
||||
return 'iD-other-line';
|
||||
else if (geom === 'vertex')
|
||||
return p.isFallback() ? '' : 'temaki-vertex';
|
||||
else if (isSmall() && geom === 'point')
|
||||
return '';
|
||||
else
|
||||
return 'maki-marker-stroked';
|
||||
if (isSmall() && p.isFallback && p.isFallback()) return 'iD-icon-' + p.id;
|
||||
if (p.icon) return p.icon;
|
||||
if (geom === 'line') return 'iD-other-line';
|
||||
if (geom === 'vertex') return p.isFallback() ? '' : 'temaki-vertex';
|
||||
if (isSmall() && geom === 'point') return '';
|
||||
return 'maki-marker-stroked';
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -60,11 +60,15 @@ export function utilKeybinding(namespace) {
|
||||
if (binding.event.key === undefined) {
|
||||
isMatch = false;
|
||||
} else if (Array.isArray(binding.event.key)) {
|
||||
if (binding.event.key.map(function(s) { return s.toLowerCase(); }).indexOf(event.key.toLowerCase()) === -1)
|
||||
if (binding.event.key.map(function(s) {
|
||||
return s.toLowerCase();
|
||||
}).indexOf(event.key.toLowerCase()) === -1) {
|
||||
isMatch = false;
|
||||
}
|
||||
} else {
|
||||
if (event.key.toLowerCase() !== binding.event.key.toLowerCase())
|
||||
if (event.key.toLowerCase() !== binding.event.key.toLowerCase()) {
|
||||
isMatch = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -365,8 +365,7 @@ export function utilPrefixDOMProperty(property) {
|
||||
var n = prefixes.length;
|
||||
var s = document.body;
|
||||
|
||||
if (property in s)
|
||||
return property;
|
||||
if (property in s) return property;
|
||||
|
||||
property = property.substr(0, 1).toUpperCase() + property.substr(1);
|
||||
|
||||
|
||||
@@ -152,8 +152,14 @@ export function utilZoomPan() {
|
||||
b = typeof transform === 'function' ? transform.apply(that, args) : transform,
|
||||
i = interpolate(a.invert(p).concat(w / a.k), b.invert(p).concat(w / b.k));
|
||||
return function(t) {
|
||||
if (t === 1) t = b; // Avoid rounding error on end.
|
||||
else { var l = i(t), k = w / l[2]; t = new Transform(k, p[0] - l[0] * k, p[1] - l[1] * k); }
|
||||
if (t === 1) {
|
||||
// Avoid rounding error on end.
|
||||
t = b;
|
||||
} else {
|
||||
var l = i(t);
|
||||
var k = w / l[2];
|
||||
t = new Transform(k, p[0] - l[0] * k, p[1] - l[1] * k);
|
||||
}
|
||||
g.zoom(null, null, t);
|
||||
};
|
||||
});
|
||||
@@ -321,8 +327,9 @@ export function utilZoomPan() {
|
||||
g.pointer0 = g.pointer1;
|
||||
delete g.pointer1;
|
||||
}
|
||||
if (g.pointer0) g.pointer0[1] = _transform.invert(g.pointer0[0]);
|
||||
else {
|
||||
if (g.pointer0) {
|
||||
g.pointer0[1] = _transform.invert(g.pointer0[0]);
|
||||
} else {
|
||||
g.end(d3_event);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user