consistent-path-prefix

July 13, 2026 ยท View on GitHub

๐Ÿ“ Enforce consistent ./ prefix on local path fields.

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

๐Ÿ”ง This rule is automatically fixable by the --fix CLI option.

Enforce a consistent ./ prefix in the legacy main, module, browser, types, typings, and bin fields. Absolute paths, URLs, and globs are ignored; other paths with a .. segment are reported. Mandatory prefixes in exports and imports are handled by valid-fields.

Options

prefix

Type: 'always' | 'never'
Default: 'always'

  • 'always' โ€” require all local relative paths to start with ./.
  • 'never' โ€” disallow the ./ prefix.
{
	'package-json/consistent-path-prefix': ['error', {
		prefix: 'always'
	}]
}

Examples

With {prefix: 'always'} (the default):

// โŒ
{
	"main": "index.js"
}
// โœ…
{
	"main": "./index.js"
}

With {prefix: 'never'}:

// โŒ
{
	"main": "./index.js"
}
// โœ…
{
	"main": "index.js"
}