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"
}