Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check license field #111

Open
fvsch opened this issue Sep 24, 2024 · 3 comments
Open

Check license field #111

fvsch opened this issue Sep 24, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@fvsch
Copy link

fvsch commented Sep 24, 2024

I had a package:

  • with a LICENSE file
  • without a "license" field in its package.json`

As a result, that package was listed as "License: none" on npmjs.com.

It looks like publint doesn't currently warn about a missing license field in package.json. Maybe it should?

Relevant npm documentation: https://docs.npmjs.com/cli/v10/configuring-npm/package-json#license

@fvsch
Copy link
Author

fvsch commented Sep 24, 2024

Ideally a check could be something like:

  1. Let license be the value of the package.json "license" field
  2. If license is empty, and the package.json doesn't include "private": true, emit a warning.
  3. If license is not empty, check that it is:
    • the string UNLICENSED
    • or a valid SPDX license expression

But I suspect checking the SPDX license expression syntax, and loading a list of SPDX licenses, might be prohibitive. Maybe it's enough to just have a generic warning when the license field is missing or empty, and link to the npm docs.

@bluwy bluwy changed the title Should publint Check license field Sep 26, 2024
@bluwy
Copy link
Owner

bluwy commented Sep 26, 2024

publint should always run on packages to be published, so I don't think "private": true needs to be checked. Maybe a heuristic instead is that if there's a LICENSE/license/... is detected, we could make sure the "license" field is also set too. The idea sounds great though.

@bluwy bluwy added the enhancement New feature or request label Sep 26, 2024
@fvsch
Copy link
Author

fvsch commented Sep 27, 2024

publint should always run on packages to be published, so I don't think "private": true needs to be checked

That makes sense. I thought the VS Code extension would run on all package.json files, but it looks like it ignores those with "private": true already (vscode-publint.ignore-private-packages is true by default).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants