From 70844f4a448ea153c5d1c716c94453e62837cc9e Mon Sep 17 00:00:00 2001 From: amtbsl <147152854+amtbsl@users.noreply.github.com> Date: Sat, 29 Aug 2026 13:33:56 +0800 Subject: [PATCH 1/2] fix: preserve scoped array dependencies --- lib/fixer.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/fixer.js b/lib/fixer.js index 0b8defa..be817ab 100644 --- a/lib/fixer.js +++ b/lib/fixer.js @@ -445,6 +445,12 @@ function depObjectify (deps, type, warn) { deps.filter(function (d) { return typeof d === 'string' }).forEach(function (d) { + d = d.trim() + var scoped = d.match(/^(@[^/\s]+\/[^@/\s><=]+)(.*)$/) + if (scoped) { + o[scoped[1]] = scoped[2].trim().replace(/^@/, '') + return + } d = d.trim().split(/(:?[@\s><=])/) var dn = d.shift() var dv = d.join('') From c40c2b59f3d7696fb9b5d657f82413d5fb583140 Mon Sep 17 00:00:00 2001 From: amtbsl <147152854+amtbsl@users.noreply.github.com> Date: Sat, 29 Aug 2026 13:34:04 +0800 Subject: [PATCH 2/2] test: cover scoped array dependencies --- test/dependencies.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/dependencies.js b/test/dependencies.js index 7e232d4..2f220a7 100644 --- a/test/dependencies.js +++ b/test/dependencies.js @@ -110,6 +110,25 @@ test('warn if dependencies is not an object', function () { ) }) +test('preserve scoped package names in array dependencies', function () { + var warnings = [] + var data = { + dependencies: ['@scope/pkg@^1.2.3'], + } + + normalize(data, function (warning) { + warnings.push(warning) + }) + + assert.deepStrictEqual(data.dependencies, { + '@scope/pkg': '^1.2.3', + }) + assert.ok( + warnings.includes(safeFormat(warningMessages.deprecatedArrayDependencies, 'dependencies')), + 'deprecation warning' + ) +}) + test('safeFormat throws TypeError on falsy argument', function () { assert.throws( () => safeFormat(null),