Skip to content

require-attribution

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

💡 This rule is manually fixable by editor suggestions.

This rule ensures that proper attribution is included in a package, requiring that either author or contributors is defined. If contributors is present, it should include at least one contributor.

When publishing a package, it’s helpful to include some amount of attribution. npm supports two ways of defining attribution in a package.json:

  • author: this is either a string with name, email, and url combined, or an object with name, email, and url. This is generally the original creator of the package, or sole maintainer in smaller projects.
  • contributors: a list of all collaborators contributing to the project. Each item in the array has the same name, email, and url properties as author has.

With Default Options (preferContributorsOnly: false)

Section titled “With Default Options (preferContributorsOnly: false)”
{
"name": "nin"
}
{
"author": "Trent Reznor <treznor@nin.com> (https://nin.com)",
"contributors": []
}
{
"name": "nin"
}
{
"author": "Trent Reznor <treznor@nin.com> (https://nin.com)",
"contributors": []
}
{
"author": "Trent Reznor <treznor@nin.com> (https://nin.com)"
}
{
"author": {
"name": "Trent Reznor",
"email": "treznor@nin.com",
"url": "https://nin.com"
}
}
{
"author": {
"name": "Trent Reznor",
"email": "treznor@nin.com",
"url": "https://nin.com"
},
"contributors": [
{
"name": "Trent Reznor",
"email": "treznor@nin.com",
"url": "https://nin.com"
},
{
"name": "Atticus Ross",
"email": "atticus@nin.com",
"url": "https://nin.com"
}
]
}
Name Description Type Default
ignorePrivate Skip attribution requirements for packages with "private": true. Boolean true
preferContributorsOnly Require that only contributors is present, and author is not defined. Boolean false

When enabled, ignorePrivate skips all attribution checks for packages that have "private": true set. This is useful for internal packages that won’t be published to npm.

{
"package-json/require-attribution": [
"error",
{
"ignorePrivate": true
}
]
}

When enabled, preferContributorsOnly requires that only contributors may be defined for attribution, and will report if author is also present.

{
"package-json/require-attribution": [
"error",
{
"preferContributorsOnly": true
}
]
}

If your package is not going to be published, and attribution is not important, then this rule can safely be disabled.