From 903314f4d624307ab8bb9300a1ff30cbe25b4180 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Wed, 17 Mar 2021 23:27:28 +0200 Subject: [PATCH] style: fix --- packages/pkgs-graph/src/index.ts | 4 +-- packages/plugin-commands-audit/src/audit.ts | 2 +- packages/plugin-commands-import/src/import.ts | 2 +- .../plugin-commands-installation/src/add.ts | 2 +- .../src/installDeps.ts | 14 ++++----- .../plugin-commands-installation/src/link.ts | 6 ++-- .../src/recursive.ts | 30 +++++++++---------- .../src/remove.ts | 2 +- .../src/unlink.ts | 4 +-- .../src/update/index.ts | 4 +-- .../src/updateToLatestSpecsFromManifest.ts | 4 +-- packages/plugin-commands-listing/src/list.ts | 4 +-- packages/plugin-commands-listing/src/why.ts | 2 +- .../plugin-commands-outdated/src/outdated.ts | 12 ++++---- .../plugin-commands-publishing/src/publish.ts | 6 ++-- .../src/implementation/index.ts | 10 +++---- .../plugin-commands-rebuild/src/rebuild.ts | 2 +- .../plugin-commands-rebuild/src/recursive.ts | 4 +-- .../plugin-commands-script-runners/src/run.ts | 4 +-- packages/plugin-commands-store/src/store.ts | 2 +- .../plugin-commands-store/src/storeAdd.ts | 4 +-- .../plugin-commands-store/src/storePrune.ts | 4 +-- .../src/storeStatus/index.ts | 4 +-- packages/pnpm/src/checkForUpdates.ts | 2 +- packages/pnpm/src/cmd/index.ts | 2 +- packages/pnpm/src/main.ts | 2 +- packages/pnpm/test/install/selfUpdate.ts | 2 +- 27 files changed, 70 insertions(+), 70 deletions(-) diff --git a/packages/pkgs-graph/src/index.ts b/packages/pkgs-graph/src/index.ts index e25c5dbdc9..b53ea5b804 100644 --- a/packages/pkgs-graph/src/index.ts +++ b/packages/pkgs-graph/src/index.ts @@ -69,7 +69,7 @@ export default function (pkgs: Array, opts?: { if (spec.type === 'directory') { const matchedPkg = R.values(pkgMap).find(pkg => path.relative(pkg.dir, spec.fetchSpec) === '') - if (!matchedPkg) { + if (matchedPkg == null) { return '' } return matchedPkg.dir @@ -78,7 +78,7 @@ export default function (pkgs: Array, opts?: { if (spec.type !== 'version' && spec.type !== 'range') return '' const pkgs = R.values(pkgMap).filter(pkg => pkg.manifest.name === depName) - if (!pkgs.length) return '' + if (pkgs.length === 0) return '' const versions = pkgs.filter(({ manifest }) => manifest.version) .map(pkg => pkg.manifest.version) as string[] diff --git a/packages/plugin-commands-audit/src/audit.ts b/packages/plugin-commands-audit/src/audit.ts index 0eff8c3358..44ddb58879 100644 --- a/packages/plugin-commands-audit/src/audit.ts +++ b/packages/plugin-commands-audit/src/audit.ts @@ -96,7 +96,7 @@ export async function handler ( } & Pick ) { const lockfile = await readWantedLockfile(opts.lockfileDir ?? opts.dir, { ignoreIncompatible: true }) - if (!lockfile) { + if (lockfile == null) { throw new PnpmError('AUDIT_NO_LOCKFILE', `No ${WANTED_LOCKFILE} found: Cannot audit a project without a lockfile`) } const include = { diff --git a/packages/plugin-commands-import/src/import.ts b/packages/plugin-commands-import/src/import.ts index 5e8023f0ae..25bcb4f50e 100644 --- a/packages/plugin-commands-import/src/import.ts +++ b/packages/plugin-commands-import/src/import.ts @@ -84,7 +84,7 @@ function getAllVersionsByPackageNames ( [packageName: string]: Set } ) { - if (!npmPackageLock.dependencies) return + if (npmPackageLock.dependencies == null) return for (const packageName of Object.keys(npmPackageLock.dependencies)) { if (!versionsByPackageNames[packageName]) { versionsByPackageNames[packageName] = new Set() diff --git a/packages/plugin-commands-installation/src/add.ts b/packages/plugin-commands-installation/src/add.ts index bcbd147eb7..f9a6031c22 100644 --- a/packages/plugin-commands-installation/src/add.ts +++ b/packages/plugin-commands-installation/src/add.ts @@ -167,7 +167,7 @@ export async function handler ( if (opts.cliOptions['save'] === false) { throw new PnpmError('OPTION_NOT_SUPPORTED', 'The "add" command currently does not support the no-save option') } - if (!params || !params.length) { + if (!params || (params.length === 0)) { throw new PnpmError('MISSING_PACKAGE_NAME', '`pnpm add` requires the package name') } if ( diff --git a/packages/plugin-commands-installation/src/installDeps.ts b/packages/plugin-commands-installation/src/installDeps.ts index 7707acbfcc..8cf3443fc3 100644 --- a/packages/plugin-commands-installation/src/installDeps.ts +++ b/packages/plugin-commands-installation/src/installDeps.ts @@ -119,7 +119,7 @@ when running add/update with the --workspace option') ) if (opts.workspaceDir) { const selectedProjectsGraph = opts.selectedProjectsGraph ?? selectProjectByDir(allProjects, opts.dir) - if (selectedProjectsGraph) { + if (selectedProjectsGraph != null) { await recursive(allProjects, params, { @@ -172,24 +172,24 @@ when running add/update with the --workspace option') manifest = {} } - const updateMatch = opts.update && params.length ? createMatcher(params) : null - if (updateMatch) { + const updateMatch = opts.update && (params.length > 0) ? createMatcher(params) : null + if (updateMatch != null) { params = matchDependencies(updateMatch, manifest, includeDirect) - if (!params.length) { + if (params.length === 0) { throw new PnpmError('NO_PACKAGE_IN_DEPENDENCIES', 'None of the specified packages were found in the dependencies.') } } if (opts.update && opts.latest) { - if (!params || !params.length) { + if (!params || (params.length === 0)) { params = updateToLatestSpecsFromManifest(manifest, includeDirect) } else { params = createLatestSpecs(params, manifest) } } if (opts.workspace) { - if (!params || !params.length) { + if (!params || (params.length === 0)) { params = updateToWorkspacePackagesFromManifest(manifest, includeDirect, workspacePackages) } else { params = createWorkspaceSpecs(params, workspacePackages) @@ -258,6 +258,6 @@ when running add/update with the --workspace option') function selectProjectByDir (projects: Project[], searchedDir: string) { const project = projects.find(({ dir }) => path.relative(dir, searchedDir) === '') - if (!project) return undefined + if (project == null) return undefined return { [searchedDir]: { dependencies: [], package: project } } } diff --git a/packages/plugin-commands-installation/src/link.ts b/packages/plugin-commands-installation/src/link.ts index e2920c237b..54521d4192 100644 --- a/packages/plugin-commands-installation/src/link.ts +++ b/packages/plugin-commands-installation/src/link.ts @@ -104,7 +104,7 @@ export async function handler ( }) // pnpm link - if (!params || !params.length) { + if ((params == null) || (params.length === 0)) { const { manifest, writeProjectManifest } = await tryReadProjectManifest(opts.dir, opts) const newManifest = await linkToGlobal(cwd, { ...linkOpts, @@ -119,7 +119,7 @@ export async function handler ( const [pkgPaths, pkgNames] = R.partition((inp) => isFilespec.test(inp), params) - if (pkgNames.length) { + if (pkgNames.length > 0) { let globalPkgNames!: string[] if (opts.workspaceDir) { workspacePackagesArr = await findWorkspacePackages(opts.workspaceDir, opts) @@ -128,7 +128,7 @@ export async function handler ( .filter(({ manifest }) => manifest.name && pkgNames.includes(manifest.name)) pkgsFoundInWorkspace.forEach((pkgFromWorkspace) => pkgPaths.push(pkgFromWorkspace.dir)) - if (pkgsFoundInWorkspace.length && !linkOpts.targetDependenciesField) { + if ((pkgsFoundInWorkspace.length > 0) && !linkOpts.targetDependenciesField) { linkOpts.targetDependenciesField = 'dependencies' } diff --git a/packages/plugin-commands-installation/src/recursive.ts b/packages/plugin-commands-installation/src/recursive.ts index 4e49344d95..5ca940e206 100755 --- a/packages/plugin-commands-installation/src/recursive.ts +++ b/packages/plugin-commands-installation/src/recursive.ts @@ -116,7 +116,7 @@ export default async function recursive ( linkWorkspacePackagesDepth: opts.linkWorkspacePackages === 'deep' ? Infinity : opts.linkWorkspacePackages ? 0 : -1, ownLifecycleHooksStdio: 'pipe', peer: opts.savePeer, - pruneLockfileImporters: (!opts.ignoredPackages || opts.ignoredPackages.size === 0) && + pruneLockfileImporters: ((opts.ignoredPackages == null) || opts.ignoredPackages.size === 0) && pkgs.length === allProjects.length, storeController: store.ctrl, storeDir: store.dir, @@ -137,7 +137,7 @@ export default async function recursive ( async function getImporters () { const importers = [] as Array<{ buildIndex: number, manifest: ProjectManifest, rootDir: string }> await Promise.all(chunks.map(async (prefixes: string[], buildIndex) => { - if (opts.ignoredPackages) { + if (opts.ignoredPackages != null) { prefixes = prefixes.filter((prefix) => !opts.ignoredPackages!.has(prefix)) } return Promise.all( @@ -160,7 +160,7 @@ export default async function recursive ( optionalDependencies: true, } - const updateMatch = cmdFullName === 'update' && params.length ? createMatcher(params) : null + const updateMatch = cmdFullName === 'update' && (params.length > 0) ? createMatcher(params) : null // For a workspace with shared lockfile if (opts.lockfileDir && ['add', 'install', 'remove', 'update'].includes(cmdFullName)) { @@ -178,26 +178,26 @@ export default async function recursive ( const modulesDir = localConfig.modulesDir ?? opts.modulesDir const { manifest, writeProjectManifest } = manifestsByPath[rootDir] let currentInput = [...params] - if (updateMatch) { + if (updateMatch != null) { currentInput = matchDependencies(updateMatch, manifest, includeDirect) - if (!currentInput.length && (typeof opts.depth === 'undefined' || opts.depth <= 0)) { + if ((currentInput.length === 0) && (typeof opts.depth === 'undefined' || opts.depth <= 0)) { installOpts.pruneLockfileImporters = false return } } if (updateToLatest) { - if (!params || !params.length) { + if (!params || (params.length === 0)) { currentInput = updateToLatestSpecsFromManifest(manifest, includeDirect) } else { currentInput = createLatestSpecs(currentInput, manifest) - if (!currentInput.length) { + if (currentInput.length === 0) { installOpts.pruneLockfileImporters = false return } } } if (opts.workspace) { - if (!currentInput || !currentInput.length) { + if (!currentInput || (currentInput.length === 0)) { currentInput = updateToWorkspacePackagesFromManifest(manifest, includeDirect, workspacePackages) } else { currentInput = createWorkspaceSpecs(currentInput, workspacePackages) @@ -241,7 +241,7 @@ export default async function recursive ( } as MutatedProject) } })) - if (!mutatedImporters.length && cmdFullName === 'update') { + if ((mutatedImporters.length === 0) && cmdFullName === 'update') { throw new PnpmError('NO_PACKAGE_IN_DEPENDENCIES', 'None of the specified packages were found in the dependencies of any of the projects.') } @@ -274,20 +274,20 @@ export default async function recursive ( const { manifest, writeProjectManifest } = manifestsByPath[rootDir] let currentInput = [...params] - if (updateMatch) { + if (updateMatch != null) { currentInput = matchDependencies(updateMatch, manifest, includeDirect) - if (!currentInput.length) return + if (currentInput.length === 0) return } if (updateToLatest) { - if (!params || !params.length) { + if (!params || (params.length === 0)) { currentInput = updateToLatestSpecsFromManifest(manifest, includeDirect) } else { currentInput = createLatestSpecs(currentInput, manifest) - if (!currentInput.length) return + if (currentInput.length === 0) return } } if (opts.workspace) { - if (!currentInput || !currentInput.length) { + if (!currentInput || (currentInput.length === 0)) { currentInput = updateToWorkspacePackagesFromManifest(manifest, includeDirect, workspacePackages) } else { currentInput = createWorkspaceSpecs(currentInput, workspacePackages) @@ -440,7 +440,7 @@ function calculateRepositoryRoot ( for (const rootDir of projectDirs) { const relativePartRegExp = new RegExp(`^(\\.\\.\\${path.sep})+`) const relativePartMatch = relativePartRegExp.exec(path.relative(workspaceDir, rootDir)) - if (relativePartMatch) { + if (relativePartMatch != null) { const relativePart = relativePartMatch[0] if (relativePart.length > relativeRepoRoot.length) { relativeRepoRoot = relativePart diff --git a/packages/plugin-commands-installation/src/remove.ts b/packages/plugin-commands-installation/src/remove.ts index 9c6264c02b..1d238326e8 100644 --- a/packages/plugin-commands-installation/src/remove.ts +++ b/packages/plugin-commands-installation/src/remove.ts @@ -146,7 +146,7 @@ export async function handler ( params: string[] ) { if (params.length === 0) throw new PnpmError('MUST_REMOVE_SOMETHING', 'At least one dependency name should be specified for removal') - if (opts.recursive && opts.allProjects && opts.selectedProjectsGraph && opts.workspaceDir) { + if (opts.recursive && (opts.allProjects != null) && (opts.selectedProjectsGraph != null) && opts.workspaceDir) { await recursive(opts.allProjects, params, { ...opts, selectedProjectsGraph: opts.selectedProjectsGraph, workspaceDir: opts.workspaceDir }, 'remove') return } diff --git a/packages/plugin-commands-installation/src/unlink.ts b/packages/plugin-commands-installation/src/unlink.ts index 14ef0f48d0..fb95ad0a1d 100644 --- a/packages/plugin-commands-installation/src/unlink.ts +++ b/packages/plugin-commands-installation/src/unlink.ts @@ -57,7 +57,7 @@ export async function handler ( }, params: string[] ) { - if (opts.recursive && opts.allProjects && opts.selectedProjectsGraph && opts.workspaceDir) { + if (opts.recursive && (opts.allProjects != null) && (opts.selectedProjectsGraph != null) && opts.workspaceDir) { await recursive(opts.allProjects, params, { ...opts, selectedProjectsGraph: opts.selectedProjectsGraph, workspaceDir: opts.workspaceDir }, 'unlink') return } @@ -68,7 +68,7 @@ export async function handler ( storeDir: store.dir, }) - if (!params || !params.length) { + if (!params || (params.length === 0)) { return mutateModules([ { dependencyNames: params, diff --git a/packages/plugin-commands-installation/src/update/index.ts b/packages/plugin-commands-installation/src/update/index.ts index 20876fa5c3..9f8c803828 100644 --- a/packages/plugin-commands-installation/src/update/index.ts +++ b/packages/plugin-commands-installation/src/update/index.ts @@ -173,7 +173,7 @@ async function interactiveUpdate ( devDependencies: opts.dev !== false, optionalDependencies: opts.optional !== false, } - const projects = opts.selectedProjectsGraph + const projects = (opts.selectedProjectsGraph != null) ? Object.values(opts.selectedProjectsGraph).map((wsPkg) => wsPkg.package) : [ { @@ -245,7 +245,7 @@ async function update ( depth, includeDirect, update: true, - updateMatching: dependencies.length && dependencies.every(dep => !dep.substring(1).includes('@')) && depth > 0 && !opts.latest + updateMatching: (dependencies.length > 0) && dependencies.every(dep => !dep.substring(1).includes('@')) && depth > 0 && !opts.latest ? matcher(dependencies) : undefined, updatePackageManifest: opts.save !== false, diff --git a/packages/plugin-commands-installation/src/updateToLatestSpecsFromManifest.ts b/packages/plugin-commands-installation/src/updateToLatestSpecsFromManifest.ts index dc9812966b..ebba1c8c68 100644 --- a/packages/plugin-commands-installation/src/updateToLatestSpecsFromManifest.ts +++ b/packages/plugin-commands-installation/src/updateToLatestSpecsFromManifest.ts @@ -11,7 +11,7 @@ export default function updateToLatestSpecsFromManifest (manifest: ProjectManife updateSpecs.push(`${depName}@${removeVersionFromSpec(depVersion)}@latest`) } else { const selector = getVerSelType(depVersion) - if (!selector) continue + if (selector == null) continue updateSpecs.push(`${depName}@latest`) } } @@ -32,7 +32,7 @@ export function createLatestSpecs (specs: string[], manifest: ProjectManifest) { if (allDeps[selector].startsWith('npm:')) { return `${selector}@${removeVersionFromSpec(allDeps[selector])}@latest` } - if (!getVerSelType(allDeps[selector])) { + if (getVerSelType(allDeps[selector]) == null) { return selector } return `${selector}@latest` diff --git a/packages/plugin-commands-listing/src/list.ts b/packages/plugin-commands-listing/src/list.ts index 567e096708..8083752164 100644 --- a/packages/plugin-commands-listing/src/list.ts +++ b/packages/plugin-commands-listing/src/list.ts @@ -134,7 +134,7 @@ export async function handler ( optionalDependencies: opts.optional !== false, } const depth = opts.cliOptions?.['depth'] ?? 0 - if (opts.recursive && opts.selectedProjectsGraph) { + if (opts.recursive && (opts.selectedProjectsGraph != null)) { const pkgs = Object.values(opts.selectedProjectsGraph).map((wsPkg) => wsPkg.package) return listRecursive(pkgs, params, { ...opts, depth, include }) } @@ -168,7 +168,7 @@ export async function render ( // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion reportAs: (opts.parseable ? 'parseable' : (opts.json ? 'json' : 'tree')) as ('parseable' | 'json' | 'tree'), } - return params.length + return (params.length > 0) ? listForPackages(params, prefixes, listOpts) : list(prefixes, listOpts) } diff --git a/packages/plugin-commands-listing/src/why.ts b/packages/plugin-commands-listing/src/why.ts index 88889600a3..5b59a2f2d6 100644 --- a/packages/plugin-commands-listing/src/why.ts +++ b/packages/plugin-commands-listing/src/why.ts @@ -96,7 +96,7 @@ export async function handler ( opts: ListCommandOptions, params: string[] ) { - if (!params.length) { + if (params.length === 0) { throw new PnpmError('MISSING_PACKAGE_NAME', '`pnpm why` requires the package name') } return list({ diff --git a/packages/plugin-commands-outdated/src/outdated.ts b/packages/plugin-commands-outdated/src/outdated.ts index eda34908e1..84c3c1ace6 100644 --- a/packages/plugin-commands-outdated/src/outdated.ts +++ b/packages/plugin-commands-outdated/src/outdated.ts @@ -161,7 +161,7 @@ export async function handler ( devDependencies: opts.dev !== false, optionalDependencies: opts.optional !== false, } - if (opts.recursive && opts.selectedProjectsGraph) { + if (opts.recursive && (opts.selectedProjectsGraph != null)) { const pkgs = Object.values(opts.selectedProjectsGraph).map((wsPkg) => wsPkg.package) return outdatedRecursive(pkgs, params, { ...opts, include }) } @@ -177,7 +177,7 @@ export async function handler ( include, }) - if (!outdatedPackages.length) return { output: '', exitCode: 0 } + if (outdatedPackages.length === 0) return { output: '', exitCode: 0 } if (opts.table !== false) { return { output: renderOutdatedTable(outdatedPackages, opts), exitCode: 1 } @@ -253,7 +253,7 @@ export function getCellWidth (data: string[][], columnNumber: number, maxWidth: } export function toOutdatedWithVersionDiff (outdated: T & OutdatedPackage): T & OutdatedWithVersionDiff { - if (outdated.latestManifest) { + if (outdated.latestManifest != null) { return { ...outdated, ...semverDiff(outdated.wanted, outdated.latestManifest.version), @@ -281,8 +281,8 @@ export function renderCurrent ({ current, wanted }: OutdatedPackage) { export function renderLatest (outdatedPkg: OutdatedWithVersionDiff): string { const { latestManifest, change, diff } = outdatedPkg - if (!latestManifest) return '' - if (change === null || !diff) { + if (latestManifest == null) return '' + if (change === null || (diff == null)) { return latestManifest.deprecated ? chalk.redBright.bold('Deprecated') : latestManifest.version @@ -292,7 +292,7 @@ export function renderLatest (outdatedPkg: OutdatedWithVersionDiff): string { } export function renderDetails ({ latestManifest }: OutdatedPackage) { - if (!latestManifest) return '' + if (latestManifest == null) return '' const outputs = [] if (latestManifest.deprecated) { outputs.push(wrapAnsi(chalk.redBright(latestManifest.deprecated), 40)) diff --git a/packages/plugin-commands-publishing/src/publish.ts b/packages/plugin-commands-publishing/src/publish.ts index 392a531fac..3a967411ba 100644 --- a/packages/plugin-commands-publishing/src/publish.ts +++ b/packages/plugin-commands-publishing/src/publish.ts @@ -129,7 +129,7 @@ Do you want to continue?`, }) } } - if (opts.recursive && opts.selectedProjectsGraph) { + if (opts.recursive && (opts.selectedProjectsGraph != null)) { await recursivePublish({ ...opts, selectedProjectsGraph: opts.selectedProjectsGraph, @@ -137,11 +137,11 @@ Do you want to continue?`, }) return } - if (params.length && params[0].endsWith('.tgz')) { + if ((params.length > 0) && params[0].endsWith('.tgz')) { runNpm(opts.npmPath, ['publish', ...params]) return } - const dir = params.length && params[0] || process.cwd() + const dir = (params.length > 0) && params[0] || process.cwd() const _runScriptsIfPresent = runScriptsIfPresent.bind(null, { depPath: dir, diff --git a/packages/plugin-commands-rebuild/src/implementation/index.ts b/packages/plugin-commands-rebuild/src/implementation/index.ts index 36df709b86..946abf6a5e 100644 --- a/packages/plugin-commands-rebuild/src/implementation/index.ts +++ b/packages/plugin-commands-rebuild/src/implementation/index.ts @@ -82,13 +82,13 @@ export async function rebuildPkgs ( maybeOpts: RebuildOptions ) { const reporter = maybeOpts?.reporter - if (reporter && typeof reporter === 'function') { + if ((reporter != null) && typeof reporter === 'function') { streamParser.on('data', reporter) } const opts = await extendOptions(maybeOpts) const ctx = await getContext(projects, opts) - if (!ctx.currentLockfile || !ctx.currentLockfile.packages) return + if (!ctx.currentLockfile || (ctx.currentLockfile.packages == null)) return const packages = ctx.currentLockfile.packages const searched: PackageSelector[] = pkgSpecs.map((arg) => { @@ -127,7 +127,7 @@ export async function rebuild ( maybeOpts: RebuildOptions ) { const reporter = maybeOpts?.reporter - if (reporter && typeof reporter === 'function') { + if ((reporter != null) && typeof reporter === 'function') { streamParser.on('data', reporter) } const opts = await extendOptions(maybeOpts) @@ -137,7 +137,7 @@ export async function rebuild ( if (opts.pending) { idsToRebuild = ctx.pendingBuilds - } else if (ctx.currentLockfile?.packages) { + } else if ((ctx.currentLockfile?.packages) != null) { idsToRebuild = Object.keys(ctx.currentLockfile.packages) } @@ -165,7 +165,7 @@ export async function rebuild ( scriptsOpts ) for (const { id, manifest } of ctx.projects) { - if (manifest?.scripts && (!opts.pending || ctx.pendingBuilds.includes(id))) { + if (((manifest?.scripts) != null) && (!opts.pending || ctx.pendingBuilds.includes(id))) { ctx.pendingBuilds.splice(ctx.pendingBuilds.indexOf(id), 1) } } diff --git a/packages/plugin-commands-rebuild/src/rebuild.ts b/packages/plugin-commands-rebuild/src/rebuild.ts index 71e9b02f7d..84bbac2ad9 100644 --- a/packages/plugin-commands-rebuild/src/rebuild.ts +++ b/packages/plugin-commands-rebuild/src/rebuild.ts @@ -86,7 +86,7 @@ export async function handler ( }, params: string[] ) { - if (opts.recursive && opts.allProjects && opts.selectedProjectsGraph && opts.workspaceDir) { + if (opts.recursive && (opts.allProjects != null) && (opts.selectedProjectsGraph != null) && opts.workspaceDir) { await recursive(opts.allProjects, params, { ...opts, selectedProjectsGraph: opts.selectedProjectsGraph, workspaceDir: opts.workspaceDir }) return } diff --git a/packages/plugin-commands-rebuild/src/recursive.ts b/packages/plugin-commands-rebuild/src/recursive.ts index 241cd63d2d..367bf90427 100755 --- a/packages/plugin-commands-rebuild/src/recursive.ts +++ b/packages/plugin-commands-rebuild/src/recursive.ts @@ -63,7 +63,7 @@ export default async function recursive ( const workspacePackages = arrayOfWorkspacePackagesToMap(allProjects) const rebuildOpts = Object.assign(opts, { ownLifecycleHooksStdio: 'pipe', - pruneLockfileImporters: (!opts.ignoredPackages || opts.ignoredPackages.size === 0) && + pruneLockfileImporters: ((opts.ignoredPackages == null) || opts.ignoredPackages.size === 0) && pkgs.length === allProjects.length, storeController: store.ctrl, storeDir: store.dir, @@ -80,7 +80,7 @@ export default async function recursive ( async function getImporters () { const importers = [] as Array<{ buildIndex: number, manifest: ProjectManifest, rootDir: string }> await Promise.all(chunks.map(async (prefixes: string[], buildIndex) => { - if (opts.ignoredPackages) { + if (opts.ignoredPackages != null) { prefixes = prefixes.filter((prefix) => !opts.ignoredPackages!.has(prefix)) } return Promise.all( diff --git a/packages/plugin-commands-script-runners/src/run.ts b/packages/plugin-commands-script-runners/src/run.ts index 6b6902b861..0bdd4ab5a1 100644 --- a/packages/plugin-commands-script-runners/src/run.ts +++ b/packages/plugin-commands-script-runners/src/run.ts @@ -247,11 +247,11 @@ function printProjectCommands ( if (output !== '') output += '\n\n' output += `Commands available via "pnpm run":\n${renderCommands(otherScripts)}` } - if (!rootManifest?.scripts) { + if ((rootManifest?.scripts) == null) { return output } const rootScripts = Object.entries(rootManifest.scripts) - if (!rootScripts.length) { + if (rootScripts.length === 0) { return output } if (output !== '') output += '\n\n' diff --git a/packages/plugin-commands-store/src/store.ts b/packages/plugin-commands-store/src/store.ts index 4d86fc597f..462c81238e 100644 --- a/packages/plugin-commands-store/src/store.ts +++ b/packages/plugin-commands-store/src/store.ts @@ -98,7 +98,7 @@ async function statusCmd (opts: StoreCommandOptions) { const modifiedPkgs = await storeStatus(Object.assign(opts, { storeDir: await storePath(opts.dir, opts.storeDir), })) - if (!modifiedPkgs || !modifiedPkgs.length) { + if (!modifiedPkgs || (modifiedPkgs.length === 0)) { logger.info({ message: 'Packages in the store are untouched', prefix: opts.dir, diff --git a/packages/plugin-commands-store/src/storeAdd.ts b/packages/plugin-commands-store/src/storeAdd.ts index 4027f46e1e..8ea4bbb25e 100644 --- a/packages/plugin-commands-store/src/storeAdd.ts +++ b/packages/plugin-commands-store/src/storeAdd.ts @@ -17,7 +17,7 @@ export default async function ( } ) { const reporter = opts?.reporter - if (reporter && typeof reporter === 'function') { + if ((reporter != null) && typeof reporter === 'function') { streamParser.on('data', reporter) } @@ -45,7 +45,7 @@ export default async function ( } })) - if (reporter && typeof reporter === 'function') { + if ((reporter != null) && typeof reporter === 'function') { streamParser.removeListener('data', reporter) } diff --git a/packages/plugin-commands-store/src/storePrune.ts b/packages/plugin-commands-store/src/storePrune.ts index 3076dfa2eb..b2b959134a 100644 --- a/packages/plugin-commands-store/src/storePrune.ts +++ b/packages/plugin-commands-store/src/storePrune.ts @@ -9,13 +9,13 @@ export default async function ( } ) { const reporter = opts?.reporter - if (reporter && typeof reporter === 'function') { + if ((reporter != null) && typeof reporter === 'function') { streamParser.on('data', reporter) } await opts.storeController.prune() await opts.storeController.close() - if (reporter && typeof reporter === 'function') { + if ((reporter != null) && typeof reporter === 'function') { streamParser.removeListener('data', reporter) } } diff --git a/packages/plugin-commands-store/src/storeStatus/index.ts b/packages/plugin-commands-store/src/storeStatus/index.ts index e3b225a9c1..86cec402e0 100644 --- a/packages/plugin-commands-store/src/storeStatus/index.ts +++ b/packages/plugin-commands-store/src/storeStatus/index.ts @@ -13,7 +13,7 @@ import extendOptions, { export default async function (maybeOpts: StoreStatusOptions) { const reporter = maybeOpts?.reporter - if (reporter && typeof reporter === 'function') { + if ((reporter != null) && typeof reporter === 'function') { streamParser.on('data', reporter) } const opts = await extendOptions(maybeOpts) @@ -50,7 +50,7 @@ export default async function (maybeOpts: StoreStatusOptions) { return (await dint.check(path.join(virtualStoreDir, dp.depPathToFilename(depPath, opts.dir), 'node_modules', name), files)) === false }, { concurrency: 8 }) - if (reporter && typeof reporter === 'function') { + if ((reporter != null) && typeof reporter === 'function') { streamParser.removeListener('data', reporter) } diff --git a/packages/pnpm/src/checkForUpdates.ts b/packages/pnpm/src/checkForUpdates.ts index f8ef677b8b..e6ef5aaa6b 100644 --- a/packages/pnpm/src/checkForUpdates.ts +++ b/packages/pnpm/src/checkForUpdates.ts @@ -11,7 +11,7 @@ export default async function () { const notifier = updateNotifier({ pkg: packageManager }) const update = notifier.update - if (!update) { + if (update == null) { return } diff --git a/packages/pnpm/src/cmd/index.ts b/packages/pnpm/src/cmd/index.ts index c2d4a0fa4f..7d3cadfa39 100644 --- a/packages/pnpm/src/cmd/index.ts +++ b/packages/pnpm/src/cmd/index.ts @@ -109,7 +109,7 @@ for (let i = 0; i < commands.length; i++) { helpByCommandName[commandName] = help cliOptionsTypesByCommandName[commandName] = cliOptionsTypes shorthandsByCommandName[commandName] = shorthands ?? {} - if (completion) { + if (completion != null) { completionByCommandName[commandName] = completion } Object.assign(rcOptionsTypes, rcOptionsTypes()) diff --git a/packages/pnpm/src/main.ts b/packages/pnpm/src/main.ts index 39231e4247..42a2a55991 100644 --- a/packages/pnpm/src/main.ts +++ b/packages/pnpm/src/main.ts @@ -165,7 +165,7 @@ export default async function run (inputArgv: string[]) { patterns: cliOptions['workspace-packages'], }) - if (!allProjects.length) { + if (allProjects.length === 0) { if (!config['parseable']) { console.log(`No projects found in "${wsDir}"`) } diff --git a/packages/pnpm/test/install/selfUpdate.ts b/packages/pnpm/test/install/selfUpdate.ts index c075c0a12c..e4678b73a1 100644 --- a/packages/pnpm/test/install/selfUpdate.ts +++ b/packages/pnpm/test/install/selfUpdate.ts @@ -1,6 +1,6 @@ import path from 'path' -import prepare from '@pnpm/prepare' import { promises as fs } from 'fs' +import prepare from '@pnpm/prepare' import isWindows from 'is-windows' import pathExists from 'path-exists' import {