You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
711 B

2 years ago
var util = require('util')
var messages = require('./warning_messages.json')
module.exports = function () {
var args = Array.prototype.slice.call(arguments, 0)
var warningName = args.shift()
if (warningName === 'typo') {
return makeTypoWarning.apply(null, args)
} else {
var msgTemplate = messages[warningName] ? messages[warningName] : warningName + ": '%s'"
args.unshift(msgTemplate)
return util.format.apply(null, args)
}
}
function makeTypoWarning (providedName, probableName, field) {
if (field) {
providedName = field + "['" + providedName + "']"
probableName = field + "['" + probableName + "']"
}
return util.format(messages.typo, providedName, probableName)
}