All Rules
tspub includes 70 rules across 6 categories. Each rule has a severity level, and many support auto-fix.
TIP
Run tspub check --list-rules to see all rules in your terminal.
Legend
| Badge | Meaning |
|---|---|
| 🔴 error | Fails the check |
| 🟡 warning | Warns but doesn't fail |
| :blue_circle: info | Informational only |
| 🔧 safe | Auto-fixable with --fix |
| ⚠️ unsafe | Auto-fixable with --fix --unsafe |
Exports (28 rules)
| Rule | Description | Severity | Fixable |
|---|---|---|---|
type-module | Check that type: "module" is set | 🔴 error | 🔧 safe |
exports-field | Check that exports field exists | 🔴 error | ⚠️ unsafe |
dot-entry | Check that exports["."] is defined | 🔴 error | ⚠️ unsafe |
types-order | Check that types condition comes first | 🔴 error | 🔧 safe |
import-condition | Check for import condition | 🔴 error | ⚠️ unsafe |
file-exists | Check exported files exist on disk | 🟡 warning | |
value-invalid | Check export values start with ./ | 🔴 error | |
default-last | Check default is last condition key | 🔴 error | 🔧 safe |
module-before-require | Check module precedes require | 🟡 warning | 🔧 safe |
imports-field | Validate imports field | 🔴 error | |
jsx-extensions | Check JSX extensions in exports | 🔴 error | |
format-mismatch | Check ESM/CJS format consistency | 🟡 warning | |
module-esm-only | Check module points to ESM | 🟡 warning | |
fallback-array | Warn against fallback arrays | 🟡 warning | |
types-format | Check .d.ts/.d.cts format matching | 🟡 warning | |
condition-types | Check conditions have sibling types | 🟡 warning | |
no-deprecated-subpath | Flag trailing / in export keys | 🟡 warning | |
imports-key-invalid | Check imports keys start with # | 🔴 error | |
browser-conflict | Warn on browser + exports conflict | 🟡 warning | |
browser-value-conflict | Detect when exports values are remapped by the browser field | 🟡 warning | |
file-not-published | Check exported files are in files | 🔴 error | |
glob-matched-files | Validate wildcard patterns match files | 🟡 warning | |
cjs-esmodule-interop | Check CJS __esModule interop issues | 🟡 warning | |
cjs-default-export | Detect CJS-only default export | :blue_circle: info | |
types-first | Check that types is the first condition in every condition map | 🔴 error | 🔧 safe |
esm-main-no-exports | Warn when main is ESM but exports is missing | 🟡 warning | |
module-no-exports | Warn when module field exists but exports is missing | 🟡 warning | |
types-not-exported | Check that types field is also represented in exports conditions | 🟡 warning |
Imports (6 rules)
| Rule | Description | Severity | Fixable |
|---|---|---|---|
default-last | Check that default is the last key in imports condition maps | 🔴 error | 🔧 safe |
module-esm-only | Check that module condition in imports points to ESM | 🟡 warning | |
module-before-require | Check that module comes before require in imports | 🟡 warning | 🔧 safe |
fallback-array | Warn against fallback arrays in imports | 🟡 warning | |
glob-matched-files | Validate that wildcard patterns in imports match files | 🟡 warning | |
no-deprecated-subpath | Warn on trailing / in imports keys (use /* instead) | 🟡 warning |
Types (14 rules)
| Rule | Description | Severity | Fixable |
|---|---|---|---|
tsconfig-exists | Check tsconfig.json exists | 🟡 warning | |
declaration | Check declaration generation is enabled | :blue_circle: info | |
strict | Check strict mode is enabled | 🟡 warning | |
module | Check tsconfig module setting | 🟡 warning | |
module-resolution | Check moduleResolution setting | 🟡 warning | |
isolated-modules | Check isolatedModules is enabled | :blue_circle: info | |
declaration-completeness | Check all exports have .d.ts files | 🟡 warning | |
no-any-export | Flag excessive any in declarations | 🟡 warning | |
resolution | Verify types resolve in node10/node16/bundler | 🔴 error | |
false-cjs-esm | Detect format mismatch between declaration files and JS (FalseCJS/FalseESM) | 🔴 error | |
false-export-default | Detect export default in types with module.exports in JS | 🟡 warning | |
missing-export-equals | Detect CJS modules whose types lack export = | :blue_circle: info | |
esm-dynamic-only | Detect when package is only available via dynamic import for ESM | 🟡 warning | |
cjs-resolves-esm | Detect when CJS require() would resolve to an ESM file | 🔴 error |
Files (10 rules)
| Rule | Description | Severity | Fixable |
|---|---|---|---|
files-field | Check files field exists | 🟡 warning | 🔧 safe |
sensitive | Check for .env, credentials | 🔴 error | |
bin-shebang | Check bin files have shebang | 🟡 warning | |
bin-executable | Check bin files have executable permissions | 🟡 warning | |
all-files-format | Check JS file format consistency | 🟡 warning | |
format-validation | Check that .mjs/.cjs files contain the expected module format | 🟡 warning | |
implicit-index-format | Check that implicit index.js matches the declared package type | 🟡 warning | |
prepublish | Check prepublishOnly script exists | 🟡 warning | 🔧 safe |
duplicate-dep | Check for duplicate dependencies | 🔴 error | |
local-dependency | Check for file: protocol deps | 🔴 error |
Metadata (11 rules)
| Rule | Description | Severity | Fixable |
|---|---|---|---|
license | Check license field exists | 🟡 warning | ⚠️ unsafe |
license-file | Check LICENSE file exists | 🟡 warning | |
repository | Check repository field exists | :blue_circle: info | |
repository-format | Check that repository field has a valid format | 🟡 warning | |
engines | Check engines.node is specified | 🟡 warning | ⚠️ unsafe |
side-effects | Check sideEffects field is set | 🟡 warning | |
deprecated-fields | Flag deprecated fields | 🟡 warning | |
field-value-type | Check that common package.json fields have correct value types | 🔴 error | |
peer-dep-conflict | Check peer dependency conflicts | 🟡 warning | |
use-exports-browser | Prefer exports over browser field | :blue_circle: info | |
module-esm | Check that top-level module field points to ESM content | 🟡 warning |
Size (1 rule)
| Rule | Description | Severity | Fixable |
|---|---|---|---|
package-size | Check package size is reasonable | 🟡 warning |