-
Notifications
You must be signed in to change notification settings - Fork 39
Closed
Labels
enhancementNew feature or requestNew feature or requestkeep-openExempts stale action from auto closing the issue/pr.Exempts stale action from auto closing the issue/pr.
Description
Is your feature request related to a problem? Please describe.
Currently, we don't globally import idb-connector, ssh2, or odbc because these are optional dependencies that may not be installed. This is ok, because they are only used by the transports and it's up to the user to use a transport which is installed.
Because of how we do the import, however, the linter flags us for non-global imports and a few other issues. I think we could do this better.
Describe the solution you'd like
Instead of doing something like this:
const idbCall = (config, xmlInput, cb) => {
const {
dbconn, dbstmt, IN, CLOB, CHAR, SQL_ATTR_DBC_SYS_NAMING, SQL_FALSE,
// idb-connector is an optional dependency, since users may not use this transport
// thus we can't globally require it
// eslint-disable-next-line max-len
// eslint-disable-next-line global-require, import/no-extraneous-dependencies, import/no-unresolved
} = require('idb-connector');we could instead wrap the require in a try/catch block:
try {
let idb = require('idb-connector');
// TODO: Handle imports of fields somehow
} catch (e) {
if (e.code !== 'MODULE_NOT_FOUND') {
throw e;
}
}https://softwareengineering.stackexchange.com/a/368839
https://stackoverflow.com/a/38885374
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestkeep-openExempts stale action from auto closing the issue/pr.Exempts stale action from auto closing the issue/pr.