Skip to content

repository-shorthand

💼 This rule is enabled in the following configs: ✅ recommended, 📦 recommended-publishable.

🔧 This rule is automatically fixable by the --fix CLI option.

This rule enforces that the repository property uses either object (default) or shorthand notation to refer to GitHub repositories.

npm previously allowed a “shorthand” form like "michaelfaith/eslint-plugin-package-json" to specify a URL to a GitHub repository (In this case "https://github.com/michaelfaith/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.

{
"repository": "michaelfaith/eslint-plugin-package-json"
}
Name Description Type Choices Default
form Specifies which repository form to enforce. String object, shorthand object

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.

{
"package-json/repository-shorthand": [
"error",
{
"form": "shorthand"
}
]
}