Switch linter from semistandard to biome

Uses the recommended rules apart from complexity/useArrowFunction,
which would affect about 1700 lines of code with little benefit
right now. This is something that can be addressed over time.
This commit is contained in:
Lovell Fuller
2025-09-17 16:47:33 +01:00
parent a0af662d78
commit b36237ddcb
85 changed files with 238 additions and 375 deletions

View File

@@ -1,8 +1,6 @@
// Copyright 2013 Lovell Fuller and others.
// SPDX-License-Identifier: Apache-2.0
'use strict';
const is = require('./is');
/**

View File

@@ -1,8 +1,6 @@
// Copyright 2013 Lovell Fuller and others.
// SPDX-License-Identifier: Apache-2.0
'use strict';
const color = require('@img/colour');
const is = require('./is');

View File

@@ -1,8 +1,6 @@
// Copyright 2013 Lovell Fuller and others.
// SPDX-License-Identifier: Apache-2.0
'use strict';
const is = require('./is');
/**

View File

@@ -1,8 +1,6 @@
// Copyright 2013 Lovell Fuller and others.
// SPDX-License-Identifier: Apache-2.0
'use strict';
const util = require('node:util');
const stream = require('node:stream');
const is = require('./is');
@@ -205,6 +203,7 @@ const debuglog = util.debuglog('sharp');
* @throws {Error} Invalid parameters
*/
const Sharp = function (input, options) {
// biome-ignore lint/complexity/noArguments: constructor factory
if (arguments.length === 1 && !is.defined(input)) {
throw new Error('Invalid input');
}

2
lib/index.d.ts vendored
View File

@@ -27,7 +27,7 @@
/// <reference types="node" />
import { Duplex } from 'stream';
import type { Duplex } from 'node:stream';
//#region Constructor functions

View File

@@ -1,8 +1,6 @@
// Copyright 2013 Lovell Fuller and others.
// SPDX-License-Identifier: Apache-2.0
'use strict';
const Sharp = require('./constructor');
require('./input')(Sharp);
require('./resize')(Sharp);

View File

@@ -1,8 +1,6 @@
// Copyright 2013 Lovell Fuller and others.
// SPDX-License-Identifier: Apache-2.0
'use strict';
const is = require('./is');
const sharp = require('./sharp');
@@ -54,7 +52,7 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
const inputDescriptor = {
autoOrient: false,
failOn: 'warning',
limitInputPixels: Math.pow(0x3FFF, 2),
limitInputPixels: 0x3FFF ** 2,
ignoreIcc: false,
unlimited: false,
sequentialRead: true
@@ -150,7 +148,7 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
if (is.defined(inputOptions.limitInputPixels)) {
if (is.bool(inputOptions.limitInputPixels)) {
inputDescriptor.limitInputPixels = inputOptions.limitInputPixels
? Math.pow(0x3FFF, 2)
? 0x3FFF ** 2
: 0;
} else if (is.integer(inputOptions.limitInputPixels) && is.inRange(inputOptions.limitInputPixels, 0, Number.MAX_SAFE_INTEGER)) {
inputDescriptor.limitInputPixels = inputOptions.limitInputPixels;
@@ -513,7 +511,7 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
}
}
} else if (is.defined(inputOptions)) {
throw new Error('Invalid input options ' + inputOptions);
throw new Error(`Invalid input options ${inputOptions}`);
}
return inputDescriptor;
}
@@ -525,7 +523,7 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
* @param {string} encoding - unused
* @param {Function} callback
*/
function _write (chunk, encoding, callback) {
function _write (chunk, _encoding, callback) {
/* istanbul ignore else */
if (Array.isArray(this.options.input.buffer)) {
/* istanbul ignore else */

View File

@@ -1,8 +1,6 @@
// Copyright 2013 Lovell Fuller and others.
// SPDX-License-Identifier: Apache-2.0
'use strict';
/**
* Is this value defined and not null?
* @private

View File

@@ -1,8 +1,6 @@
// Copyright 2013 Lovell Fuller and others.
// SPDX-License-Identifier: Apache-2.0
'use strict';
const { spawnSync } = require('node:child_process');
const { createHash } = require('node:crypto');
const semverCoerce = require('semver/functions/coerce');
@@ -96,7 +94,7 @@ const isUnsupportedNodeRuntime = () => {
/* istanbul ignore next */
const isEmscripten = () => {
const { CC } = process.env;
return Boolean(CC && CC.endsWith('/emcc'));
return Boolean(CC?.endsWith('/emcc'));
};
const isRosetta = () => {

View File

@@ -1,8 +1,6 @@
// Copyright 2013 Lovell Fuller and others.
// SPDX-License-Identifier: Apache-2.0
'use strict';
const is = require('./is');
/**

View File

@@ -1,8 +1,6 @@
// Copyright 2013 Lovell Fuller and others.
// SPDX-License-Identifier: Apache-2.0
'use strict';
const path = require('node:path');
const is = require('./is');
const sharp = require('./sharp');

View File

@@ -1,8 +1,6 @@
// Copyright 2013 Lovell Fuller and others.
// SPDX-License-Identifier: Apache-2.0
'use strict';
const is = require('./is');
/**

View File

@@ -1,8 +1,6 @@
// Copyright 2013 Lovell Fuller and others.
// SPDX-License-Identifier: Apache-2.0
'use strict';
// Inspects the runtime environment and exports the relevant sharp.node binary
const { familySync, versionSync } = require('detect-libc');
@@ -88,7 +86,7 @@ if (sharp) {
` Found ${libcFound}`,
` Requires ${libcRequires}`
);
} catch (errEngines) {}
} catch (_errEngines) {}
}
if (isLinux && /\/snap\/core[0-9]{2}/.test(messages)) {
help.push(

View File

@@ -1,8 +1,6 @@
// Copyright 2013 Lovell Fuller and others.
// SPDX-License-Identifier: Apache-2.0
'use strict';
const events = require('node:events');
const detectLibc = require('detect-libc');