diff --git a/lib/postinstall/update-package.js b/lib/postinstall/update-package.js index 7e222166..e7b89ac9 100644 --- a/lib/postinstall/update-package.js +++ b/lib/postinstall/update-package.js @@ -79,6 +79,14 @@ const patchPackage = async (path, root, config) => { if (pkg.content.templateVersion) { update.templateVersion = undefined } + if (pkg.content.scripts && pkg.content.scripts['lint:fix']) { + // some old packages using standard had a lint:fix script + delete update.scripts['lint:fix'] + } + if (pkg.content.standard) { + // remove standard configuration if it exists + update.standard = undefined + } } pkg.update(update) diff --git a/lib/postlint/check-package.js b/lib/postlint/check-package.js index 869430eb..07ffe4eb 100644 --- a/lib/postlint/check-package.js +++ b/lib/postlint/check-package.js @@ -6,6 +6,7 @@ const unwantedPackages = [ 'eslint-plugin-promise', 'eslint-plugin-standard', 'eslint-plugin-import', + 'standard', ] const hasOwn = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key) diff --git a/tap-snapshots/test/postlint/check-package.js.test.cjs b/tap-snapshots/test/postlint/check-package.js.test.cjs index b130d542..f305198c 100644 --- a/tap-snapshots/test/postlint/check-package.js.test.cjs +++ b/tap-snapshots/test/postlint/check-package.js.test.cjs @@ -78,8 +78,9 @@ Array [ eslint-plugin-promise eslint-plugin-standard eslint-plugin-import + standard ), - "solution": "npm rm @npmcli/lint eslint-plugin-promise eslint-plugin-standard eslint-plugin-import", + "solution": "npm rm @npmcli/lint eslint-plugin-promise eslint-plugin-standard eslint-plugin-import standard", }, ] ` diff --git a/test/postinstall/update-package.js b/test/postinstall/update-package.js index 68d73409..5608f9b3 100644 --- a/test/postinstall/update-package.js +++ b/test/postinstall/update-package.js @@ -161,3 +161,29 @@ t.test('converts template Version', async (t) => { t.equal(contents.templateVersion, undefined, 'did not get template version') t.equal(contents.templateOSS.version, TEMPLATE_VERSION, 'did not get template version') }) + +t.test('removes standard', async (t) => { + const pkg = { + name: 'testpkg', + scripts: { + test: 'test', + 'lint:fix': 'something', + }, + standard: { + ignore: [], + }, + } + + const project = t.testdir({ + 'package.json': JSON.stringify(pkg, null, 2), + }) + + const needsAction = await patchPackage(project) + t.equal(needsAction, true, 'needs action') + + const contents = JSON.parse(await fs.readFile(join(project, 'package.json'), { + encoding: 'utf8', + })) + t.equal(contents.standard, undefined, 'removed standard') + t.equal(contents.scripts['lint:fix'], undefined, 'removes lint:fix script') +})