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

🐛 Bug: prefer-repository-shorthand in conflict with npm publish requirements #223

Closed
3 tasks done
JoshuaKGoldberg opened this issue Mar 19, 2024 · 2 comments · Fixed by #248
Closed
3 tasks done
Assignees
Labels
status: accepting prs Please, send a pull request to resolve this! type: bug Something isn't working :(

Comments

@JoshuaKGoldberg
Copy link
Owner

JoshuaKGoldberg commented Mar 19, 2024

Bug Report Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have pulled the latest main branch of the repository.
  • I have searched for related issues and found none that matched my issue.

Expected

As of #71 -> #70, the package-json/prefer-repository-shorthand rule is enforcing the "repository" field in package.json files is a shorthand string like "JoshuaKGoldberg/eslint-plugin-package-json" if possible. Since that was mentioned as supported in npm/npm#3783 and is still documented in https://docs.npmjs.com/cli/v10/configuring-npm/package-json#repository. And it seems to have worked till now.

Actual

I'm seeing a warning in release jobs asking to switch it to an object. Example from https://github.com/JoshuaKGoldberg/emojipedia/actions/runs/8346102080/job/22842590478:

ERROR npm WARN publish npm auto-corrected some errors in your package.json when publishing.  Please run "npm pkg fix" to address these errors.
npm WARN publish errors corrected:
npm WARN publish "repository" was changed from a string to an object
npm WARN publish "repository.url" was normalized to "git+https://github.com/JoshuaKGoldberg/emojipedia.git"

What gives, npm? Should this rule be removed?

My hunch is that this is a bug in npm publishing, but filing here for visibility.

Additional Info

cc @azat-io - have you seen this too?

Also filed:

@JoshuaKGoldberg JoshuaKGoldberg added the status: in discussion Not yet ready for implementation or a pull request label Mar 19, 2024
@JoshuaKGoldberg
Copy link
Owner Author

Welp, per npm/cli#7299 (comment), we'll have to make the rule go the other way. It should enforce the object form rather than string.

Aside: this is a good example for why I prefer rules with non-opionated names. I.e. "abc" instead of "no-abc" or "prefer-abc". I should have thought of that here, heh.

@JoshuaKGoldberg JoshuaKGoldberg self-assigned this Mar 20, 2024
@JoshuaKGoldberg JoshuaKGoldberg added type: bug Something isn't working :( status: accepting prs Please, send a pull request to resolve this! and removed status: in discussion Not yet ready for implementation or a pull request labels Mar 20, 2024
JoshuaKGoldberg added a commit that referenced this issue Mar 25, 2024
## PR Checklist

-   [x] Addresses an existing open issue: fixes #223
- [x] That issue was marked as [`status: accepting
prs`](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22)
- [x] Steps in
[CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/main/.github/CONTRIBUTING.md)
were taken

## Overview

Renames the `prefer-repository-shorthand` rule to `repository-shorthand`
and splits the rule's logic on a new `form` option that can be
`"object"` _(default)_ or `"shorthand"` _(legacy)_. The rule effectively
used to always be `"shorthand"`; now it's `"object"` unless configured
otherwise.
Copy link

🎉 This is included in version v0.12.0 🎉

The release is available on:

Cheers! 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepting prs Please, send a pull request to resolve this! type: bug Something isn't working :(
Projects
None yet
1 participant