Skip to content

Commit 63f2fd7

Browse files
committed
feat: warn on unknown configs
1 parent 2a1e11f commit 63f2fd7

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

workspaces/config/lib/index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ class Config {
274274
}
275275

276276
try {
277+
// This does not have an actual definition
277278
defaultsObject['npm-version'] = require(join(this.npmPath, 'package.json')).version
278279
} catch {
279280
// in some weird state where the passed in npmPath does not have a package.json
@@ -568,11 +569,28 @@ class Config {
568569
}
569570
}
570571
}
572+
// Some defaults like npm-version are not user-definable and thus don't have definitions
573+
if (where !== 'default') {
574+
this.#checkUnknown(where, key)
575+
}
571576
conf.data[k] = v
572577
}
573578
}
574579
}
575580

581+
#checkUnknown (where, key) {
582+
if (!this.definitions[key]) {
583+
if (!key.includes(':')) {
584+
log.warn(`Unknown ${where} config "${where === 'cli' ? '--' : ''}${key}". This will stop working in the next major version of npm.`)
585+
return
586+
}
587+
const baseKey = key.split(':').pop()
588+
if (!this.definitions[baseKey] && !this.nerfDarts.includes(baseKey)) {
589+
log.warn(`Unknown ${where} config "${baseKey}" (${key}). This will stop working in the next major version of npm.`)
590+
}
591+
}
592+
}
593+
576594
#checkDeprecated (key) {
577595
if (this.deprecated[key]) {
578596
log.warn('config', key, this.deprecated[key])

0 commit comments

Comments
 (0)