Skip to content

valid-author

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

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

This rule uses package-json-validator to validate the author property in package.json files against the npm specification. The field can be either a string or an object with name and optionally email or url properties.

{
"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" }
}

This rule is automatically fixable. It will replace an empty author string, or author values that are of the wrong type, with a value that has name and email, populated by data from git config. Furthermore, if author is the correct type, but is missing name or the name or email are empty, the fixer will populate those values with data from git config as well. If the calls to git config fail, the fixer won’t make the change. In order to be more performant in monorepos, the author values retrieved from git config will be cached at the module level and will be reused across multiple runs.