mirror of
https://github.com/tenrok/axios.git
synced 2026-06-17 19:21:29 +03:00
Warn about common option misspellings (#6489)
* chore(tests): add failing tests for baseUrl * chore(tests): simplify to just warning * feat: warn about likely-misspelled options * chore: add semi-colon * chore: add missing semi-colons --------- Co-authored-by: Ell Bradshaw <ell@c9a.co> Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
@@ -97,6 +97,11 @@ class Axios {
|
||||
}
|
||||
}
|
||||
|
||||
validator.assertOptions(config, {
|
||||
baseUrl: validators.spelling('baseURL'),
|
||||
withXsrfToken: validators.spelling('withXSRFToken')
|
||||
}, true);
|
||||
|
||||
// Set config.method
|
||||
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
||||
|
||||
|
||||
@@ -52,6 +52,14 @@ validators.transitional = function transitional(validator, version, message) {
|
||||
};
|
||||
};
|
||||
|
||||
validators.spelling = function spelling(correctSpelling) {
|
||||
return (value, opt) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Assert object's properties type
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user