💼 This rule is enabled in the ✅ recommended
config.
🔧 This rule is automatically fixable by the --fix
CLI option.
This rule enforces that repository
entries in a package.json
use either object (default) or shorthand notation to refer to GitHub repositories when possible.
npm previously allowed a "shorthand" form like "JoshuaKGoldberg/eslint-plugin-package-json"
to specifying a full URL to a GitHub repository like "https://github.com/JoshuaKGoldberg/eslint-plugin-package-json"
.
However, current versions of npm now normalize that form to the object longhand with type
and url
and warn against the shorthand.
Examples of incorrect code for this rule with the default options:
{
"repository": "JoshuaKGoldberg/eslint-plugin-package-json"
}
Examples of correct code for this rule with the default options:
{
"repository": {
"type": "git",
"url": "https://github.com/JoshuaKGoldberg/eslint-plugin-package-json"
}
}
{
"package-json/order-properties": [
"error",
{
"form": "shorthand"
}
]
}
The form
property specifies whether to use:
"object"
(default): an object with"type"
and"url"
"shorthand"
: the shorthand string equivalent.
The object
form is generally recommended as that's what npm publish
prefers.
If and when npm drops support for the
"shorthand"
form, this rule will likely remove its options.