Enforce consistent root exports subpath style in package.json.
✅ This rule is included in the package-json stylistic presets.
The Node.js exports field allows a single root export to be written as a direct value or under the "." subpath.
Both forms resolve the package root, but using one style consistently keeps package manifests easier to compare.
By default, this rule prefers the explicit "." subpath form.
The explicit form keeps the top-level exports shape stable if the package later adds additional subpaths.
Which single root export style to enforce.
Use "explicit" to require the "." subpath wrapper.
Use "implicit" to prefer the direct root export value when no other subpaths are present.
any
packageJson.
any
rules({
exportsSubpathsStyle: {
prefer: string;
}
exportsSubpathsStyle: {
prefer: string
prefer: "implicit",
},
});
With "implicit", this rule does not unwrap exports objects that declare more than the root subpath.
Multiple package subpaths require the explicit object form.
If your project does not use exports, or your package manifests intentionally mix both single-root forms to match generated output from another tool, this rule may not be useful for that package.