From b36237ddcbc5b9bbdc9c94e7d71989fd57b4f76a Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Wed, 17 Sep 2025 16:47:33 +0100 Subject: [PATCH] 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. --- .editorconfig | 4 +--- .github/workflows/ci.yml | 2 +- biome.json | 29 +++++++++++++++++++++++++++ docs/astro.config.mjs | 2 +- docs/build.mjs | 2 -- install/check.js | 6 ++---- lib/channel.js | 2 -- lib/colour.js | 2 -- lib/composite.js | 2 -- lib/constructor.js | 3 +-- lib/index.d.ts | 2 +- lib/index.js | 2 -- lib/input.js | 10 ++++------ lib/is.js | 2 -- lib/libvips.js | 4 +--- lib/operation.js | 2 -- lib/output.js | 2 -- lib/resize.js | 2 -- lib/sharp.js | 4 +--- lib/utility.js | 2 -- npm/from-local-build.js | 2 -- package.json | 9 ++------- test/beforeEach.js | 2 -- test/bench/parallel.js | 13 +++++-------- test/bench/perf.js | 22 ++++++++++----------- test/bench/random.js | 6 ++---- test/fixtures/index.js | 10 ++++------ test/types/sharp.test-d.ts | 7 +++++-- test/unit/affine.js | 4 +--- test/unit/alpha.js | 12 +++++------- test/unit/avif.js | 24 +++++++++++------------ test/unit/bandbool.js | 10 ++++------ test/unit/blur.js | 4 +--- test/unit/boolean.js | 18 ++++++++--------- test/unit/clahe.js | 4 +--- test/unit/clone.js | 6 ++---- test/unit/colourspace.js | 4 +--- test/unit/composite.js | 8 +++----- test/unit/convolve.js | 4 +--- test/unit/dilate.js | 4 +--- test/unit/erode.js | 4 +--- test/unit/extend.js | 4 +--- test/unit/extract.js | 4 +--- test/unit/extractChannel.js | 4 +--- test/unit/failOn.js | 8 +++----- test/unit/fixtures.js | 4 +--- test/unit/gamma.js | 4 +--- test/unit/gif.js | 6 ++---- test/unit/heif.js | 4 +--- test/unit/io.js | 39 ++++++++++++++----------------------- test/unit/join.js | 4 +--- test/unit/joinChannel.js | 6 ++---- test/unit/jp2.js | 6 ++---- test/unit/jpeg.js | 4 +--- test/unit/jxl.js | 4 +--- test/unit/libvips.js | 6 ++---- test/unit/linear.js | 12 +++++------- test/unit/median.js | 4 +--- test/unit/metadata.js | 8 +++----- test/unit/modulate.js | 4 +--- test/unit/negate.js | 6 ++---- test/unit/noise.js | 4 +--- test/unit/normalize.js | 16 +++++++-------- test/unit/png.js | 7 +++---- test/unit/raw.js | 32 ++++++++++++++---------------- test/unit/recomb.js | 4 +--- test/unit/resize-contain.js | 4 +--- test/unit/resize-cover.js | 4 +--- test/unit/resize.js | 12 +++++------- test/unit/rotate.js | 20 +++++++++---------- test/unit/sharpen.js | 4 +--- test/unit/stats.js | 12 +++++------- test/unit/svg.js | 6 ++---- test/unit/text.js | 4 +--- test/unit/threshold.js | 6 ++---- test/unit/tiff.js | 6 ++---- test/unit/tile.js | 36 ++++++++++++++++------------------ test/unit/timeout.js | 4 +--- test/unit/tint.js | 4 +--- test/unit/toBuffer.js | 4 +--- test/unit/toFormat.js | 4 +--- test/unit/trim.js | 4 +--- test/unit/unflatten.js | 2 -- test/unit/util.js | 4 +--- test/unit/webp.js | 6 ++---- 85 files changed, 238 insertions(+), 375 deletions(-) create mode 100644 biome.json diff --git a/.editorconfig b/.editorconfig index 5760be58..62fb51fe 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,6 +7,4 @@ indent_size = 2 charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true - -[*.md] -trim_trailing_whitespace = false +max_line_length = 120 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b777acb9..c815127f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/setup-node@v5 with: node-version: "24" - - run: npm install --ignore-scripts --omit=optional + - run: npm install --ignore-scripts - run: npm run lint-cpp - run: npm run lint-js - run: npm run lint-licensing diff --git a/biome.json b/biome.json new file mode 100644 index 00000000..2ed1c104 --- /dev/null +++ b/biome.json @@ -0,0 +1,29 @@ +{ + "$schema": "https://biomejs.dev/schemas/2.2.4/schema.json", + "vcs": { + "enabled": true, + "clientKind": "git", + "useIgnoreFile": true + }, + "files": { + "ignoreUnknown": true + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "complexity": { + "useArrowFunction": "off" + } + } + }, + "formatter": { + "enabled": false, + "useEditorconfig": true + }, + "javascript": { + "formatter": { + "quoteStyle": "single" + } + } +} diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs index 49b1c00e..2209c338 100644 --- a/docs/astro.config.mjs +++ b/docs/astro.config.mjs @@ -1,6 +1,6 @@ // @ts-check -import { defineConfig } from 'astro/config'; import starlight from '@astrojs/starlight'; +import { defineConfig } from 'astro/config'; import starlightAutoSidebar from 'starlight-auto-sidebar'; import { version } from '../package.json'; diff --git a/docs/build.mjs b/docs/build.mjs index de4d8b71..522e6cd9 100644 --- a/docs/build.mjs +++ b/docs/build.mjs @@ -1,8 +1,6 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - import fs from 'node:fs/promises'; import path from 'node:path'; import jsdoc2md from 'jsdoc-to-markdown'; diff --git a/install/check.js b/install/check.js index 0e00133a..8e96da86 100644 --- a/install/check.js +++ b/install/check.js @@ -1,8 +1,6 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - try { const { useGlobalLibvips, globalLibvipsVersion, log, spawnRebuild } = require('../lib/libvips'); @@ -12,14 +10,14 @@ try { try { const addonApi = require('node-addon-api'); log(`Found node-addon-api ${addonApi.version || ''}`); - } catch (err) { + } catch (_err) { log('Please add node-addon-api to your dependencies'); return; } try { const gyp = require('node-gyp'); log(`Found node-gyp ${gyp().version}`); - } catch (err) { + } catch (_err) { log('Please add node-gyp to your dependencies'); return; } diff --git a/lib/channel.js b/lib/channel.js index b6381ae9..bb1368cb 100644 --- a/lib/channel.js +++ b/lib/channel.js @@ -1,8 +1,6 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - const is = require('./is'); /** diff --git a/lib/colour.js b/lib/colour.js index e17b77bd..8de8d332 100644 --- a/lib/colour.js +++ b/lib/colour.js @@ -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'); diff --git a/lib/composite.js b/lib/composite.js index 98f8aefe..1d41ba9d 100644 --- a/lib/composite.js +++ b/lib/composite.js @@ -1,8 +1,6 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - const is = require('./is'); /** diff --git a/lib/constructor.js b/lib/constructor.js index a349f42a..82acbd08 100644 --- a/lib/constructor.js +++ b/lib/constructor.js @@ -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'); } diff --git a/lib/index.d.ts b/lib/index.d.ts index 41236345..83e010d8 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -27,7 +27,7 @@ /// -import { Duplex } from 'stream'; +import type { Duplex } from 'node:stream'; //#region Constructor functions diff --git a/lib/index.js b/lib/index.js index 8cfc08a8..cb632edf 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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); diff --git a/lib/input.js b/lib/input.js index aca0b16c..f6a86922 100644 --- a/lib/input.js +++ b/lib/input.js @@ -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 */ diff --git a/lib/is.js b/lib/is.js index a63cb206..c61b6bbd 100644 --- a/lib/is.js +++ b/lib/is.js @@ -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 diff --git a/lib/libvips.js b/lib/libvips.js index 1bab0ca5..96edde12 100644 --- a/lib/libvips.js +++ b/lib/libvips.js @@ -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 = () => { diff --git a/lib/operation.js b/lib/operation.js index f76f65dc..824da911 100644 --- a/lib/operation.js +++ b/lib/operation.js @@ -1,8 +1,6 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - const is = require('./is'); /** diff --git a/lib/output.js b/lib/output.js index f1cdaf84..65321559 100644 --- a/lib/output.js +++ b/lib/output.js @@ -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'); diff --git a/lib/resize.js b/lib/resize.js index 9e4aa78a..287d0ae3 100644 --- a/lib/resize.js +++ b/lib/resize.js @@ -1,8 +1,6 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - const is = require('./is'); /** diff --git a/lib/sharp.js b/lib/sharp.js index 78853e95..8a90d826 100644 --- a/lib/sharp.js +++ b/lib/sharp.js @@ -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( diff --git a/lib/utility.js b/lib/utility.js index 4b11892d..d91605e5 100644 --- a/lib/utility.js +++ b/lib/utility.js @@ -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'); diff --git a/npm/from-local-build.js b/npm/from-local-build.js index 2fee2db9..76719cb3 100644 --- a/npm/from-local-build.js +++ b/npm/from-local-build.js @@ -1,8 +1,6 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - // Populate the npm package for the current platform with the local build const { copyFileSync, cpSync, readFileSync, writeFileSync, appendFileSync } = require('node:fs'); diff --git a/package.json b/package.json index 82f92e04..4dd62386 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,7 @@ "test": "npm run lint && npm run test-unit", "lint": "npm run lint-cpp && npm run lint-js && npm run lint-licensing && npm run lint-types", "lint-cpp": "cpplint", - "lint-js": "semistandard", + "lint-js": "biome lint", "lint-licensing": "license-checker --production --summary --onlyAllow=\"Apache-2.0;BSD;ISC;LGPL-3.0-or-later;MIT\"", "lint-types": "tsd", "test-leak": "./test/leak/leak.sh", @@ -168,6 +168,7 @@ "@img/sharp-win32-x64": "0.34.4" }, "devDependencies": { + "@biomejs/biome": "^2.2.4", "@emnapi/runtime": "^1.5.0", "@img/sharp-libvips-dev": "1.2.3", "@img/sharp-libvips-dev-wasm32": "1.2.3", @@ -186,7 +187,6 @@ "node-addon-api": "^8.5.0", "node-gyp": "^11.4.2", "nyc": "^17.1.0", - "semistandard": "^17.0.0", "tar-fs": "^3.1.1", "tsd": "^0.33.0" }, @@ -200,11 +200,6 @@ "funding": { "url": "https://opencollective.com/libvips" }, - "semistandard": { - "env": [ - "mocha" - ] - }, "cc": { "linelength": "120", "filter": [ diff --git a/test/beforeEach.js b/test/beforeEach.js index 5a4d4fea..586869fe 100644 --- a/test/beforeEach.js +++ b/test/beforeEach.js @@ -1,8 +1,6 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - const sharp = require('../'); const usingCache = !process.env.G_DEBUG; diff --git a/test/bench/parallel.js b/test/bench/parallel.js index 5c2568c5..7f2c4aaa 100644 --- a/test/bench/parallel.js +++ b/test/bench/parallel.js @@ -1,11 +1,9 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - process.env.UV_THREADPOOL_SIZE = 64; -const assert = require('assert'); +const assert = require('node:assert'); const async = require('async'); const sharp = require('../../'); @@ -21,13 +19,12 @@ const timer = setInterval(function () { }, 100); async.mapSeries([1, 1, 2, 4, 8, 16, 32, 64], function (parallelism, next) { - const start = new Date().getTime(); + const start = Date.now(); async.times(parallelism, - function (id, callback) { - /* jslint unused: false */ + function (_id, callback) { sharp(fixtures.inputJpg).resize(width, height).toBuffer(function (err, buffer) { buffer = null; - callback(err, new Date().getTime() - start); + callback(err, Date.now() - start); }); }, function (err, ids) { @@ -37,7 +34,7 @@ async.mapSeries([1, 1, 2, 4, 8, 16, 32, 64], function (parallelism, next) { const mean = ids.reduce(function (a, b) { return a + b; }) / ids.length; - console.log(parallelism + ' parallel calls: fastest=' + ids[0] + 'ms slowest=' + ids[ids.length - 1] + 'ms mean=' + mean + 'ms'); + console.log(`${parallelism} parallel calls: fastest=${ids[0]}ms slowest=${ids[ids.length - 1]}ms mean=${mean}ms`); next(); } ); diff --git a/test/bench/perf.js b/test/bench/perf.js index eef42808..c10802c7 100644 --- a/test/bench/perf.js +++ b/test/bench/perf.js @@ -1,10 +1,8 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const fs = require('fs'); -const { execSync } = require('child_process'); +const fs = require('node:fs'); +const { execSync } = require('node:child_process'); const async = require('async'); const Benchmark = require('benchmark'); @@ -12,7 +10,7 @@ const Benchmark = require('benchmark'); const safeRequire = (name) => { try { return require(name); - } catch (err) {} + } catch (_err) {} return null; }; @@ -280,7 +278,7 @@ async.series({ }); } }).on('cycle', function (event) { - console.log('jpeg ' + String(event.target)); + console.log(`jpeg ${String(event.target)}`); }).on('complete', function () { callback(null, this.filter('fastest').map('name')); }).run(); @@ -505,7 +503,7 @@ async.series({ }); } }).on('cycle', function (event) { - console.log('operations ' + String(event.target)); + console.log(`operations ${String(event.target)}`); }).on('complete', function () { callback(null, this.filter('fastest').map('name')); }).run(); @@ -579,7 +577,7 @@ async.series({ }); } }).on('cycle', function (event) { - console.log('kernels ' + String(event.target)); + console.log(`kernels ${String(event.target)}`); }).on('complete', function () { callback(null, this.filter('fastest').map('name')); }).run(); @@ -735,7 +733,7 @@ async.series({ sharp(inputPngBuffer) .resize(width, heightPng) .png({ compressionLevel: 6 }) - .toBuffer(function (err, data) { + .toBuffer(function (err) { if (err) { throw err; } else { @@ -820,7 +818,7 @@ async.series({ } }); pngSuite.on('cycle', function (event) { - console.log(' png ' + String(event.target)); + console.log(` png ${String(event.target)}`); }).on('complete', function () { callback(null, this.filter('fastest').map('name')); }).run(); @@ -881,7 +879,7 @@ async.series({ }); } }).on('cycle', function (event) { - console.log('webp ' + String(event.target)); + console.log(`webp ${String(event.target)}`); }).on('complete', function () { callback(null, this.filter('fastest').map('name')); }).run(); @@ -892,7 +890,7 @@ async.series({ } Object.keys(results).forEach(function (format) { if (results[format].toString().substr(0, 5) !== 'sharp') { - console.log('sharp was slower than ' + results[format] + ' for ' + format); + console.log(`sharp was slower than ${results[format]} for ${format}`); } }); console.dir(sharp.cache()); diff --git a/test/bench/random.js b/test/bench/random.js index 6c6a2378..fa575d35 100644 --- a/test/bench/random.js +++ b/test/bench/random.js @@ -1,11 +1,9 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - const imagemagick = require('imagemagick'); const gm = require('gm'); -const assert = require('assert'); +const assert = require('node:assert'); const Benchmark = require('benchmark'); const sharp = require('../../'); @@ -73,5 +71,5 @@ new Benchmark.Suite('random').add('imagemagick', { console.log(String(event.target)); }).on('complete', function () { const winner = this.filter('fastest').map('name'); - assert.strictEqual('sharp', String(winner), 'sharp was slower than ' + winner); + assert.strictEqual('sharp', String(winner), `sharp was slower than ${winner}`); }).run(); diff --git a/test/fixtures/index.js b/test/fixtures/index.js index b69d6465..153eb37b 100644 --- a/test/fixtures/index.js +++ b/test/fixtures/index.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const path = require('path'); +const path = require('node:path'); const sharp = require('../../'); const maxColourDistance = require('../../lib/sharp')._maxColourDistance; @@ -196,10 +194,10 @@ module.exports = { assertMaxColourDistance: function (actualImagePath, expectedImagePath, acceptedDistance) { if (typeof actualImagePath !== 'string') { - throw new TypeError('`actualImagePath` must be a string; got ' + actualImagePath); + throw new TypeError(`\`actualImagePath\` must be a string; got ${actualImagePath}`); } if (typeof expectedImagePath !== 'string') { - throw new TypeError('`expectedImagePath` must be a string; got ' + expectedImagePath); + throw new TypeError(`\`expectedImagePath\` must be a string; got ${expectedImagePath}`); } if (typeof acceptedDistance !== 'number') { // Default threshold @@ -207,7 +205,7 @@ module.exports = { } const distance = maxColourDistance(actualImagePath, expectedImagePath); if (distance > acceptedDistance) { - throw new Error('Expected maximum absolute distance of ' + acceptedDistance + ', actual ' + distance); + throw new Error(`Expected maximum absolute distance of ${acceptedDistance}, actual ${distance}`); } } diff --git a/test/types/sharp.test-d.ts b/test/types/sharp.test-d.ts index 27e5ec46..9c6e7850 100644 --- a/test/types/sharp.test-d.ts +++ b/test/types/sharp.test-d.ts @@ -1,6 +1,9 @@ +// biome-ignore-all lint/correctness/noUnusedFunctionParameters: types only test file +// biome-ignore-all lint/correctness/noUnusedVariables: types only test file + import sharp = require('../../'); -import { createReadStream, createWriteStream } from 'fs'; +import { createReadStream, createWriteStream } from 'node:fs'; const input: Buffer = Buffer.alloc(0); const readableStream: NodeJS.ReadableStream = createReadStream(input); @@ -79,7 +82,7 @@ sharp({ let transformer = sharp() .resize(300) .on('info', (info: sharp.OutputInfo) => { - console.log('Image height is ' + info.height); + console.log(`Image height is ${info.height}`); }); readableStream.pipe(transformer).pipe(writableStream); diff --git a/test/unit/affine.js b/test/unit/affine.js index 2122f007..6ff523be 100644 --- a/test/unit/affine.js +++ b/test/unit/affine.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/alpha.js b/test/unit/alpha.js index c7c0d6e6..13b3bc27 100644 --- a/test/unit/alpha.js +++ b/test/unit/alpha.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const fixtures = require('../fixtures'); const sharp = require('../../'); @@ -67,7 +65,7 @@ describe('Alpha transparency', function () { it('Do not flatten', function (done) { sharp(fixtures.inputPngWithTransparency) .flatten(false) - .toBuffer(function (err, data, info) { + .toBuffer(function (err, _data, info) { if (err) throw err; assert.strictEqual('png', info.format); assert.strictEqual(4, info.channels); @@ -78,7 +76,7 @@ describe('Alpha transparency', function () { it('Ignored for JPEG', function (done) { sharp(fixtures.inputJpg) .flatten({ background: '#ff0000' }) - .toBuffer(function (err, data, info) { + .toBuffer(function (err, _data, info) { if (err) throw err; assert.strictEqual('jpeg', info.format); assert.strictEqual(3, info.channels); @@ -100,7 +98,7 @@ describe('Alpha transparency', function () { it('Enlargement with non-nearest neighbor interpolation shouldn’t cause dark edges', function () { const base = 'alpha-premultiply-enlargement-2048x1536-paper.png'; - const actual = fixtures.path('output.' + base); + const actual = fixtures.path(`output.${base}`); const expected = fixtures.expected(base); return sharp(fixtures.inputPngAlphaPremultiplicationSmall) .resize(2048, 1536) @@ -112,7 +110,7 @@ describe('Alpha transparency', function () { it('Reduction with non-nearest neighbor interpolation shouldn’t cause dark edges', function () { const base = 'alpha-premultiply-reduction-1024x768-paper.png'; - const actual = fixtures.path('output.' + base); + const actual = fixtures.path(`output.${base}`); const expected = fixtures.expected(base); return sharp(fixtures.inputPngAlphaPremultiplicationLarge) .resize(1024, 768) diff --git a/test/unit/avif.js b/test/unit/avif.js index 9eeb5000..8f3cb606 100644 --- a/test/unit/avif.js +++ b/test/unit/avif.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const { inputAvif, inputJpg, inputGifAnimated } = require('../fixtures'); @@ -20,8 +18,8 @@ describe('AVIF', () => { .resize(32) .jpeg() .toBuffer(); - const { size, ...metadata } = await sharp(data) - .metadata(); + const { size, ...metadata } = await sharp(data).metadata(); + void size; assert.deepStrictEqual(metadata, { autoOrient: { height: 13, @@ -49,8 +47,8 @@ describe('AVIF', () => { .resize(32) .avif({ effort: 0 }) .toBuffer(); - const { size, ...metadata } = await sharp(data) - .metadata(); + const { size, ...metadata } = await sharp(data).metadata(); + void size; assert.deepStrictEqual(metadata, { autoOrient: { height: 26, @@ -77,8 +75,8 @@ describe('AVIF', () => { const data = await sharp(inputAvif) .resize(32) .toBuffer(); - const { size, ...metadata } = await sharp(data) - .metadata(); + const { size, ...metadata } = await sharp(data).metadata(); + void size; assert.deepStrictEqual(metadata, { autoOrient: { height: 13, @@ -106,8 +104,8 @@ describe('AVIF', () => { .resize(10) .avif({ effort: 0 }) .toBuffer(); - const { size, ...metadata } = await sharp(data) - .metadata(); + const { size, ...metadata } = await sharp(data).metadata(); + void size; assert.deepStrictEqual(metadata, { autoOrient: { height: 300, @@ -136,8 +134,8 @@ describe('AVIF', () => { .sharpen() .avif({ effort: 0 }) .toBuffer(); - const { size, ...metadata } = await sharp(data) - .metadata(); + const { size, ...metadata } = await sharp(data).metadata(); + void size; assert.deepStrictEqual(metadata, { autoOrient: { height: 26, diff --git a/test/unit/bandbool.js b/test/unit/bandbool.js index 66ad404c..5fad6590 100644 --- a/test/unit/bandbool.js +++ b/test/unit/bandbool.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const fixtures = require('../fixtures'); const sharp = require('../../'); @@ -14,7 +12,7 @@ describe('Bandbool per-channel boolean operations', function () { sharp.bool.eor ] .forEach(function (op) { - it(op + ' operation', function (done) { + it(`${op} operation`, function (done) { sharp(fixtures.inputPngBooleanNoAlpha) .bandbool(op) .toColourspace('b-w') @@ -23,7 +21,7 @@ describe('Bandbool per-channel boolean operations', function () { assert.strictEqual(200, info.width); assert.strictEqual(200, info.height); assert.strictEqual(1, info.channels); - fixtures.assertSimilar(fixtures.expected('bandbool_' + op + '_result.png'), data, done); + fixtures.assertSimilar(fixtures.expected(`bandbool_${op}_result.png`), data, done); }); }); }); @@ -31,7 +29,7 @@ describe('Bandbool per-channel boolean operations', function () { it('sRGB image retains 3 channels', function (done) { sharp(fixtures.inputJpg) .bandbool('and') - .toBuffer(function (err, data, info) { + .toBuffer(function (err, _data, info) { if (err) throw err; assert.strictEqual(3, info.channels); done(); diff --git a/test/unit/blur.js b/test/unit/blur.js index facff648..efa7163e 100644 --- a/test/unit/blur.js +++ b/test/unit/blur.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/boolean.js b/test/unit/boolean.js index c5fcaf67..e1c3e3f2 100644 --- a/test/unit/boolean.js +++ b/test/unit/boolean.js @@ -1,10 +1,8 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const fs = require('fs'); -const assert = require('assert'); +const fs = require('node:fs'); +const assert = require('node:assert'); const fixtures = require('../fixtures'); const sharp = require('../../'); @@ -18,7 +16,7 @@ describe('Boolean operation between two images', function () { sharp.bool.eor ] .forEach(function (op) { - it(op + ' operation, file', function (done) { + it(`${op} operation, file`, function (done) { sharp(fixtures.inputJpg) .resize(320, 240) .boolean(fixtures.inputJpgBooleanTest, op) @@ -26,11 +24,11 @@ describe('Boolean operation between two images', function () { if (err) throw err; assert.strictEqual(320, info.width); assert.strictEqual(240, info.height); - fixtures.assertSimilar(fixtures.expected('boolean_' + op + '_result.jpg'), data, done); + fixtures.assertSimilar(fixtures.expected(`boolean_${op}_result.jpg`), data, done); }); }); - it(op + ' operation, buffer', function (done) { + it(`${op} operation, buffer`, function (done) { sharp(fixtures.inputJpg) .resize(320, 240) .boolean(inputJpgBooleanTestBuffer, op) @@ -38,11 +36,11 @@ describe('Boolean operation between two images', function () { if (err) throw err; assert.strictEqual(320, info.width); assert.strictEqual(240, info.height); - fixtures.assertSimilar(fixtures.expected('boolean_' + op + '_result.jpg'), data, done); + fixtures.assertSimilar(fixtures.expected(`boolean_${op}_result.jpg`), data, done); }); }); - it(op + ' operation, raw', function (done) { + it(`${op} operation, raw`, function (done) { sharp(fixtures.inputJpgBooleanTest) .raw() .toBuffer(function (err, data, info) { @@ -54,7 +52,7 @@ describe('Boolean operation between two images', function () { if (err) throw err; assert.strictEqual(320, info.width); assert.strictEqual(240, info.height); - fixtures.assertSimilar(fixtures.expected('boolean_' + op + '_result.jpg'), data, done); + fixtures.assertSimilar(fixtures.expected(`boolean_${op}_result.jpg`), data, done); }); }); }); diff --git a/test/unit/clahe.js b/test/unit/clahe.js index 9c93536b..8f459c4b 100644 --- a/test/unit/clahe.js +++ b/test/unit/clahe.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../lib'); const fixtures = require('../fixtures'); diff --git a/test/unit/clone.js b/test/unit/clone.js index 0db81ae5..3ac46cee 100644 --- a/test/unit/clone.js +++ b/test/unit/clone.js @@ -1,10 +1,8 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const fs = require('fs'); -const assert = require('assert'); +const fs = require('node:fs'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/colourspace.js b/test/unit/colourspace.js index 33e4e329..e311f5fe 100644 --- a/test/unit/colourspace.js +++ b/test/unit/colourspace.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/composite.js b/test/unit/composite.js index d748d8f7..c027b027 100644 --- a/test/unit/composite.js +++ b/test/unit/composite.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const fixtures = require('../fixtures'); const sharp = require('../../'); @@ -322,7 +320,7 @@ describe('composite', () => { describe('string gravity', () => { Object.keys(sharp.gravity).forEach(gravity => { it(gravity, done => { - const expected = fixtures.expected('overlay-gravity-' + gravity + '.jpg'); + const expected = fixtures.expected(`overlay-gravity-${gravity}.jpg`); sharp(fixtures.inputJpg) .resize(80) .composite([{ @@ -344,7 +342,7 @@ describe('composite', () => { describe('tile and gravity', () => { Object.keys(sharp.gravity).forEach(gravity => { it(gravity, done => { - const expected = fixtures.expected('overlay-tile-gravity-' + gravity + '.jpg'); + const expected = fixtures.expected(`overlay-tile-gravity-${gravity}.jpg`); sharp(fixtures.inputJpg) .resize(80) .composite([{ diff --git a/test/unit/convolve.js b/test/unit/convolve.js index dfb8dd52..31b2fb3e 100644 --- a/test/unit/convolve.js +++ b/test/unit/convolve.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/dilate.js b/test/unit/dilate.js index 94588a28..eb092a14 100644 --- a/test/unit/dilate.js +++ b/test/unit/dilate.js @@ -1,6 +1,4 @@ -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/erode.js b/test/unit/erode.js index 4d2da81f..1a149305 100644 --- a/test/unit/erode.js +++ b/test/unit/erode.js @@ -1,6 +1,4 @@ -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/extend.js b/test/unit/extend.js index 3ddbd0e1..1c8eb307 100644 --- a/test/unit/extend.js +++ b/test/unit/extend.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/extract.js b/test/unit/extract.js index c2eae90b..53e4f8a0 100644 --- a/test/unit/extract.js +++ b/test/unit/extract.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/extractChannel.js b/test/unit/extractChannel.js index 2d19588a..edb3978c 100644 --- a/test/unit/extractChannel.js +++ b/test/unit/extractChannel.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/failOn.js b/test/unit/failOn.js index 650ba057..48e758c0 100644 --- a/test/unit/failOn.js +++ b/test/unit/failOn.js @@ -1,10 +1,8 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); -const fs = require('fs'); +const assert = require('node:assert'); +const fs = require('node:fs'); const sharp = require('../../lib'); const fixtures = require('../fixtures'); @@ -32,7 +30,7 @@ describe('failOn', () => { isWarningEmitted = true; }) .resize(32, 24) - .toBuffer(function (err, data, info) { + .toBuffer(function (err, _data, info) { if (err) throw err; assert.strictEqual(true, isWarningEmitted); assert.strictEqual('png', info.format); diff --git a/test/unit/fixtures.js b/test/unit/fixtures.js index fb0ee74e..ee398958 100644 --- a/test/unit/fixtures.js +++ b/test/unit/fixtures.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const fixtures = require('../fixtures'); describe('Test fixtures', function () { diff --git a/test/unit/gamma.js b/test/unit/gamma.js index 934a4519..21a33343 100644 --- a/test/unit/gamma.js +++ b/test/unit/gamma.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/gif.js b/test/unit/gif.js index 61a3e199..8ae20e95 100644 --- a/test/unit/gif.js +++ b/test/unit/gif.js @@ -1,10 +1,8 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const fs = require('fs'); -const assert = require('assert'); +const fs = require('node:fs'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/heif.js b/test/unit/heif.js index be304b3d..af3ee62e 100644 --- a/test/unit/heif.js +++ b/test/unit/heif.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); diff --git a/test/unit/io.js b/test/unit/io.js index a2ee4eb5..ed6decaf 100644 --- a/test/unit/io.js +++ b/test/unit/io.js @@ -1,11 +1,9 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const fs = require('fs'); -const path = require('path'); -const assert = require('assert'); +const fs = require('node:fs'); +const path = require('node:path'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); @@ -388,9 +386,8 @@ describe('Input/output', function () { }); it('Fail when output File is input File via Promise', function (done) { - sharp(fixtures.inputJpg).toFile(fixtures.inputJpg).then(function (data) { - assert(false); - done(); + sharp(fixtures.inputJpg).toFile(fixtures.inputJpg).then(function () { + done(new Error('Unexpectedly resolved Promise')); }).catch(function (err) { assert(err instanceof Error); assert.strictEqual('Cannot use same file for input and output', err.message); @@ -409,9 +406,8 @@ describe('Input/output', function () { it('Fail when output File is input File via Promise (relative output, absolute input)', function (done) { const relativePath = path.relative(process.cwd(), fixtures.inputJpg); - sharp(fixtures.inputJpg).toFile(relativePath).then(function (data) { - assert(false); - done(); + sharp(fixtures.inputJpg).toFile(relativePath).then(function () { + done(new Error('Unexpectedly resolved Promise')); }).catch(function (err) { assert(err instanceof Error); assert.strictEqual('Cannot use same file for input and output', err.message); @@ -430,9 +426,8 @@ describe('Input/output', function () { it('Fail when output File is input File via Promise (relative input, absolute output)', function (done) { const relativePath = path.relative(process.cwd(), fixtures.inputJpg); - sharp(relativePath).toFile(fixtures.inputJpg).then(function (data) { - assert(false); - done(); + sharp(relativePath).toFile(fixtures.inputJpg).then(function () { + done(new Error('Unexpectedly resolved Promise')); }).catch(function (err) { assert(err instanceof Error); assert.strictEqual('Cannot use same file for input and output', err.message); @@ -449,9 +444,8 @@ describe('Input/output', function () { }); it('Fail when output File is empty via Promise', function (done) { - sharp(fixtures.inputJpg).toFile('').then(function (data) { - assert(false); - done(); + sharp(fixtures.inputJpg).toFile('').then(function () { + done(new Error('Unexpectedly resolved Promise')); }).catch(function (err) { assert(err instanceof Error); assert.strictEqual('Missing output file path', err.message); @@ -522,7 +516,7 @@ describe('Input/output', function () { try { sharp().toFormat('zoinks'); isValid = true; - } catch (e) {} + } catch (_err) {} assert(!isValid); done(); }); @@ -633,7 +627,7 @@ describe('Input/output', function () { sharp(fixtures.inputJpg) .resize(320, 240) .png({ compressionLevel: 1, force: false }) - .toBuffer(function (err, data, info) { + .toBuffer(function (err, _data, info) { if (err) throw err; assert.strictEqual('jpeg', info.format); assert.strictEqual(320, info.width); @@ -1059,7 +1053,7 @@ describe('Input/output', function () { }); const badPipeline = sharp({ raw: { width: 840, height: 500, channels: 3 } }) .toFormat('jpeg') - .toBuffer(function (err, data, info) { + .toBuffer(function (err) { assert.strictEqual(err.message.indexOf('memory area too small') > 0, true); const readable = fs.createReadStream(fixtures.inputJPGBig); const inPipeline = sharp() @@ -1067,10 +1061,7 @@ describe('Input/output', function () { .raw(); const goodPipeline = sharp({ raw: { width: 840, height: 472, channels: 3 } }) .toFormat('jpeg') - .toBuffer(function (err, data, info) { - if (err) throw err; - done(); - }); + .toBuffer(done); readable.pipe(inPipeline).pipe(goodPipeline); }); readable.pipe(inPipeline).pipe(badPipeline); diff --git a/test/unit/join.js b/test/unit/join.js index 0e14e97e..600ffb9a 100644 --- a/test/unit/join.js +++ b/test/unit/join.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/joinChannel.js b/test/unit/joinChannel.js index acc0e767..42bc2383 100644 --- a/test/unit/joinChannel.js +++ b/test/unit/joinChannel.js @@ -1,10 +1,8 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); -const fs = require('fs'); +const assert = require('node:assert'); +const fs = require('node:fs'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/jp2.js b/test/unit/jp2.js index 3fd2f4a6..30b458ac 100644 --- a/test/unit/jp2.js +++ b/test/unit/jp2.js @@ -1,10 +1,8 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const fs = require('fs'); -const assert = require('assert'); +const fs = require('node:fs'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/jpeg.js b/test/unit/jpeg.js index 6f7ca978..916d2358 100644 --- a/test/unit/jpeg.js +++ b/test/unit/jpeg.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/jxl.js b/test/unit/jxl.js index 32200407..7fcfd75f 100644 --- a/test/unit/jxl.js +++ b/test/unit/jxl.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); diff --git a/test/unit/libvips.js b/test/unit/libvips.js index ded3f8bb..dfd61b26 100644 --- a/test/unit/libvips.js +++ b/test/unit/libvips.js @@ -1,10 +1,8 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); -const fs = require('fs'); +const assert = require('node:assert'); +const fs = require('node:fs'); const semver = require('semver'); const libvips = require('../../lib/libvips'); diff --git a/test/unit/linear.js b/test/unit/linear.js index d668aabd..0ac952f2 100644 --- a/test/unit/linear.js +++ b/test/unit/linear.js @@ -1,12 +1,10 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - const sharp = require('../../'); const fixtures = require('../fixtures'); -const assert = require('assert'); +const assert = require('node:assert'); describe('Linear adjustment', function () { const blackPoint = 70; @@ -17,7 +15,7 @@ describe('Linear adjustment', function () { it('applies linear levels adjustment w/o alpha ch', function (done) { sharp(fixtures.inputJpgWithLowContrast) .linear(a, b) - .toBuffer(function (err, data, info) { + .toBuffer(function (err, data) { if (err) throw err; fixtures.assertSimilar(fixtures.expected('low-contrast-linear.jpg'), data, done); }); @@ -26,7 +24,7 @@ describe('Linear adjustment', function () { it('applies slope level adjustment w/o alpha ch', function (done) { sharp(fixtures.inputJpgWithLowContrast) .linear(a) - .toBuffer(function (err, data, info) { + .toBuffer(function (err, data) { if (err) throw err; fixtures.assertSimilar(fixtures.expected('low-contrast-slope.jpg'), data, done); }); @@ -35,7 +33,7 @@ describe('Linear adjustment', function () { it('applies offset level adjustment w/o alpha ch', function (done) { sharp(fixtures.inputJpgWithLowContrast) .linear(null, b) - .toBuffer(function (err, data, info) { + .toBuffer(function (err, data) { if (err) throw err; fixtures.assertSimilar(fixtures.expected('low-contrast-offset.jpg'), data, done); }); @@ -83,7 +81,7 @@ describe('Linear adjustment', function () { it('per channel level adjustment', function (done) { sharp(fixtures.inputWebP) - .linear([0.25, 0.5, 0.75], [150, 100, 50]).toBuffer(function (err, data, info) { + .linear([0.25, 0.5, 0.75], [150, 100, 50]).toBuffer(function (err, data) { if (err) throw err; fixtures.assertSimilar(fixtures.expected('linear-per-channel.jpg'), data, done); }); diff --git a/test/unit/median.js b/test/unit/median.js index b11ab5d4..227e4c60 100644 --- a/test/unit/median.js +++ b/test/unit/median.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); diff --git a/test/unit/metadata.js b/test/unit/metadata.js index 14f48afa..4b3ee6c5 100644 --- a/test/unit/metadata.js +++ b/test/unit/metadata.js @@ -1,10 +1,8 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const fs = require('fs'); -const assert = require('assert'); +const fs = require('node:fs'); +const assert = require('node:assert'); const exifReader = require('exif-reader'); const icc = require('icc'); @@ -756,7 +754,7 @@ describe('Image metadata', function () { sharp(fixtures.inputJpg) .resize(64) .withIccProfile(fixtures.path('hilutite.icm')) - .toFile(output, function (err, info) { + .toFile(output, function (err) { if (err) throw err; fixtures.assertMaxColourDistance(output, fixtures.expected('hilutite.jpg'), 9); done(); diff --git a/test/unit/modulate.js b/test/unit/modulate.js index 988fc055..04d27281 100644 --- a/test/unit/modulate.js +++ b/test/unit/modulate.js @@ -1,10 +1,8 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - const sharp = require('../../'); -const assert = require('assert'); +const assert = require('node:assert'); const fixtures = require('../fixtures'); describe('Modulate', function () { diff --git a/test/unit/negate.js b/test/unit/negate.js index 646b9b13..c442d7cf 100644 --- a/test/unit/negate.js +++ b/test/unit/negate.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); @@ -104,7 +102,7 @@ describe('Negate', function () { const output = fixtures.path('output.unmodified-by-negate.png'); sharp(fixtures.inputJpgWithLowContrast) .negate(false) - .toFile(output, function (err, info) { + .toFile(output, function (err) { if (err) throw err; fixtures.assertMaxColourDistance(output, fixtures.inputJpgWithLowContrast, 0); done(); diff --git a/test/unit/noise.js b/test/unit/noise.js index ac3a63db..97b8b16f 100644 --- a/test/unit/noise.js +++ b/test/unit/noise.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/normalize.js b/test/unit/normalize.js index d9e62d82..843c01df 100644 --- a/test/unit/normalize.js +++ b/test/unit/normalize.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); @@ -24,7 +22,7 @@ describe('Normalization', function () { sharp(fixtures.inputJpgWithLowContrast) .normalise() .raw() - .toBuffer(function (err, data, info) { + .toBuffer(function (err, data) { if (err) throw err; assertNormalized(data); done(); @@ -36,7 +34,7 @@ describe('Normalization', function () { .greyscale() .normalize() .raw() - .toBuffer(function (err, data, info) { + .toBuffer(function (err, data) { if (err) throw err; assertNormalized(data); done(); @@ -47,7 +45,7 @@ describe('Normalization', function () { sharp(fixtures.inputPngWithGreyAlpha) .normalise() .raw() - .toBuffer(function (err, data, info) { + .toBuffer(function (err, data) { if (err) throw err; assertNormalized(data); done(); @@ -90,7 +88,7 @@ describe('Normalization', function () { const output = fixtures.path('output.unmodified-png-with-one-color.png'); sharp(fixtures.inputPngWithOneColor) .normalize() - .toFile(output, function (err, info) { + .toFile(output, function (err) { if (err) done(err); fixtures.assertMaxColourDistance(output, fixtures.inputPngWithOneColor, 0); done(); @@ -101,7 +99,7 @@ describe('Normalization', function () { sharp(fixtures.inputPngWithTransparency16bit) .normalise() .raw() - .toBuffer(function (err, data, info) { + .toBuffer(function (err, data) { if (err) throw err; assertNormalized(data); done(); @@ -112,7 +110,7 @@ describe('Normalization', function () { sharp(fixtures.inputJpgWithLowContrast) .normalise({ lower: 10, upper: 70 }) .raw() - .toBuffer(function (err, data, info) { + .toBuffer(function (err, data) { if (err) throw err; assertNormalized(data); done(); diff --git a/test/unit/png.js b/test/unit/png.js index 84a74cbc..9e8b4db4 100644 --- a/test/unit/png.js +++ b/test/unit/png.js @@ -1,10 +1,8 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const fs = require('fs'); -const assert = require('assert'); +const fs = require('node:fs'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); @@ -137,6 +135,7 @@ describe('PNG', function () { .toBuffer(); const { size, ...metadata } = await sharp(data).metadata(); + void size; assert.deepStrictEqual(metadata, { autoOrient: { height: 68, diff --git a/test/unit/raw.js b/test/unit/raw.js index 4385288c..28f4d392 100644 --- a/test/unit/raw.js +++ b/test/unit/raw.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); @@ -200,7 +198,7 @@ describe('Raw pixel data', function () { }); writable .jpeg() - .toBuffer(function (err, data, info) { + .toBuffer(function (err, _data, info) { if (err) throw err; assert.strictEqual('jpeg', info.format); assert.strictEqual(32, info.width); @@ -285,20 +283,20 @@ describe('Raw pixel data', function () { }); }); - for (const { constructor, depth, bits } of [ - { constructor: Uint8Array, depth: undefined, bits: 8 }, - { constructor: Uint8Array, depth: 'uchar', bits: 8 }, - { constructor: Uint8ClampedArray, depth: 'uchar', bits: 8 }, - { constructor: Int8Array, depth: 'char', bits: 8 }, - { constructor: Uint16Array, depth: 'ushort', bits: 16 }, - { constructor: Int16Array, depth: 'short', bits: 16 }, - { constructor: Uint32Array, depth: 'uint', bits: 32 }, - { constructor: Int32Array, depth: 'int', bits: 32 }, - { constructor: Float32Array, depth: 'float', bits: 32 }, - { constructor: Float64Array, depth: 'double', bits: 64 } + for (const { type, depth, bits } of [ + { type: Uint8Array, depth: undefined, bits: 8 }, + { type: Uint8Array, depth: 'uchar', bits: 8 }, + { type: Uint8ClampedArray, depth: 'uchar', bits: 8 }, + { type: Int8Array, depth: 'char', bits: 8 }, + { type: Uint16Array, depth: 'ushort', bits: 16 }, + { type: Int16Array, depth: 'short', bits: 16 }, + { type: Uint32Array, depth: 'uint', bits: 32 }, + { type: Int32Array, depth: 'int', bits: 32 }, + { type: Float32Array, depth: 'float', bits: 32 }, + { type: Float64Array, depth: 'double', bits: 64 } ]) { - it(constructor.name, () => - sharp(new constructor(3), { raw: { width: 1, height: 1, channels: 3 } }) + it(type.name, () => + sharp(new type(3), { raw: { width: 1, height: 1, channels: 3 } }) .raw({ depth }) .toBuffer({ resolveWithObject: true }) .then(({ data, info }) => { diff --git a/test/unit/recomb.js b/test/unit/recomb.js index 49959720..b894371a 100644 --- a/test/unit/recomb.js +++ b/test/unit/recomb.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/resize-contain.js b/test/unit/resize-contain.js index 6e7f9ccc..8dcc908c 100644 --- a/test/unit/resize-contain.js +++ b/test/unit/resize-contain.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/resize-cover.js b/test/unit/resize-cover.js index 95ce1b01..b93670d3 100644 --- a/test/unit/resize-cover.js +++ b/test/unit/resize-cover.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/resize.js b/test/unit/resize.js index 255fb15f..b59a049d 100644 --- a/test/unit/resize.js +++ b/test/unit/resize.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); @@ -129,7 +127,7 @@ describe('Resize dimensions', function () { .resize(0x4000, 0x4000) .extract({ top: 0x2000, left: 0x2000, width: 256, height: 256 }) .webp() - .toBuffer(function (err, data, info) { + .toBuffer(function (err, _data, info) { if (err) throw err; assert.strictEqual('webp', info.format); assert.strictEqual(256, info.width); @@ -149,7 +147,7 @@ describe('Resize dimensions', function () { assert.strictEqual(607, info.height); sharp(data) .resize(233, 131) - .toBuffer(function (err, data, info) { + .toBuffer(function (err, _data, info) { if (err) throw err; assert.strictEqual('webp', info.format); assert.strictEqual(233, info.width); @@ -169,7 +167,7 @@ describe('Resize dimensions', function () { sharp(data) .rotate(90) .resize(533, 800) - .toBuffer(function (err, data, info) { + .toBuffer(function (err, _data, info) { if (err) throw err; assert.strictEqual(533, info.width); assert.strictEqual(800, info.height); @@ -660,7 +658,7 @@ describe('Resize dimensions', function () { sharp(fixtures.inputTiff8BitDepth) .resize(210, 210, { kernel: 'nearest' }) .png() - .toBuffer(function (err, data, info) { + .toBuffer(function (err, _data, info) { if (err) throw err; assert.strictEqual(210, info.width); assert.strictEqual(210, info.height); diff --git a/test/unit/rotate.js b/test/unit/rotate.js index 0a7298b6..25303ce8 100644 --- a/test/unit/rotate.js +++ b/test/unit/rotate.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); @@ -173,8 +171,8 @@ describe('Rotation', function () { }); [-3690, -450, -90, 90, 450, 3690].forEach(function (angle) { - it('Rotate by any 90-multiple angle (' + angle + 'deg)', function (done) { - sharp(fixtures.inputJpg320x240).rotate(angle).toBuffer(function (err, data, info) { + it(`Rotate by any 90-multiple angle (${angle}deg)`, function (done) { + sharp(fixtures.inputJpg320x240).rotate(angle).toBuffer(function (err, _data, info) { if (err) throw err; assert.strictEqual(240, info.width); assert.strictEqual(320, info.height); @@ -184,8 +182,8 @@ describe('Rotation', function () { }); [-3750, -510, -150, 30, 390, 3630].forEach(function (angle) { - it('Rotate by any 30-multiple angle (' + angle + 'deg)', function (done) { - sharp(fixtures.inputJpg320x240).rotate(angle).toBuffer(function (err, data, info) { + it(`Rotate by any 30-multiple angle (${angle}deg)`, function (done) { + sharp(fixtures.inputJpg320x240).rotate(angle).toBuffer(function (err, _data, info) { if (err) throw err; assert.strictEqual(397, info.width); assert.strictEqual(368, info.height); @@ -195,8 +193,8 @@ describe('Rotation', function () { }); [-3780, -540, 0, 180, 540, 3780].forEach(function (angle) { - it('Rotate by any 180-multiple angle (' + angle + 'deg)', function (done) { - sharp(fixtures.inputJpg320x240).rotate(angle).toBuffer(function (err, data, info) { + it(`Rotate by any 180-multiple angle (${angle}deg)`, function (done) { + sharp(fixtures.inputJpg320x240).rotate(angle).toBuffer(function (err, _data, info) { if (err) throw err; assert.strictEqual(320, info.width); assert.strictEqual(240, info.height); @@ -446,7 +444,7 @@ describe('Rotation', function () { sharp(fixtures.inputJpg) .rotate(45) .rotate(90) - .toBuffer(function (err, data, info) { + .toBuffer(function (err, _data, info) { if (err) throw err; assert.strictEqual(2225, info.width); assert.strictEqual(2725, info.height); @@ -458,7 +456,7 @@ describe('Rotation', function () { sharp(fixtures.inputJpg) .rotate(90) .rotate(45) - .toBuffer(function (err, data, info) { + .toBuffer(function (err, _data, info) { if (err) throw err; assert.strictEqual(3500, info.width); assert.strictEqual(3500, info.height); diff --git a/test/unit/sharpen.js b/test/unit/sharpen.js index 8d447ba1..78b6f98f 100644 --- a/test/unit/sharpen.js +++ b/test/unit/sharpen.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/stats.js b/test/unit/stats.js index 487e37dd..9f3a73da 100644 --- a/test/unit/stats.js +++ b/test/unit/stats.js @@ -1,10 +1,8 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const fs = require('fs'); -const assert = require('assert'); +const fs = require('node:fs'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); @@ -711,7 +709,7 @@ describe('Image Stats', function () { it('File input with corrupt header fails gracefully, Promise out', function () { return sharp(fixtures.inputJpgWithCorruptHeader) - .stats().then(function (stats) { + .stats().then(function () { throw new Error('Corrupt Header file'); }).catch(function (err) { assert.ok(!!err); @@ -724,7 +722,7 @@ describe('Image Stats', function () { fs.createReadStream(fixtures.inputJpgWithCorruptHeader).pipe(pipeline); return pipeline - .stats().then(function (stats) { + .stats().then(function () { throw new Error('Corrupt Header file'); }).catch(function (err) { assert.ok(!!err); @@ -740,7 +738,7 @@ describe('Image Stats', function () { }); it('Non-existent file in, Promise out', function (done) { - sharp('fail').stats().then(function (stats) { + sharp('fail').stats().then(function () { throw new Error('Non-existent file'); }, function (err) { assert.ok(!!err); diff --git a/test/unit/svg.js b/test/unit/svg.js index 6591cf2d..f79f3efa 100644 --- a/test/unit/svg.js +++ b/test/unit/svg.js @@ -1,10 +1,8 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const fs = require('fs'); -const assert = require('assert'); +const fs = require('node:fs'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/text.js b/test/unit/text.js index 0efe05bc..25885997 100644 --- a/test/unit/text.js +++ b/test/unit/text.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/threshold.js b/test/unit/threshold.js index 1f93d659..acd8add2 100644 --- a/test/unit/threshold.js +++ b/test/unit/threshold.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); @@ -64,7 +62,7 @@ describe('Threshold', function () { it('threshold false (=0)', function (done) { sharp(fixtures.inputJpg) .threshold(false) - .toBuffer(function (err, data, info) { + .toBuffer(function (err, data) { if (err) throw err; fixtures.assertSimilar(fixtures.inputJpg, data, done); }); diff --git a/test/unit/tiff.js b/test/unit/tiff.js index dab8948a..d4243aa5 100644 --- a/test/unit/tiff.js +++ b/test/unit/tiff.js @@ -1,10 +1,8 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const fs = require('fs'); -const assert = require('assert'); +const fs = require('node:fs'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/tile.js b/test/unit/tile.js index 53e91bf5..90381f66 100644 --- a/test/unit/tile.js +++ b/test/unit/tile.js @@ -1,11 +1,9 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const fs = require('fs'); -const path = require('path'); -const assert = require('assert'); +const fs = require('node:fs'); +const path = require('node:path'); +const assert = require('node:assert'); const extractZip = require('extract-zip'); @@ -47,7 +45,7 @@ const assertDeepZoomTiles = function (directory, expectedSize, expectedLevels, d .catch(done); }; -const assertZoomifyTiles = function (directory, expectedTileSize, expectedLevels, done) { +const assertZoomifyTiles = function (directory, expectedLevels, done) { fs.stat(path.join(directory, 'ImageProperties.xml'), function (err, stat) { if (err) throw err; assert.ok(stat.isFile()); @@ -57,7 +55,7 @@ const assertZoomifyTiles = function (directory, expectedTileSize, expectedLevels fs.readdirSync(path.join(directory, 'TileGroup0')).forEach(function (tile) { // Verify tile file name assert.ok(/^[0-9]+-[0-9]+-[0-9]+\.jpg$/.test(tile)); - const level = parseInt(tile.split('-')[0]); + const level = Number(tile.split('-')[0]); maxTileLevel = Math.max(maxTileLevel, level); }); @@ -67,7 +65,7 @@ const assertZoomifyTiles = function (directory, expectedTileSize, expectedLevels }); }; -const assertGoogleTiles = function (directory, expectedTileSize, expectedLevels, done) { +const assertGoogleTiles = function (directory, expectedLevels, done) { // Get levels const dirents = fs.readdirSync(directory, { withFileTypes: true }); const levels = dirents.filter(dirent => dirent.isDirectory()).map(dirent => dirent.name); @@ -411,7 +409,7 @@ describe('Tile', function () { size: 512, depth: 'one' }) - .toFile(fixtures.path('output.512_depth_one.dzi'), function (err, info) { + .toFile(fixtures.path('output.512_depth_one.dzi'), function (err) { if (err) throw err; // Verify only one depth generated assertDeepZoomTiles(directory, 512, 1, done); @@ -427,7 +425,7 @@ describe('Tile', function () { size: 512, depth: 'onepixel' }) - .toFile(fixtures.path('output.512_depth_onepixel.dzi'), function (err, info) { + .toFile(fixtures.path('output.512_depth_onepixel.dzi'), function (err) { if (err) throw err; // Verify only one depth generated assertDeepZoomTiles(directory, 512, 13, done); @@ -443,7 +441,7 @@ describe('Tile', function () { size: 256, depth: 'onetile' }) - .toFile(fixtures.path('output.256_depth_onetile.dzi'), function (err, info) { + .toFile(fixtures.path('output.256_depth_onetile.dzi'), function (err) { if (err) throw err; // Verify only one depth generated assertDeepZoomTiles(directory, 256, 5, done); @@ -459,7 +457,7 @@ describe('Tile', function () { size: 256, skipBlanks: 0 }) - .toFile(fixtures.path('output.256_skip_blanks.dzi'), function (err, info) { + .toFile(fixtures.path('output.256_skip_blanks.dzi'), function (err) { if (err) throw err; // assert them 0_0.jpeg doesn't exist because it's a white tile const whiteTilePath = path.join(directory, '11', '0_0.jpeg'); @@ -510,7 +508,7 @@ describe('Tile', function () { assert.strictEqual(2225, info.height); assert.strictEqual(3, info.channels); assert.strictEqual(undefined, info.size); - assertZoomifyTiles(directory, 256, 1, done); + assertZoomifyTiles(directory, 1, done); }); }); }); @@ -531,7 +529,7 @@ describe('Tile', function () { assert.strictEqual(2225, info.height); assert.strictEqual(3, info.channels); assert.strictEqual(undefined, info.size); - assertZoomifyTiles(directory, 256, 5, done); + assertZoomifyTiles(directory, 5, done); }); }); }); @@ -552,7 +550,7 @@ describe('Tile', function () { assert.strictEqual(2225, info.height); assert.strictEqual(3, info.channels); assert.strictEqual(undefined, info.size); - assertZoomifyTiles(directory, 256, 13, done); + assertZoomifyTiles(directory, 13, done); }); }); }); @@ -576,7 +574,7 @@ describe('Tile', function () { assert.strictEqual(1536, info.height); assert.strictEqual(3, info.channels); assert.strictEqual(undefined, info.size); - assertZoomifyTiles(directory, 256, 4, done); + assertZoomifyTiles(directory, 4, done); }); }); }); @@ -733,7 +731,7 @@ describe('Tile', function () { assert.strictEqual(2225, info.height); assert.strictEqual(3, info.channels); assert.strictEqual(undefined, info.size); - assertGoogleTiles(directory, 256, 1, done); + assertGoogleTiles(directory, 1, done); }); }); }); @@ -754,7 +752,7 @@ describe('Tile', function () { assert.strictEqual(2225, info.height); assert.strictEqual(3, info.channels); assert.strictEqual(undefined, info.size); - assertGoogleTiles(directory, 256, 5, done); + assertGoogleTiles(directory, 5, done); }); }); }); @@ -778,7 +776,7 @@ describe('Tile', function () { assert.strictEqual(2074, info.height); assert.strictEqual(3, info.channels); assert.strictEqual(undefined, info.size); - assertGoogleTiles(directory, 256, 5, done); + assertGoogleTiles(directory, 5, done); }); }); }); diff --git a/test/unit/timeout.js b/test/unit/timeout.js index b80ef263..21782917 100644 --- a/test/unit/timeout.js +++ b/test/unit/timeout.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/tint.js b/test/unit/tint.js index 19f4ae2d..93cf1777 100644 --- a/test/unit/tint.js +++ b/test/unit/tint.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/toBuffer.js b/test/unit/toBuffer.js index 4db428b9..163f284b 100644 --- a/test/unit/toBuffer.js +++ b/test/unit/toBuffer.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/toFormat.js b/test/unit/toFormat.js index a48742db..089a797e 100644 --- a/test/unit/toFormat.js +++ b/test/unit/toFormat.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/trim.js b/test/unit/trim.js index aa559d5a..6261a866 100644 --- a/test/unit/trim.js +++ b/test/unit/trim.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const sharp = require('../../'); const inRange = require('../../lib/is').inRange; diff --git a/test/unit/unflatten.js b/test/unit/unflatten.js index 68147b24..b7941cf5 100644 --- a/test/unit/unflatten.js +++ b/test/unit/unflatten.js @@ -1,8 +1,6 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - const sharp = require('../../'); const fixtures = require('../fixtures'); diff --git a/test/unit/util.js b/test/unit/util.js index ecec8a06..e29109ca 100644 --- a/test/unit/util.js +++ b/test/unit/util.js @@ -1,9 +1,7 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const assert = require('assert'); +const assert = require('node:assert'); const semver = require('semver'); const sharp = require('../../'); diff --git a/test/unit/webp.js b/test/unit/webp.js index c9aae0dd..32f45f4e 100644 --- a/test/unit/webp.js +++ b/test/unit/webp.js @@ -1,10 +1,8 @@ // Copyright 2013 Lovell Fuller and others. // SPDX-License-Identifier: Apache-2.0 -'use strict'; - -const fs = require('fs'); -const assert = require('assert'); +const fs = require('node:fs'); +const assert = require('node:assert'); const sharp = require('../../'); const fixtures = require('../fixtures');