From 8f1796da573cc2f7b43834d57dafaa5476855a4f Mon Sep 17 00:00:00 2001 From: NovemLinguae Date: Wed, 4 Dec 2024 05:58:39 -0800 Subject: [PATCH] eslint: fix no-throw-literal manual fixes --- .eslintrc.json | 1 - morebits.js | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 086f4739c..b74f7b0f0 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -56,7 +56,6 @@ "no-new": "warn", "no-return-assign": "warn", "no-script-url": "warn", - "no-throw-literal": "warn", "no-unused-expressions": "warn", "no-use-before-define": "warn", "no-useless-concat": "warn", diff --git a/morebits.js b/morebits.js index 206cfec32..55cf4f597 100644 --- a/morebits.js +++ b/morebits.js @@ -1585,7 +1585,7 @@ Morebits.array = { */ uniq: function(arr) { if (!Array.isArray(arr)) { - throw 'A non-array object passed to Morebits.array.uniq'; + throw new Error('A non-array object passed to Morebits.array.uniq'); } return arr.filter((item, idx) => arr.indexOf(item) === idx); }, @@ -1600,7 +1600,7 @@ Morebits.array = { */ dups: function(arr) { if (!Array.isArray(arr)) { - throw 'A non-array object passed to Morebits.array.dups'; + throw new Error('A non-array object passed to Morebits.array.dups'); } return arr.filter((item, idx) => arr.indexOf(item) !== idx); }, @@ -1615,7 +1615,7 @@ Morebits.array = { */ chunk: function(arr, size) { if (!Array.isArray(arr)) { - throw 'A non-array object passed to Morebits.array.chunk'; + throw new Error('A non-array object passed to Morebits.array.chunk'); } if (typeof size !== 'number' || size <= 0) { // pretty impossible to do anything :) return [ arr ]; // we return an array consisting of this array. @@ -5231,7 +5231,7 @@ Morebits.status.onError = function(handler) { if (typeof handler === 'function') { Morebits.status.errorEvent = handler; } else { - throw 'Morebits.status.onError: handler is not a function'; + throw new Error('Morebits.status.onError: handler is not a function'); } };