diff --git a/lib/config/migration.js b/lib/config/migration.js index 558c48408fd2c86006d862d8e9d793cbbc0bb801..bcdad02fbbe4944f0f4e8709ae01efc1f036ff4a 100644 --- a/lib/config/migration.js +++ b/lib/config/migration.js @@ -167,7 +167,7 @@ function migrateConfig(config) { } else if ( key === 'automerge' && is.string(val) && - ['none', 'patch', 'minor', 'any'].indexOf(val) !== -1 + ['none', 'patch', 'minor', 'any'].includes(val) ) { delete migratedConfig.automerge; isMigrated = true; @@ -253,14 +253,14 @@ function migrateConfig(config) { } } for (let i = 0; i < schedules.length; i += 1) { - if (schedules[i].indexOf('on the last day of the month') !== -1) { + if (schedules[i].includes('on the last day of the month')) { isMigrated = true; schedules[i] = schedules[i].replace( 'on the last day of the month', 'on the first day of the month' ); } - if (schedules[i].indexOf('on every weekday') !== -1) { + if (schedules[i].includes('on every weekday')) { isMigrated = true; schedules[i] = schedules[i].replace( 'on every weekday', @@ -291,7 +291,7 @@ function migrateConfig(config) { migratedConfig.schedule = schedules; } } - } else if (is.string(val) && val.indexOf('{{semanticPrefix}}') === 0) { + } else if (is.string(val) && val.startsWith('{{semanticPrefix}}')) { isMigrated = true; migratedConfig[key] = val.replace( '{{semanticPrefix}}', diff --git a/lib/config/presets.js b/lib/config/presets.js index 5cbc6a24d92f9a9fc10fe2c0222ecb090e911791..7f6062cdf021df29de64171cc86176e8fbe13edc 100644 --- a/lib/config/presets.js +++ b/lib/config/presets.js @@ -21,7 +21,7 @@ async function resolveConfigPresets(inputConfig, existingPresets = []) { if (inputConfig.extends && inputConfig.extends.length) { for (const preset of inputConfig.extends) { // istanbul ignore if - if (existingPresets.indexOf(preset) !== -1) { + if (existingPresets.includes(preset)) { logger.warn(`Already seen preset ${preset} in ${existingPresets}`); } else { logger.trace(`Resolving preset "${preset}"`); @@ -78,7 +78,7 @@ async function resolveConfigPresets(inputConfig, existingPresets = []) { config[key].push(element); } } - } else if (is.object(val) && ignoredKeys.indexOf(key) === -1) { + } else if (is.object(val) && !ignoredKeys.includes(key)) { // Resolve nested objects logger.trace(`Resolving object "${key}"`); config[key] = await resolveConfigPresets(val, existingPresets); @@ -146,7 +146,7 @@ function parsePreset(input) { // non-scoped namespace [, packageName] = str.match(/(.*?)(:|$)/); presetName = str.slice(packageName.length + 1); - if (packageName.indexOf('renovate-config-') !== 0) { + if (!packageName.startsWith('renovate-config-')) { packageName = `renovate-config-${packageName}`; } if (presetName === '') { diff --git a/lib/config/validation.js b/lib/config/validation.js index a590592af070e3a662381926d53b4f33afdd244a..6b2099514f09a8f96564b2b0ab7e9ff604ef83dd 100644 --- a/lib/config/validation.js +++ b/lib/config/validation.js @@ -41,7 +41,7 @@ async function validateConfig(config, isPreset, parentPath) { 'forkToken', 'repository', ]; - return ignoredNodes.indexOf(key) !== -1; + return ignoredNodes.includes(key); } for (const [key, val] of Object.entries(config)) { diff --git a/lib/logger/config-serializer.js b/lib/logger/config-serializer.js index 56a6f70707513769da3ba42a791e9c415a06a259..7c67090c52252e3d308456e1bf536d1913b48274 100644 --- a/lib/logger/config-serializer.js +++ b/lib/logger/config-serializer.js @@ -24,10 +24,10 @@ function configSerializer(config) { const arrayFields = ['packageFiles', 'upgrades']; // eslint-disable-next-line array-callback-return return traverse(config).map(function scrub(val) { - if (val && redactedFields.indexOf(this.key) !== -1) { + if (val && redactedFields.includes(this.key)) { this.update('***********'); } - if (val && templateFields.indexOf(this.key) !== -1) { + if (val && templateFields.includes(this.key)) { this.update('[Template]'); } if (val && contentFields.includes(this.key)) { diff --git a/lib/logger/pretty-stdout.js b/lib/logger/pretty-stdout.js index f054450849c1ec0d75ec76a713859f3746873a81..601a01bcc6d04b62af979308c29565fbdd45731f 100644 --- a/lib/logger/pretty-stdout.js +++ b/lib/logger/pretty-stdout.js @@ -59,7 +59,7 @@ function getDetails(rec) { } const recFiltered = { ...rec }; Object.keys(recFiltered).forEach(key => { - if (bunyanFields.indexOf(key) !== -1 || metaFields.indexOf(key) !== -1) { + if (bunyanFields.includes(key) || metaFields.includes(key)) { delete recFiltered[key]; } }); diff --git a/lib/platform/github/gh-got-wrapper.js b/lib/platform/github/gh-got-wrapper.js index 1628ddc0de7e7b70209e1468e9a1fd25b960af1d..14f0af5e6629511675b8fb3c467e991ed3a009d7 100644 --- a/lib/platform/github/gh-got-wrapper.js +++ b/lib/platform/github/gh-got-wrapper.js @@ -77,8 +77,7 @@ async function get(path, opts, retries = 5) { retries > 0 && err.statusCode === 403 && err.message && - err.message.indexOf('You have triggered an abuse detection mechanism') === - 0 + err.message.startsWith('You have triggered an abuse detection mechanism') ) { logger.info( { statusCode: err.statusCode, message: err.message }, diff --git a/lib/platform/github/index.js b/lib/platform/github/index.js index 0d6f61556516040814594d25f1df2d7c3a1fa9f4..f9c48aade899d1ff76a6c428739a545c0034c045 100644 --- a/lib/platform/github/index.js +++ b/lib/platform/github/index.js @@ -396,7 +396,7 @@ async function getAllRenovateBranches(branchPrefix) { } )).body; return allBranches.reduce((arr, branch) => { - if (branch.ref.indexOf(`refs/heads/${branchPrefix}`) === 0) { + if (branch.ref.startsWith(`refs/heads/${branchPrefix}`)) { arr.push(branch.ref.substring('refs/heads/'.length)); } if ( diff --git a/lib/workers/branch/schedule.js b/lib/workers/branch/schedule.js index 50fa348cba4cf6a1017c34c64d3248453687ea48..41384c04a81c1420d05e68a2b30e5ab9f190ed4e 100644 --- a/lib/workers/branch/schedule.js +++ b/lib/workers/branch/schedule.js @@ -121,7 +121,7 @@ function isScheduledNow(config) { ]; const scheduledDays = schedule.d.map(day => dowMap[day]); logger.debug({ scheduledDays }, `scheduledDays`); - if (scheduledDays.indexOf(currentDay) === -1) { + if (!scheduledDays.includes(currentDay)) { logger.debug( `Does not match schedule because ${currentDay} is not in ${scheduledDays}` ); diff --git a/lib/workers/pr/index.js b/lib/workers/pr/index.js index 7b93f86adaac08d7c94e123b3a6115c713fc2293..f39462fb35e07305150aa34af493b92b228fb5c2 100644 --- a/lib/workers/pr/index.js +++ b/lib/workers/pr/index.js @@ -108,7 +108,7 @@ async function ensurePr(prConfig) { const upgradeKey = `${upgrade.depName}-${upgrade.manager}-${ upgrade.fromVersion }-${upgrade.toVersion}`; - if (processedUpgrades.indexOf(upgradeKey) !== -1) { + if (processedUpgrades.includes(upgradeKey)) { continue; // eslint-disable-line no-continue } processedUpgrades.push(upgradeKey); diff --git a/lib/workers/repository/finalise/prune.js b/lib/workers/repository/finalise/prune.js index a357c567ae560dffb56ae817694f61b003675859..dba4bfba99ee3c0faddd1a07abac5499e3807935 100644 --- a/lib/workers/repository/finalise/prune.js +++ b/lib/workers/repository/finalise/prune.js @@ -33,7 +33,7 @@ async function pruneStaleBranches(config, branchList) { ); } const remainingBranches = renovateBranches.filter( - branch => branchList.indexOf(branch) === -1 + branch => !branchList.includes(branch) ); logger.debug(`remainingBranches=${remainingBranches}`); if (remainingBranches.length === 0) { diff --git a/lib/workers/repository/onboarding/pr/config-description.js b/lib/workers/repository/onboarding/pr/config-description.js index 5e89e3e74828e23988afcde873e6e93193f3dd37..7563e2c61ff2b47a0d694aa91facd5fcc1de1844 100644 --- a/lib/workers/repository/onboarding/pr/config-description.js +++ b/lib/workers/repository/onboarding/pr/config-description.js @@ -26,9 +26,7 @@ function getConfigDesc(config, packageFiles) { logger.debug({ length: descriptionArr.length }, 'Found description array'); const managers = packageFiles ? Object.keys(packageFiles) : []; if (!(managers.includes('docker') || managers.includes('docker-compose'))) { - descriptionArr = descriptionArr.filter( - val => val.indexOf('Docker-only') === -1 - ); + descriptionArr = descriptionArr.filter(val => !val.includes('Docker-only')); } let desc = `\n## Configuration Summary\n\nBased on the currently configured presets, Renovate will:\n\n`; desc +=