valid-fields

July 13, 2026 ยท View on GitHub

๐Ÿ“ Enforce valid values for package.json fields.

๐Ÿ’ผ This rule is enabled in the โœ… recommended config.

๐Ÿ”ง๐Ÿ’ก This rule is automatically fixable by the --fix CLI option and manually fixable by editor suggestions.

Validate the structure and values of individual package.json fields when they are present. Each check is objective correctness with no options and nothing to opt out of, so they live together in one rule. Fields that need options or encode an opinion have their own dedicated rules instead.

Each field is validated only when it exists; use require-fields to enforce presence.

Semantic checks include repository URLs and exports/imports targets. Condition ordering and type coverage belong to require-default-condition and require-types-in-exports. Legacy entry-point fields (main, module, browser, types, and typings) are intentionally ignored.

The following fields are validated:

  • name
  • version
  • private
  • description
  • license
  • repository
  • homepage
  • bugs
  • funding
  • author
  • contributors
  • type
  • exports
  • imports
  • bin
  • man
  • sideEffects
  • engines
  • devEngines
  • os
  • cpu
  • publishConfig
  • packageManager
  • scripts
  • files
  • workspaces
  • keywords
  • dependencies
  • devDependencies
  • optionalDependencies
  • peerDependencies
  • peerDependenciesMeta
  • bundledDependencies
  • overrides

Examples

// โŒ
{
	"name": "My-Package",
	"version": "v1.0.0",
	"license": "MITT"
}
// โœ…
{
	"name": "my-package",
	"version": "1.0.0",
	"license": "MIT"
}
// โŒ
{
	"exports": {
		"default": 123
	}
}
// โœ…
{
	"exports": {
		"default": "./index.js"
	}
}
// โŒ
{
	"engines": {
		"node": ">=18 || garbage"
	}
}
// โœ…
{
	"engines": {
		"node": "^18.0.0 || ^20.0.0"
	}
}