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.
Examples
Section titled “Examples”{ "repository": "michaelfaith/eslint-plugin-package-json"}{ "repository": { "type": "git", "url": "https://github.com/michaelfaith/eslint-plugin-package-json" }}Options
Section titled “Options”| 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" } ]}Related Rules
Section titled “Related Rules”require-repository- Enforces that therepositoryproperty is present.valid-repository- Enforces that therepositoryproperty is valid.