Skip to content

require-package-json-export

💡 This rule is manually fixable by editor suggestions.

This rule requires that if a package.json includes exports (or publishConfig.exports) that an explicit ./package.json export is included.

When a package declares exports, that represents the entire API surface for that package. By including an explicit export for the package.json, external tools can more easily consume it (via direct import/require). If the package does not export the package.json, it makes it harder for tools to load / inspect it.

{
"exports": "./index.mjs"
}
{
"exports": {
".": "./index.mjs"
}
}
{
"exports": {
"import": "./index.mjs",
"require": "./index.cjs"
}
}

If you’re not concerned about providing easier access to your package’s package.json, then you can safely exclude this rule.