From f387b9055a103276abcb0a930218ee76e9e2aca8 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Fri, 1 Nov 2024 19:02:43 +0000 Subject: [PATCH] Fix linting --- src/array.js | 1 + src/cycle.js | 1 + src/get.js | 4 ++++ src/get.test.js | 4 +++- src/indices.js | 1 + src/indices.test.js | 1 + src/key.js | 2 ++ src/key.test.js | 2 ++ src/main.test.js | 1 + src/object.js | 1 + src/size.js | 1 + src/size.test.js | 1 + src/to_json.js | 2 ++ src/type.js | 1 + src/uncaught.js | 1 + 15 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/array.js b/src/array.js index 0bbe4233..47948b0a 100644 --- a/src/array.js +++ b/src/array.js @@ -36,6 +36,7 @@ export const recurseArray = ({ }) if (state.value !== undefined) { + // eslint-disable-next-line fp/no-mutating-methods newArray.push(state.value) } } diff --git a/src/cycle.js b/src/cycle.js index 00532c50..d70545fc 100644 --- a/src/cycle.js +++ b/src/cycle.js @@ -18,6 +18,7 @@ export const checkCycleThenRecurse = ({ } if (ancestors.has(value)) { + // eslint-disable-next-line fp/no-mutating-methods changes.push({ path, oldValue: value, diff --git a/src/get.js b/src/get.js index f8cd4983..3b3cf90f 100644 --- a/src/get.js +++ b/src/get.js @@ -16,6 +16,7 @@ export const safeGetProp = ({ parent, key, changes, path }) => { const prop = getProp({ parent, key, changes, path }) return { prop, safe: true } } catch (error) { + // eslint-disable-next-line fp/no-mutating-methods changes.push({ path, oldValue: undefined, @@ -40,6 +41,7 @@ const getProp = ({ parent, key, changes, path }) => { // When `parent[key]` was a getter and|or setter const addGetterChange = ({ changes, path, prop, descriptor: { get, set } }) => { if (get !== undefined || set !== undefined) { + // eslint-disable-next-line fp/no-mutating-methods changes.push({ path, oldValue: get, @@ -57,6 +59,7 @@ const addDescriptorChange = ({ descriptor: { writable, configurable }, }) => { if (writable === false) { + // eslint-disable-next-line fp/no-mutating-methods changes.push({ path, oldValue: prop, @@ -66,6 +69,7 @@ const addDescriptorChange = ({ } if (configurable === false) { + // eslint-disable-next-line fp/no-mutating-methods changes.push({ path, oldValue: prop, diff --git a/src/get.test.js b/src/get.test.js index 0f2ed755..d2783664 100644 --- a/src/get.test.js +++ b/src/get.test.js @@ -16,6 +16,7 @@ each( ], ({ title }, { descriptor, reason }) => { test(`Make properties configurable and writable | ${title}`, (t) => { + // eslint-disable-next-line fp/no-mutating-methods const input = Object.defineProperty({}, 'prop', { value: true, enumerable: true, @@ -60,7 +61,7 @@ each( input: { // eslint-disable-next-line fp/no-get-set get prop() { - // eslint-disable-next-line fp/no-this + // eslint-disable-next-line fp/no-mutating-methods, fp/no-this Object.defineProperty(this, 'prop', { value: true, enumerable: true, @@ -106,6 +107,7 @@ test('Resolve setters without getters', (t) => { test('Omit getters that throw', (t) => { const error = new Error('test') + // eslint-disable-next-line fp/no-mutating-methods const input = Object.defineProperty({}, 'prop', { get: () => { throw error.message diff --git a/src/indices.js b/src/indices.js index 650bb10b..6cf301d2 100644 --- a/src/indices.js +++ b/src/indices.js @@ -14,6 +14,7 @@ export const addNotArrayIndexChanges = (array, changes, path) => { for (const key of Reflect.ownKeys(array)) { if (!arrayProps.has(key)) { + // eslint-disable-next-line fp/no-mutating-methods changes.push({ path: [...path, key], oldValue: safeGetChangeProp({ parent: array, key }), diff --git a/src/indices.test.js b/src/indices.test.js index 346d27ee..c589162a 100644 --- a/src/indices.test.js +++ b/src/indices.test.js @@ -20,6 +20,7 @@ each( // eslint-disable-next-line max-params ({ title }, key, enumerable, { descriptor, oldValue }) => { test(`Omit array properties that are not indices | ${title}`, (t) => { + // eslint-disable-next-line fp/no-mutating-methods const array = Object.defineProperty([true], key, { ...descriptor, enumerable, diff --git a/src/key.js b/src/key.js index 46fe1dca..83ecba9f 100644 --- a/src/key.js +++ b/src/key.js @@ -3,6 +3,7 @@ // - Non-enumerable properties, except in arrays export const omitInvalidKey = ({ parent, key, prop, changes, path }) => { if (typeof key === 'symbol') { + // eslint-disable-next-line fp/no-mutating-methods changes.push({ path, oldValue: prop, @@ -13,6 +14,7 @@ export const omitInvalidKey = ({ parent, key, prop, changes, path }) => { } if (!isEnum.call(parent, key) && !Array.isArray(parent)) { + // eslint-disable-next-line fp/no-mutating-methods changes.push({ path, oldValue: prop, diff --git a/src/key.test.js b/src/key.test.js index 91064020..d69a2eb1 100644 --- a/src/key.test.js +++ b/src/key.test.js @@ -19,6 +19,7 @@ each( ], }, { + // eslint-disable-next-line fp/no-mutating-methods input: Object.defineProperty({}, 'prop', { value: true, enumerable: false, @@ -36,6 +37,7 @@ each( ], }, { + // eslint-disable-next-line fp/no-mutating-methods input: Object.defineProperty([], '0', { value: true, enumerable: false, diff --git a/src/main.test.js b/src/main.test.js index c6d1acf7..c75739dc 100644 --- a/src/main.test.js +++ b/src/main.test.js @@ -12,6 +12,7 @@ test('Is deep by default on arrays', (t) => { test('Can be shallow on objects', (t) => { const value = { one: 0n } + // eslint-disable-next-line fp/no-mutating-methods Object.defineProperty(value, 'two', { value: true, enumerable: false, diff --git a/src/object.js b/src/object.js index 20374b99..86e5b3af 100644 --- a/src/object.js +++ b/src/object.js @@ -57,6 +57,7 @@ const getNewObject = (object) => // - This mimics `JSON.stringify()` behavior const addClassChange = ({ object, newObject, changes, path }) => { if (!isPlainObj(object)) { + // eslint-disable-next-line fp/no-mutating-methods changes.push({ path, oldValue: object, diff --git a/src/size.js b/src/size.js index a86687d0..c5eaa7cb 100644 --- a/src/size.js +++ b/src/size.js @@ -36,6 +36,7 @@ export const addSize = ({ type, size, maxSize, changes, path, context }) => { return { size: newSize, stop } } + // eslint-disable-next-line fp/no-mutating-methods changes.push({ path, oldValue: getOldValue(context), diff --git a/src/size.test.js b/src/size.test.js index 17312dcc..136f38c5 100644 --- a/src/size.test.js +++ b/src/size.test.js @@ -168,6 +168,7 @@ each( change: { reason: 'ignoredUndefined' }, }, { + // eslint-disable-next-line fp/no-mutating-methods input: Object.defineProperty({}, 'prop', { get: () => { throw error diff --git a/src/to_json.js b/src/to_json.js index a5764e84..15c1e143 100644 --- a/src/to_json.js +++ b/src/to_json.js @@ -18,6 +18,7 @@ export const callToJSON = (value, changes, path) => { try { const toJSONResult = triggerToJSON(value) + // eslint-disable-next-line fp/no-mutating-methods changes.push({ path, oldValue: value, @@ -26,6 +27,7 @@ export const callToJSON = (value, changes, path) => { }) return toJSONResult } catch (error) { + // eslint-disable-next-line fp/no-mutating-methods changes.push({ path, oldValue: value, diff --git a/src/type.js b/src/type.js index d41b3700..ddb70fa2 100644 --- a/src/type.js +++ b/src/type.js @@ -9,6 +9,7 @@ export const omitInvalidTypes = (value, changes, path) => { return value } + // eslint-disable-next-line fp/no-mutating-methods changes.push({ path, oldValue: value, newValue: undefined, reason }) } diff --git a/src/uncaught.js b/src/uncaught.js index 78198ec6..a6497d13 100644 --- a/src/uncaught.js +++ b/src/uncaught.js @@ -20,6 +20,7 @@ export const handleUnsafeException = ({ error, size, }) => { + // eslint-disable-next-line fp/no-mutating-methods changes.push({ path, oldValue: value,