Linter: apply all recommended biome settings

Enforces previously-skipped useArrowFunction check
This commit is contained in:
Lovell Fuller
2025-11-03 21:14:45 +00:00
parent 09d5aa8cfa
commit 4f9f8179a6
66 changed files with 1823 additions and 1910 deletions

View File

@@ -163,7 +163,7 @@ function bandbool (boolOp) {
* @module Sharp
* @private
*/
module.exports = function (Sharp) {
module.exports = (Sharp) => {
Object.assign(Sharp.prototype, {
// Public instance functions
removeAlpha,

View File

@@ -175,7 +175,7 @@ function _setBackgroundColourOption (key, value) {
* @module Sharp
* @private
*/
module.exports = function (Sharp) {
module.exports = (Sharp) => {
Object.assign(Sharp.prototype, {
// Public
tint,

View File

@@ -206,7 +206,7 @@ function composite (images) {
* @module Sharp
* @private
*/
module.exports = function (Sharp) {
module.exports = (Sharp) => {
Sharp.prototype.composite = composite;
Sharp.blend = blend;
};

View File

@@ -12,6 +12,10 @@ require('./sharp');
// Use NODE_DEBUG=sharp to enable libvips warnings
const debuglog = util.debuglog('sharp');
const queueListener = (queueLength) => {
Sharp.queue.emit('change', queueLength);
};
/**
* Constructor factory to create an instance of `sharp`, to which further methods are chained.
*
@@ -398,9 +402,7 @@ const Sharp = function (input, options) {
debuglog(warning);
},
// Function to notify of queue length changes
queueListener: function (queueLength) {
Sharp.queue.emit('change', queueLength);
}
queueListener
};
this.options.input = this._createInputDescriptor(input, options, { allowStream: true });
return this;

View File

@@ -792,7 +792,7 @@ function stats (callback) {
* @module Sharp
* @private
*/
module.exports = function (Sharp) {
module.exports = (Sharp) => {
Object.assign(Sharp.prototype, {
// Private
_inputOptionsFromObject,

View File

@@ -7,55 +7,43 @@
* Is this value defined and not null?
* @private
*/
const defined = function (val) {
return typeof val !== 'undefined' && val !== null;
};
const defined = (val) => typeof val !== 'undefined' && val !== null;
/**
* Is this value an object?
* @private
*/
const object = function (val) {
return typeof val === 'object';
};
const object = (val) => typeof val === 'object';
/**
* Is this value a plain object?
* @private
*/
const plainObject = function (val) {
return Object.prototype.toString.call(val) === '[object Object]';
};
const plainObject = (val) => Object.prototype.toString.call(val) === '[object Object]';
/**
* Is this value a function?
* @private
*/
const fn = function (val) {
return typeof val === 'function';
};
const fn = (val) => typeof val === 'function';
/**
* Is this value a boolean?
* @private
*/
const bool = function (val) {
return typeof val === 'boolean';
};
const bool = (val) => typeof val === 'boolean';
/**
* Is this value a Buffer object?
* @private
*/
const buffer = function (val) {
return val instanceof Buffer;
};
const buffer = (val) => val instanceof Buffer;
/**
* Is this value a typed array object?. E.g. Uint8Array or Uint8ClampedArray?
* @private
*/
const typedArray = function (val) {
const typedArray = (val) => {
if (defined(val)) {
switch (val.constructor) {
case Uint8Array:
@@ -78,49 +66,37 @@ const typedArray = function (val) {
* Is this value an ArrayBuffer object?
* @private
*/
const arrayBuffer = function (val) {
return val instanceof ArrayBuffer;
};
const arrayBuffer = (val) => val instanceof ArrayBuffer;
/**
* Is this value a non-empty string?
* @private
*/
const string = function (val) {
return typeof val === 'string' && val.length > 0;
};
const string = (val) => typeof val === 'string' && val.length > 0;
/**
* Is this value a real number?
* @private
*/
const number = function (val) {
return typeof val === 'number' && !Number.isNaN(val);
};
const number = (val) => typeof val === 'number' && !Number.isNaN(val);
/**
* Is this value an integer?
* @private
*/
const integer = function (val) {
return Number.isInteger(val);
};
const integer = (val) => Number.isInteger(val);
/**
* Is this value within an inclusive given range?
* @private
*/
const inRange = function (val, min, max) {
return val >= min && val <= max;
};
const inRange = (val, min, max) => val >= min && val <= max;
/**
* Is this value within the elements of an array?
* @private
*/
const inArray = function (val, list) {
return list.includes(val);
};
const inArray = (val, list) => list.includes(val);
/**
* Create an Error with a message relating to an invalid parameter.
@@ -131,11 +107,9 @@ const inArray = function (val, list) {
* @returns {Error} Containing the formatted message.
* @private
*/
const invalidParameterError = function (name, expected, actual) {
return new Error(
const invalidParameterError = (name, expected, actual) => new Error(
`Expected ${expected} for ${name} but received ${actual} of type ${typeof actual}`
);
};
/**
* Ensures an Error from C++ contains a JS stack.
@@ -145,7 +119,7 @@ const invalidParameterError = function (name, expected, actual) {
* @returns {Error} Error with message and stack.
* @private
*/
const nativeError = function (native, context) {
const nativeError = (native, context) => {
context.message = native.message;
return context;
};

View File

@@ -742,9 +742,7 @@ function convolve (kernel) {
}
// Default scale is sum of kernel values
if (!is.integer(kernel.scale)) {
kernel.scale = kernel.kernel.reduce(function (a, b) {
return a + b;
}, 0);
kernel.scale = kernel.kernel.reduce((a, b) => a + b, 0);
}
// Clip scale to a minimum value of 1
if (kernel.scale < 1) {
@@ -989,7 +987,7 @@ function modulate (options) {
* @module Sharp
* @private
*/
module.exports = function (Sharp) {
module.exports = (Sharp) => {
Object.assign(Sharp.prototype, {
autoOrient,
rotate,

View File

@@ -1623,7 +1623,7 @@ function _pipeline (callback, stack) {
* @module Sharp
* @private
*/
module.exports = function (Sharp) {
module.exports = (Sharp) => {
Object.assign(Sharp.prototype, {
// Public
toFile,

View File

@@ -579,7 +579,7 @@ function trim (options) {
* @module Sharp
* @private
*/
module.exports = function (Sharp) {
module.exports = (Sharp) => {
Object.assign(Sharp.prototype, {
resize,
extend,

View File

@@ -277,7 +277,7 @@ function unblock (options) {
* @module Sharp
* @private
*/
module.exports = function (Sharp) {
module.exports = (Sharp) => {
Sharp.cache = cache;
Sharp.concurrency = concurrency;
Sharp.counters = counters;