JoshuaKGoldberg / package.json-validator

Tools to validate package.json files
MIT License
107 stars 26 forks source link

Feature: Don't require version if package has `"private": true` #84

Closed altano closed 2 months ago

altano commented 5 months ago

While it is valid for a private package ("private": true) to have a version, it certainly shouldn't require one.

Tools like changeset require that you remove the private package version number (instead of, say providing a useless one like 0.0.1) or it will try to manage that version, even if the package is private. Ideally this package would just allow no versions on private packages.

(Moving the discussion from https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/250 to here)

altano commented 5 months ago

BTW the README for this project mentions an option to pick which spec to use, with "npm" being the default.

Where is the npm package.json spec? I can't find it.

JoshuaKGoldberg commented 5 months ago

👍 from me on this. The npm docs in https://docs.npmjs.com/cli/v10/configuring-npm/package-json#version say:

If you don't plan to publish your package, the name and version fields are optional.

Ignoring whether skipping the name is ok even if it's optional, skipping version seems like a straightforward "yes". Thanks for filing!

JoshuaKGoldberg commented 5 months ago

Where is the npm package.json spec? I can't find it.

I don't believe there's a spec more specific than what's linked in the README: docs.npmjs.com. I've never seen one at any rate.

altano commented 5 months ago

FWIW I went back to having a version of "0.0.0" in my private packages because pnpm won't publish packages that have dev dependencies on private packages without a version, for some reason. I was also able to get changesets to ignore these private, versioned packages so I'm a happy camper. (https://github.com/pnpm/pnpm/issues/5094)

I still think this feature request is a good idea for this package, so I'm not closing the issue. Just thought I'd call out that I'm not clamoring for it.

JoshuaKGoldberg commented 2 months ago

Published in package-json-validator@0.6.5. Thanks for the issue @altano and PR @hyoban! 🚀