diff --git a/lib/api/docker.js b/lib/api/docker.js index 159b058d1ed21cffec43d0ae1920d0f799338578..196d0b9cb4f03a1d3873407b3e4104cf0394c5b8 100644 --- a/lib/api/docker.js +++ b/lib/api/docker.js @@ -9,7 +9,7 @@ async function getDigest(name, tag, logger) { try { const authUrl = `https://auth.docker.io/token?service=registry.docker.io&scope=repository:${repository}:pull`; logger.debug(`Obtaining docker registry token for ${repository}`); - const token = (await got(authUrl, { json: true })).body.token; + const { token } = (await got(authUrl, { json: true })).body; if (!token) { logger.warn('Failed to obtain docker registry token'); return null; diff --git a/lib/api/github.js b/lib/api/github.js index 95f9626b6e899514fc64d916bcb412bf1b09ffb7..dc2e9247baaaf9e57969bf12a8383aa7912e316d 100644 --- a/lib/api/github.js +++ b/lib/api/github.js @@ -651,7 +651,7 @@ async function getFileContent(filePath, branchName) { ); try { const file = await getFile(filePath, branchName); - return new Buffer(file, 'base64').toString(); + return Buffer.from(file, 'base64').toString(); } catch (error) { if (error.statusCode === 404) { // If file not found, then return null JSON @@ -751,7 +751,7 @@ async function createBlob(fileContents) { return (await ghGotRetry.post(`repos/${config.repoName}/git/blobs`, { body: { encoding: 'base64', - content: new Buffer(fileContents).toString('base64'), + content: Buffer.from(fileContents).toString('base64'), }, })).body.sha; } diff --git a/lib/api/gitlab.js b/lib/api/gitlab.js index bb25a9b9dd8001906fdd3d609009f0f750646b21..55022b0709e56c6fde43b6fa33355d5bb6046588 100644 --- a/lib/api/gitlab.js +++ b/lib/api/gitlab.js @@ -226,7 +226,7 @@ async function getBranchStatus(branchName, requiredStatusChecks) { if (check.status === 'failed') { status = 'failure'; } else if (check.status !== 'success') { - status = check.status; + ({ status } = check); } } }); @@ -448,7 +448,7 @@ async function getFile(filePath, branchName) { async function getFileContent(filePath, branchName) { try { const file = await getFile(filePath, branchName); - return new Buffer(file, 'base64').toString(); + return Buffer.from(file, 'base64').toString(); } catch (error) { if (error.statusCode === 404) { // If file not found, then return null JSON @@ -475,7 +475,7 @@ async function createFile(branchName, filePath, fileContents, message) { branch_name: branchName, commit_message: message, encoding: 'base64', - content: new Buffer(fileContents).toString('base64'), + content: Buffer.from(fileContents).toString('base64'), }; } else { url = `projects/${config.repoName}/repository/files/${filePath}`; @@ -483,7 +483,7 @@ async function createFile(branchName, filePath, fileContents, message) { branch: branchName, commit_message: message, encoding: 'base64', - content: new Buffer(fileContents).toString('base64'), + content: Buffer.from(fileContents).toString('base64'), }; } await glGot.post(url, opts); @@ -500,7 +500,7 @@ async function updateFile(branchName, filePath, fileContents, message) { branch_name: branchName, commit_message: message, encoding: 'base64', - content: new Buffer(fileContents).toString('base64'), + content: Buffer.from(fileContents).toString('base64'), }; } else { url = `projects/${config.repoName}/repository/files/${filePath}`; @@ -508,7 +508,7 @@ async function updateFile(branchName, filePath, fileContents, message) { branch: branchName, commit_message: message, encoding: 'base64', - content: new Buffer(fileContents).toString('base64'), + content: Buffer.from(fileContents).toString('base64'), }; } await glGot.put(url, opts); diff --git a/lib/config/decrypt.js b/lib/config/decrypt.js index 1a13820645f9809b4e1bf7a5463a4b173ed96523..e0c3ae04dcca1ecd396d46f90b20a5c41152d1f8 100644 --- a/lib/config/decrypt.js +++ b/lib/config/decrypt.js @@ -21,7 +21,7 @@ function decryptConfig( const decryptedStr = crypto .privateDecrypt( privateKey, - new Buffer(val[encryptedKey], 'base64') + Buffer.from(val[encryptedKey], 'base64') ) .toString(); logger.info(`Decrypted ${encryptedKey}`); diff --git a/lib/config/migration.js b/lib/config/migration.js index 74dea3413b368ea46e0c1536ca80a04b582bc808..0d5a3491359b5930e2624110c99d16173166a56c 100644 --- a/lib/config/migration.js +++ b/lib/config/migration.js @@ -145,7 +145,7 @@ function migrateConfig(config, parentConfig) { } if (isMigrated) { if (typeof val === 'string' && schedules.length === 1) { - migratedConfig.schedule = schedules[0]; + [migratedConfig.schedule] = schedules; } else { migratedConfig.schedule = schedules; } diff --git a/lib/config/presets.js b/lib/config/presets.js index 0e76d809c3839eed75e29afc79e72cf429483a05..2d16653331164b4a5f51db6b38f4c95b13f6b805 100644 --- a/lib/config/presets.js +++ b/lib/config/presets.js @@ -113,7 +113,7 @@ function parsePreset(input) { presetName = str.slice(1); } else if (str[0] === '@') { // scoped namespace - packageName = str.match(/(@.*?)(:|$)/)[1]; + [, packageName] = str.match(/(@.*?)(:|$)/); str = str.slice(packageName.length); if (!packageName.includes('/')) { packageName += '/renovate-config'; @@ -125,7 +125,7 @@ function parsePreset(input) { } } else { // non-scoped namespace - packageName = str.match(/(.*?)(:|$)/)[1]; + [, packageName] = str.match(/(.*?)(:|$)/); presetName = str.slice(packageName.length + 1); if (packageName.indexOf('renovate-config-') !== 0) { packageName = `renovate-config-${packageName}`; @@ -187,7 +187,7 @@ async function getPreset(preset, logger) { if (presetKeys.every(key => packageListKeys.includes(key))) { delete presetConfig.description; } - const migratedConfig = migration.migrateConfig(presetConfig).migratedConfig; + const { migratedConfig } = migration.migrateConfig(presetConfig); return massage.massageConfig(migratedConfig); } diff --git a/lib/logger/pretty-stdout.js b/lib/logger/pretty-stdout.js index a48055940fe03afea2bc3f96ebd3bcb70e0aa99d..f054450849c1ec0d75ec76a713859f3746873a81 100644 --- a/lib/logger/pretty-stdout.js +++ b/lib/logger/pretty-stdout.js @@ -1,7 +1,7 @@ // Code derived from https://github.com/hadfieldn/node-bunyan-RenovateStream and heavily edited // Neither fork nor original repo appear to be maintained -const Stream = require('stream').Stream; +const { Stream } = require('stream'); const util = require('util'); const chalk = require('chalk'); const stringify = require('json-stringify-pretty-compact'); diff --git a/lib/workers/branch/status-checks.js b/lib/workers/branch/status-checks.js index a7a427cf060ba49226b7e46cb44c7ae763365534..2fc441812300326bdda8ba0cfcec1636b769734f 100644 --- a/lib/workers/branch/status-checks.js +++ b/lib/workers/branch/status-checks.js @@ -10,7 +10,7 @@ async function setUnpublishable(config) { if (typeof unpublishable !== 'undefined') { unpublishable = unpublishable && upgrade.unpublishable; } else { - unpublishable = upgrade.unpublishable; + ({ unpublishable } = upgrade); } } } diff --git a/lib/workers/package-file/index.js b/lib/workers/package-file/index.js index 0d4f967230c061c48b8d6d5f80543e3647359df5..2406209763187e8a7ba802b5e51c8e1459b41cd5 100644 --- a/lib/workers/package-file/index.js +++ b/lib/workers/package-file/index.js @@ -16,7 +16,7 @@ async function renovatePackageFile(packageFileConfig) { npmApi.setNpmrc(config.npmrc); } let upgrades = []; - logger = config.logger; + ({ logger } = config); logger.info(`Processing package file`); // Check if config is disabled @@ -75,7 +75,7 @@ async function renovatePackageFile(packageFileConfig) { async function renovateMeteorPackageFile(packageFileConfig) { const config = { ...packageFileConfig }; let upgrades = []; - logger = config.logger; + ({ logger } = config); logger.info(`Processing meteor package file`); // Check if config is disabled @@ -95,7 +95,7 @@ async function renovateMeteorPackageFile(packageFileConfig) { async function renovateDockerfile(packageFileConfig) { let upgrades = []; - logger = packageFileConfig.logger; + ({ logger } = packageFileConfig); logger.info(`Processing Dockerfile`); // Check if config is disabled diff --git a/lib/workers/package/index.js b/lib/workers/package/index.js index bedf0875806ed311ec71c4671003d066677753a0..1aecca9b015a47f072d813f1113bd9717a75b1f3 100644 --- a/lib/workers/package/index.js +++ b/lib/workers/package/index.js @@ -8,7 +8,7 @@ module.exports = { // Returns all results for a given dependency config async function renovatePackage(config) { - const logger = config.logger; + const { logger } = config; logger.trace(`renovatePackage(${config.depName})`); if (config.enabled === false) { logger.debug('package is disabled'); diff --git a/lib/workers/package/versions.js b/lib/workers/package/versions.js index 58a4cf9c82a4da39ed38ef167c1f19f93d537b81..57e78ee9517eca97c306b5c13e28fb456a265335 100644 --- a/lib/workers/package/versions.js +++ b/lib/workers/package/versions.js @@ -18,8 +18,8 @@ function determineUpgrades(npmDep, config) { const result = { type: 'warning', }; - const currentVersion = config.currentVersion; - const versions = npmDep.versions; + const { currentVersion } = config; + const { versions } = npmDep; if (!versions || Object.keys(versions).length === 0) { result.message = `No versions returned from registry for this package`; logger.warn(result.message); diff --git a/lib/workers/pr/index.js b/lib/workers/pr/index.js index 5ab329ea6251d15853a4b4d20061254353a386b3..082e6edf4950e747be1b825159e828d2e9431511 100644 --- a/lib/workers/pr/index.js +++ b/lib/workers/pr/index.js @@ -16,9 +16,8 @@ async function ensurePr(prConfig) { const { logger } = config; logger.trace({ config }, 'ensurePr'); // If there is a group, it will use the config of the first upgrade in the array - const upgrades = config.upgrades; + const { branchName, upgrades } = config; config.upgrades = []; - const branchName = config.branchName; const branchStatus = await config.api.getBranchStatus( branchName, config.requiredStatusChecks @@ -100,7 +99,7 @@ async function ensurePr(prConfig) { commit.shortSha = change.sha.slice(0, 7); commit.url = `${logJSON.project.repository}/commit/${change.sha}`; if (change.message) { - commit.message = change.message.split('\n')[0]; + [commit.message] = change.message.split('\n'); if (!config.isGitHub || config.privateRepo === true) { commit.message = commit.message.replace( issueRe, diff --git a/lib/workers/repository/apis.js b/lib/workers/repository/apis.js index 44e57c0e874b07e49c8a09c434eb07076a19578e..b4498493b41e04f9d4b54ea53db6be99cf649e51 100644 --- a/lib/workers/repository/apis.js +++ b/lib/workers/repository/apis.js @@ -46,7 +46,7 @@ async function checkMonorepos(input) { let workspaces = []; for (const packageFile of config.packageFiles) { if (packageFile.packageFile === 'package.json') { - workspaces = packageFile.content.workspaces; + ({ workspaces } = packageFile.content); } } logger.debug({ workspaces }, 'workspaces'); @@ -418,7 +418,7 @@ async function resolvePackageFiles(inputConfig) { ); continue; // eslint-disable-line } - packageFile.currentFrom = fromMatch[1]; + [, packageFile.currentFrom] = fromMatch; logger.debug('Adding Dockerfile'); } diff --git a/lib/workers/repository/cleanup.js b/lib/workers/repository/cleanup.js index f219a5de0b63a35a75caa6dc6c87de73cf7fcae7..559aadb7ada0c9cba99a021fcb312e7f929140f6 100644 --- a/lib/workers/repository/cleanup.js +++ b/lib/workers/repository/cleanup.js @@ -3,7 +3,7 @@ module.exports = { }; async function pruneStaleBranches(config, branchList) { - const logger = config.logger; + const { logger } = config; logger.debug('Removing any stale branches'); logger.trace({ config, branchList }, `pruneStaleBranches`); if (config.platform !== 'github') { diff --git a/package.json b/package.json index ea5626046f12390db1138d6ff410922c635b76f7..d52ec8e59c9005af987dd0ece6ecc818cda502e2 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "chai": "4.1.2", "condition-circle": "1.5.0", "eslint": "4.6.1", - "eslint-config-airbnb-base": "11.3.2", + "eslint-config-airbnb-base": "12.0.0", "eslint-config-prettier": "2.4.0", "eslint-plugin-import": "2.7.0", "eslint-plugin-prettier": "2.2.0", diff --git a/test/.eslintrc.js b/test/.eslintrc.js index e0048625ec30267c17bc10c95bd5671636f62fe8..b575cb6d3ec276d9a509d273f7664ea44f8ed875 100644 --- a/test/.eslintrc.js +++ b/test/.eslintrc.js @@ -1,9 +1,10 @@ module.exports = { - 'env': { - 'jest': true, - }, - 'rules': { - 'import/no-extraneous-dependencies': 0, - 'global-require': 0 - }, + env: { + jest: true + }, + rules: { + "prefer-promise-reject-errors": 0, + "import/no-extraneous-dependencies": 0, + "global-require": 0 + } }; diff --git a/yarn.lock b/yarn.lock index 1b5898216527f12c27ec8153f7e7d9b6503c93f6..6ee76d95efcd5faccbe3e31f912f66e77fda6050 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1402,9 +1402,9 @@ escodegen@^1.6.1: optionalDependencies: source-map "~0.5.6" -eslint-config-airbnb-base@11.3.2: - version "11.3.2" - resolved "https://registry.yarnpkg.com/eslint-config-airbnb-base/-/eslint-config-airbnb-base-11.3.2.tgz#8703b11abe3c88ac7ec2b745b7fdf52e00ae680a" +eslint-config-airbnb-base@12.0.0: + version "12.0.0" + resolved "https://registry.yarnpkg.com/eslint-config-airbnb-base/-/eslint-config-airbnb-base-12.0.0.tgz#99063aaef4b8698083481a00e165cbe15e82d615" dependencies: eslint-restricted-globals "^0.1.1"