From 6549bcc197d34571f804db16f72c85b738268ed0 Mon Sep 17 00:00:00 2001 From: Quincy Morgan <2046746+quincylvania@users.noreply.github.com> Date: Fri, 23 Oct 2020 11:27:32 -0400 Subject: [PATCH] Enable no-eq-null eslint rule --- .eslintrc | 1 + modules/util/get_set_value.js | 4 ++-- modules/util/zoom_pan.js | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.eslintrc b/.eslintrc index c7a7f3374..376e73565 100644 --- a/.eslintrc +++ b/.eslintrc @@ -29,6 +29,7 @@ "no-console": "warn", "no-constructor-return": "error", "no-div-regex": "error", + "no-eq-null": "error", "no-eval": "error", "no-extend-native": "error", "no-extra-bind": "error", diff --git a/modules/util/get_set_value.js b/modules/util/get_set_value.js index e77e84d49..d55f805ae 100644 --- a/modules/util/get_set_value.js +++ b/modules/util/get_set_value.js @@ -14,14 +14,14 @@ export function utilGetSetValue(selection, value) { function valueFunction() { var x = value.apply(this, arguments); - if (x == null) { + if (x === null || x === undefined) { delete this.value; } else if (this.value !== x) { this.value = x; } } - return value == null + return (value === null || value === undefined) ? valueNull : (typeof value === 'function' ? valueFunction : valueConstant); } diff --git a/modules/util/zoom_pan.js b/modules/util/zoom_pan.js index fa473489b..ee69ed73b 100644 --- a/modules/util/zoom_pan.js +++ b/modules/util/zoom_pan.js @@ -95,7 +95,7 @@ export function utilZoomPan() { zoom.transform(selection, function() { var e = extent.apply(this, arguments), t0 = _transform, - p0 = p == null ? centroid(e) : typeof p === 'function' ? p.apply(this, arguments) : p, + p0 = !p ? centroid(e) : typeof p === 'function' ? p.apply(this, arguments) : p, p1 = t0.invert(p0), k1 = typeof k === 'function' ? k.apply(this, arguments) : k; return constrain(translate(scale(t0, k1), p0, p1), e, translateExtent); @@ -115,7 +115,7 @@ export function utilZoomPan() { zoom.transform(selection, function() { var e = extent.apply(this, arguments), t = _transform, - p0 = p == null ? centroid(e) : typeof p === 'function' ? p.apply(this, arguments) : p; + p0 = !p ? centroid(e) : typeof p === 'function' ? p.apply(this, arguments) : p; return constrain(d3_zoomIdentity.translate(p0[0], p0[1]).scale(t.k).translate( typeof x === 'function' ? -x.apply(this, arguments) : -x, typeof y === 'function' ? -y.apply(this, arguments) : -y @@ -146,7 +146,7 @@ export function utilZoomPan() { args = arguments, g = gesture(that, args), e = extent.apply(that, args), - p = point == null ? centroid(e) : typeof point === 'function' ? point.apply(that, args) : point, + p = !point ? centroid(e) : typeof point === 'function' ? point.apply(that, args) : point, w = Math.max(e[1][0] - e[0][0], e[1][1] - e[0][1]), a = _transform, b = typeof transform === 'function' ? transform.apply(that, args) : transform,