Skip to content

valid-exports

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

The rule checks that, if present, the exports property is a validated according the following criteria:

  • It should be of type string or object.
  • If it’s a string, it should be a path to an entry point.
  • If it’s an export condition object, its properties should have values that are either a path to an entry point, or another exports condition object.

Example of incorrect code for this rule:

{
"exports": {
"import": true
}
}

Example of correct code for this rule:

{
"exports": "./index.js"
}
{
"exports": {
".": "./index.js",
"./secondary": "./secondary.js"
}
}
{
"exports": {
".": {
"import": {
"types": "./esm/index.d.mts",
"default": "./esm/index.mjs"
},
"require": {
"types": "./cjs/index.d.cts",
"default": "./cjs/index.cjs"
}
}
}
}