Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

fix `prefer-rest-params` errors

Jason Kente8391edb486e
diff --git a/.eslintrc b/.eslintrc
index 479070995..d36c0eec3 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -82,16 +82,13 @@
"class-methods-use-this": "warn",
"no-plusplus": "warn",
"max-len": "off",
-
+
"consistent-return": "off",
"no-underscore-dangle": "off",
- "vars-on-top": "off",
"func-names": "off",
- "no-param-reassign": "off",
+ "no-param-reassign": "warn",
"no-use-before-define": "off",
- "prefer-rest-params": "off",
-
// Import rules overrides
"import/prefer-default-export": "off",
"import/no-cycle": "warn",
@@ -110,9 +107,9 @@
"jsx-a11y/click-events-have-key-events": "off",
// React rules overrides
- "react/jsx-props-no-spreading": "warn",
- "react/destructuring-assignment": "off", // 464 errors (Set to WARN)
+ "react/destructuring-assignment": "warn", // 464 errors
"react/no-unused-state": "warn", // 38 errors
+ "react/jsx-props-no-spreading": "warn",
"react/jsx-filename-extension": "off",
"react/sort-comp": "off",
diff --git a/web/js/debug.js b/web/js/debug.js
index ea041df9f..b0689c790 100644
--- a/web/js/debug.js
+++ b/web/js/debug.js
@@ -21,8 +21,7 @@ export const debug = (function() {
const delayedCallback = function(jqXHR, wrap, delay) {
return function(fn) {
- wrap(function() {
- const args = arguments;
+ wrap((...args) => {
setTimeout(() => {
if (fn) {
fn.apply(jqXHR, args);
@@ -35,10 +34,9 @@ export const debug = (function() {
self.loadDelay = function(delay) {
const { ajax } = $;
- $.ajax = function() {
- const ajaxArgs = arguments;
+ $.ajax = function(...ajaxArgs) {
console.log('delay', delay, ajaxArgs);
- const jqXHR = ajax.apply($, arguments);
+ const jqXHR = ajax.apply($, ajaxArgs);
const { done } = jqXHR;
jqXHR.done = delayedCallback(jqXHR, done, delay);
diff --git a/web/js/map/animate.js b/web/js/map/animate.js
index cad014f09..9305b1597 100644
--- a/web/js/map/animate.js
+++ b/web/js/map/animate.js
@@ -28,8 +28,7 @@ export function mapAnimate(config, ui, store) {
const distanceDuration = polarProjectionCheck ? distance / 50000 : distance; // limit large polar projection distances from coordinate transforms
let duration = Math.floor(distanceDuration * 20 + 1000); // approx 6 seconds to go 360 degrees
if (!rotation) rotation = 0;
- const animationPromise = function() {
- const args = Array.prototype.slice.call(arguments);
+ const animationPromise = function(...args) {
return new Promise((resolve, reject) => {
args.push((complete) => {
if (complete) resolve();
diff --git a/web/js/ui/ui.js b/web/js/ui/ui.js
index 51e7bfa22..03d092218 100644
--- a/web/js/ui/ui.js
+++ b/web/js/ui/ui.js
@@ -15,8 +15,8 @@ export default (function(self) {
*
* @param {Exception} cause The exception object that caused the error
*/
- self.error = function() {
- console.error(...arguments);
+ self.error = function(...args) {
+ console.error(args);
self.notify(
"<div class='error-header'>"
diff --git a/web/js/util/events.js b/web/js/util/events.js
index cc51c6829..0d444688e 100644
--- a/web/js/util/events.js
+++ b/web/js/util/events.js
@@ -36,12 +36,13 @@ export function events() {
allListeners.push(callback);
};
- self.trigger = function(event) {
+ self.trigger = function(...args) {
+ const [event] = args;
const listeners = events[event];
if (!listeners && !allListeners) {
return;
}
- const eventArguments = Array.prototype.slice.call(arguments, 1);
+ const eventArguments = args.slice(1);
lodashEach(events[event], (listener) => {
listener.apply(self, eventArguments);
});
diff --git a/web/js/util/util.js b/web/js/util/util.js
index f9424a259..291f7bd16 100644
--- a/web/js/util/util.js
+++ b/web/js/util/util.js
@@ -908,9 +908,9 @@ export default (function(self) {
* @return the function wrapped in a try/catch block.
*/
self.wrap = function(func) {
- return function() {
+ return function(...args) {
try {
- return func.apply(func, arguments);
+ return func.apply(func, args);
} catch (error) {
self.error(error);
}
@@ -1084,11 +1084,11 @@ export default (function(self) {
// arguments array contains all args passed. String must be formatted
// so that first replacement starts with "{1}"
// usage example: wv.util.format("{1}{2}",'World','view')
- self.format = function() {
- let formatted = arguments[0];
- for (let i = 1; i < arguments.length; i++) {
+ self.format = function(...args) {
+ let [formatted] = args;
+ for (let i = 1; i < args.length; i++) {
const regexp = new RegExp(`\\{${i}\\}`, 'gi');
- formatted = formatted.replace(regexp, arguments[i]);
+ formatted = formatted.replace(regexp, args[i]);
}
return formatted;
};