Skip to content

exports rules

Validate the exports field in package.json — condition ordering, file existence, format matching, and more.

Rules (28)

RuleDescriptionSeverityFixable
type-moduleCheck that type: "module" is set appropriately🔴 error🔧
exports-fieldCheck that exports field exists in package.json🔴 error⚠️
dot-entryCheck that exports has a "." entry🔴 error⚠️
types-orderCheck that types condition comes before default in exports🔴 error🔧
import-conditionCheck that exports has an import condition🔴 error⚠️
file-existsCheck that files referenced in exports exist on disk🟡 warning
value-invalidCheck that every string value in exports starts with ./🔴 error
default-lastCheck that "default" is the last key in every condition map🔴 error🔧
module-before-requireCheck that "module" comes before "require" in condition maps🟡 warning🔧
imports-fieldValidate package.json imports field🔴 error
jsx-extensionsCheck that exports don't use invalid JSX extensions🔴 error
format-mismatchCheck that export file contents match the expected module format🟡 warning
module-esm-onlyCheck that "module" condition in exports points to ESM content🟡 warning
fallback-arrayWarn against fallback arrays in exports🟡 warning
types-formatCheck that types conditions use the correct .d.mts/.d.cts extensions for dual packages🟡 warning
condition-typesCheck that export conditions with JS entries have sibling types🟡 warning
no-deprecated-subpathWarn on trailing / in exports keys (use /* instead)🟡 warning
imports-key-invalidCheck that all imports field keys start with #🔴 error
browser-conflictWarn when both top-level browser field and exports exist🟡 warning
browser-value-conflictDetect when exports values are remapped by the browser field🟡 warning
file-not-publishedCheck that files referenced in exports/main/bin are included in the published package🔴 error
glob-matched-filesValidate that wildcard patterns in exports match at least one file🟡 warning
cjs-esmodule-interopDetect CJS files using __esModule interop pattern that may cause inconsistent bundler behavior🟡 warning
cjs-default-exportDetect CJS-only packages with only a default export and no named exports:blue_circle: info
types-firstCheck that "types" is the first condition in every condition map🔴 error🔧
esm-main-no-exportsWarn when "main" is ESM but "exports" is missing🟡 warning
module-no-exportsWarn when "module" field exists but "exports" is missing🟡 warning
types-not-exportedCheck that "types" field is also represented in exports conditions🟡 warning

Released under the MIT License.