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.
More Details
Section titled “More Details”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.
Examples
Section titled “Examples”{ "exports": "./index.mjs"}{ "exports": { ".": "./index.mjs" }}{ "exports": { "import": "./index.mjs", "require": "./index.cjs" }}{ "exports": { ".": "./index.mjs", "./package.json": "./package.json" }}{ "exports": { ".": { "import": "./index.mjs", "require": "./index.cjs" }, "./package.json": "./package.json" }}When Not to Use It
Section titled “When Not to Use It”If you’re not concerned about providing easier access to your package’s package.json, then you can safely exclude this rule.
Related Rules
Section titled “Related Rules”require-exports- Enforces that theexportsproperty is present.valid-exports- Enforces that theexportsproperty is valid.