Skip to content

Latest commit

 

History

History
132 lines (103 loc) · 1.95 KB

File metadata and controls

132 lines (103 loc) · 1.95 KB

valid-author

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

npm requires that the author field in package.json follows certain specifications if it is present.

This rule uses package-json-validator to validate the author field in package.json files against the npm specification.

Rule Details

This rule aims to ensure that the author field complies with npm specifications.

The field can be either a string or an object with specific properties.

Examples of incorrect code for this rule:

{
	"author": ""
}
{
	"author": null
}
{
	"author": "John <invalid>"
}
{
	"author": "John (not-url)"
}
{
	"author": {}
}
{
	"author": { "email": "john@example.com" }
}
{
	"author": { "name": "", "email": "john@example.com" }
}
{
	"author": { "name": "John", "email": "invalid" }
}
{
	"author": { "name": "John", "url": "invalid" }
}

Examples of correct code for this rule:

{
	"author": "John Doe"
}
{
	"author": "John <john@example.com>"
}
{
	"author": "John (https://example.com)"
}
{
	"author": "John <john@example.com> (https://example.com)"
}
{
	"author": { "name": "John" }
}
{
	"author": { "name": "John", "email": "john@example.com" }
}
{
	"author": { "name": "John", "url": "https://example.com" }
}
{
	"author": {
		"name": "John",
		"email": "john@example.com",
		"url": "https://example.com"
	}
}

When Not To Use It

If you don't care about strict compliance with npm's author field specification, or if you don't use this field in your projects, you can disable this rule.