diff --git a/.eslintrc.js b/.eslintrc.js index dafb44e3..07591b79 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1 +1,13 @@ -module.exports = { "extends": "airbnb-base" }; \ No newline at end of file +module.exports = { + "extends": "airbnb-base", + env: { + node: true + }, + rules: { + // Tweak rules set by airbnb config + 'no-console': 'off', // allow console + 'import/no-extraneous-dependencies': ["error", {"optionalDependencies": true}], // Allow optional dep import + // Warn unresolved imports ie: idb-connector import will be unresolved when on non IBM i system. + 'import/no-unresolved': ['off', { commonjs: true }], + }, +}; diff --git a/lib/transports/idbTransport.js b/lib/transports/idbTransport.js index 48bc32a9..502be3f3 100644 --- a/lib/transports/idbTransport.js +++ b/lib/transports/idbTransport.js @@ -18,6 +18,7 @@ const idbCall = (config, xmlInput, cb) => { const { dbconn, dbstmt, IN, CLOB, CHAR, SQL_ATTR_DBC_SYS_NAMING, SQL_FALSE, + // eslint-disable-next-line global-require } = require('idb-connector'); const { @@ -67,7 +68,7 @@ const idbCall = (config, xmlInput, cb) => { conn.close(); cb(err, val); - } + }; stmt.prepare(sql, (prepareError) => { if (prepareError) { @@ -101,7 +102,6 @@ const idbCall = (config, xmlInput, cb) => { xmlOutput += chunk.OUT151; }); done(null, xmlOutput); - return; }); }); }); diff --git a/lib/transports/sshTransport.js b/lib/transports/sshTransport.js index 727b9559..884c506d 100644 --- a/lib/transports/sshTransport.js +++ b/lib/transports/sshTransport.js @@ -16,6 +16,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. function sshCall(config, xmlIn, done) { + // eslint-disable-next-line global-require const { Client } = require('ssh2'); const { diff --git a/package.json b/package.json index f35b8442..6e544230 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "scripts": { "test": "./node_modules/mocha/bin/mocha --recursive test/unit", "test-integration": "./node_modules/mocha/bin/mocha --timeout 5s test/functional/*.js", + "lint": "./node_modules/eslint/bin/eslint.js lib/ test/", "release": "standard-version" }, "repository": { diff --git a/test/functional/checkObjectExists.js b/test/functional/checkObjectExists.js index 969965da..02f1aa58 100644 --- a/test/functional/checkObjectExists.js +++ b/test/functional/checkObjectExists.js @@ -1,8 +1,6 @@ const lib = 'NODETKTEST'; const createLib = `CRTLIB LIB(${lib}) TYPE(*TEST) TEXT('Used to test Node.js toolkit')`; const findLib = `SELECT SCHEMA_NAME FROM qsys2.sysschemas WHERE SCHEMA_NAME = '${lib}'`; -const dataQueue = 'TESTQ'; -const dataArea = 'TESTDA'; function checkObjectExistsSSH(config, object = {}, callback) { /* eslint-disable global-require */ diff --git a/test/functional/deprecated/iProdFunctional.js b/test/functional/deprecated/iProdFunctional.js index d3a38c61..d30d90f4 100644 --- a/test/functional/deprecated/iProdFunctional.js +++ b/test/functional/deprecated/iProdFunctional.js @@ -132,7 +132,6 @@ describe('iProd Functional Tests', () => { // REST transport currently failing with 414 URI Too Long response code // The requested URL's length exceeds the capacity limit for this server describe('getInstalledProducts', () => { - // eslint-disable-next-line func-names it('returns info for installed products', (done) => { const connection = new iConn(database, username, password, restOptions); diff --git a/test/functional/iDataQueueFunctional.js b/test/functional/iDataQueueFunctional.js index fae5705c..b0e7cd4a 100644 --- a/test/functional/iDataQueueFunctional.js +++ b/test/functional/iDataQueueFunctional.js @@ -34,8 +34,8 @@ describe('DataQueue Functional Tests', () => { checkObjectExists(config, dqName, '*DTAQ', (error) => { if (error) { throw error; } - checkObjectExists(config, dqName2, '*DTAQ', (error) => { - if (error) { throw error; } + checkObjectExists(config, dqName2, '*DTAQ', (error2) => { + if (error2) { throw error2; } done(); }); });