Note: The default ITS GitLab runner is a shared resource and is subject to slowdowns during heavy usage.
You can run your own GitLab runner that is dedicated just to your group if you need to avoid processing delays.

Commit 3e34510b authored by Erik Schwartz's avatar Erik Schwartz 🉐
Browse files

Merge branch 'update-packages-and-linting' into 'master'

Bump npm package versions, apply stricter linting

See merge request !1
parents 7178d4f1 8bf67291
{
"extends": "strongloop",
"extends": ["plugin:node/recommended"],
"env": {
"es6": true
},
"parserOptions": {
"ecmaVersion": 8
},
"plugins": [
"jsdoc"
],
"rules": {
"no-trailing-spaces": "error"
"block-scoped-var": "error",
"camelcase": "error",
"consistent-return": "error",
"eol-last": "error",
"no-async-promise-executor": "error",
"no-invalid-regexp": "error",
"no-lonely-if": "error",
"no-multi-spaces": "error",
"no-param-reassign": "error",
"no-return-await": "error",
"no-self-assign": "error",
"no-self-compare": "error",
"no-var": "error",
"no-tabs": "error",
"no-trailing-spaces": "error",
"no-unexpected-multiline": "error",
"no-unreachable": "error",
"no-unsafe-finally": "error",
"no-unsafe-negation": "error",
"no-useless-return": "error",
"no-whitespace-before-property": "error",
"prefer-const": "error",
"prefer-promise-reject-errors": "error",
"prefer-regex-literals": "error",
"quotes": ["error", "single"],
"radix": "error",
"require-await": "error",
"require-atomic-updates": "error",
"use-isnan": "error",
"valid-typeof": "error",
"jsdoc/check-alignment": 1,
"jsdoc/check-param-names": 1,
"jsdoc/check-syntax": 1,
"jsdoc/check-tag-names": 1,
"jsdoc/check-types": 1,
"jsdoc/check-values": 1,
"jsdoc/implements-on-classes": 1,
"jsdoc/match-description": 1,
"jsdoc/newline-after-description": 1,
"jsdoc/no-undefined-types": 1,
"jsdoc/require-jsdoc": 1,
"jsdoc/require-param": 1,
"jsdoc/require-param-description": 1,
"jsdoc/require-param-name": 1,
"jsdoc/require-param-type": 1,
"jsdoc/require-returns": 1,
"jsdoc/require-returns-check": 1,
"jsdoc/require-returns-description": 1,
"jsdoc/require-returns-type": 1,
"jsdoc/valid-types": 1
}
}
'use strict';
/* eslint consistent-return: 0 */
/* eslint "jsdoc/require-returns-check": 0 */
// -------------------------------------------------------------------------
// Variable definitions
// -------------------------------------------------------------------------
......@@ -12,17 +15,31 @@ const ssh = new SshClient();
// Helper functions
// -------------------------------------------------------------------------
/**
* Read SFTP options from file.
*
* @param {string} json - Name of JSON file.
* @returns {object} SFTP options.
*/
function readSftpOptions(json) {
try {
let o = fs.readFileSync(json);
o = JSON.parse(o);
return o;
const o = fs.readFileSync(json);
return JSON.parse(o);
} catch (err) {
console.error('Options read error: ' + err);
console.error(`Options read error: ${err}`);
throw err;
}
}
/**
* Download file from SFTP server.
*
* @param {object} sshOpt - SFTP options.
* @param {string} remoteFile - Name of file on remote SFTP server.
* @param {string} localFile - Name to save file as locally.
* @param {Function} callback - Callback function.
* @returns {Function} Callback function.
*/
function downloadFile(sshOpt, remoteFile, localFile, callback) {
ssh.on('ready', () => {
ssh.sftp((err, sftp) => {
......@@ -35,7 +52,7 @@ function downloadFile(sshOpt, remoteFile, localFile, callback) {
// This will commonly be the case since we are polling for the
// presence of a file (i.e. this is not an error). Return with
// an informational message and be done.
return callback(null, 'Remote file (' + remoteFile + ') not found');
return callback(null, `Remote file (${remoteFile}) not found`);
}
sftp.fastGet(remoteFile, localFile, (err) => {
if (err) {
......@@ -48,7 +65,7 @@ function downloadFile(sshOpt, remoteFile, localFile, callback) {
// system, but give a warning about it.
console.error('Problem removing remote file');
}
return callback(null, 'Downloaded to ' + localFile);
return callback(null, `Downloaded to ${localFile}`);
});
});
});
......@@ -66,7 +83,7 @@ function downloadFile(sshOpt, remoteFile, localFile, callback) {
// -------------------------------------------------------------------------
exports.doIt = function(optionsConf, callback) {
let o = readSftpOptions(optionsConf);
const o = readSftpOptions(optionsConf);
downloadFile(o.sshSettings, o.remoteFile, o.localFile, (err, msg) => {
if (err) {
ssh.end();
......
This diff is collapsed.
{
"name": "recfu-mover",
"version": "1.0.1",
"version": "1.0.2",
"main": "app.js",
"dependencies": {
"eslint": "^6.8.0",
"eslint-config-strongloop": "^2.1.0",
"eslint-plugin-jsdoc": "^32.3.3",
"eslint-plugin-node": "^11.1.0",
"mocha": "^7.0.1",
"rewire": "^4.0.1",
"ssh2": "^0.8.7"
......
......@@ -22,7 +22,7 @@ const exampleConf = liveConf + '.EXAMPLE';
// --------------------------------------------------------------------------
describe('Filesystem & JSON parsing integration', function() {
let configs = [exampleConf];
const configs = [exampleConf];
if (fs.existsSync(liveConf)) {
configs.push(liveConf);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment