diff --git a/bin/config-validator.js b/bin/config-validator.js index e74162cd650063fe9445bfef5883f3b1f547957f..68f5a1b1bdc83e230bde3011f01a4905efae8eeb 100755 --- a/bin/config-validator.js +++ b/bin/config-validator.js @@ -27,7 +27,9 @@ async function validate(desc, config, isPreset = false) { } (async () => { - for (const file of configFileNames.filter(name => name !== 'package.json')) { + for (const file of configFileNames.filter( + (name) => name !== 'package.json' + )) { try { const rawContent = fs.readFileSync(file, 'utf8'); console.log(`Validating ${file}`); diff --git a/lib/config/cli.ts b/lib/config/cli.ts index 2ee615ed7cabf0df02fc7e2c62a8dcb1fdb6301c..fd7b3d3c7bcbd6052742f66ea317ba54a8c6f4a1 100644 --- a/lib/config/cli.ts +++ b/lib/config/cli.ts @@ -17,7 +17,7 @@ export interface RenovateCliConfig extends Record<string, any> { export function getConfig(input: string[]): RenovateCliConfig { // massage migrated configuration keys const argv = input - .map(a => + .map((a) => a .replace('--endpoints=', '--host-rules=') .replace('--expose-env=true', '--trust-level=high') @@ -27,7 +27,7 @@ export function getConfig(input: string[]): RenovateCliConfig { .replace('"endpoint":"', '"baseUrl":"') .replace('"host":"', '"hostName":"') ) - .filter(a => !a.startsWith('--git-fs')); + .filter((a) => !a.startsWith('--git-fs')); const options = getOptions(); const config: RenovateCliConfig = {}; @@ -53,7 +53,7 @@ export function getConfig(input: string[]): RenovateCliConfig { try { return JSON.parse(val); } catch (err) { - return val.split(',').map(el => el.trim()); + return val.split(',').map((el) => el.trim()); } }, object: (val: string): any => { @@ -72,7 +72,7 @@ export function getConfig(input: string[]): RenovateCliConfig { let program = new Command().arguments('[repositories...]'); - options.forEach(option => { + options.forEach((option) => { if (option.cli !== false) { const param = `<${option.type}>`.replace('<boolean>', '[boolean]'); const optionString = `${getCliName(option)} ${param}`; @@ -103,14 +103,14 @@ export function getConfig(input: string[]): RenovateCliConfig { program = program .version(version, '-v, --version') .on('--help', helpConsole) - .action(repositories => { + .action((repositories) => { if (repositories && repositories.length) { config.repositories = repositories; } }) .parse(argv); - options.forEach(option => { + options.forEach((option) => { if (option.cli !== false) { if (program[option.name] !== undefined) { config[option.name] = program[option.name]; diff --git a/lib/config/decrypt.ts b/lib/config/decrypt.ts index fcd80604330c80d49ec0b666b55592ae8cf64e59..296a532e144eb832c7ccf193bf11aec4361a89cc 100644 --- a/lib/config/decrypt.ts +++ b/lib/config/decrypt.ts @@ -84,7 +84,7 @@ export function decryptConfig( delete decryptedConfig.encrypted; } else if (is.array(val)) { decryptedConfig[key] = []; - val.forEach(item => { + val.forEach((item) => { if (is.object(item) && !is.array(item)) { (decryptedConfig[key] as RenovateConfig[]).push( decryptConfig(item as RenovateConfig, privateKey) diff --git a/lib/config/defaults.ts b/lib/config/defaults.ts index 1748362b45b6dbbf323f341ed17fa2bde6fb1a4a..e09aeba09b0f478563036637c24828f2216c32a9 100644 --- a/lib/config/defaults.ts +++ b/lib/config/defaults.ts @@ -17,7 +17,7 @@ export function getDefault(option: RenovateOptions): any { export function getConfig(): RenovateConfig { const options = getOptions(); const config: RenovateConfig = {}; - options.forEach(option => { + options.forEach((option) => { if (!option.parent) { config[option.name] = getDefault(option); } diff --git a/lib/config/definitions.spec.ts b/lib/config/definitions.spec.ts index 55b5330e80783acdba2dd1a3a873dc045b3e8d54..460a84e2877a5a4a3a3ad59a370e17d6d03cfada 100644 --- a/lib/config/definitions.spec.ts +++ b/lib/config/definitions.spec.ts @@ -8,6 +8,6 @@ jest.mock('../manager', () => ({ describe(getName(__filename), () => { it('test manager should have no defaultConfig', () => { const opts = getOptions(); - expect(opts.filter(o => o.name === 'testManager')).toEqual([]); + expect(opts.filter((o) => o.name === 'testManager')).toEqual([]); }); }); diff --git a/lib/config/env.ts b/lib/config/env.ts index 3946d684bf42c62f0bb767472405e20218bfc5c6..09f389fc7191367a11e7d609fc5768ae5d774b7f 100644 --- a/lib/config/env.ts +++ b/lib/config/env.ts @@ -24,13 +24,13 @@ export function getConfig(env: NodeJS.ProcessEnv): RenovateConfig { const coersions = { boolean: (val: string): boolean => val === 'true', - array: (val: string): string[] => val.split(',').map(el => el.trim()), + array: (val: string): string[] => val.split(',').map((el) => el.trim()), string: (val: string): string => val.replace(/\\n/g, '\n'), object: (val: string): any => JSON.parse(val), integer: parseInt, }; - options.forEach(option => { + options.forEach((option) => { if (option.env !== false) { const envName = getEnvName(option); if (env[envName]) { @@ -86,7 +86,7 @@ export function getConfig(env: NodeJS.ProcessEnv): RenovateConfig { 'VSTS_TOKEN', ]; // eslint-disable-next-line no-param-reassign - unsupportedEnv.forEach(val => delete env[val]); + unsupportedEnv.forEach((val) => delete env[val]); return config; } diff --git a/lib/config/index.spec.ts b/lib/config/index.spec.ts index e5c9d405a8692d7c17ad605c1514a72dd3a31298..fac0d6cc1aa978b847ac34a2e51381ed629ebbb7 100644 --- a/lib/config/index.spec.ts +++ b/lib/config/index.spec.ts @@ -83,7 +83,7 @@ describe('config/index', () => { }; const configParser = await import('./index'); const config = configParser.mergeChildConfig(parentConfig, childConfig); - expect(config.packageRules.map(rule => rule.a)).toMatchObject([ + expect(config.packageRules.map((rule) => rule.a)).toMatchObject([ 1, 2, 3, diff --git a/lib/config/index.ts b/lib/config/index.ts index 0e012e657b9ce078c5d6d825408f353304dc7a65..047bc94f57e9d6617ca156e988c11c69d73ffa73 100644 --- a/lib/config/index.ts +++ b/lib/config/index.ts @@ -112,7 +112,7 @@ export async function parseConfigs( // Move global variables that we need to use later const importGlobals = ['prBanner', 'prFooter']; config.global = {}; - importGlobals.forEach(key => { + importGlobals.forEach((key) => { config.global[key] = config[key]; delete config[key]; }); diff --git a/lib/config/massage.ts b/lib/config/massage.ts index 375027781f7dc4ed7bc5652e5ffca434e60fbcba..2e4c68ed5218de525f1e4c419b5e9323eb98910f 100644 --- a/lib/config/massage.ts +++ b/lib/config/massage.ts @@ -11,7 +11,7 @@ let allowedStrings: string[]; export function massageConfig(config: RenovateConfig): RenovateConfig { if (!allowedStrings) { allowedStrings = []; - options.forEach(option => { + options.forEach((option) => { if (option.allowString) { allowedStrings.push(option.name); } @@ -26,7 +26,7 @@ export function massageConfig(config: RenovateConfig): RenovateConfig { delete massagedConfig.npmToken; } else if (is.array(val)) { massagedConfig[key] = []; - val.forEach(item => { + val.forEach((item) => { if (is.object(item)) { (massagedConfig[key] as RenovateConfig[]).push( massageConfig(item as RenovateConfig) @@ -66,7 +66,7 @@ export function massageConfig(config: RenovateConfig): RenovateConfig { } } for (const rule of newRules) { - updateTypes.forEach(updateType => { + updateTypes.forEach((updateType) => { delete rule[updateType]; }); } diff --git a/lib/config/migration.ts b/lib/config/migration.ts index da3bbf7532b7d0b0f013826ee744282fc8903524..3140be5f33b04a5a43ca2641bfb40c8c345ed095 100644 --- a/lib/config/migration.ts +++ b/lib/config/migration.ts @@ -47,7 +47,7 @@ export function migrateConfig( try { if (!optionTypes) { optionTypes = {}; - options.forEach(option => { + options.forEach((option) => { optionTypes[option.name] = option.type; }); } @@ -69,7 +69,7 @@ export function migrateConfig( if (is.array(val)) { migratedConfig.packageRules = migratedConfig.packageRules || []; const migratedPathRules = migratedConfig.pathRules.map( - p => migrateConfig(p, key).migratedConfig + (p) => migrateConfig(p, key).migratedConfig ); migratedConfig.packageRules = migratedPathRules.concat( migratedConfig.packageRules @@ -282,7 +282,9 @@ export function migrateConfig( isMigrated = true; migratedConfig.packageRules = migratedConfig.packageRules || []; migratedConfig.packageRules = migratedConfig.packageRules.concat( - migratedConfig.packages.map(p => migrateConfig(p, key).migratedConfig) + migratedConfig.packages.map( + (p) => migrateConfig(p, key).migratedConfig + ) ); delete migratedConfig.packages; } else if (key === 'excludedPackageNames') { @@ -386,7 +388,7 @@ export function migrateConfig( '{{#if semanticCommitType}}{{semanticCommitType}}{{#if semanticCommitScope}}({{semanticCommitScope}}){{/if}}: {{/if}}' ); } else if (key === 'depTypes' && is.array(val)) { - val.forEach(depType => { + val.forEach((depType) => { if (is.object(depType) && !is.array(depType)) { const depTypeName = (depType as any).depType; if (depTypeName) { diff --git a/lib/config/presets/index.ts b/lib/config/presets/index.ts index 1e0bf2b048a178561a751e16f5d6ae1b46e01a5e..ee2bdc2d515075bfb815916c2e022c78f952667b 100644 --- a/lib/config/presets/index.ts +++ b/lib/config/presets/index.ts @@ -68,7 +68,7 @@ export function parsePreset(input: string): ParsedPreset { params = str .slice(str.indexOf('(') + 1, -1) .split(',') - .map(elem => elem.trim()); + .map((elem) => elem.trim()); str = str.slice(0, str.indexOf('(')); } if (str.startsWith(':')) { @@ -133,7 +133,7 @@ export async function getPreset(preset: string): Promise<RenovateConfig> { 'packagePatterns', 'excludePackagePatterns', ]; - if (presetKeys.every(key => packageListKeys.includes(key))) { + if (presetKeys.every((key) => packageListKeys.includes(key))) { delete presetConfig.description; } const { migratedConfig } = migration.migrateConfig(presetConfig); diff --git a/lib/config/presets/npm.spec.ts b/lib/config/presets/npm.spec.ts index fd441c911d6dc0f3bc1daa522412a3b9249f29df..868478c0eaf060d185c0e8ab008616d229d1976e 100644 --- a/lib/config/presets/npm.spec.ts +++ b/lib/config/presets/npm.spec.ts @@ -17,9 +17,7 @@ describe('config/presets/npm', () => { delete process.env.RENOVATE_CACHE_NPM_MINUTES; }); it('should throw if no package', async () => { - nock('https://registry.npmjs.org') - .get('/nopackage') - .reply(404); + nock('https://registry.npmjs.org').get('/nopackage').reply(404); await expect(npm.getPreset('nopackage', 'default')).rejects.toThrow( /dep not found/ ); diff --git a/lib/config/validation-helpers/managers.ts b/lib/config/validation-helpers/managers.ts index dfa6ef9dc9e57a366b6ecfc0afa87d548475619c..9a6db2268f208ddedc6a066fca242be08c87918f 100644 --- a/lib/config/validation-helpers/managers.ts +++ b/lib/config/validation-helpers/managers.ts @@ -17,7 +17,7 @@ export function check({ if (Array.isArray(resolvedRule.managers)) { if ( resolvedRule.managers.find( - confManager => !getManagerList().includes(confManager) + (confManager) => !getManagerList().includes(confManager) ) ) { managersErrMessage = `${currentPath}: diff --git a/lib/config/validation.ts b/lib/config/validation.ts index 200bb43792d16a6e3f93c40c810fc48499cd322e..203a860981ff918e2cdde27b3e3863a0aa1c0e07 100644 --- a/lib/config/validation.ts +++ b/lib/config/validation.ts @@ -23,7 +23,7 @@ export async function validateConfig( ): Promise<ValidationResult> { if (!optionTypes) { optionTypes = {}; - options.forEach(option => { + options.forEach((option) => { optionTypes[option.name] = option.type; }); } @@ -212,10 +212,12 @@ export async function validateConfig( ]; for (const regexManager of val) { if ( - Object.keys(regexManager).some(k => !allowedKeys.includes(k)) + Object.keys(regexManager).some( + (k) => !allowedKeys.includes(k) + ) ) { const disallowedKeys = Object.keys(regexManager).filter( - k => !allowedKeys.includes(k) + (k) => !allowedKeys.includes(k) ); errors.push({ depName: 'Configuration Error', @@ -253,7 +255,7 @@ export async function validateConfig( for (const field of mandatoryFields) { if ( !regexManager[`${field}Template`] && - !regexManager.matchStrings.some(matchString => + !regexManager.matchStrings.some((matchString) => matchString.includes(`(?<${field}>`) ) ) { @@ -314,8 +316,8 @@ export async function validateConfig( } else if (type === 'object' && currentPath !== 'compatibility') { if (is.object(val)) { const ignoredObjects = options - .filter(option => option.freeChoice) - .map(option => option.name); + .filter((option) => option.freeChoice) + .map((option) => option.name); if (!ignoredObjects.includes(key)) { const subValidation = await module.exports.validateConfig( val, diff --git a/lib/datasource/crate/index.ts b/lib/datasource/crate/index.ts index 785724fdf651bab3af89e47e9fee22e67e7a9043..4d4f820aecf43937eeb84df31ccd06c13cad7bf5 100644 --- a/lib/datasource/crate/index.ts +++ b/lib/datasource/crate/index.ts @@ -53,7 +53,7 @@ export async function getReleases({ } res = res.body; res = res.split('\n'); - res = res.map(line => line.trim()).filter(line => line.length !== 0); + res = res.map((line) => line.trim()).filter((line) => line.length !== 0); if (res.length === 0) { logger.warn( { dependency: lookupName }, diff --git a/lib/datasource/docker/index.ts b/lib/datasource/docker/index.ts index acc5411fac6412857a8eca1dbb07c67808dee46d..d8d9e22fbfcac62985268677ffd2ce1963cc81d8 100644 --- a/lib/datasource/docker/index.ts +++ b/lib/datasource/docker/index.ts @@ -97,7 +97,7 @@ function getECRAuthToken( config.secretAccessKey = opts.password; } const ecr = new AWS.ECR(config); - return new Promise<string>(resolve => { + return new Promise<string>((resolve) => { ecr.getAuthorizationToken({}, (err, data) => { if (err) { logger.trace({ err }, 'err'); @@ -612,7 +612,7 @@ export async function getReleases({ if (!tags) { return null; } - const releases = tags.map(version => ({ version })); + const releases = tags.map((version) => ({ version })); const ret: ReleaseResult = { dockerRegistry: registry, dockerRepository: repository, diff --git a/lib/datasource/git-refs/index.spec.ts b/lib/datasource/git-refs/index.spec.ts index 018f1c6772b17f2cb6a522dc2124e5869321d862..fb0ef7aa9f4d7f47ab1b5346c7dc71dbb9b9473b 100644 --- a/lib/datasource/git-refs/index.spec.ts +++ b/lib/datasource/git-refs/index.spec.ts @@ -40,7 +40,7 @@ describe('datasource/git-refs', () => { lookupName, }); - const result = versions.releases.map(x => x.version).sort(); + const result = versions.releases.map((x) => x.version).sort(); expect(result).toEqual(['0.0.1', 'v0.0.2', 'v0.0.3']); }); }); diff --git a/lib/datasource/git-refs/index.ts b/lib/datasource/git-refs/index.ts index 56277e3f7dd4455fefbe9bbed9bdb01c5ae9f73d..d9fa25d751535095ee4587737ee4d0b84ab370ef 100644 --- a/lib/datasource/git-refs/index.ts +++ b/lib/datasource/git-refs/index.ts @@ -49,7 +49,7 @@ export async function getRawRefs({ .split('\n'); const refMatch = /(?<type>\w+)\/(?<value>.*)/; - const result = refs.map(ref => { + const result = refs.map((ref) => { const match = refMatch.exec(ref); return { type: match.groups.type, @@ -72,9 +72,9 @@ export async function getReleases({ const rawRefs: RawRefs[] = await getRawRefs({ lookupName }); const refs = rawRefs - .filter(ref => ref.type === 'tags' || ref.type === 'heads') - .map(ref => ref.value) - .filter(ref => semver.isVersion(ref)); + .filter((ref) => ref.type === 'tags' || ref.type === 'heads') + .map((ref) => ref.value) + .filter((ref) => semver.isVersion(ref)); const uniqueRefs = [...new Set(refs)]; @@ -82,7 +82,7 @@ export async function getReleases({ const result: ReleaseResult = { sourceUrl, - releases: uniqueRefs.map(ref => ({ + releases: uniqueRefs.map((ref) => ({ version: ref, gitRef: ref, })), diff --git a/lib/datasource/git-submodules/index.spec.ts b/lib/datasource/git-submodules/index.spec.ts index ddba901f603d083d90519e189e0015b45a257cb1..75c33c49b7fe84ee85b7831ef39b71ae8747b666 100644 --- a/lib/datasource/git-submodules/index.spec.ts +++ b/lib/datasource/git-submodules/index.spec.ts @@ -39,7 +39,7 @@ describe('datasource/git-submoduless', () => { lookupName, registryUrls, }); - const result = versions.releases.map(x => x.version).sort(); + const result = versions.releases.map((x) => x.version).sort(); expect(result).toEqual(['commithash1']); }); }); diff --git a/lib/datasource/git-submodules/index.ts b/lib/datasource/git-submodules/index.ts index ddcbb50869d674431810b3c610997e492d724ee3..fb501d9a9e42d5122396bf8dbfff8bd9ed3132ee 100644 --- a/lib/datasource/git-submodules/index.ts +++ b/lib/datasource/git-submodules/index.ts @@ -52,4 +52,4 @@ export async function getReleases({ export const getDigest = ( config: DigestConfig, newValue?: string -): Promise<string> => new Promise(resolve => resolve(newValue)); +): Promise<string> => new Promise((resolve) => resolve(newValue)); diff --git a/lib/datasource/git-tags/index.spec.ts b/lib/datasource/git-tags/index.spec.ts index b40c894683479d8fbbd63cb71062d9d62e9a8a38..ff8efdc99c4c1d9c7cd603da96b6409d0c75e3a6 100644 --- a/lib/datasource/git-tags/index.spec.ts +++ b/lib/datasource/git-tags/index.spec.ts @@ -39,7 +39,7 @@ describe('datasource/git-tags', () => { const versions = await getReleases({ lookupName, }); - const result = versions.releases.map(x => x.version).sort(); + const result = versions.releases.map((x) => x.version).sort(); expect(result).toEqual(['0.0.1', 'v0.0.2']); }); }); diff --git a/lib/datasource/git-tags/index.ts b/lib/datasource/git-tags/index.ts index e3100080001561951595d15d1c4ba13443c89bde..796a76c449d3a420da1134b4e7dc7770b6366c2d 100644 --- a/lib/datasource/git-tags/index.ts +++ b/lib/datasource/git-tags/index.ts @@ -13,15 +13,15 @@ export async function getReleases({ return null; } const tags = rawRefs - .filter(ref => ref.type === 'tags') - .map(ref => ref.value) - .filter(tag => semver.isVersion(tag)); + .filter((ref) => ref.type === 'tags') + .map((ref) => ref.value) + .filter((tag) => semver.isVersion(tag)); const sourceUrl = lookupName.replace(/\.git$/, '').replace(/\/$/, ''); const result: ReleaseResult = { sourceUrl, - releases: tags.map(tag => ({ + releases: tags.map((tag) => ({ version: tag, gitRef: tag, })), diff --git a/lib/datasource/github-releases/index.spec.ts b/lib/datasource/github-releases/index.spec.ts index b1272f5b915e97433250fd564ef68d3ec78d7a80..bf0b4dd8b7fe18988bf2723d4e70efaf3f5c506a 100644 --- a/lib/datasource/github-releases/index.spec.ts +++ b/lib/datasource/github-releases/index.spec.ts @@ -26,7 +26,7 @@ describe('datasource/github-releases', () => { expect(res).toMatchSnapshot(); expect(res.releases).toHaveLength(4); expect( - res.releases.find(release => release.version === 'v1.1.0') + res.releases.find((release) => release.version === 'v1.1.0') ).toBeDefined(); }); }); diff --git a/lib/datasource/github-tags/index.ts b/lib/datasource/github-tags/index.ts index 05ae4ce3eae25477bd388c8bd328a79717fb3d2a..44c3064e846b24a70b884bb584e615115441f4c7 100644 --- a/lib/datasource/github-tags/index.ts +++ b/lib/datasource/github-tags/index.ts @@ -131,7 +131,7 @@ export async function getReleases({ await ghGot<GitHubTag>(url, { paginate: true, }) - ).body.map(o => o.name); + ).body.map((o) => o.name); } catch (err) { logger.debug({ repo, err }, 'Error retrieving from github'); } @@ -142,7 +142,7 @@ export async function getReleases({ sourceUrl: 'https://github.com/' + repo, releases: null, }; - dependency.releases = versions.map(version => ({ + dependency.releases = versions.map((version) => ({ version, gitRef: version, })); diff --git a/lib/datasource/go/index.ts b/lib/datasource/go/index.ts index ad579a5007b40c2b3c53f7be9744e90b8646d5b1..24444a478d5560b7fde02f6636423e44df7d68cd 100644 --- a/lib/datasource/go/index.ts +++ b/lib/datasource/go/index.ts @@ -103,9 +103,9 @@ export async function getReleases({ logger.trace(`go.getReleases.prefix:${prefix}`); const submodReleases = res.releases .filter( - release => release.version && release.version.startsWith(prefix) + (release) => release.version && release.version.startsWith(prefix) ) - .map(release => { + .map((release) => { const r2 = release; r2.version = r2.version.replace(`${prefix}/`, ''); return r2; @@ -118,7 +118,7 @@ export async function getReleases({ } if (res && res.releases) { res.releases = res.releases.filter( - release => release.version && release.version.startsWith('v') + (release) => release.version && release.version.startsWith('v') ); } return res; diff --git a/lib/datasource/gradle-version/index.ts b/lib/datasource/gradle-version/index.ts index e0fa9d3a2d87b932425d930a7c58da9bfb836630..c1c942dd6cba948744fab963ef3d3206d77ec1cc 100644 --- a/lib/datasource/gradle-version/index.ts +++ b/lib/datasource/gradle-version/index.ts @@ -48,17 +48,17 @@ export async function getReleases({ : [GradleVersionsServiceUrl]; const allReleases: Release[][] = await Promise.all( - versionsUrls.map(async url => { + versionsUrls.map(async (url) => { try { const response = await http.getJson<GradleRelease[]>(url); const releases = response.body - .filter(release => !release.snapshot && !release.nightly) + .filter((release) => !release.snapshot && !release.nightly) .filter( - release => + (release) => // some milestone have wrong metadata and need to be filtered by version name content release.rcFor === '' && !release.version.includes('milestone') ) - .map(release => ({ + .map((release) => ({ version: coerce(release.version).toString(), downloadUrl: release.downloadUrl, checksumUrl: release.checksumUrl, diff --git a/lib/datasource/helm/index.ts b/lib/datasource/helm/index.ts index 1b15ff6f2e1c41f0b18acc85251842dfc969bd61..e4ad15ec8823484cd1a69c37565630dab61341ff 100644 --- a/lib/datasource/helm/index.ts +++ b/lib/datasource/helm/index.ts @@ -100,7 +100,7 @@ export async function getReleases({ logger.debug(`Couldn't get index.yaml file from ${helmRepository}`); return null; } - const releases = repositoryData.find(chart => chart.name === lookupName); + const releases = repositoryData.find((chart) => chart.name === lookupName); if (!releases) { logger.warn( { dependency: lookupName }, diff --git a/lib/datasource/index.ts b/lib/datasource/index.ts index 1e277e1f1b25650f8c975201be3e4b9d54aed261..6c8a21f99e86f61de1fe9b444adf190c13b0fcfe 100644 --- a/lib/datasource/index.ts +++ b/lib/datasource/index.ts @@ -108,7 +108,7 @@ export async function getPkgReleases( } if (res.releases) { res.releases = res.releases - .filter(release => version.isVersion(release.version)) + .filter((release) => version.isVersion(release.version)) .sort(sortReleases); } return res; diff --git a/lib/datasource/maven/index.spec.ts b/lib/datasource/maven/index.spec.ts index 5b786828f3e48233bbbc55de161817dddd9a3c37..a15ee49ff762c47cb82f434b9c4b80fca22d2296 100644 --- a/lib/datasource/maven/index.spec.ts +++ b/lib/datasource/maven/index.spec.ts @@ -95,7 +95,7 @@ describe('datasource/maven', () => { }); function generateReleases(versions) { - return versions.map(v => ({ version: v })); + return versions.map((v) => ({ version: v })); } describe('getReleases', () => { diff --git a/lib/datasource/maven/index.ts b/lib/datasource/maven/index.ts index 958e346a9be92f6a5454c382c37ff10f513fa038..e4edde6b69caabc99fb2af541322f4c28d31993a 100644 --- a/lib/datasource/maven/index.ts +++ b/lib/datasource/maven/index.ts @@ -140,14 +140,14 @@ function extractVersions(metadata: XmlDocument): string[] { if (!elements) { return []; } - return elements.map(el => el.val); + return elements.map((el) => el.val); } export async function getReleases({ lookupName, registryUrls, }: GetReleasesConfig): Promise<ReleaseResult | null> { - const repositories = registryUrls.map(repository => + const repositories = registryUrls.map((repository) => repository.replace(/\/?$/, '/') ); const dependency = getDependencyParts(lookupName); @@ -162,7 +162,7 @@ export async function getReleases({ const mavenMetadata = await downloadMavenXml(metadataUrl); if (mavenMetadata) { const newVersions = extractVersions(mavenMetadata).filter( - version => !versions.includes(version) + (version) => !versions.includes(version) ); const latestVersion = getLatestStableVersion(newVersions); if (latestVersion) { @@ -193,6 +193,6 @@ export async function getReleases({ return { ...dependency, ...dependencyInfo, - releases: versions.map(v => ({ version: v })), + releases: versions.map((v) => ({ version: v })), }; } diff --git a/lib/datasource/metadata.ts b/lib/datasource/metadata.ts index 23ddf1df746dcf526921c14d5c183ebcbd5d1835..50240edd1116b65b16d9d86498c93e571696d154 100644 --- a/lib/datasource/metadata.ts +++ b/lib/datasource/metadata.ts @@ -116,7 +116,7 @@ export function addMetaData( } const extraBaseUrls = []; // istanbul ignore next - hostRules.hosts({ hostType: 'github' }).forEach(host => { + hostRules.hosts({ hostType: 'github' }).forEach((host) => { extraBaseUrls.push(host, `gist.${host}`); }); if (dep.sourceUrl) { diff --git a/lib/datasource/npm/get.spec.ts b/lib/datasource/npm/get.spec.ts index d83b3f906fbba88d3de40d93fcd1c00bcdf961c5..4cb4596789be724404d98268091a6b6e2270fcc5 100644 --- a/lib/datasource/npm/get.spec.ts +++ b/lib/datasource/npm/get.spec.ts @@ -33,7 +33,7 @@ describe(getName(__filename), () => { `@myco:registry=https://test.org\n//test.org/:_authToken=XXX`, ]; - it.each(configs)('%p', async npmrc => { + it.each(configs)('%p', async (npmrc) => { expect.assertions(1); setNpmrc(npmrc); await getDependency('@myco/test', 0); @@ -55,7 +55,7 @@ describe(getName(__filename), () => { `@myco:registry=https://test.org\n_auth=dGVzdDp0ZXN0`, ]; - it.each(configs)('%p', async npmrc => { + it.each(configs)('%p', async (npmrc) => { expect.assertions(1); setNpmrc(npmrc); await getDependency('@myco/test', 0); @@ -75,7 +75,7 @@ describe(getName(__filename), () => { `registry=https://test.org`, ]; - it.each(configs)('%p', async npmrc => { + it.each(configs)('%p', async (npmrc) => { expect.assertions(1); setNpmrc(npmrc); await getDependency('@myco/test', 0); diff --git a/lib/datasource/npm/get.ts b/lib/datasource/npm/get.ts index 478852756030ce53e18141753f097eb2a91edcdc..c7e84efd2307b97341c1a0370eb8d5b13a44aead 100644 --- a/lib/datasource/npm/get.ts +++ b/lib/datasource/npm/get.ts @@ -186,7 +186,7 @@ export async function getDependency( dep.deprecationMessage = `On registry \`${regUrl}\`, the "latest" version (v${dep.latestVersion}) of dependency \`${packageName}\` has the following deprecation notice:\n\n\`${latestVersion.deprecated}\`\n\nMarking the latest version of an npm package as deprecated results in the entire package being considered deprecated, so contact the package author you think this is a mistake.`; dep.deprecationSource = id; } - dep.releases = Object.keys(res.versions).map(version => { + dep.releases = Object.keys(res.versions).map((version) => { const release: NpmRelease = { version, gitRef: res.versions[version].gitHead, diff --git a/lib/datasource/npm/index.spec.ts b/lib/datasource/npm/index.spec.ts index 66be8f70945c4dab00789afb3deef7cd05f1ad24..02c30d180fd65cfc809c5fce20fe31892c6c36ad 100644 --- a/lib/datasource/npm/index.spec.ts +++ b/lib/datasource/npm/index.spec.ts @@ -69,9 +69,7 @@ describe(getName(__filename), () => { expect(res).toBeNull(); }); it('should fetch package info from npm', async () => { - nock('https://registry.npmjs.org') - .get('/foobar') - .reply(200, npmResponse); + nock('https://registry.npmjs.org').get('/foobar').reply(200, npmResponse); const res = await npm.getReleases({ lookupName: 'foobar' }); expect(res).toMatchSnapshot(); expect(getRelease(res, '0.0.1').canBeUnpublished).toBe(false); @@ -96,9 +94,7 @@ describe(getName(__filename), () => { '0.0.1': '2018-05-06T07:21:53+02:00', }, }; - nock('https://registry.npmjs.org') - .get('/foobar') - .reply(200, pkg); + nock('https://registry.npmjs.org').get('/foobar').reply(200, pkg); const res = await npm.getReleases({ lookupName: 'foobar' }); expect(res).toMatchSnapshot(); expect(res.sourceUrl).toBeDefined(); @@ -119,9 +115,7 @@ describe(getName(__filename), () => { '0.0.1': '2018-05-06T07:21:53+02:00', }, }; - nock('https://registry.npmjs.org') - .get('/foobar') - .reply(200, pkg); + nock('https://registry.npmjs.org').get('/foobar').reply(200, pkg); const res = await npm.getReleases({ lookupName: 'foobar' }); expect(res).toMatchSnapshot(); expect(res.sourceUrl).toBeDefined(); @@ -158,9 +152,7 @@ describe(getName(__filename), () => { expect(res.deprecationMessage).toMatchSnapshot(); }); it('should handle foobar', async () => { - nock('https://registry.npmjs.org') - .get('/foobar') - .reply(200, npmResponse); + nock('https://registry.npmjs.org').get('/foobar').reply(200, npmResponse); const res = await npm.getReleases({ lookupName: 'foobar' }); expect(res).toMatchSnapshot(); }); @@ -173,74 +165,52 @@ describe(getName(__filename), () => { }); it('should handle no time', async () => { delete npmResponse.time['0.0.2']; - nock('https://registry.npmjs.org') - .get('/foobar') - .reply(200, npmResponse); + nock('https://registry.npmjs.org').get('/foobar').reply(200, npmResponse); const res = await npm.getReleases({ lookupName: 'foobar' }); expect(res).toMatchSnapshot(); expect(getRelease(res, '0.0.1').canBeUnpublished).toBe(false); expect(getRelease(res, '0.0.2').canBeUnpublished).toBeUndefined(); }); it('should return canBeUnpublished=true', async () => { - npmResponse.time['0.0.2'] = moment() - .subtract(6, 'hours') - .format(); - nock('https://registry.npmjs.org') - .get('/foobar') - .reply(200, npmResponse); + npmResponse.time['0.0.2'] = moment().subtract(6, 'hours').format(); + nock('https://registry.npmjs.org').get('/foobar').reply(200, npmResponse); const res = await npm.getReleases({ lookupName: 'foobar' }); expect(getRelease(res, '0.0.1').canBeUnpublished).toBe(false); expect(getRelease(res, '0.0.2').canBeUnpublished).toBe(true); }); it('should return null if lookup fails 401', async () => { - nock('https://registry.npmjs.org') - .get('/foobar') - .reply(401); + nock('https://registry.npmjs.org').get('/foobar').reply(401); const res = await npm.getReleases({ lookupName: 'foobar' }); expect(res).toBeNull(); }); it('should return null if lookup fails', async () => { - nock('https://registry.npmjs.org') - .get('/foobar') - .reply(404); + nock('https://registry.npmjs.org').get('/foobar').reply(404); const res = await npm.getReleases({ lookupName: 'foobar' }); expect(res).toBeNull(); }); it('should throw error for unparseable', async () => { - nock('https://registry.npmjs.org') - .get('/foobar') - .reply(200, 'oops'); + nock('https://registry.npmjs.org').get('/foobar').reply(200, 'oops'); await expect(npm.getReleases({ lookupName: 'foobar' })).rejects.toThrow(); }); it('should throw error for 429', async () => { - nock('https://registry.npmjs.org') - .get('/foobar') - .reply(429); - nock('https://registry.npmjs.org') - .get('/foobar') - .reply(429); + nock('https://registry.npmjs.org').get('/foobar').reply(429); + nock('https://registry.npmjs.org').get('/foobar').reply(429); await expect(npm.getReleases({ lookupName: 'foobar' })).rejects.toThrow(); }); it('should throw error for 5xx', async () => { - nock('https://registry.npmjs.org') - .get('/foobar') - .reply(503); + nock('https://registry.npmjs.org').get('/foobar').reply(503); await expect(npm.getReleases({ lookupName: 'foobar' })).rejects.toThrow( Error(DATASOURCE_FAILURE) ); }); it('should throw error for 408', async () => { - nock('https://registry.npmjs.org') - .get('/foobar') - .reply(408); + nock('https://registry.npmjs.org').get('/foobar').reply(408); await expect(npm.getReleases({ lookupName: 'foobar' })).rejects.toThrow( Error(DATASOURCE_FAILURE) ); }); it('should throw error for others', async () => { - nock('https://registry.npmjs.org') - .get('/foobar') - .reply(451); + nock('https://registry.npmjs.org').get('/foobar').reply(451); await expect(npm.getReleases({ lookupName: 'foobar' })).rejects.toThrow(); }); it('should send an authorization header if provided', async () => { @@ -248,16 +218,12 @@ describe(getName(__filename), () => { type: 'Basic', token: '1234', })); - nock('https://registry.npmjs.org') - .get('/foobar') - .reply(200, npmResponse); + nock('https://registry.npmjs.org').get('/foobar').reply(200, npmResponse); const res = await npm.getReleases({ lookupName: 'foobar' }); expect(res).toMatchSnapshot(); }); it('should use NPM_TOKEN if provided', async () => { - nock('https://registry.npmjs.org') - .get('/foobar') - .reply(200, npmResponse); + nock('https://registry.npmjs.org').get('/foobar').reply(200, npmResponse); const oldToken = process.env.NPM_TOKEN; process.env.NPM_TOKEN = 'some-token'; const res = await npm.getReleases({ lookupName: 'foobar' }); @@ -300,17 +266,13 @@ describe(getName(__filename), () => { npm.setNpmrc(); }); it('should use default registry if missing from npmrc', async () => { - nock('https://registry.npmjs.org') - .get('/foobar') - .reply(200, npmResponse); + nock('https://registry.npmjs.org').get('/foobar').reply(200, npmResponse); const npmrc = 'foo=bar'; const res = await npm.getReleases({ lookupName: 'foobar', npmrc }); expect(res).toMatchSnapshot(); }); it('should cache package info from npm', async () => { - nock('https://registry.npmjs.org') - .get('/foobar') - .reply(200, npmResponse); + nock('https://registry.npmjs.org').get('/foobar').reply(200, npmResponse); const npmrc = '//registry.npmjs.org/:_authToken=abcdefghijklmnopqrstuvwxyz'; const res1 = await npm.getReleases({ lookupName: 'foobar', npmrc }); const res2 = await npm.getReleases({ lookupName: 'foobar', npmrc }); diff --git a/lib/datasource/nuget/v2.ts b/lib/datasource/nuget/v2.ts index fceb7e94d38eea744b1f84d7a07f99ddeaf9cfad..15a41f9bcf7ec40523d312ff6193a76b28d20b0e 100644 --- a/lib/datasource/nuget/v2.ts +++ b/lib/datasource/nuget/v2.ts @@ -50,7 +50,7 @@ export async function getReleases( const nextPkgUrlListLink = pkgVersionsListDoc .childrenNamed('link') - .find(node => node.attr.rel === 'next'); + .find((node) => node.attr.rel === 'next'); pkgUrlList = nextPkgUrlListLink ? nextPkgUrlListLink.attr.href : null; } while (pkgUrlList !== null); diff --git a/lib/datasource/nuget/v3.ts b/lib/datasource/nuget/v3.ts index d1fb91e5b5817de22f4b7da6277c14f76064ce08..0dc28aed471b0e1345e0171107c25eab988215ff 100644 --- a/lib/datasource/nuget/v3.ts +++ b/lib/datasource/nuget/v3.ts @@ -34,7 +34,7 @@ export async function getQueryUrl(url: string): Promise<string | null> { // TODO: fix types const servicesIndexRaw = await http.getJson<any>(url); const searchQueryService = servicesIndexRaw.body.resources.find( - resource => + (resource) => resource['@type'] && resource['@type'].startsWith(resourceType) ); const searchQueryServiceId = searchQueryService['@id']; @@ -74,23 +74,23 @@ export async function getReleases( // TODO: fix types const pkgUrlListRaw = await http.getJson<any>(queryUrl); const match = pkgUrlListRaw.body.data.find( - item => item.id.toLowerCase() === pkgName.toLowerCase() + (item) => item.id.toLowerCase() === pkgName.toLowerCase() ); // https://docs.microsoft.com/en-us/nuget/api/search-query-service-resource#search-result if (!match) { // There are no pkgName or releases in current feed return null; } - dep.releases = match.versions.map(item => ({ + dep.releases = match.versions.map((item) => ({ version: item.version, })); try { // For nuget.org we have a way to get nuspec file const sanitizedVersions = dep.releases - .map(release => semver.valid(release.version)) + .map((release) => semver.valid(release.version)) .filter(Boolean) - .filter(version => !semver.prerelease(version)); + .filter((version) => !semver.prerelease(version)); let lastVersion: string; // istanbul ignore else if (sanitizedVersions.length) { diff --git a/lib/datasource/packagist/index.spec.ts b/lib/datasource/packagist/index.spec.ts index 1f206ddf19a9e598f1bf22d36ad3bc03a350088b..b560d8a3c4624c1613ee732ac34da5e7b9a3c26a 100644 --- a/lib/datasource/packagist/index.spec.ts +++ b/lib/datasource/packagist/index.spec.ts @@ -25,7 +25,7 @@ describe('datasource/packagist', () => { let config: any; beforeEach(() => { jest.resetAllMocks(); - hostRules.find = jest.fn(input => input); + hostRules.find = jest.fn((input) => input); hostRules.hosts = jest.fn(() => []); global.repoCache = {}; config = { diff --git a/lib/datasource/packagist/index.ts b/lib/datasource/packagist/index.ts index a4b10883ea5cec347f4a2fbf57699e67afa0d5c4..843ed725b53a1778ca266c2cec33a912afcc3858 100644 --- a/lib/datasource/packagist/index.ts +++ b/lib/datasource/packagist/index.ts @@ -137,7 +137,7 @@ function extractDepReleases(versions: RegistryFile): ReleaseResult { dep.releases = []; return dep; } - dep.releases = Object.keys(versions).map(version => { + dep.releases = Object.keys(versions).map((version) => { const release = versions[version]; dep.homepage = release.homepage || dep.homepage; if (release.source && release.source.url) { @@ -179,7 +179,7 @@ async function getAllPackages(regUrl: string): Promise<AllPackages | null> { const { packages, providersUrl, files, includesFiles } = registryMeta; const providerPackages: Record<string, string> = {}; if (files) { - const queue = files.map(file => (): Promise<PackagistFile> => + const queue = files.map((file) => (): Promise<PackagistFile> => getPackagistFile(regUrl, file) ); const resolvedFiles = await pAll(queue, { concurrency: 5 }); diff --git a/lib/datasource/pod/index.ts b/lib/datasource/pod/index.ts index 88a8408b49f7eb9f3d30661c5da2cca6fef2248a..325d9e043716c68792cf4be4bd7638763e8fce01 100644 --- a/lib/datasource/pod/index.ts +++ b/lib/datasource/pod/index.ts @@ -104,7 +104,7 @@ async function getReleasesFromCDN( const line = lines[idx]; const [name, ...versions] = line.split('/'); if (name === lookupName.replace(/\/.*$/, '')) { - const releases = versions.map(version => ({ version })); + const releases = versions.map((version) => ({ version })); return { releases }; } } diff --git a/lib/datasource/pypi/index.ts b/lib/datasource/pypi/index.ts index 78548e4c326884a697bc57960e03a2637c8c5a76..842e1f074ed797a8fa8b798dbb5f9c7fcff8b110 100644 --- a/lib/datasource/pypi/index.ts +++ b/lib/datasource/pypi/index.ts @@ -22,8 +22,8 @@ function compatibleVersions( if (!(compatibility && compatibility.python)) { return versions; } - return versions.filter(version => - releases[version].some(release => { + return versions.filter((version) => + releases[version].some((release) => { if (!release.requires_python) { return true; } @@ -71,7 +71,7 @@ async function getDependency( dependency.releases = []; if (dep.releases) { const versions = compatibleVersions(dep.releases, compatibility); - dependency.releases = versions.map(version => ({ + dependency.releases = versions.map((version) => ({ version, releaseTimestamp: (dep.releases[version][0] || {}).upload_time, })); @@ -140,7 +140,7 @@ async function getSimpleDependency( } dependency.releases = []; if (versions && versions.size > 0) { - dependency.releases = [...versions].map(version => ({ + dependency.releases = [...versions].map((version) => ({ version, })); } diff --git a/lib/datasource/ruby-version/index.ts b/lib/datasource/ruby-version/index.ts index bc45f3791b6d9bf33cfe8e85a1a0f2cf3074689f..e195d703dbe4b005c6544a0780b22a8cd15ea771 100644 --- a/lib/datasource/ruby-version/index.ts +++ b/lib/datasource/ruby-version/index.ts @@ -34,7 +34,7 @@ export async function getReleases( const rows = root.querySelector('.release-list').querySelectorAll('tr'); for (const row of rows) { const columns: string[] = Array.from( - row.querySelectorAll('td').map(td => td.innerHTML) + row.querySelectorAll('td').map((td) => td.innerHTML) ); if (columns.length) { const version = columns[0].replace('Ruby ', ''); diff --git a/lib/datasource/rubygems/get-rubygems-org.ts b/lib/datasource/rubygems/get-rubygems-org.ts index 71d59162836b74ae71107a5e4505f0c78cfa84cc..412ad3b75321a0a9a74ac62da5c2ef313e5bdfed 100644 --- a/lib/datasource/rubygems/get-rubygems-org.ts +++ b/lib/datasource/rubygems/get-rubygems-org.ts @@ -55,13 +55,13 @@ async function updateRubyGemsVersions(): Promise<void> { [pkg, versions] = split; pkg = copystr(pkg); packageReleases[pkg] = packageReleases[pkg] || []; - const lineVersions = versions.split(',').map(version => version.trim()); + const lineVersions = versions.split(',').map((version) => version.trim()); for (const lineVersion of lineVersions) { if (lineVersion.startsWith('-')) { const deletedVersion = lineVersion.slice(1); logger.trace({ pkg, deletedVersion }, 'Rubygems: Deleting version'); packageReleases[pkg] = packageReleases[pkg].filter( - version => version !== deletedVersion + (version) => version !== deletedVersion ); } else { packageReleases[pkg].push(copystr(lineVersion)); @@ -108,7 +108,7 @@ export async function getRubygemsOrgDependency( } const dep: ReleaseResult = { name: lookupName, - releases: packageReleases[lookupName].map(version => ({ version })), + releases: packageReleases[lookupName].map((version) => ({ version })), }; return dep; } diff --git a/lib/datasource/rubygems/index.spec.ts b/lib/datasource/rubygems/index.spec.ts index 0565135818b513e478f242c9869868ef330593a3..5247219a4812ab5f27f26ea1ca33f9327b5b9a68 100644 --- a/lib/datasource/rubygems/index.spec.ts +++ b/lib/datasource/rubygems/index.spec.ts @@ -73,10 +73,10 @@ describe('datasource/rubygems', () => { expect(res.releases).toHaveLength(2); expect(res).toMatchSnapshot(); expect( - res.releases.find(release => release.version === '0.1.1') + res.releases.find((release) => release.version === '0.1.1') ).toBeDefined(); expect( - res.releases.find(release => release.version === '0.1.2') + res.releases.find((release) => release.version === '0.1.2') ).toBeUndefined(); }); diff --git a/lib/datasource/sbt-package/index.spec.ts b/lib/datasource/sbt-package/index.spec.ts index c985c49c81a10f79a6fea8872cfaad3f44faa042..b387b34781b5e0de9671aa36c9e7606b11f9a022 100644 --- a/lib/datasource/sbt-package/index.spec.ts +++ b/lib/datasource/sbt-package/index.spec.ts @@ -28,9 +28,7 @@ describe('datasource/sbt', () => { describe('getPkgReleases', () => { beforeEach(() => { nock.disableNetConnect(); - nock('https://failed_repo') - .get('/maven/org/scalatest/') - .reply(404, null); + nock('https://failed_repo').get('/maven/org/scalatest/').reply(404, null); nock('https://repo.maven.apache.org') .get('/maven2/org/scalatest/') .reply( diff --git a/lib/datasource/sbt-package/index.ts b/lib/datasource/sbt-package/index.ts index 011e490dab664810eee627d1001296a0c82ed840..6ff727e84020d987af8063e891d4ce107d82e4c8 100644 --- a/lib/datasource/sbt-package/index.ts +++ b/lib/datasource/sbt-package/index.ts @@ -23,7 +23,7 @@ export async function resolvePackageReleases( if (indexContent) { const releases: string[] = []; const parseSubdirs = (content: string): string[] => - parseIndexDir(content, x => { + parseIndexDir(content, (x) => { if (x === artifact) { return true; } @@ -44,7 +44,7 @@ export async function resolvePackageReleases( searchSubdirs = [`${artifact}_${scalaVersion}`]; } const parseReleases = (content: string): string[] => - parseIndexDir(content, x => !/^\.+$/.test(x)); + parseIndexDir(content, (x) => !/^\.+$/.test(x)); for (const searchSubdir of searchSubdirs) { const content = await downloadHttpProtocol( ensureTrailingSlash(`${searchRoot}/${searchSubdir}`), @@ -52,7 +52,7 @@ export async function resolvePackageReleases( ); if (content) { const subdirReleases = parseReleases(content); - subdirReleases.forEach(x => releases.push(x)); + subdirReleases.forEach((x) => releases.push(x)); } } if (releases.length) { @@ -72,9 +72,9 @@ export async function getReleases({ const artifactIdSplit = artifactId.split('_'); const [artifact, scalaVersion] = artifactIdSplit; - const repoRoots = registryUrls.map(x => x.replace(/\/?$/, '')); + const repoRoots = registryUrls.map((x) => x.replace(/\/?$/, '')); const searchRoots: string[] = []; - repoRoots.forEach(repoRoot => { + repoRoots.forEach((repoRoot) => { // Optimize lookup order searchRoots.push(`${repoRoot}/${groupIdSplit.join('/')}`); searchRoots.push(`${repoRoot}/${groupIdSplit.join('.')}`); @@ -96,7 +96,7 @@ export async function getReleases({ group: groupId, name: artifactId, dependencyUrl, - releases: versions.map(v => ({ version: v })), + releases: versions.map((v) => ({ version: v })), }; } } diff --git a/lib/datasource/sbt-plugin/index.spec.ts b/lib/datasource/sbt-plugin/index.spec.ts index ca8076951c34673d547e90b97284afb843f7558f..278e187753ae35633bc52763d15be1ebe788073f 100644 --- a/lib/datasource/sbt-plugin/index.spec.ts +++ b/lib/datasource/sbt-plugin/index.spec.ts @@ -27,9 +27,7 @@ describe('datasource/sbt', () => { describe('getPkgReleases', () => { beforeEach(() => { nock.disableNetConnect(); - nock('https://failed_repo') - .get('/maven/org/scalatest/') - .reply(404, null); + nock('https://failed_repo').get('/maven/org/scalatest/').reply(404, null); nock('https://repo.maven.apache.org') .get('/maven2/org/scalatest/') .reply( diff --git a/lib/datasource/sbt-plugin/index.ts b/lib/datasource/sbt-plugin/index.ts index 99fca4260f5567ddb37f56056a307d0fdd745836..68a9557359cb36907f2c6eee538e9ac061abdb53 100644 --- a/lib/datasource/sbt-plugin/index.ts +++ b/lib/datasource/sbt-plugin/index.ts @@ -18,7 +18,7 @@ async function resolvePluginReleases( ): Promise<string[]> { const searchRoot = `${rootUrl}/${artifact}`; const parse = (content: string): string[] => - parseIndexDir(content, x => !/^\.+$/.test(x)); + parseIndexDir(content, (x) => !/^\.+$/.test(x)); const indexContent = await downloadHttpProtocol( ensureTrailingSlash(searchRoot), 'sbt' @@ -26,7 +26,9 @@ async function resolvePluginReleases( if (indexContent) { const releases: string[] = []; const scalaVersionItems = parse(indexContent); - const scalaVersions = scalaVersionItems.map(x => x.replace(/^scala_/, '')); + const scalaVersions = scalaVersionItems.map((x) => + x.replace(/^scala_/, '') + ); const searchVersions = !scalaVersions.includes(scalaVersion) ? scalaVersions : [scalaVersion]; @@ -46,7 +48,7 @@ async function resolvePluginReleases( ); if (releasesIndexContent) { const releasesParsed = parse(releasesIndexContent); - releasesParsed.forEach(x => releases.push(x)); + releasesParsed.forEach((x) => releases.push(x)); } } } @@ -67,9 +69,9 @@ export async function getReleases({ const artifactIdSplit = artifactId.split('_'); const [artifact, scalaVersion] = artifactIdSplit; - const repoRoots = registryUrls.map(x => x.replace(/\/?$/, '')); + const repoRoots = registryUrls.map((x) => x.replace(/\/?$/, '')); const searchRoots: string[] = []; - repoRoots.forEach(repoRoot => { + repoRoots.forEach((repoRoot) => { // Optimize lookup order searchRoots.push(`${repoRoot}/${groupIdSplit.join('.')}`); searchRoots.push(`${repoRoot}/${groupIdSplit.join('/')}`); @@ -91,7 +93,7 @@ export async function getReleases({ group: groupId, name: artifactId, dependencyUrl, - releases: versions.map(v => ({ version: v })), + releases: versions.map((v) => ({ version: v })), }; } } diff --git a/lib/datasource/terraform-module/index.ts b/lib/datasource/terraform-module/index.ts index 060c675748c9b994a6868bc35e6d270af98aeab2..cd0c396e6548736ac40719e6168f07629a598048 100644 --- a/lib/datasource/terraform-module/index.ts +++ b/lib/datasource/terraform-module/index.ts @@ -89,7 +89,7 @@ export async function getReleases({ if (res.source) { dep.sourceUrl = res.source; } - dep.releases = res.versions.map(version => ({ + dep.releases = res.versions.map((version) => ({ version, })); if (pkgUrl.startsWith('https://registry.terraform.io/')) { diff --git a/lib/datasource/terraform-provider/index.ts b/lib/datasource/terraform-provider/index.ts index e380a1e537c4280ab6301ef807e1918946026066..c91805b2c8ab7a64f92b2f4f26c6613a63b57052 100644 --- a/lib/datasource/terraform-provider/index.ts +++ b/lib/datasource/terraform-provider/index.ts @@ -47,7 +47,7 @@ export async function getReleases({ if (res.source) { dep.sourceUrl = res.source; } - dep.releases = res.versions.map(version => ({ + dep.releases = res.versions.map((version) => ({ version, })); if (pkgUrl.startsWith('https://registry.terraform.io/')) { diff --git a/lib/logger/cmd-serializer.ts b/lib/logger/cmd-serializer.ts index 3a8d2599cadf8430a3a0f88a88286d5aad48f568..b3aabfb340edb59afb1701cf27512feee1da6c96 100644 --- a/lib/logger/cmd-serializer.ts +++ b/lib/logger/cmd-serializer.ts @@ -1,5 +1,5 @@ // istanbul ignore next -export default function(cmd: string | string[]): string | string[] { +export default function (cmd: string | string[]): string | string[] { if (typeof cmd === 'string') { return cmd.replace(/https:\/\/[^@]*@/g, 'https://**redacted**@'); } diff --git a/lib/logger/err-serializer.ts b/lib/logger/err-serializer.ts index 509870003615db338e113ffafc9781b7c7d63141..b85d751276531e750e84d9d6a1ff253ad265589e 100644 --- a/lib/logger/err-serializer.ts +++ b/lib/logger/err-serializer.ts @@ -31,7 +31,7 @@ export default function errSerializer(err: any): any { 'private-header', 'Private-header', ]; - redactedHeaders.forEach(header => { + redactedHeaders.forEach((header) => { if (response.gotOptions.headers[header]) { response.gotOptions.headers[header] = '** redacted **'; } diff --git a/lib/logger/index.ts b/lib/logger/index.ts index b0d7012b095f924f79f5d9e722074dce3264204b..1f8a05c669a33c1f1ccce38876fa6c3d91096db7 100644 --- a/lib/logger/index.ts +++ b/lib/logger/index.ts @@ -98,7 +98,7 @@ interface Logger { export const logger: Logger = {} as any; -loggerLevels.forEach(loggerLevel => { +loggerLevels.forEach((loggerLevel) => { logger[loggerLevel] = logFactory(loggerLevel); }); @@ -122,7 +122,7 @@ export function addMeta(obj: any): void { // removeMeta removes the provided fields from meta export function removeMeta(fields: string[]): void { - Object.keys(meta).forEach(key => { + Object.keys(meta).forEach((key) => { if (fields.includes(key)) { delete meta[key]; } diff --git a/lib/logger/pretty-stdout.ts b/lib/logger/pretty-stdout.ts index 61c7a11910b15fce6c2a64bad7f310a7a48bcad9..933846df1438b63d761d4436d5e28e5dc078031b 100644 --- a/lib/logger/pretty-stdout.ts +++ b/lib/logger/pretty-stdout.ts @@ -45,12 +45,12 @@ export function getMeta(rec: BunyanRecord): string { return ''; } let res = rec.module ? ` [${rec.module}]` : ``; - const filteredMeta = metaFields.filter(elem => rec[elem]); + const filteredMeta = metaFields.filter((elem) => rec[elem]); if (!filteredMeta.length) { return res; } const metaStr = filteredMeta - .map(field => `${field}=${rec[field]}`) + .map((field) => `${field}=${rec[field]}`) .join(', '); res = ` (${metaStr})${res}`; return chalk.gray(res); @@ -62,7 +62,7 @@ export function getDetails(rec: BunyanRecord): string { } const recFiltered = { ...rec }; delete recFiltered.module; - Object.keys(recFiltered).forEach(key => { + Object.keys(recFiltered).forEach((key) => { if ( key === 'logContext' || bunyanFields.includes(key) || @@ -76,7 +76,7 @@ export function getDetails(rec: BunyanRecord): string { return ''; } return `${remainingKeys - .map(key => `${indent(`"${key}": ${stringify(recFiltered[key])}`, true)}`) + .map((key) => `${indent(`"${key}": ${stringify(recFiltered[key])}`, true)}`) .join(',\n')}\n`; } diff --git a/lib/manager/ansible/extract.ts b/lib/manager/ansible/extract.ts index c871fa818ba5f2a909a6277362ba501e9cd9759c..48dd675979e0f969228656d8ab04b3596ad6d3b2 100644 --- a/lib/manager/ansible/extract.ts +++ b/lib/manager/ansible/extract.ts @@ -30,7 +30,7 @@ export default function extractPackageFile( lineNumber += 1; } deps = deps.filter( - dep => !(dep.currentValue && dep.currentValue.includes('${')) + (dep) => !(dep.currentValue && dep.currentValue.includes('${')) ); if (!deps.length) { return null; diff --git a/lib/manager/bazel/extract.ts b/lib/manager/bazel/extract.ts index 9480d4bc19e867cbbdbd12a34d8b1f72b49a1298..063c8e80b7fd267dfe47a67074f46536ff300f87 100644 --- a/lib/manager/bazel/extract.ts +++ b/lib/manager/bazel/extract.ts @@ -63,7 +63,7 @@ function findBalancedParenIndex(longString: string): number { parenNestingDepth--; break; case '"': - if (i > 1 && arr.slice(i - 2, i).every(prev => char === prev)) { + if (i > 1 && arr.slice(i - 2, i).every((prev) => char === prev)) { intShouldNotBeOdd++; } break; @@ -87,7 +87,7 @@ function parseContent(content: string): string[] { ...content .split(regEx(prefix + '\\s*\\(', 'g')) .slice(1) - .map(base => { + .map((base) => { const ind = findBalancedParenIndex(base); return ind >= 0 && `${prefix}(${base.slice(0, ind)})`; @@ -106,7 +106,7 @@ export function extractPackageFile(content: string): PackageFile | null { } logger.debug({ definitions }, `Found ${definitions.length} definitions`); const deps: PackageDependency[] = []; - definitions.forEach(def => { + definitions.forEach((def) => { logger.debug({ def }, 'Checking bazel definition'); const [depType] = def.split('(', 1); const dep: PackageDependency = { depType, managerData: { def } }; diff --git a/lib/manager/bazel/update.ts b/lib/manager/bazel/update.ts index 11e7efb6efea90f400f805ef6f7126d8ecacb057..519f69df5fdab5bf2b38cd5aa96c6e9c64fed0f9 100644 --- a/lib/manager/bazel/update.ts +++ b/lib/manager/bazel/update.ts @@ -39,7 +39,7 @@ function extractUrls(content: string): string[] | null { .replace(/urls?=\[/, '') .replace(/,?\]$/, '') .split(',') - .map(url => url.replace(/"/g, '')); + .map((url) => url.replace(/"/g, '')); return urls; } @@ -67,7 +67,7 @@ async function getHashFromUrl(url: string): Promise<string | null> { async function getHashFromUrls(urls: string[]): Promise<string | null> { const hashes = ( - await Promise.all(urls.map(url => getHashFromUrl(url))) + await Promise.all(urls.map((url) => getHashFromUrl(url))) ).filter(Boolean); const distinctHashes = [...new Set(hashes)]; if (!distinctHashes.length) { @@ -151,7 +151,7 @@ export async function updateDependency({ ); const match = upgrade.managerData.def.match(/(?<=archive\/).*(?=\.tar\.gz)/g) || []; - match.forEach(matchedHash => { + match.forEach((matchedHash) => { newDef = newDef.replace(matchedHash, upgrade.newDigest); }); } diff --git a/lib/manager/bundler/artifacts.ts b/lib/manager/bundler/artifacts.ts index 16b5b19c7c09e7071cfa18245e44b42eaddb2680..3e271f52da1fb8b83e8892b81dbc5eaeda1eea25 100644 --- a/lib/manager/bundler/artifacts.ts +++ b/lib/manager/bundler/artifacts.ts @@ -54,7 +54,7 @@ function buildBundleHostVariable(hostRule: HostRule): Record<string, string> { hostConfigVariablePrefix + getDomain(hostRule) .split('.') - .map(term => term.toUpperCase()) + .map((term) => term.toUpperCase()) .join('__'); return { @@ -181,7 +181,7 @@ export async function updateArtifacts( resolveMatches.push(resolveMatch[1].split(' ').shift()); } } while (resolveMatch); - if (resolveMatches.some(match => !updatedDeps.includes(match))) { + if (resolveMatches.some((match) => !updatedDeps.includes(match))) { logger.debug( { resolveMatches, updatedDeps }, 'Found new resolve matches - reattempting recursively' diff --git a/lib/manager/bundler/extract.spec.ts b/lib/manager/bundler/extract.spec.ts index 16dc25d857cc00103821b922bfb68cbe219674eb..b5f8ecc3b43a1d08c5663e5682398b1079ca184e 100644 --- a/lib/manager/bundler/extract.spec.ts +++ b/lib/manager/bundler/extract.spec.ts @@ -78,10 +78,10 @@ describe('lib/manager/bundler/extract', () => { // couple of dependency of ruby rails are not present in the lock file. Filter out those before processing expect( res.deps - .filter(dep => { + .filter((dep) => { return Object.prototype.hasOwnProperty.call(dep, 'lockedVersion'); }) - .every(dep => { + .every((dep) => { return ( Object.prototype.hasOwnProperty.call(dep, 'lockedVersion') && isValid(dep.lockedVersion) @@ -100,7 +100,7 @@ describe('lib/manager/bundler/extract', () => { const res = await extractPackageFile(webPackerGemfile, 'Gemfile'); expect(res).toMatchSnapshot(); expect( - res.deps.every(dep => { + res.deps.every((dep) => { return ( Object.prototype.hasOwnProperty.call(dep, 'lockedVersion') && isValid(dep.lockedVersion) @@ -115,10 +115,10 @@ describe('lib/manager/bundler/extract', () => { expect(res).toMatchSnapshot(); expect( res.deps - .filter(dep => { + .filter((dep) => { return Object.prototype.hasOwnProperty.call(dep, 'lockedVersion'); }) - .every(dep => { + .every((dep) => { return ( Object.prototype.hasOwnProperty.call(dep, 'lockedVersion') && isValid(dep.lockedVersion) @@ -132,7 +132,7 @@ describe('lib/manager/bundler/extract', () => { const res = await extractPackageFile(rubyCIGemfile, 'Gemfile'); expect(res).toMatchSnapshot(); expect( - res.deps.every(dep => { + res.deps.every((dep) => { return ( Object.prototype.hasOwnProperty.call(dep, 'lockedVersion') && isValid(dep.lockedVersion) @@ -147,7 +147,7 @@ describe('lib/manager/bundler/extract', () => { const res = await extractPackageFile(gitlabFossGemfile, 'Gemfile'); expect(res).toMatchSnapshot(); expect( - res.deps.every(dep => { + res.deps.every((dep) => { return ( Object.prototype.hasOwnProperty.call(dep, 'lockedVersion') && isValid(dep.lockedVersion) diff --git a/lib/manager/bundler/extract.ts b/lib/manager/bundler/extract.ts index 2b3938286d3ce714255d3d0330d6d3ff4cff16d2..b486c73a8ab0c7606d7a5c6815bb21552d3a26a8 100644 --- a/lib/manager/bundler/extract.ts +++ b/lib/manager/bundler/extract.ts @@ -69,8 +69,8 @@ export async function extractPackageFile( if (groupMatch) { const depTypes = groupMatch[1] .split(',') - .map(group => group.trim()) - .map(group => group.replace(/^:/, '')); + .map((group) => group.trim()) + .map((group) => group.replace(/^:/, '')); const groupLineNumber = lineNumber; let groupContent = ''; let groupLine = ''; @@ -84,7 +84,7 @@ export async function extractPackageFile( const groupRes = await extractPackageFile(groupContent); if (groupRes) { res.deps = res.deps.concat( - groupRes.deps.map(dep => ({ + groupRes.deps.map((dep) => ({ ...dep, depTypes, managerData: { @@ -118,7 +118,7 @@ export async function extractPackageFile( const sourceRes = await extractPackageFile(sourceContent); if (sourceRes) { res.deps = res.deps.concat( - sourceRes.deps.map(dep => ({ + sourceRes.deps.map((dep) => ({ ...dep, registryUrls: [repositoryUrl], managerData: { @@ -145,7 +145,7 @@ export async function extractPackageFile( if (platformsRes) { res.deps = res.deps.concat( // eslint-disable-next-line no-loop-func - platformsRes.deps.map(dep => ({ + platformsRes.deps.map((dep) => ({ ...dep, managerData: { lineNumber: dep.managerData.lineNumber + platformsLineNumber + 1, @@ -170,7 +170,7 @@ export async function extractPackageFile( if (ifRes) { res.deps = res.deps.concat( // eslint-disable-next-line no-loop-func - ifRes.deps.map(dep => ({ + ifRes.deps.map((dep) => ({ ...dep, managerData: { lineNumber: dep.managerData.lineNumber + ifLineNumber + 1, diff --git a/lib/manager/bundler/locked-version.ts b/lib/manager/bundler/locked-version.ts index 099386763e8062be464721f127d4e5c684d45303..0989d08e3424c26b8912569ebe5386b8366eb3a4 100644 --- a/lib/manager/bundler/locked-version.ts +++ b/lib/manager/bundler/locked-version.ts @@ -8,7 +8,7 @@ export function extractLockFileEntries( const gemLock = new Map<string, string>(); try { let parsingGemSection = false; - lockFileContent.split('\n').forEach(eachLine => { + lockFileContent.split('\n').forEach((eachLine) => { const whitespace = eachLine.indexOf(eachLine.trim()); const isGemLine = eachLine.trim().startsWith('GEM'); if (parsingGemSection === false && whitespace === 0 && isGemLine) { diff --git a/lib/manager/bundler/update.ts b/lib/manager/bundler/update.ts index 7dd987eb766d28fb6b1f9400567bd21e5a7aaf7d..7e3bcb1363db73bf54a2cc6c7f9b25aa178952a3 100644 --- a/lib/manager/bundler/update.ts +++ b/lib/manager/bundler/update.ts @@ -22,7 +22,7 @@ export function updateDependency({ } const newValue = upgrade.newValue .split(',') - .map(part => `, ${delimiter}${part.trim()}${delimiter}`) + .map((part) => `, ${delimiter}${part.trim()}${delimiter}`) .join(''); const newLine = lineToChange.replace( new RegExp( diff --git a/lib/manager/cargo/extract.ts b/lib/manager/cargo/extract.ts index 353b803db55f636cfda55ac873253e6f17b6455e..a67af614135c9950abb6bb375bc4f7f406303406 100644 --- a/lib/manager/cargo/extract.ts +++ b/lib/manager/cargo/extract.ts @@ -15,7 +15,7 @@ function extractFromSection( if (!sectionContent) { return []; } - Object.keys(sectionContent).forEach(depName => { + Object.keys(sectionContent).forEach((depName) => { let skipReason: SkipReason; let currentValue = sectionContent[depName]; let nestedVersion = false; @@ -85,7 +85,7 @@ export function extractPackageFile( let targetDeps: PackageDependency[] = []; if (targetSection) { const targets = Object.keys(targetSection); - targets.forEach(target => { + targets.forEach((target) => { const targetContent = parsedContent.target[target]; // Dependencies for `${target}` const deps = [ diff --git a/lib/manager/composer/extract.ts b/lib/manager/composer/extract.ts index 5744369b89bfbba8f272785914a7a09b1838a8e9..a75ca4ac7aaa280f0b1b268ac2e9ac1cf82c2a0c 100644 --- a/lib/manager/composer/extract.ts +++ b/lib/manager/composer/extract.ts @@ -161,7 +161,7 @@ export async function extractPackageFile( } if (lockParsed) { const lockedDep = lockParsed.packages.find( - item => item.name === dep.depName + (item) => item.name === dep.depName ); if (lockedDep && semverComposer.isVersion(lockedDep.version)) { dep.lockedVersion = lockedDep.version.replace(/^v/i, ''); diff --git a/lib/manager/docker-compose/extract.ts b/lib/manager/docker-compose/extract.ts index d5821b317656dc69cc08256fbbd0f1b92afb72f0..54558acd70f5fcf66f322f623d53cf9c6287bfb7 100644 --- a/lib/manager/docker-compose/extract.ts +++ b/lib/manager/docker-compose/extract.ts @@ -22,7 +22,7 @@ class LineMapper { constructor(content: string, filter: RegExp) { this.imageLines = [...content.split('\n').entries()] - .filter(entry => filter.test(entry[1])) + .filter((entry) => filter.test(entry[1])) .map(([lineNumber, line]) => ({ lineNumber, line, used: false })); } @@ -66,8 +66,8 @@ export function extractPackageFile( // Image name/tags for services are only eligible for update if they don't // use variables and if the image is not built locally const deps = Object.values(config.services || {}) - .filter(service => service && service.image && !service.build) - .map(service => { + .filter((service) => service && service.image && !service.build) + .map((service) => { const dep = getDep(service.image); const lineNumber = lineMapper.pluckLineNumber(service.image); // istanbul ignore if diff --git a/lib/manager/git-submodules/extract.ts b/lib/manager/git-submodules/extract.ts index b08ce2b591fab39170b752a26a531f9d1d0d713a..49893752ad1d6dd69bcddc45459254297848e5ad 100644 --- a/lib/manager/git-submodules/extract.ts +++ b/lib/manager/git-submodules/extract.ts @@ -63,7 +63,7 @@ async function getModules( ) .trim() .split(/\n/) - .filter(s => !!s); + .filter((s) => !!s); const res: GitModule[] = []; diff --git a/lib/manager/gitlabci-include/extract.spec.ts b/lib/manager/gitlabci-include/extract.spec.ts index ac845e8dfaefad2e076f84f7f9737018aad47a8d..527fff5cef65e878a0071695ad9dd2f2a84d81ec 100644 --- a/lib/manager/gitlabci-include/extract.spec.ts +++ b/lib/manager/gitlabci-include/extract.spec.ts @@ -23,7 +23,7 @@ describe('lib/manager/gitlabci-include/extract', () => { 'http://gitlab.test/api/v4', 'http://gitlab.test/api/v4/', ]; - endpoints.forEach(endpoint => { + endpoints.forEach((endpoint) => { const res = extractPackageFile(yamlFile, '.gitlab-ci.yml', { endpoint, }); diff --git a/lib/manager/gomod/extract.spec.ts b/lib/manager/gomod/extract.spec.ts index e59be32d25576393530d6e58c70556bfa3b3b4e2..2c5b6940568fc097c2d89947832a5b602cb024fd 100644 --- a/lib/manager/gomod/extract.spec.ts +++ b/lib/manager/gomod/extract.spec.ts @@ -13,14 +13,14 @@ describe('lib/manager/gomod/extract', () => { const res = extractPackageFile(gomod1).deps; expect(res).toMatchSnapshot(); expect(res).toHaveLength(8); - expect(res.filter(e => e.skipReason)).toHaveLength(1); - expect(res.filter(e => e.depType === 'replace')).toHaveLength(1); + expect(res.filter((e) => e.skipReason)).toHaveLength(1); + expect(res.filter((e) => e.depType === 'replace')).toHaveLength(1); }); it('extracts multi-line requires', () => { const res = extractPackageFile(gomod2).deps; expect(res).toMatchSnapshot(); expect(res).toHaveLength(58); - expect(res.filter(e => e.skipReason)).toHaveLength(0); + expect(res.filter((e) => e.skipReason)).toHaveLength(0); }); }); }); diff --git a/lib/manager/gomod/update.ts b/lib/manager/gomod/update.ts index c7d4965f6415027a4571ed0f8ed1503f63564716..d723e06c6fe081b4844b701bb1cd3adad232f835 100644 --- a/lib/manager/gomod/update.ts +++ b/lib/manager/gomod/update.ts @@ -8,10 +8,7 @@ export function updateDependency({ try { logger.debug(`gomod.updateDependency: ${upgrade.newValue}`); const { depName, depType } = upgrade; - let depNameNoVersion = depName - .split('/') - .slice(0, 3) - .join('/'); + let depNameNoVersion = depName.split('/').slice(0, 3).join('/'); if (depNameNoVersion.startsWith('gopkg.in')) { depNameNoVersion = depNameNoVersion.replace(/\.v\d+$/, ''); } diff --git a/lib/manager/gradle-wrapper/artifacts.spec.ts b/lib/manager/gradle-wrapper/artifacts.spec.ts index f89ea7319b6ea7e960fd840a01a0bc09fa108c59..00e85681a636b626dc648dbd3cc297b0acbe8203 100644 --- a/lib/manager/gradle-wrapper/artifacts.spec.ts +++ b/lib/manager/gradle-wrapper/artifacts.spec.ts @@ -61,7 +61,7 @@ describe(getName(__filename), () => { 'gradle/wrapper/gradle-wrapper.jar', 'gradlew', 'gradlew.bat', - ].map(fileProjectPath => { + ].map((fileProjectPath) => { return { file: { name: fileProjectPath, @@ -81,7 +81,7 @@ describe(getName(__filename), () => { 'gradle/wrapper/gradle-wrapper.jar', 'gradlew', 'gradlew.bat', - ].forEach(file => { + ].forEach((file) => { expect( readFileSync(resolve(__dirname, `./__fixtures__/testFiles/${file}`)) ).toEqual( @@ -116,7 +116,7 @@ describe(getName(__filename), () => { // 5.6.4 => 5.6.4 (updates execs) // 6.3 => (5.6.4) (downgrades execs) // looks like a bug in Gradle - ['gradle/wrapper/gradle-wrapper.properties'].forEach(file => { + ['gradle/wrapper/gradle-wrapper.properties'].forEach((file) => { expect( readFileSync( resolve(__dirname, `./__fixtures__/testFiles/${file}`), @@ -157,7 +157,7 @@ describe(getName(__filename), () => { expect(res[0].artifactError.stderr).not.toEqual(''); // 5.6.4 => 5.6.4 (updates execs) - unexpected behavior (looks like a bug in Gradle) - ['gradle/wrapper/gradle-wrapper.properties'].forEach(file => { + ['gradle/wrapper/gradle-wrapper.properties'].forEach((file) => { expect( readFileSync( resolve(__dirname, `./__fixtures__/testFiles/${file}`), @@ -198,7 +198,7 @@ describe(getName(__filename), () => { expect(res[0].artifactError.stderr).not.toEqual(''); // 5.6.4 => 5.6.4 (updates execs) - unexpected behavior (looks like a bug in Gradle) - ['gradle/wrapper/gradle-wrapper.properties'].forEach(file => { + ['gradle/wrapper/gradle-wrapper.properties'].forEach((file) => { expect( readFileSync( resolve(__dirname, `./__fixtures__/testFiles/${file}`), diff --git a/lib/manager/gradle-wrapper/artifacts.ts b/lib/manager/gradle-wrapper/artifacts.ts index aa2d8911b1a42df0cfa2bf9cb330ff23f9d9a5ed..790262e8adc3f7b2dd4d027f6bdbd29ff5d554c5 100644 --- a/lib/manager/gradle-wrapper/artifacts.ts +++ b/lib/manager/gradle-wrapper/artifacts.ts @@ -65,11 +65,11 @@ export async function updateArtifacts({ 'gradle/wrapper/gradle-wrapper.jar', 'gradlew', 'gradlew.bat', - ].map(async fileProjectPath => addIfUpdated(status, fileProjectPath)) + ].map(async (fileProjectPath) => addIfUpdated(status, fileProjectPath)) ) - ).filter(e => e != null); + ).filter((e) => e != null); logger.debug( - { files: updateArtifactsResult.map(r => r.file.name) }, + { files: updateArtifactsResult.map((r) => r.file.name) }, `Returning updated gradle-wrapper files` ); return updateArtifactsResult; diff --git a/lib/manager/gradle/build-gradle.ts b/lib/manager/gradle/build-gradle.ts index 7fdc8dd3d112184731ad16bcf76cd15bbe39e7b1..78b4b22f7880818d34065d927921268f7b45609a 100644 --- a/lib/manager/gradle/build-gradle.ts +++ b/lib/manager/gradle/build-gradle.ts @@ -62,7 +62,7 @@ function allMapFormatOrders( `${version}${comma}${group}${comma}${name}`, `${name}${comma}${version}${comma}${group}`, `${version}${comma}${name}${comma}${group}`, - ].map(regex => new RegExp(`${prefix}${regex}${postfix}`)); + ].map((regex) => new RegExp(`${prefix}${regex}${postfix}`)); } function moduleMapVersionFormatMatch(dependency: GradleDependency): RegExp[] { @@ -243,10 +243,7 @@ function updateGlobalMapVariables( } // Remove first path segment of variable and try again - variable = variable - .split('.') - .splice(1) - .join('.'); + variable = variable.split('.').splice(1).join('.'); } } return null; diff --git a/lib/manager/gradle/gradle-updates-report.ts b/lib/manager/gradle/gradle-updates-report.ts index 504708fea03861571ac671ee8b516c4e9e51296b..3cec3ebda4207ab748c43ac7bd136689a0a77a35 100644 --- a/lib/manager/gradle/gradle-updates-report.ts +++ b/lib/manager/gradle/gradle-updates-report.ts @@ -97,7 +97,7 @@ function mergeDependenciesWithRepositories( if (!project.dependencies) { return []; } - return project.dependencies.map(dep => ({ + return project.dependencies.map((dep) => ({ ...dep, repos: [...project.repositories], })); @@ -116,13 +116,13 @@ function combineReposOnDuplicatedDependencies( currentValue: GradleDependencyWithRepos ): GradleDependencyWithRepos[] { const existingDependency = accumulator.find( - dep => dep.name === currentValue.name && dep.group === currentValue.group + (dep) => dep.name === currentValue.name && dep.group === currentValue.group ); if (!existingDependency) { accumulator.push(currentValue); } else { const nonExistingRepos = currentValue.repos.filter( - repo => !existingDependency.repos.includes(repo) + (repo) => !existingDependency.repos.includes(repo) ); existingDependency.repos.push(...nonExistingRepos); } @@ -152,8 +152,8 @@ export async function extractDependenciesFromUpdatesReport( .reduce(combineReposOnDuplicatedDependencies, []); return dependencies - .map(gradleModule => buildDependency(gradleModule)) - .map(dep => { + .map((gradleModule) => buildDependency(gradleModule)) + .map((dep) => { /* https://github.com/renovatebot/renovate/issues/4627 */ const { depName, currentValue } = dep; if (depName.endsWith('_%%')) { diff --git a/lib/manager/helm-requirements/extract.spec.ts b/lib/manager/helm-requirements/extract.spec.ts index dfa4d14b681c1bb5daec935bf6ec606fc3327cfe..cd9ccef80592652a49f3031a0e96c26588b444b5 100644 --- a/lib/manager/helm-requirements/extract.spec.ts +++ b/lib/manager/helm-requirements/extract.spec.ts @@ -35,7 +35,7 @@ describe('lib/manager/helm-requirements/extract', () => { }); expect(result).not.toBeNull(); expect(result).toMatchSnapshot(); - expect(result.deps.every(dep => dep.skipReason)); + expect(result.deps.every((dep) => dep.skipReason)); }); it('parses simple requirements.yaml correctly', async () => { platform.getFile.mockReturnValueOnce(` @@ -100,7 +100,7 @@ describe('lib/manager/helm-requirements/extract', () => { }); expect(result).not.toBeNull(); expect(result).toMatchSnapshot(); - expect(result.deps.every(dep => dep.skipReason)); + expect(result.deps.every((dep) => dep.skipReason)); }); it("doesn't fail if Chart.yaml is invalid", async () => { platform.getFile.mockReturnValueOnce(` diff --git a/lib/manager/helm-requirements/extract.ts b/lib/manager/helm-requirements/extract.ts index 90b266bd3a3bd30ad9586367c21fde00ffb54e72..89122f3ceb691e76e19c81cae341d59ae271e168 100644 --- a/lib/manager/helm-requirements/extract.ts +++ b/lib/manager/helm-requirements/extract.ts @@ -44,7 +44,7 @@ export async function extractPackageFile( logger.debug({ fileName }, 'requirements.yaml has no dependencies'); return null; } - deps = doc.dependencies.map(dep => { + deps = doc.dependencies.map((dep) => { const res: PackageDependency = { depName: dep.name, currentValue: dep.version, diff --git a/lib/manager/helm-requirements/update.ts b/lib/manager/helm-requirements/update.ts index 67a20548bc8853ab5c6af49ec471f6d1108cb5be..8b6bee08c86ec64ec8247ed5e84cd5ee075e2a93 100644 --- a/lib/manager/helm-requirements/update.ts +++ b/lib/manager/helm-requirements/update.ts @@ -21,9 +21,9 @@ export function updateDependency({ return fileContent; } const { depName, newValue } = upgrade; - const oldVersion = doc.dependencies.filter(dep => dep.name === depName)[0] + const oldVersion = doc.dependencies.filter((dep) => dep.name === depName)[0] .version; - doc.dependencies = doc.dependencies.map(dep => + doc.dependencies = doc.dependencies.map((dep) => dep.name === depName ? { ...dep, version: newValue } : dep ); const searchString = `${oldVersion}`; diff --git a/lib/manager/helm-values/extract.ts b/lib/manager/helm-values/extract.ts index e7fc2ac7577a5b6b78ff37b7f8a89641bdf9191b..21c67b7aaafdb498fe026197593a98c7bdb2d5d5 100644 --- a/lib/manager/helm-values/extract.ts +++ b/lib/manager/helm-values/extract.ts @@ -21,7 +21,7 @@ function findDependencies( return packageDependencies; } - Object.keys(parsedContent).forEach(key => { + Object.keys(parsedContent).forEach((key) => { if (matchesHelmValuesDockerHeuristic(key, parsedContent[key])) { const currentItem = parsedContent[key]; diff --git a/lib/manager/helmfile/extract.spec.ts b/lib/manager/helmfile/extract.spec.ts index 43352e580a09f35bf4d01f0f8018b2764f22ce13..bd734902b09dda584073667a0b8e26578cb19767 100644 --- a/lib/manager/helmfile/extract.spec.ts +++ b/lib/manager/helmfile/extract.spec.ts @@ -56,7 +56,7 @@ describe('lib/manager/helmfile/extract', () => { }); expect(result).not.toBeNull(); expect(result).toMatchSnapshot(); - expect(result.deps.every(dep => dep.skipReason)); + expect(result.deps.every((dep) => dep.skipReason)); }); it('skip templetized release with invalid characters', () => { @@ -100,7 +100,7 @@ describe('lib/manager/helmfile/extract', () => { }); expect(result).not.toBeNull(); expect(result).toMatchSnapshot(); - expect(result.deps.every(dep => dep.skipReason)); + expect(result.deps.every((dep) => dep.skipReason)); }); it('skip chart with unknown repository', () => { @@ -121,7 +121,7 @@ describe('lib/manager/helmfile/extract', () => { }); expect(result).not.toBeNull(); expect(result).toMatchSnapshot(); - expect(result.deps.every(dep => dep.skipReason)); + expect(result.deps.every((dep) => dep.skipReason)); }); it('skip chart with special character in the name', () => { @@ -145,7 +145,7 @@ describe('lib/manager/helmfile/extract', () => { }); expect(result).not.toBeNull(); expect(result).toMatchSnapshot(); - expect(result.deps.every(dep => dep.skipReason)); + expect(result.deps.every((dep) => dep.skipReason)); }); it('skip chart that does not have specified version', () => { @@ -165,7 +165,7 @@ describe('lib/manager/helmfile/extract', () => { }); expect(result).not.toBeNull(); expect(result).toMatchSnapshot(); - expect(result.deps.every(dep => dep.skipReason)); + expect(result.deps.every((dep) => dep.skipReason)); }); }); }); diff --git a/lib/manager/helmfile/extract.ts b/lib/manager/helmfile/extract.ts index 662a9647fbb04931e420acd29d0260a2400db20c..a4e612b4964ded3f061db96053b0503427884b9a 100644 --- a/lib/manager/helmfile/extract.ts +++ b/lib/manager/helmfile/extract.ts @@ -35,7 +35,7 @@ export function extractPackageFile( } logger.debug({ aliases }, 'repositories discovered.'); - deps = doc.releases.map(dep => { + deps = doc.releases.map((dep) => { let depName = dep.chart; let repoName = null; diff --git a/lib/manager/helmfile/update.ts b/lib/manager/helmfile/update.ts index 45ff5cbf5d5b3d6b17f9c3ed47c147effc765a08..0f173076da22dece3d80460527ad15388b32e116 100644 --- a/lib/manager/helmfile/update.ts +++ b/lib/manager/helmfile/update.ts @@ -22,9 +22,9 @@ export function updateDependency({ } const { depName, newValue } = upgrade; const oldVersion = doc.releases.filter( - dep => dep.chart.split('/')[1] === depName + (dep) => dep.chart.split('/')[1] === depName )[0].version; - doc.releases = doc.releases.map(dep => + doc.releases = doc.releases.map((dep) => dep.chart.split('/')[1] === depName ? { ...dep, version: newValue } : dep ); const searchString = `${oldVersion}`; diff --git a/lib/manager/homebrew/extract.ts b/lib/manager/homebrew/extract.ts index 454ff063abf9a823e5f63b94f025c12e67190756..115a837021154ab15bd55f1fefb7f4083641f505 100644 --- a/lib/manager/homebrew/extract.ts +++ b/lib/manager/homebrew/extract.ts @@ -7,14 +7,14 @@ import { SkipReason } from '../../types'; function parseSha256(idx: number, content: string): string | null { let i = idx; i += 'sha256'.length; - i = skip(i, content, c => { + i = skip(i, content, (c) => { return isSpace(c); }); if (content[i] !== '"' && content[i] !== "'") { return null; } i += 1; - const j = skip(i, content, c => { + const j = skip(i, content, (c) => { return c !== '"' && c !== "'"; }); const sha256 = content.slice(i, j); @@ -33,7 +33,7 @@ function extractSha256(content: string): string | null { function parseUrl(idx: number, content: string): string | null { let i = idx; i += 'url'.length; - i = skip(i, content, c => { + i = skip(i, content, (c) => { return isSpace(c); }); const chr = content[i]; @@ -41,7 +41,7 @@ function parseUrl(idx: number, content: string): string | null { return null; } i += 1; - const j = skip(i, content, c => { + const j = skip(i, content, (c) => { return c !== '"' && c !== "'" && !isSpace(c); }); const url = content.slice(i, j); @@ -78,7 +78,7 @@ export function parseUrlPath(urlStr: string): UrlPathParsedResult | null { return null; } let s = url.pathname.split('/'); - s = s.filter(val => val); + s = s.filter((val) => val); const ownerName = s[0]; const repoName = s[1]; let currentValue: string; @@ -108,17 +108,17 @@ export function parseUrlPath(urlStr: string): UrlPathParsedResult | null { function parseClassHeader(idx: number, content: string): string | null { let i = idx; i += 'class'.length; - i = skip(i, content, c => { + i = skip(i, content, (c) => { return isSpace(c); }); // Skip all non space and non '<' characters - let j = skip(i, content, c => { + let j = skip(i, content, (c) => { return !isSpace(c) && c !== '<'; }); const className = content.slice(i, j); i = j; // Skip spaces - i = skip(i, content, c => { + i = skip(i, content, (c) => { return isSpace(c); }); if (content[i] === '<') { @@ -126,11 +126,11 @@ function parseClassHeader(idx: number, content: string): string | null { } else { return null; } // Skip spaces - i = skip(i, content, c => { + i = skip(i, content, (c) => { return isSpace(c); }); // Skip non-spaces - j = skip(i, content, c => { + j = skip(i, content, (c) => { return !isSpace(c); }); if (content.slice(i, j) !== 'Formula') { diff --git a/lib/manager/homebrew/update.ts b/lib/manager/homebrew/update.ts index cdd58b66655dffe2e9d9ca111e8d9b5e5d584ab2..1a5368abb8cc0874a7bdbaf2c8cc1c5935a5058f 100644 --- a/lib/manager/homebrew/update.ts +++ b/lib/manager/homebrew/update.ts @@ -16,7 +16,7 @@ function replaceUrl( ): string | null { let i = idx; i += 'url'.length; - i = skip(i, content, c => isSpace(c)); + i = skip(i, content, (c) => isSpace(c)); const chr = content[i]; if (chr !== '"' && chr !== "'") { return null; @@ -79,7 +79,7 @@ function replaceSha256( ): string | null { let i = idx; i += 'sha256'.length; - i = skip(i, content, c => isSpace(c)); + i = skip(i, content, (c) => isSpace(c)); const chr = content[i]; if (chr !== '"' && chr !== "'") { return null; diff --git a/lib/manager/homebrew/util.spec.ts b/lib/manager/homebrew/util.spec.ts index b5213c02fe814d3cfc9fef0cf4312cb694a96e58..976f5001c68fe28fff9aa06a5ee1fd6ef5d3431d 100644 --- a/lib/manager/homebrew/util.spec.ts +++ b/lib/manager/homebrew/util.spec.ts @@ -5,7 +5,7 @@ describe('lib/manager/homebrew/util', () => { it('handles out of bounds case', () => { const content = 'some content'; const idx = content.length * 2; - expect(skip(idx, content, c => c === '!')).toBe(idx); + expect(skip(idx, content, (c) => c === '!')).toBe(idx); }); }); }); diff --git a/lib/manager/kubernetes/extract.ts b/lib/manager/kubernetes/extract.ts index 8e84bdf4eacde91fbeee613b2bf8bdce6e1f401d..906080377d0ed57ddbf0c82ab9cc7404ffbd6fe5 100644 --- a/lib/manager/kubernetes/extract.ts +++ b/lib/manager/kubernetes/extract.ts @@ -32,7 +32,7 @@ export function extractPackageFile(content: string): PackageFile | null { lineNumber += 1; } deps = deps.filter( - dep => !(dep.currentValue && dep.currentValue.includes('${')) + (dep) => !(dep.currentValue && dep.currentValue.includes('${')) ); if (!deps.length) { return null; diff --git a/lib/manager/leiningen/extract.ts b/lib/manager/leiningen/extract.ts index ec06eed38ec3cd211230403ba2c246d9b062061c..58587eb390452a9cf3330e4b9f1b582286bc477b 100644 --- a/lib/manager/leiningen/extract.ts +++ b/lib/manager/leiningen/extract.ts @@ -118,8 +118,8 @@ function extractLeinRepos(content: string): string[] { } const repoSectionContent = repoContent.slice(0, endIdx); const matches = repoSectionContent.match(/"https?:\/\/[^"]*"/g) || []; - const urls = matches.map(x => x.replace(/^"/, '').replace(/"$/, '')); - urls.forEach(url => result.push(url)); + const urls = matches.map((x) => x.replace(/^"/, '').replace(/"$/, '')); + urls.forEach((url) => result.push(url)); } return result; diff --git a/lib/manager/maven/extract.ts b/lib/manager/maven/extract.ts index 0f15e9db65c96258692e430cb48a3f8555fccbc7..6e8aa0d80bf78bf394a55e76683990e82f1cd1b5 100644 --- a/lib/manager/maven/extract.ts +++ b/lib/manager/maven/extract.ts @@ -92,19 +92,19 @@ function applyProps( props: MavenProp ): PackageDependency<Record<string, any>> { const replaceAll = (str: string): string => - str.replace(/\${.*?}/g, substr => { + str.replace(/\${.*?}/g, (substr) => { const propKey = substr.slice(2, -1).trim(); const propValue = props[propKey]; return propValue ? propValue.val : substr; }); const depName = replaceAll(dep.depName); - const registryUrls = dep.registryUrls.map(url => replaceAll(url)); + const registryUrls = dep.registryUrls.map((url) => replaceAll(url)); let fileReplacePosition = dep.fileReplacePosition; let propSource = null; let groupName = null; - const currentValue = dep.currentValue.replace(/^\${.*?}$/, substr => { + const currentValue = dep.currentValue.replace(/^\${.*?}$/, (substr) => { const propKey = substr.slice(2, -1).trim(); const propValue = props[propKey]; if (propValue) { @@ -196,9 +196,9 @@ export function extractPackage( repoUrls.push(repoUrl); } } - result.deps.forEach(dep => { + result.deps.forEach((dep) => { if (dep.registryUrls) { - repoUrls.forEach(url => dep.registryUrls.push(url)); + repoUrls.forEach((url) => dep.registryUrls.push(url)); } }); } @@ -218,7 +218,7 @@ export function resolveParents(packages: PackageFile[]): PackageFile[] { const extractedDeps: Record<string, PackageDependency[]> = {}; const extractedProps: Record<string, MavenProp> = {}; const registryUrls: Record<string, Set<string>> = {}; - packages.forEach(pkg => { + packages.forEach((pkg) => { const name = pkg.packageFile; packageFileNames.push(name); extractedPackages[name] = pkg; @@ -228,7 +228,7 @@ export function resolveParents(packages: PackageFile[]): PackageFile[] { // Construct package-specific prop scopes // and merge them in reverse order, // which allows inheritance/overriding. - packageFileNames.forEach(name => { + packageFileNames.forEach((name) => { registryUrls[name] = new Set(); const propsHierarchy: Record<string, MavenProp>[] = []; const visitedPackages: Set<string> = new Set(); @@ -237,9 +237,9 @@ export function resolveParents(packages: PackageFile[]): PackageFile[] { propsHierarchy.unshift(pkg.mavenProps); if (pkg.deps) { - pkg.deps.forEach(dep => { + pkg.deps.forEach((dep) => { if (dep.registryUrls) { - dep.registryUrls.forEach(url => { + dep.registryUrls.forEach((url) => { registryUrls[name].add(url); }); } @@ -258,25 +258,25 @@ export function resolveParents(packages: PackageFile[]): PackageFile[] { }); // Resolve registryUrls - packageFileNames.forEach(name => { + packageFileNames.forEach((name) => { const pkg = extractedPackages[name]; - pkg.deps.forEach(rawDep => { + pkg.deps.forEach((rawDep) => { const urlsSet = new Set([...rawDep.registryUrls, ...registryUrls[name]]); rawDep.registryUrls = [...urlsSet]; // eslint-disable-line no-param-reassign }); }); // Resolve placeholders - packageFileNames.forEach(name => { + packageFileNames.forEach((name) => { const pkg = extractedPackages[name]; - pkg.deps.forEach(rawDep => { + pkg.deps.forEach((rawDep) => { const dep = applyProps(rawDep, extractedProps[name]); const sourceName = dep.propSource || name; extractedDeps[sourceName].push(dep); }); }); - return packageFileNames.map(name => ({ + return packageFileNames.map((name) => ({ ...extractedPackages[name], deps: extractedDeps[name], })); @@ -285,9 +285,9 @@ export function resolveParents(packages: PackageFile[]): PackageFile[] { function cleanResult( packageFiles: PackageFile<Record<string, any>>[] ): PackageFile<Record<string, any>>[] { - packageFiles.forEach(packageFile => { + packageFiles.forEach((packageFile) => { delete packageFile.mavenProps; // eslint-disable-line no-param-reassign - packageFile.deps.forEach(dep => { + packageFile.deps.forEach((dep) => { delete dep.propSource; // eslint-disable-line no-param-reassign }); }); diff --git a/lib/manager/maven/index.spec.ts b/lib/manager/maven/index.spec.ts index 75c7d9b49a21230031ecb838dd710a94074bc734..4aafead7a5b35dcd08be1eee30ee394e97f5c2fe 100644 --- a/lib/manager/maven/index.spec.ts +++ b/lib/manager/maven/index.spec.ts @@ -24,7 +24,7 @@ const origContent = readFileSync( ); function selectDep(deps: PackageDependency[], name = 'org.example:quuz') { - return deps.find(dep => dep.depName === name); + return deps.find((dep) => dep.depName === name); } describe('manager/maven', () => { diff --git a/lib/manager/metadata.spec.ts b/lib/manager/metadata.spec.ts index 3fbb95b21c00fc10af49e7822d1c81ac6f809f38..1af7018fb28f348e49402aee228ad682ac18af68 100644 --- a/lib/manager/metadata.spec.ts +++ b/lib/manager/metadata.spec.ts @@ -3,11 +3,11 @@ import * as fs from 'fs-extra'; describe('manager metadata', () => { const managerList: string[] = fs .readdirSync(__dirname, { withFileTypes: true }) - .filter(dirent => dirent.isDirectory()) - .map(dirent => dirent.name) - .filter(name => !name.startsWith('__')) + .filter((dirent) => dirent.isDirectory()) + .map((dirent) => dirent.name) + .filter((name) => !name.startsWith('__')) .sort(); - test.each(managerList)('%s has readme with no h1 or h2', async manager => { + test.each(managerList)('%s has readme with no h1 or h2', async (manager) => { let readme: string; try { readme = await fs.readFile(`${__dirname}/${manager}/readme.md`, 'utf8'); @@ -28,7 +28,7 @@ describe('manager metadata', () => { } expect( - res.some(line => line.startsWith('# ') || line.startsWith('## ')) + res.some((line) => line.startsWith('# ') || line.startsWith('## ')) ).toBe(false); }); }); diff --git a/lib/manager/meteor/extract.ts b/lib/manager/meteor/extract.ts index e05c03b20ceb6dc0df2a18898a7a9c4e93c9975b..18bcf6b16a824d8c554387cf79f1df419a5a7277 100644 --- a/lib/manager/meteor/extract.ts +++ b/lib/manager/meteor/extract.ts @@ -12,10 +12,10 @@ export function extractPackageFile(content: string): PackageFile | null { deps = npmDepends[1] .replace(/(\s|\\n|\\t|'|")/g, '') .split(',') - .map(dep => dep.trim()) - .filter(dep => dep.length) - .map(dep => dep.split(/:(.*)/)) - .map(arr => { + .map((dep) => dep.trim()) + .filter((dep) => dep.length) + .map((dep) => dep.split(/:(.*)/)) + .map((arr) => { const [depName, currentValue] = arr; // istanbul ignore if if (!(depName && currentValue)) { @@ -27,7 +27,7 @@ export function extractPackageFile(content: string): PackageFile | null { datasource: datasourceNpm.id, }; }) - .filter(dep => dep.depName && dep.currentValue); + .filter((dep) => dep.depName && dep.currentValue); } catch (err) /* istanbul ignore next */ { logger.warn({ content }, 'Failed to parse meteor package.js'); } diff --git a/lib/manager/npm/extract/index.spec.ts b/lib/manager/npm/extract/index.spec.ts index 9c7648444deb30ee12f01da8a7d43fa343f76b8e..ff35d4765867569352ac419a71ef2f6172906754 100644 --- a/lib/manager/npm/extract/index.spec.ts +++ b/lib/manager/npm/extract/index.spec.ts @@ -84,7 +84,7 @@ describe('manager/npm/extract', () => { expect(res).toMatchSnapshot(); }); it('finds a lock file', async () => { - platform.getFile = jest.fn(fileName => { + platform.getFile = jest.fn((fileName) => { if (fileName === 'yarn.lock') { return '# yarn.lock'; } @@ -98,7 +98,7 @@ describe('manager/npm/extract', () => { expect(res).toMatchSnapshot(); }); it('finds and filters .npmrc', async () => { - platform.getFile = jest.fn(fileName => { + platform.getFile = jest.fn((fileName) => { if (fileName === '.npmrc') { return 'save-exact = true\npackage-lock = false\n'; } @@ -112,7 +112,7 @@ describe('manager/npm/extract', () => { expect(res.npmrc).toBeDefined(); }); it('finds and discards .npmrc', async () => { - platform.getFile = jest.fn(fileName => { + platform.getFile = jest.fn((fileName) => { if (fileName === '.npmrc') { // eslint-disable-next-line return '//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}\n'; @@ -127,7 +127,7 @@ describe('manager/npm/extract', () => { expect(res.npmrc).toBeUndefined(); }); it('finds lerna', async () => { - platform.getFile = jest.fn(fileName => { + platform.getFile = jest.fn((fileName) => { if (fileName === 'lerna.json') { return '{}'; } @@ -141,7 +141,7 @@ describe('manager/npm/extract', () => { expect(res).toMatchSnapshot(); }); it('finds "npmClient":"npm" in lerna.json', async () => { - platform.getFile = jest.fn(fileName => { + platform.getFile = jest.fn((fileName) => { if (fileName === 'lerna.json') { return '{ "npmClient": "npm" }'; } @@ -155,7 +155,7 @@ describe('manager/npm/extract', () => { expect(res).toMatchSnapshot(); }); it('finds "npmClient":"yarn" in lerna.json', async () => { - platform.getFile = jest.fn(fileName => { + platform.getFile = jest.fn((fileName) => { if (fileName === 'lerna.json') { return '{ "npmClient": "yarn" }'; } @@ -169,7 +169,7 @@ describe('manager/npm/extract', () => { expect(res).toMatchSnapshot(); }); it('finds simple yarn workspaces', async () => { - platform.getFile = jest.fn(fileName => { + platform.getFile = jest.fn((fileName) => { if (fileName === 'lerna.json') { return '{}'; } @@ -183,7 +183,7 @@ describe('manager/npm/extract', () => { expect(res).toMatchSnapshot(); }); it('finds complex yarn workspaces', async () => { - platform.getFile = jest.fn(fileName => { + platform.getFile = jest.fn((fileName) => { if (fileName === 'lerna.json') { return '{}'; } diff --git a/lib/manager/npm/extract/monorepo.ts b/lib/manager/npm/extract/monorepo.ts index f06f14f97f1d7d7661af5c45380a0737afa240ea..21dcef9cb2ad0ac8f5beec4ca1d9d74f0e7fa191 100644 --- a/lib/manager/npm/extract/monorepo.ts +++ b/lib/manager/npm/extract/monorepo.ts @@ -8,7 +8,7 @@ import { PackageFile } from '../../common'; function matchesAnyPattern(val: string, patterns: string[]): boolean { const res = patterns.some( - pattern => pattern === val + '/' || minimatch(val, pattern, { dot: true }) + (pattern) => pattern === val + '/' || minimatch(val, pattern, { dot: true }) ); logger.trace({ val, patterns, res }, `matchesAnyPattern`); return res; @@ -36,18 +36,18 @@ export function detectMonorepos(packageFiles: Partial<PackageFile>[]): void { const internalPackagePatterns = (is.array(packages) ? packages : [packages] - ).map(pattern => upath.join(basePath, pattern)); - const internalPackageFiles = packageFiles.filter(sp => + ).map((pattern) => upath.join(basePath, pattern)); + const internalPackageFiles = packageFiles.filter((sp) => matchesAnyPattern(path.dirname(sp.packageFile), internalPackagePatterns) ); const internalPackages = internalPackageFiles - .map(sp => sp.packageJsonName) + .map((sp) => sp.packageJsonName) .filter(Boolean); // add all names to main package.json p.internalPackages = internalPackages; for (const subPackage of internalPackageFiles) { subPackage.internalPackages = internalPackages.filter( - name => name !== subPackage.packageJsonName + (name) => name !== subPackage.packageJsonName ); subPackage.lernaDir = lernaDir; subPackage.lernaClient = lernaClient; diff --git a/lib/manager/npm/post-update/index.ts b/lib/manager/npm/post-update/index.ts index a23ef4ca3e128c399e2ccdeeae37c85e7ee87ab0..65559d3eb8ef786d626c74b38b5e9bbbd1cf865d 100644 --- a/lib/manager/npm/post-update/index.ts +++ b/lib/manager/npm/post-update/index.ts @@ -136,7 +136,7 @@ export async function writeExistingFiles( } const npmFiles = packageFiles.npm; logger.debug( - { packageFiles: npmFiles.map(n => n.packageFile) }, + { packageFiles: npmFiles.map((n) => n.packageFile) }, 'Writing package.json files' ); const writtenLockFiles = []; @@ -199,7 +199,7 @@ export async function writeExistingFiles( try { const npmLockParsed = JSON.parse(existingNpmLock); if (npmLockParsed.dependencies) { - widens.forEach(depName => { + widens.forEach((depName) => { delete npmLockParsed.dependencies[depName]; }); } @@ -446,7 +446,7 @@ export async function getAdditionalFiles( const fileName = path.basename(lockFile); logger.debug(`Generating ${fileName} for ${lockFileDir}`); const upgrades = config.upgrades.filter( - upgrade => upgrade.npmLock === lockFile + (upgrade) => upgrade.npmLock === lockFile ); const res = await npm.generateLockFile( fullLockFileDir, @@ -509,7 +509,7 @@ export async function getAdditionalFiles( logger.debug(`Generating yarn.lock for ${lockFileDir}`); const lockFileName = upath.join(lockFileDir, 'yarn.lock'); const upgrades = config.upgrades.filter( - upgrade => upgrade.yarnLock === lockFile + (upgrade) => upgrade.yarnLock === lockFile ); const res = await yarn.generateLockFile( upath.join(config.localDir, lockFileDir), @@ -563,7 +563,7 @@ export async function getAdditionalFiles( if (yarnrc) { const mirrorLine = yarnrc .split('\n') - .find(line => line.startsWith('yarn-offline-mirror ')); + .find((line) => line.startsWith('yarn-offline-mirror ')); if (mirrorLine) { const mirrorPath = mirrorLine .split(' ')[1] @@ -663,7 +663,7 @@ export async function getAdditionalFiles( let lockFile: string; logger.debug(`Finding package.json for lerna directory "${lernaDir}"`); const lernaPackageFile = packageFiles.npm.find( - p => path.dirname(p.packageFile) === lernaDir + (p) => path.dirname(p.packageFile) === lernaDir ); if (!lernaPackageFile) { logger.debug('No matching package.json found'); diff --git a/lib/manager/npm/post-update/npm.ts b/lib/manager/npm/post-update/npm.ts index 6d13ecc5711f7760dc9e4a5c8690da2943ada744..4eecc4e471ab047292bec0baaf87ae66709ef5b9 100644 --- a/lib/manager/npm/post-update/npm.ts +++ b/lib/manager/npm/post-update/npm.ts @@ -79,7 +79,7 @@ export async function generateLockFile( if (config.cacheDir) { volumes.push(config.cacheDir); } - cmd += volumes.map(v => `-v "${v}":"${v}" `).join(''); + cmd += volumes.map((v) => `-v "${v}":"${v}" `).join(''); if (config.dockerMapDotfiles) { const homeDir = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE; @@ -87,7 +87,7 @@ export async function generateLockFile( cmd += `-v ${homeNpmrc}:/home/ubuntu/.npmrc `; } const envVars = ['NPM_CONFIG_CACHE', 'npm_config_store']; - cmd += envVars.map(e => `-e ${e} `).join(''); + cmd += envVars.map((e) => `-e ${e} `).join(''); cmd += `-w "${cwd}" `; cmd += `renovate/npm npm`; } @@ -103,20 +103,20 @@ export async function generateLockFile( } logger.debug(`Using npm: ${cmd} ${args}`); // istanbul ignore if - if (!upgrades.every(upgrade => upgrade.isLockfileUpdate)) { + if (!upgrades.every((upgrade) => upgrade.isLockfileUpdate)) { // TODO: Switch to native util.promisify once using only node 8 ({ stdout, stderr } = await exec(`${cmd} ${args}`, { cwd, env, })); } - const lockUpdates = upgrades.filter(upgrade => upgrade.isLockfileUpdate); + const lockUpdates = upgrades.filter((upgrade) => upgrade.isLockfileUpdate); if (lockUpdates.length) { logger.debug('Performing lockfileUpdate (npm)'); const updateCmd = `${cmd} ${args}` + lockUpdates - .map(update => ` ${update.depName}@${update.toVersion}`) + .map((update) => ` ${update.depName}@${update.toVersion}`) .join(''); const updateRes = await exec(updateCmd, { cwd, diff --git a/lib/manager/npm/post-update/pnpm.ts b/lib/manager/npm/post-update/pnpm.ts index 7134573566632bb4443548e8d39ae239e779ac08..e1db6dbd37a74102ba43ac032f78de2b89b7bd9d 100644 --- a/lib/manager/npm/post-update/pnpm.ts +++ b/lib/manager/npm/post-update/pnpm.ts @@ -75,7 +75,7 @@ export async function generateLockFile( if (config.cacheDir) { volumes.push(config.cacheDir); } - cmd += volumes.map(v => `-v "${v}":"${v}" `).join(''); + cmd += volumes.map((v) => `-v "${v}":"${v}" `).join(''); // istanbul ignore if if (config.dockerMapDotfiles) { const homeDir = @@ -84,7 +84,7 @@ export async function generateLockFile( cmd += `-v ${homeNpmrc}:/home/ubuntu/.npmrc `; } const envVars = ['NPM_CONFIG_CACHE', 'npm_config_store']; - cmd += envVars.map(e => `-e ${e} `).join(''); + cmd += envVars.map((e) => `-e ${e} `).join(''); cmd += `-w "${cwd}" `; cmd += `renovate/pnpm pnpm`; } diff --git a/lib/manager/npm/post-update/yarn.ts b/lib/manager/npm/post-update/yarn.ts index 15a46f5dd5a1e8bf208f593b30930db93466cc46..6e3385f8f663054efcf29f3f71b07fafcc9990dd 100644 --- a/lib/manager/npm/post-update/yarn.ts +++ b/lib/manager/npm/post-update/yarn.ts @@ -38,7 +38,7 @@ export async function generateLockFile( cmd = `node ${installedPath}`; const yarnIntegrity = config.upgrades && - config.upgrades.some(upgrade => upgrade.yarnIntegrity); + config.upgrades.some((upgrade) => upgrade.yarnIntegrity); if (!yarnIntegrity) { logger.warn('Using yarn@1.9.4 for install is deprecated'); try { @@ -101,14 +101,14 @@ export async function generateLockFile( env, }); const lockUpdates = upgrades - .filter(upgrade => upgrade.isLockfileUpdate) - .map(upgrade => upgrade.depName); + .filter((upgrade) => upgrade.isLockfileUpdate) + .map((upgrade) => upgrade.depName); if (lockUpdates.length) { logger.debug('Performing lockfileUpdate (yarn)'); const updateCmd = cmd + ' upgrade' + - lockUpdates.map(depName => ` ${depName}`).join('') + + lockUpdates.map((depName) => ` ${depName}`).join('') + cmdExtras; const updateRes = await exec(updateCmd, { cwd, diff --git a/lib/manager/pip_requirements/extract.ts b/lib/manager/pip_requirements/extract.ts index 3e5efc48dd3a5459e1f7ca16624c2a13eecbc170..1d05dc8c817b44768e419c950cd262694f1e0ed2 100644 --- a/lib/manager/pip_requirements/extract.ts +++ b/lib/manager/pip_requirements/extract.ts @@ -23,7 +23,7 @@ export function extractPackageFile( let indexUrl: string; const extraUrls = []; - content.split('\n').forEach(line => { + content.split('\n').forEach((line) => { if (line.startsWith('--index-url ')) { indexUrl = line.substring('--index-url '.length).split(' ')[0]; } @@ -50,9 +50,9 @@ export function extractPackageFile( const regex = new RegExp(`^${dependencyPattern}$`, 'g'); const deps = content .split('\n') - .map(rawline => { + .map((rawline) => { let dep: PackageDependency = {}; - const [line, comment] = rawline.split('#').map(part => part.trim()); + const [line, comment] = rawline.split('#').map((part) => part.trim()); if (isSkipComment(comment)) { dep.skipReason = SkipReason.Ignored; } diff --git a/lib/manager/pip_setup/extract.ts b/lib/manager/pip_setup/extract.ts index deca3402af5d7af7a10d91fab34fc61aa4864bb5..c15b2aa05365c539c59ab279d93110fe49c907c7 100644 --- a/lib/manager/pip_setup/extract.ts +++ b/lib/manager/pip_setup/extract.ts @@ -120,14 +120,14 @@ export async function extractPackageFile( const regex = new RegExp(`^${dependencyPattern}`); const lines = content.split('\n'); const deps = requires - .map(req => { - const lineNumber = lines.findIndex(l => l.includes(req)); + .map((req) => { + const lineNumber = lines.findIndex((l) => l.includes(req)); if (lineNumber === -1) { return null; } const rawline = lines[lineNumber]; let dep: PackageDependency = {}; - const [, comment] = rawline.split('#').map(part => part.trim()); + const [, comment] = rawline.split('#').map((part) => part.trim()); if (isSkipComment(comment)) { dep.skipReason = SkipReason.Ignored; } diff --git a/lib/manager/pip_setup/index.spec.ts b/lib/manager/pip_setup/index.spec.ts index e400f02b5c038dec0789626947140e1ad60669cf..93775062c56c03e96f3b77d7fe6d9a7ce162af2b 100644 --- a/lib/manager/pip_setup/index.spec.ts +++ b/lib/manager/pip_setup/index.spec.ts @@ -36,7 +36,7 @@ const pythonVersionCallResults = [ // TODO: figure out snapshot similarity for each CI platform const fixSnapshots = (snapshots: ExecSnapshots): ExecSnapshots => - snapshots.map(snapshot => ({ + snapshots.map((snapshot) => ({ ...snapshot, cmd: snapshot.cmd.replace(/^.*\/extract\.py"\s+/, '<extract.py> '), })); diff --git a/lib/manager/pipenv/extract.spec.ts b/lib/manager/pipenv/extract.spec.ts index 114f86feac8dde657e32d9c608c7edbcf654207b..a86690765be280321e5d466264fe3412fdd67115 100644 --- a/lib/manager/pipenv/extract.spec.ts +++ b/lib/manager/pipenv/extract.spec.ts @@ -34,12 +34,12 @@ describe('lib/manager/pipenv/extract', () => { const res = extractPackageFile(pipfile1); expect(res).toMatchSnapshot(); expect(res.deps).toHaveLength(6); - expect(res.deps.filter(dep => !dep.skipReason)).toHaveLength(4); + expect(res.deps.filter((dep) => !dep.skipReason)).toHaveLength(4); }); it('marks packages with "extras" as skipReason === any-version', () => { const res = extractPackageFile(pipfile3); - expect(res.deps.filter(r => !r.skipReason)).toHaveLength(0); - expect(res.deps.filter(r => r.skipReason)).toHaveLength(6); + expect(res.deps.filter((r) => !r.skipReason)).toHaveLength(0); + expect(res.deps.filter((r) => r.skipReason)).toHaveLength(6); }); it('extracts multiple dependencies', () => { const res = extractPackageFile(pipfile2); @@ -50,24 +50,24 @@ describe('lib/manager/pipenv/extract', () => { const content = '[packages]\r\nflask = {git = "https://github.com/pallets/flask.git"}\r\nwerkzeug = ">=0.14"'; const res = extractPackageFile(content); - expect(res.deps.filter(r => !r.skipReason)).toHaveLength(1); + expect(res.deps.filter((r) => !r.skipReason)).toHaveLength(1); }); it('ignores invalid package names', () => { const content = '[packages]\r\nfoo = "==1.0.0"\r\n_invalid = "==1.0.0"'; const res = extractPackageFile(content); expect(res.deps).toHaveLength(2); - expect(res.deps.filter(dep => !dep.skipReason)).toHaveLength(1); + expect(res.deps.filter((dep) => !dep.skipReason)).toHaveLength(1); }); it('ignores relative path dependencies', () => { const content = '[packages]\r\nfoo = "==1.0.0"\r\ntest = {path = "."}'; const res = extractPackageFile(content); - expect(res.deps.filter(r => !r.skipReason)).toHaveLength(1); + expect(res.deps.filter((r) => !r.skipReason)).toHaveLength(1); }); it('ignores invalid versions', () => { const content = '[packages]\r\nfoo = "==1.0.0"\r\nsome-package = "==0 0"'; const res = extractPackageFile(content); expect(res.deps).toHaveLength(2); - expect(res.deps.filter(dep => !dep.skipReason)).toHaveLength(1); + expect(res.deps.filter((dep) => !dep.skipReason)).toHaveLength(1); }); it('extracts all sources', () => { const content = diff --git a/lib/manager/pipenv/extract.ts b/lib/manager/pipenv/extract.ts index 70ed932b75aa2284467d684ca8f01620c683ccff..b2ea6aec9c59c391cd049c576d2fb3cee8be77de 100644 --- a/lib/manager/pipenv/extract.ts +++ b/lib/manager/pipenv/extract.ts @@ -46,7 +46,7 @@ function extractFromSection( const pipfileSection = pipfile[section]; const deps = Object.entries(pipfileSection) - .map(x => { + .map((x) => { const [depName, requirements] = x; let currentValue: string; let nestedVersion: boolean; @@ -103,7 +103,7 @@ function extractFromSection( if (requirements.index) { if (is.array(pipfile.source)) { const source = pipfile.source.find( - item => item.name === requirements.index + (item) => item.name === requirements.index ); if (source) { dep.registryUrls = [source.url]; @@ -128,7 +128,7 @@ export function extractPackageFile(content: string): PackageFile | null { } const res: PackageFile = { deps: [] }; if (pipfile.source) { - res.registryUrls = pipfile.source.map(source => source.url); + res.registryUrls = pipfile.source.map((source) => source.url); } res.deps = [ diff --git a/lib/manager/poetry/extract.ts b/lib/manager/poetry/extract.ts index ba4f945e878052cf977864a29e14f06ebfa8ccd4..e55beb23656daa17e6cd9cdb94d06abdfb886aed 100644 --- a/lib/manager/poetry/extract.ts +++ b/lib/manager/poetry/extract.ts @@ -15,7 +15,7 @@ function extractFromSection( if (!sectionContent) { return []; } - Object.keys(sectionContent).forEach(depName => { + Object.keys(sectionContent).forEach((depName) => { let skipReason: SkipReason; let currentValue = sectionContent[depName]; let nestedVersion = false; diff --git a/lib/manager/regex/index.spec.ts b/lib/manager/regex/index.spec.ts index c2810eef81071209be57681f84719ebc4b81642e..acf2f44c242fe245676fab552e7f27ee857b0fca 100644 --- a/lib/manager/regex/index.spec.ts +++ b/lib/manager/regex/index.spec.ts @@ -28,10 +28,10 @@ describe(getName(__filename), () => { ); expect(res).toMatchSnapshot(); expect(res.deps).toHaveLength(8); - expect(res.deps.find(dep => dep.depName === 'yarn').versioning).toEqual( + expect(res.deps.find((dep) => dep.depName === 'yarn').versioning).toEqual( 'semver' ); - expect(res.deps.find(dep => dep.depName === 'gradle').versioning).toEqual( + expect(res.deps.find((dep) => dep.depName === 'gradle').versioning).toEqual( 'maven' ); }); diff --git a/lib/manager/terraform/extract.spec.ts b/lib/manager/terraform/extract.spec.ts index 8e795f2802b05ba108dad800df9902f08d167fa1..3c4f7a4dca004c4058f357bfee3a5ee127f49946 100644 --- a/lib/manager/terraform/extract.spec.ts +++ b/lib/manager/terraform/extract.spec.ts @@ -20,7 +20,7 @@ describe('lib/manager/terraform/extract', () => { const res = extractPackageFile(tf1); expect(res).toMatchSnapshot(); expect(res.deps).toHaveLength(22); - expect(res.deps.filter(dep => dep.skipReason)).toHaveLength(6); + expect(res.deps.filter((dep) => dep.skipReason)).toHaveLength(6); }); it('returns null if only local deps', () => { expect(extractPackageFile(tf2)).toBeNull(); diff --git a/lib/manager/terraform/extract.ts b/lib/manager/terraform/extract.ts index 943ed944594645a40e1c0d6c09e932141f4c195b..9110b3eaf97005d0bf539e80831f8c6723decfb5 100644 --- a/lib/manager/terraform/extract.ts +++ b/lib/manager/terraform/extract.ts @@ -80,7 +80,7 @@ export function extractPackageFile(content: string): PackageFile | null { } catch (err) /* istanbul ignore next */ { logger.warn({ err }, 'Error extracting buildkite plugins'); } - deps.forEach(dep => { + deps.forEach((dep) => { if ( dep.managerData.terraformDependencyType === TerraformDependencyTypes.module @@ -150,7 +150,7 @@ export function extractPackageFile(content: string): PackageFile | null { delete dep.managerData; /* eslint-enable no-param-reassign */ }); - if (deps.some(dep => dep.skipReason !== 'local')) { + if (deps.some((dep) => dep.skipReason !== 'local')) { return { deps }; } return null; diff --git a/lib/manager/travis/package.ts b/lib/manager/travis/package.ts index 4bef0691f67483a752e001f273fed0d48f2f9148..5a59f18d7cf60278389e267e2d828804964e6342 100644 --- a/lib/manager/travis/package.ts +++ b/lib/manager/travis/package.ts @@ -102,7 +102,7 @@ export async function getPackageUpdates( logger.debug({ supportPolicy }, `supportPolicy`); // TODO: `newValue` is a (string | number)[] ! let newValue: any[] = (supportPolicy as (keyof NodeJsPolicies)[]) - .map(policy => policies[policy]) + .map((policy) => policies[policy]) .reduce((result, policy) => result.concat(policy), []) .sort((a, b) => a - b); const newMajor = newValue[newValue.length - 1]; @@ -113,13 +113,13 @@ export async function getPackageUpdates( datasource: datasourceGithubTags.id, depName: 'nodejs/node', }) - ).releases.map(release => release.version); - newValue = newValue.map(value => + ).releases.map((release) => release.version); + newValue = newValue.map((value) => maxSatisfyingVersion(versions, `${value}`) ); } if (is.string(config.currentValue[0])) { - newValue = newValue.map(val => `${val}`); + newValue = newValue.map((val) => `${val}`); } newValue.sort((a, b) => a - b); diff --git a/lib/manager/travis/update.ts b/lib/manager/travis/update.ts index 1c658128572622bf81843296b24e14696f99b1d7..089ad98ccc1f737a4c88e6f122ca96fd7bd5f13c 100644 --- a/lib/manager/travis/update.ts +++ b/lib/manager/travis/update.ts @@ -21,7 +21,7 @@ export function updateDependency({ } let newString = `node_js:\n`; // TODO: `newValue` is a string! - (upgrade.newValue as any).forEach(version => { + (upgrade.newValue as any).forEach((version) => { newString += `${indent}- ${quote}${version}${quote}\n`; }); return fileContent.replace(/node_js:(\n\s+-[^\n]+)+\n/, newString); diff --git a/lib/platform/azure/azure-helper.spec.ts b/lib/platform/azure/azure-helper.spec.ts index e812179c3e96499d4cb74c6d230309d97f447448..eed3319f3fb19c0bd34ad6d45c0ef27b647f838a 100644 --- a/lib/platform/azure/azure-helper.spec.ts +++ b/lib/platform/azure/azure-helper.spec.ts @@ -130,7 +130,7 @@ describe('platform/azure/helpers', () => { objectMode: true, /* eslint-disable func-names */ /* eslint-disable object-shorthand */ - read: function() { + read: function () { if (eventCount < 1) { eventCount += 1; return this.push('{"typeKey": "GitItemNotFoundException"}'); @@ -160,7 +160,7 @@ describe('platform/azure/helpers', () => { objectMode: true, /* eslint-disable func-names */ /* eslint-disable object-shorthand */ - read: function() { + read: function () { if (eventCount < 1) { eventCount += 1; return this.push('{"typeKey": "GitUnresolvableToCommitException"}'); @@ -190,7 +190,7 @@ describe('platform/azure/helpers', () => { objectMode: true, /* eslint-disable func-names */ /* eslint-disable object-shorthand */ - read: function() { + read: function () { if (eventCount < 1) { eventCount += 1; return this.push('{"hello"= "test"}'); diff --git a/lib/platform/azure/azure-helper.ts b/lib/platform/azure/azure-helper.ts index ca42e321277fca6be42a1d29c7bc6aa0a47d1d2d..61969d872345172421c7991e1d4930960bdef1d6 100644 --- a/lib/platform/azure/azure-helper.ts +++ b/lib/platform/azure/azure-helper.ts @@ -118,7 +118,7 @@ export async function getAzureBranchObj( async function streamToString(stream: NodeJS.ReadableStream): Promise<string> { const chunks: string[] = []; /* eslint-disable promise/avoid-new */ - const p = await new Promise<string>(resolve => { + const p = await new Promise<string>((resolve) => { stream.on('data', (chunk: any) => { chunks.push(chunk.toString()); }); @@ -266,16 +266,16 @@ export async function getMergeMethod( await (await azureApi.policyApi()).getPolicyConfigurations(project) ) .filter( - p => - p.settings.scope.some(s => s.repositoryId === repoId) && + (p) => + p.settings.scope.some((s) => s.repositoryId === repoId) && p.type.id === mergePolicyGuid ) - .map(p => p.settings)[0]; + .map((p) => p.settings)[0]; try { return Object.keys(policyConfigurations) - .map(p => GitPullRequestMergeStrategy[p.slice(5)]) - .find(p => p); + .map((p) => GitPullRequestMergeStrategy[p.slice(5)]) + .find((p) => p); } catch (err) { return GitPullRequestMergeStrategy.NoFastForward; } diff --git a/lib/platform/azure/index.spec.ts b/lib/platform/azure/index.spec.ts index c7c90fe84ff16904f889eaaeb28d461dacc82fcf..a16e2b30e146318f7c01eb16c4b26d8b99fcf611 100644 --- a/lib/platform/azure/index.spec.ts +++ b/lib/platform/azure/index.spec.ts @@ -18,7 +18,7 @@ describe('platform/azure', () => { jest.mock('../git/storage'); jest.mock('../../util/host-rules'); hostRules = require('../../util/host-rules'); - require('../../util/sanitize').sanitize = jest.fn(input => input); + require('../../util/sanitize').sanitize = jest.fn((input) => input); azure = await import('.'); azureApi = require('./azure-got-wrapper'); azureHelper = require('./azure-helper'); @@ -639,7 +639,7 @@ describe('platform/azure', () => { updatePullRequest: updateFn, } as any) ); - azureHelper.getRenovatePRFormat.mockImplementation(x => x as any); + azureHelper.getRenovatePRFormat.mockImplementation((x) => x as any); const pr = await azure.createPr({ branchName: 'some-branch', prTitle: 'The Title', diff --git a/lib/platform/azure/index.ts b/lib/platform/azure/index.ts index cb5debc846dbf645167caf88fe639531a726e709..4c423a67bb6d7032e34098e3050d4eca44c3b04c 100644 --- a/lib/platform/azure/index.ts +++ b/lib/platform/azure/index.ts @@ -91,7 +91,7 @@ export async function getRepos(): Promise<string[]> { logger.debug('Autodiscovering Azure DevOps repositories'); const azureApiGit = await azureApi.gitApi(); const repos = await azureApiGit.getRepositories(); - return repos.map(repo => `${repo.project.name}/${repo.name}`); + return repos.map((repo) => `${repo.project.name}/${repo.name}`); } async function getBranchCommit(fullBranchName: string): Promise<string> { @@ -115,7 +115,7 @@ export async function initRepo({ const repos = await azureApiGit.getRepositories(); const names = azureHelper.getProjectAndRepo(repository); const repo = repos.filter( - c => + (c) => c.name.toLowerCase() === names.repo.toLowerCase() && c.project.name.toLowerCase() === names.project.toLowerCase() )[0]; @@ -275,7 +275,7 @@ export async function getPr(pullRequestId: number): Promise<Pr | null> { return null; } const azurePr = (await getPrList()).find( - item => item.pullRequestId === pullRequestId + (item) => item.pullRequestId === pullRequestId ); if (!azurePr) { @@ -289,8 +289,8 @@ export async function getPr(pullRequestId: number): Promise<Pr | null> { ); azurePr.labels = labels - .filter(label => label.active) - .map(label => label.name); + .filter((label) => label.active) + .map((label) => label.name); const commits = await azureApiGit.getPullRequestCommits( config.repoId, @@ -312,11 +312,11 @@ export async function findPr({ const prs = await getPrList(); prsFiltered = prs.filter( - item => item.sourceRefName === azureHelper.getNewBranchName(branchName) + (item) => item.sourceRefName === azureHelper.getNewBranchName(branchName) ); if (prTitle) { - prsFiltered = prsFiltered.filter(item => item.title === prTitle); + prsFiltered = prsFiltered.filter((item) => item.title === prTitle); } switch (state) { @@ -324,10 +324,12 @@ export async function findPr({ // no more filter needed, we can go further... break; case PR_STATE_NOT_OPEN: - prsFiltered = prsFiltered.filter(item => item.state !== PR_STATE_OPEN); + prsFiltered = prsFiltered.filter( + (item) => item.state !== PR_STATE_OPEN + ); break; default: - prsFiltered = prsFiltered.filter(item => item.state === state); + prsFiltered = prsFiltered.filter((item) => item.state === state); break; } } catch (error) { @@ -476,7 +478,7 @@ export async function createPr({ ); } await Promise.all( - labels.map(label => + labels.map((label) => azureApiGit.createPullRequestLabel( { name: label, @@ -519,7 +521,7 @@ export async function ensureComment({ let threadIdFound = null; let commentIdFound = null; let commentNeedsUpdating = false; - threads.forEach(thread => { + threads.forEach((thread) => { const firstCommentContent = thread.comments[0].content; if ( (topic && firstCommentContent?.startsWith(header)) || @@ -578,7 +580,7 @@ export async function ensureCommentRemoval( const threads = await azureApiGit.getThreads(config.repoId, issueNo); let threadIdFound = null; - threads.forEach(thread => { + threads.forEach((thread) => { if (thread.comments[0].content.startsWith(`### ${topic}\n\n`)) { threadIdFound = thread.id; } @@ -653,11 +655,11 @@ async function getUserIds(users: string[]): Promise<User[]> { const azureApiGit = await azureApi.gitApi(); const azureApiCore = await azureApi.coreApi(); const repos = await azureApiGit.getRepositories(); - const repo = repos.filter(c => c.id === config.repoId)[0]; + const repo = repos.filter((c) => c.id === config.repoId)[0]; const teams = await azureApiCore.getTeams(repo.project.id); const members = await Promise.all( teams.map( - async t => + async (t) => /* eslint-disable no-return-await */ await azureApiCore.getTeamMembersWithExtendedProperties( repo.project.id, @@ -667,14 +669,14 @@ async function getUserIds(users: string[]): Promise<User[]> { ); const ids: { id: string; name: string }[] = []; - members.forEach(listMembers => { - listMembers.forEach(m => { - users.forEach(r => { + members.forEach((listMembers) => { + listMembers.forEach((m) => { + users.forEach((r) => { if ( r.toLowerCase() === m.identity.displayName.toLowerCase() || r.toLowerCase() === m.identity.uniqueName.toLowerCase() ) { - if (ids.filter(c => c.id === m.identity.id).length === 0) { + if (ids.filter((c) => c.id === m.identity.id).length === 0) { ids.push({ id: m.identity.id, name: r }); } } @@ -682,10 +684,10 @@ async function getUserIds(users: string[]): Promise<User[]> { }); }); - teams.forEach(t => { - users.forEach(r => { + teams.forEach((t) => { + users.forEach((r) => { if (r.toLowerCase() === t.name.toLowerCase()) { - if (ids.filter(c => c.id === t.id).length === 0) { + if (ids.filter((c) => c.id === t.id).length === 0) { ids.push({ id: t.id, name: r }); } } @@ -709,7 +711,7 @@ export async function addAssignees( await ensureComment({ number: issueNo, topic: 'Add Assignees', - content: ids.map(a => `@<${a.id}>`).join(', '), + content: ids.map((a) => `@<${a.id}>`).join(', '), }); } @@ -728,7 +730,7 @@ export async function addReviewers( const ids = await getUserIds(reviewers); await Promise.all( - ids.map(async obj => { + ids.map(async (obj) => { await azureApiGit.createPullRequestReviewer( {}, config.repoId, @@ -760,7 +762,7 @@ export async function getPrFiles(prId: number): Promise<string[]> { ( await Promise.all( prIterations.map( - async iteration => + async (iteration) => ( await azureApiGit.getPullRequestIterationChanges( config.repoId, @@ -772,7 +774,7 @@ export async function getPrFiles(prId: number): Promise<string[]> { ) ) .reduce((acc, val) => acc.concat(val), []) - .map(change => change.item.path.slice(1)) + .map((change) => change.item.path.slice(1)) ), ]; } diff --git a/lib/platform/bitbucket-server/index.spec.ts b/lib/platform/bitbucket-server/index.spec.ts index a80fa31192efbfc0c463b367e86d57e9ee9c78c0..7be3603c69814b00d6a8f1871bb02c6847f778bc 100644 --- a/lib/platform/bitbucket-server/index.spec.ts +++ b/lib/platform/bitbucket-server/index.spec.ts @@ -183,7 +183,7 @@ describe('platform/bitbucket-server', () => { it.each(['ff-only', 'rebase-ff-only', 'squash-ff-only'])( 'return true if %s strategy is enabled', - async id => { + async (id) => { expect.assertions(1); api.get.mockResolvedValueOnce({ body: { @@ -201,7 +201,7 @@ describe('platform/bitbucket-server', () => { it.each(['no-ff', 'ff', 'rebase-no-ff', 'squash'])( 'return false if %s strategy is enabled', - async id => { + async (id) => { expect.assertions(1); api.get.mockResolvedValueOnce({ body: { diff --git a/lib/platform/bitbucket-server/index.ts b/lib/platform/bitbucket-server/index.ts index eda47919162c0d5a4d0aa506229e869a8cf8920b..bac9e13a44fa8b36914918bf74e836c8f8ff1bd1 100644 --- a/lib/platform/bitbucket-server/index.ts +++ b/lib/platform/bitbucket-server/index.ts @@ -734,7 +734,9 @@ export async function addReviewers( body: { title: pr.title, version: pr.version, - reviewers: Array.from(reviewersSet).map(name => ({ user: { name } })), + reviewers: Array.from(reviewersSet).map((name) => ({ + user: { name }, + })), }, } ); @@ -841,7 +843,7 @@ export async function ensureComment({ if (topic) { logger.debug(`Ensuring comment "${topic}" in #${number}`); body = `### ${topic}\n\n${sanitizedContent}`; - comments.forEach(comment => { + comments.forEach((comment) => { if (comment.text.startsWith(`### ${topic}\n\n`)) { commentId = comment.id; commentNeedsUpdating = comment.text !== body; @@ -850,7 +852,7 @@ export async function ensureComment({ } else { logger.debug(`Ensuring content-only comment in #${number}`); body = `${sanitizedContent}`; - comments.forEach(comment => { + comments.forEach((comment) => { if (comment.text === body) { commentId = comment.id; commentNeedsUpdating = false; @@ -887,7 +889,7 @@ export async function ensureCommentRemoval( logger.debug(`Ensuring comment "${topic}" in #${prNo} is removed`); const comments = await getComments(prNo); let commentId: number; - comments.forEach(comment => { + comments.forEach((comment) => { if (comment.text.startsWith(`### ${topic}\n\n`)) { commentId = comment.id; } @@ -1003,7 +1005,7 @@ export async function getPrFiles(prNo: number): Promise<string[]> { const values = await utils.accumulateValues<{ path: { toString: string } }>( `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests/${prNo}/changes?withComments=false` ); - return values.map(f => f.path.toString); + return values.map((f) => f.path.toString); } export async function updatePr( diff --git a/lib/platform/bitbucket/comments.ts b/lib/platform/bitbucket/comments.ts index d4f4c8951c2186e50ac3040301948bdcd22dae37..cbd41cc975a468d1849728a03a3b43844d38de28 100644 --- a/lib/platform/bitbucket/comments.ts +++ b/lib/platform/bitbucket/comments.ts @@ -77,7 +77,7 @@ export async function ensureComment({ if (topic) { logger.debug(`Ensuring comment "${topic}" in #${prNo}`); body = `### ${topic}\n\n${content}`; - comments.forEach(comment => { + comments.forEach((comment) => { if (comment.content.raw.startsWith(`### ${topic}\n\n`)) { commentId = comment.id; commentNeedsUpdating = comment.content.raw !== body; @@ -86,7 +86,7 @@ export async function ensureComment({ } else { logger.debug(`Ensuring content-only comment in #${prNo}`); body = `${content}`; - comments.forEach(comment => { + comments.forEach((comment) => { if (comment.content.raw === body) { commentId = comment.id; commentNeedsUpdating = false; @@ -121,7 +121,7 @@ export async function ensureCommentRemoval( logger.debug(`Ensuring comment "${topic}" in #${prNo} is removed`); const comments = await getComments(config, prNo); let commentId: number; - comments.forEach(comment => { + comments.forEach((comment) => { if (comment.content.raw.startsWith(`### ${topic}\n\n`)) { commentId = comment.id; } diff --git a/lib/platform/bitbucket/index.ts b/lib/platform/bitbucket/index.ts index d7369de70ec5fe58c6a08ec6ca6145b188fdaad1..78e1ab5c17320f59162ffaa17964449c0c682d74 100644 --- a/lib/platform/bitbucket/index.ts +++ b/lib/platform/bitbucket/index.ts @@ -67,7 +67,7 @@ export async function getRepos(): Promise<string[]> { const repos = await utils.accumulateValues<{ full_name: string }>( `/2.0/repositories/?role=contributor` ); - return repos.map(repo => repo.full_name); + return repos.map((repo) => repo.full_name); } catch (err) /* istanbul ignore next */ { logger.error({ err }, `bitbucket getRepos error`); throw err; @@ -233,7 +233,7 @@ export async function getPrList(): Promise<Pr[]> { if (!config.prList) { logger.debug('Retrieving PR list'); let url = `/2.0/repositories/${config.repository}/pullrequests?`; - url += utils.prStates.all.map(state => 'state=' + state).join('&'); + url += utils.prStates.all.map((state) => 'state=' + state).join('&'); const prs = await utils.accumulateValues(url, undefined, undefined, 50); config.prList = prs.map(utils.prInfo); logger.debug({ length: config.prList.length }, 'Retrieved Pull Requests'); @@ -249,7 +249,7 @@ export async function findPr({ logger.debug(`findPr(${branchName}, ${prTitle}, ${state})`); const prList = await getPrList(); const pr = prList.find( - p => + (p) => p.branchName === branchName && (!prTitle || p.title === prTitle) && matchesState(p.state, state) @@ -463,7 +463,8 @@ export async function getBranchStatusCheck( context: string ): Promise<BranchStatus | null> { const statuses = await getStatus(branchName); - const bbState = (statuses.find(status => status.key === context) || {}).state; + const bbState = (statuses.find((status) => status.key === context) || {}) + .state; return bbToRenovateStatusMapping[bbState] || null; } @@ -798,7 +799,7 @@ export async function getPrFiles(prNo: number): Promise<string[]> { { json: false } as any ) ).body; - const files = parseDiff(diff).map(file => file.to); + const files = parseDiff(diff).map((file) => file.to); return files; } diff --git a/lib/platform/git/storage.ts b/lib/platform/git/storage.ts index 4c25006bf719fea3aa7b0a02a5b50671b1d6e866..af2a6ef84ad7d2adef5b9a33f699e438e9ba113b 100644 --- a/lib/platform/git/storage.ts +++ b/lib/platform/git/storage.ts @@ -95,9 +95,9 @@ export class Storage { private async _cleanLocalBranches(): Promise<void> { const existingBranches = (await this._git.raw(['branch'])) .split('\n') - .map(branch => branch.trim()) - .filter(branch => branch.length) - .filter(branch => !branch.startsWith('* ')); + .map((branch) => branch.trim()) + .filter((branch) => branch.length) + .filter((branch) => !branch.startsWith('* ')); logger.debug({ existingBranches }); for (const branchName of existingBranches) { await this._deleteLocalBranch(branchName); @@ -166,7 +166,7 @@ export class Storage { let opts = ['--depth=2']; if (config.extraCloneOpts) { opts = opts.concat( - Object.entries(config.extraCloneOpts).map(e => `${e[0]}=${e[1]}`) + Object.entries(config.extraCloneOpts).map((e) => `${e[0]}=${e[1]}`) ); } await this._git.clone(config.url, '.', opts); @@ -252,7 +252,7 @@ export class Storage { n: 10, format: { message: '%s' }, }); - return res.all.map(commit => commit.message); + return res.all.map((commit) => commit.message); } async setBaseBranch(branchName: string): Promise<void> { @@ -377,7 +377,7 @@ export class Storage { const branches = await this._git.branch(['--remotes', '--verbose']); return branches.all .map(localName) - .filter(branchName => branchName.startsWith(branchPrefix)); + .filter((branchName) => branchName.startsWith(branchPrefix)); } async isBranchStale(branchName: string): Promise<boolean> { diff --git a/lib/platform/gitea/index.spec.ts b/lib/platform/gitea/index.spec.ts index ff9c0e10be7ed68bc2e5331d0e5d1e3fd85cee76..3351c8b044228a18dbd8397d5119368dac86800b 100644 --- a/lib/platform/gitea/index.spec.ts +++ b/lib/platform/gitea/index.spec.ts @@ -796,7 +796,7 @@ describe('platform/gitea', () => { branchName: mockNewPR.head.ref, prTitle: mockNewPR.title, prBody: mockNewPR.body, - labels: mockLabels.map(l => l.name), + labels: mockLabels.map((l) => l.name), }); expect(helper.createPR).toHaveBeenCalledTimes(1); @@ -805,7 +805,7 @@ describe('platform/gitea', () => { head: mockNewPR.head.ref, title: mockNewPR.title, body: mockNewPR.body, - labels: mockLabels.map(l => l.id), + labels: mockLabels.map((l) => l.id), }); }); @@ -964,7 +964,7 @@ index 0000000..2173594 describe('findIssue', () => { it('should return existing open issue', async () => { - const mockIssue = mockIssues.find(i => i.title === 'open-issue'); + const mockIssue = mockIssues.find((i) => i.title === 'open-issue'); helper.searchIssues.mockResolvedValueOnce(mockIssues); await initFakeRepo(); @@ -975,7 +975,7 @@ index 0000000..2173594 }); it('should not return existing closed issue', async () => { - const mockIssue = mockIssues.find(i => i.title === 'closed-issue'); + const mockIssue = mockIssues.find((i) => i.title === 'closed-issue'); helper.searchIssues.mockResolvedValueOnce(mockIssues); await initFakeRepo(); @@ -1016,7 +1016,7 @@ index 0000000..2173594 }); it('should not reopen closed issue by default', async () => { - const closedIssue = mockIssues.find(i => i.title === 'closed-issue'); + const closedIssue = mockIssues.find((i) => i.title === 'closed-issue'); helper.searchIssues.mockResolvedValueOnce(mockIssues); await initFakeRepo(); @@ -1040,7 +1040,7 @@ index 0000000..2173594 }); it('should reopen closed issue if desired', async () => { - const closedIssue = mockIssues.find(i => i.title === 'closed-issue'); + const closedIssue = mockIssues.find((i) => i.title === 'closed-issue'); helper.searchIssues.mockResolvedValueOnce(mockIssues); await initFakeRepo(); @@ -1064,7 +1064,7 @@ index 0000000..2173594 }); it('should not update existing closed issue if desired', async () => { - const closedIssue = mockIssues.find(i => i.title === 'closed-issue'); + const closedIssue = mockIssues.find((i) => i.title === 'closed-issue'); helper.searchIssues.mockResolvedValueOnce(mockIssues); await initFakeRepo(); @@ -1080,7 +1080,9 @@ index 0000000..2173594 }); it('should close all open duplicate issues except first one when updating', async () => { - const duplicates = mockIssues.filter(i => i.title === 'duplicate-issue'); + const duplicates = mockIssues.filter( + (i) => i.title === 'duplicate-issue' + ); const firstDuplicate = duplicates[0]; helper.searchIssues.mockResolvedValueOnce(duplicates); diff --git a/lib/platform/gitea/index.ts b/lib/platform/gitea/index.ts index 4a12c91926ede84ba0e2d1166b78e2771f3bb577..a0d401a9496d7491054668a45e2277fc49a456f6 100644 --- a/lib/platform/gitea/index.ts +++ b/lib/platform/gitea/index.ts @@ -123,7 +123,7 @@ function findCommentByTopic( comments: helper.Comment[], topic: string ): helper.Comment | null { - return comments.find(c => c.body.startsWith(`### ${topic}\n\n`)); + return comments.find((c) => c.body.startsWith(`### ${topic}\n\n`)); } async function isPRModified( @@ -169,7 +169,7 @@ function getLabelList(): Promise<helper.Label[]> { .getRepoLabels(config.repository, { useCache: false, }) - .then(labels => { + .then((labels) => { logger.debug(`Retrieved ${labels.length} Labels`); return labels; }); @@ -181,7 +181,7 @@ function getLabelList(): Promise<helper.Label[]> { async function lookupLabelByName(name: string): Promise<number | null> { logger.debug(`lookupLabelByName(${name})`); const labelList = await getLabelList(); - return labelList.find(l => l.name === name)?.id; + return labelList.find((l) => l.name === name)?.id; } const platform: Platform = { @@ -330,7 +330,7 @@ const platform: Platform = { logger.debug('Auto-discovering Gitea repositories'); try { const repos = await helper.searchRepos({ uid: botUserID }); - return repos.map(r => r.full_name); + return repos.map((r) => r.full_name); } catch (err) { logger.error({ err }, 'Gitea getRepos() error'); throw err; @@ -414,7 +414,7 @@ const platform: Platform = { config.repository, branchName ); - const cs = ccs.statuses.find(s => s.context === context); + const cs = ccs.statuses.find((s) => s.context === context); if (!cs) { return null; } // no status check exists @@ -440,7 +440,7 @@ const platform: Platform = { if (config.prList === null) { config.prList = helper .searchPRs(config.repository, {}, { useCache: false }) - .then(prs => { + .then((prs) => { const prList = prs.map(toRenovatePR).filter(Boolean); logger.debug(`Retrieved ${prList.length} Pull Requests`); return prList; @@ -453,7 +453,7 @@ const platform: Platform = { async getPr(number: number): Promise<Pr | null> { // Search for pull request in cached list or attempt to query directly const prList = await platform.getPrList(); - let pr = prList.find(p => p.number === number); + let pr = prList.find((p) => p.number === number); if (pr) { logger.debug('Returning from cached PRs'); } else { @@ -491,7 +491,7 @@ const platform: Platform = { logger.debug(`findPr(${branchName}, ${title}, ${state})`); const prList = await platform.getPrList(); const pr = prList.find( - p => + (p) => p.sourceRepo === config.repository && p.branchName === branchName && matchesState(p.state, state) && @@ -622,7 +622,7 @@ const platform: Platform = { if (config.issueList === null) { config.issueList = helper .searchIssues(config.repository, {}, { useCache: false }) - .then(issues => { + .then((issues) => { const issueList = issues.map(toRenovateIssue); logger.debug(`Retrieved ${issueList.length} Issues`); return issueList; @@ -634,7 +634,9 @@ const platform: Platform = { async findIssue(title: string): Promise<Issue> { const issueList = await platform.getIssueList(); - const issue = issueList.find(i => i.state === 'open' && i.title === title); + const issue = issueList.find( + (i) => i.state === 'open' && i.title === title + ); if (issue) { logger.debug(`Found Issue #${issue.number}`); @@ -651,11 +653,11 @@ const platform: Platform = { logger.debug(`ensureIssue(${title})`); try { const issueList = await platform.getIssueList(); - const issues = issueList.filter(i => i.title === title); + const issues = issueList.filter((i) => i.title === title); // Update any matching issues which currently exist if (issues.length) { - let activeIssue = issues.find(i => i.state === 'open'); + let activeIssue = issues.find((i) => i.state === 'open'); // If no active issue was found, decide if it shall be skipped, re-opened or updated without state change if (!activeIssue) { @@ -764,7 +766,7 @@ const platform: Platform = { comment = findCommentByTopic(commentList, topic); body = `### ${topic}\n\n${body}`; } else { - comment = commentList.find(c => c.body === body); + comment = commentList.find((c) => c.body === body); } // Create a new comment if no match has been found, otherwise update if necessary diff --git a/lib/platform/github/gh-got-wrapper.ts b/lib/platform/github/gh-got-wrapper.ts index 132cf50baa184845fe983cfe18690a35ca06b51b..ee2bcf8b04b3ec41dc0c47191667aa73010bf21c 100644 --- a/lib/platform/github/gh-got-wrapper.ts +++ b/lib/platform/github/gh-got-wrapper.ts @@ -164,7 +164,7 @@ async function get( new Array(lastPage), (x, i) => i + 1 ).slice(1); - const queue = pageNumbers.map(page => (): Promise<GotResponse> => { + const queue = pageNumbers.map((page) => (): Promise<GotResponse> => { const nextUrl = URL.parse(linkHeader.next.url, true); delete nextUrl.search; nextUrl.query.page = page.toString(); @@ -176,7 +176,7 @@ async function get( }); const pages = await pAll<{ body: any[] }>(queue, { concurrency: 5 }); result.body = result.body.concat( - ...pages.filter(Boolean).map(page => page.body) + ...pages.filter(Boolean).map((page) => page.body) ); } } diff --git a/lib/platform/github/index.ts b/lib/platform/github/index.ts index 927ea570004322ea6d728fde585b0889eabcc106..bfa4d08fe51dbf0b782af3df58a617957dc64f7a 100644 --- a/lib/platform/github/index.ts +++ b/lib/platform/github/index.ts @@ -389,7 +389,7 @@ export async function initRepo({ token: forkToken || opts.token, paginate: true, }) - ).body.map(r => r.full_name); + ).body.map((r) => r.full_name); try { config.repository = ( await api.post(`repos/${repository}/forks`, { @@ -901,8 +901,9 @@ export async function getPr(prNo: number): Promise<Pr | null> { // Check against gitAuthor const commitAuthorEmail = ( await api.get( - `repos/${config.parentRepo || - config.repository}/pulls/${prNo}/commits` + `repos/${ + config.parentRepo || config.repository + }/pulls/${prNo}/commits` ) ).body[0].commit.author.email; if (commitAuthorEmail === global.gitAuthor.email) { @@ -934,8 +935,9 @@ export async function getPr(prNo: number): Promise<Pr | null> { logger.debug({ prNo }, 'Checking all commits'); const prCommits = ( await api.get( - `repos/${config.parentRepo || - config.repository}/pulls/${prNo}/commits` + `repos/${ + config.parentRepo || config.repository + }/pulls/${prNo}/commits` ) ).body; // Filter out "Update branch" presses @@ -991,8 +993,9 @@ export async function getPrList(): Promise<Pr[]> { let res; try { res = await api.get( - `repos/${config.parentRepo || - config.repository}/pulls?per_page=100&state=all`, + `repos/${ + config.parentRepo || config.repository + }/pulls?per_page=100&state=all`, { paginate: true } ); } catch (err) /* istanbul ignore next */ { @@ -1036,7 +1039,7 @@ export async function findPr({ logger.debug(`findPr(${branchName}, ${prTitle}, ${state})`); const prList = await getPrList(); const pr = prList.find( - p => + (p) => p.branchName === branchName && (!prTitle || p.title === prTitle) && matchesState(p.state, state) && @@ -1166,13 +1169,13 @@ export async function getBranchStatus( } if ( commitStatus.state === 'failure' || - checkRuns.some(run => run.conclusion === 'failure') + checkRuns.some((run) => run.conclusion === 'failure') ) { return BranchStatus.red; } if ( (commitStatus.state === 'success' || commitStatus.statuses.length === 0) && - checkRuns.every(run => ['neutral', 'success'].includes(run.conclusion)) + checkRuns.every((run) => ['neutral', 'success'].includes(run.conclusion)) ) { return BranchStatus.green; } @@ -1291,7 +1294,7 @@ async function getIssues(): Promise<Issue[]> { const result = await getGraphqlNodes<Issue>(query, 'issues'); logger.debug(`Retrieved ${result.length} issues`); - return result.map(issue => ({ + return result.map((issue) => ({ ...issue, state: issue.state.toLowerCase(), })); @@ -1308,7 +1311,7 @@ export async function getIssueList(): Promise<Issue[]> { export async function findIssue(title: string): Promise<Issue | null> { logger.debug(`findIssue(${title})`); const [issue] = (await getIssueList()).filter( - i => i.state === 'open' && i.title === title + (i) => i.state === 'open' && i.title === title ); if (!issue) { return null; @@ -1345,9 +1348,9 @@ export async function ensureIssue({ const body = sanitize(rawBody); try { const issueList = await getIssueList(); - const issues = issueList.filter(i => i.title === title); + const issues = issueList.filter((i) => i.title === title); if (issues.length) { - let issue = issues.find(i => i.state === 'open'); + let issue = issues.find((i) => i.state === 'open'); if (!issue) { if (once) { logger.debug('Issue already closed - skipping recreation'); @@ -1445,14 +1448,15 @@ export async function addReviewers( ): Promise<void> { logger.debug(`Adding reviewers ${reviewers} to #${prNo}`); - const userReviewers = reviewers.filter(e => !e.startsWith('team:')); + const userReviewers = reviewers.filter((e) => !e.startsWith('team:')); const teamReviewers = reviewers - .filter(e => e.startsWith('team:')) - .map(e => e.replace(/^team:/, '')); + .filter((e) => e.startsWith('team:')) + .map((e) => e.replace(/^team:/, '')); try { await api.post( - `repos/${config.parentRepo || - config.repository}/pulls/${prNo}/requested_reviewers`, + `repos/${ + config.parentRepo || config.repository + }/pulls/${prNo}/requested_reviewers`, { body: { reviewers: userReviewers, @@ -1494,8 +1498,9 @@ export async function deleteLabel( async function addComment(issueNo: number, body: string): Promise<void> { // POST /repos/:owner/:repo/issues/:number/comments await api.post( - `repos/${config.parentRepo || - config.repository}/issues/${issueNo}/comments`, + `repos/${ + config.parentRepo || config.repository + }/issues/${issueNo}/comments`, { body: { body }, } @@ -1505,8 +1510,9 @@ async function addComment(issueNo: number, body: string): Promise<void> { async function editComment(commentId: number, body: string): Promise<void> { // PATCH /repos/:owner/:repo/issues/comments/:id await api.patch( - `repos/${config.parentRepo || - config.repository}/issues/comments/${commentId}`, + `repos/${ + config.parentRepo || config.repository + }/issues/comments/${commentId}`, { body: { body }, } @@ -1516,8 +1522,9 @@ async function editComment(commentId: number, body: string): Promise<void> { async function deleteComment(commentId: number): Promise<void> { // DELETE /repos/:owner/:repo/issues/comments/:id await api.delete( - `repos/${config.parentRepo || - config.repository}/issues/comments/${commentId}` + `repos/${ + config.parentRepo || config.repository + }/issues/comments/${commentId}` ); } @@ -1529,8 +1536,9 @@ async function getComments(issueNo: number): Promise<Comment[]> { } // GET /repos/:owner/:repo/issues/:number/comments logger.debug(`Getting comments for #${issueNo}`); - const url = `repos/${config.parentRepo || - config.repository}/issues/${issueNo}/comments?per_page=100`; + const url = `repos/${ + config.parentRepo || config.repository + }/issues/${issueNo}/comments?per_page=100`; try { const comments = ( await api.get<Comment[]>(url, { @@ -1562,7 +1570,7 @@ export async function ensureComment({ if (topic) { logger.debug(`Ensuring comment "${topic}" in #${number}`); body = `### ${topic}\n\n${sanitizedContent}`; - comments.forEach(comment => { + comments.forEach((comment) => { if (comment.body.startsWith(`### ${topic}\n\n`)) { commentId = comment.id; commentNeedsUpdating = comment.body !== body; @@ -1571,7 +1579,7 @@ export async function ensureComment({ } else { logger.debug(`Ensuring content-only comment in #${number}`); body = `${sanitizedContent}`; - comments.forEach(comment => { + comments.forEach((comment) => { if (comment.body === body) { commentId = comment.id; commentNeedsUpdating = false; @@ -1616,7 +1624,7 @@ export async function ensureCommentRemoval( logger.debug(`Ensuring comment "${topic}" in #${issueNo} is removed`); const comments = await getComments(issueNo); let commentId: number; - comments.forEach(comment => { + comments.forEach((comment) => { if (comment.body.startsWith(`### ${topic}\n\n`)) { commentId = comment.id; } @@ -1766,8 +1774,9 @@ export async function mergePr( } logger.debug('Found approving reviews'); } - const url = `repos/${config.parentRepo || - config.repository}/pulls/${prNo}/merge`; + const url = `repos/${ + config.parentRepo || config.repository + }/pulls/${prNo}/merge`; const options = { body: {} as any, }; diff --git a/lib/platform/gitlab/index.spec.ts b/lib/platform/gitlab/index.spec.ts index 602828fe531758e3d5d854e48b8061f7a88e211d..40bbe75b1f7c6527c3de5cf4ae01affca5f55115 100644 --- a/lib/platform/gitlab/index.spec.ts +++ b/lib/platform/gitlab/index.spec.ts @@ -565,7 +565,7 @@ describe('platform/gitlab', () => { describe('setBranchStatus', () => { it.each([BranchStatus.green, BranchStatus.yellow, BranchStatus.red])( 'sets branch status yellow', - async state => { + async (state) => { await initRepo(); await gitlab.setBranchStatus({ branchName: 'some-branch', diff --git a/lib/platform/gitlab/index.ts b/lib/platform/gitlab/index.ts index cc445eda375081c12676deacd66fd6a68ad57ed5..9dc3e88476df5d57be50c9acdd41063d0a6edd71 100644 --- a/lib/platform/gitlab/index.ts +++ b/lib/platform/gitlab/index.ts @@ -349,8 +349,8 @@ export async function getBranchStatus( } let status: BranchStatus = BranchStatus.green; // default to green res - .filter(check => !check.allow_failure) - .forEach(check => { + .filter((check) => !check.allow_failure) + .forEach((check) => { if (status !== BranchStatus.red) { // if red, stay red let mappedStatus: BranchStatus = diff --git a/lib/platform/index.spec.ts b/lib/platform/index.spec.ts index f5cd5f94c7638396d20a2cfb5bf14c8dd9638be5..b3ed3bd211e98e5353df8eb0263736be2c036542 100644 --- a/lib/platform/index.spec.ts +++ b/lib/platform/index.spec.ts @@ -31,7 +31,7 @@ describe('platform', () => { const loadedMgr = loadModules( __dirname, null, - m => !['utils', 'git'].includes(m) + (m) => !['utils', 'git'].includes(m) ); expect(Array.from(platforms.keys())).toEqual(Object.keys(loadedMgr)); diff --git a/lib/platform/index.ts b/lib/platform/index.ts index 0b4b4a9795c97fd20d1905c107af4bf23dac55e4..02860793622d423a266fecf4db2ec1d314f01ead 100644 --- a/lib/platform/index.ts +++ b/lib/platform/index.ts @@ -73,7 +73,7 @@ export async function initPlatform( hostType: returnConfig.platform, hostName: URL.parse(returnConfig.endpoint).hostname, }; - ['token', 'username', 'password'].forEach(field => { + ['token', 'username', 'password'].forEach((field) => { if (config[field]) { platformRule[field] = config[field]; delete returnConfig[field]; diff --git a/lib/proxy.ts b/lib/proxy.ts index fb2266379eec755faf78800e962e928750835fbe..762b44c953abe17b77affb55075313a508c642d5 100644 --- a/lib/proxy.ts +++ b/lib/proxy.ts @@ -6,7 +6,7 @@ import { const envVars = ['HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY']; export function bootstrap(): ProxyAgentConfigurationType { - envVars.forEach(envVar => { + envVars.forEach((envVar) => { /* istanbul ignore if: env is case-insensitive on windows */ if ( typeof process.env[envVar] === 'undefined' && diff --git a/lib/util/exec/docker/index.ts b/lib/util/exec/docker/index.ts index 1b3ada28918ce3e58547e07d0b5811fbbb97bfdc..7b8f65848f1d18d322fb357575182eb536e80e8a 100644 --- a/lib/util/exec/docker/index.ts +++ b/lib/util/exec/docker/index.ts @@ -49,13 +49,13 @@ function uniq<T = unknown>( eql = (x: T, y: T): boolean => x === y ): T[] { return array.filter((x, idx, arr) => { - return arr.findIndex(y => eql(x, y)) === idx; + return arr.findIndex((y) => eql(x, y)) === idx; }); } function prepareVolumes(volumes: VolumeOption[] = []): string[] { const expanded: (VolumesPair | null)[] = volumes.map(expandVolumeOption); - const filtered: VolumesPair[] = expanded.filter(vol => vol !== null); + const filtered: VolumesPair[] = expanded.filter((vol) => vol !== null); const unique: VolumesPair[] = uniq<VolumesPair>(filtered, volumesEql); return unique.map(([from, to]) => { return `-v "${from}":"${to}"`; @@ -63,7 +63,7 @@ function prepareVolumes(volumes: VolumeOption[] = []): string[] { } function prepareCommands(commands: Opt<string>[]): string[] { - return commands.filter(command => command && typeof command === 'string'); + return commands.filter((command) => command && typeof command === 'string'); } async function getDockerTag( @@ -84,9 +84,9 @@ async function getDockerTag( ); const imageReleases = await getReleases({ lookupName }); if (imageReleases && imageReleases.releases) { - let versions = imageReleases.releases.map(release => release.version); + let versions = imageReleases.releases.map((release) => release.version); versions = versions.filter( - version => isVersion(version) && matches(version, constraint) + (version) => isVersion(version) && matches(version, constraint) ); versions = versions.sort(sortVersions); if (versions.length) { @@ -149,7 +149,7 @@ export async function removeDanglingContainers(): Promise<void> { const containerIds = res.stdout .trim() .split('\n') - .map(container => container.trim()) + .map((container) => container.trim()) .filter(Boolean); logger.debug({ containerIds }, 'Removing dangling child containers'); await rawExec(`docker rm -f ${containerIds.join(' ')}`, { @@ -187,8 +187,8 @@ export async function generateDockerCommand( if (envVars) { result.push( ...uniq(envVars) - .filter(x => typeof x === 'string') - .map(e => `-e ${e}`) + .filter((x) => typeof x === 'string') + .map((e) => `-e ${e}`) ); } diff --git a/lib/util/exec/env.spec.ts b/lib/util/exec/env.spec.ts index 885a1ae3ea092c1fed2596a3eeba15342e3578d1..5bdbff6af90f1bd1567f355122b08b1e4d5d7345 100644 --- a/lib/util/exec/env.spec.ts +++ b/lib/util/exec/env.spec.ts @@ -12,12 +12,12 @@ describe('getChildProcess environment when trustlevel set to low', () => { 'DOCKER_HOST', ]; beforeEach(() => { - envVars.forEach(env => { + envVars.forEach((env) => { process.env[env] = env; }); }); afterEach(() => { - envVars.forEach(env => delete process.env[env]); + envVars.forEach((env) => delete process.env[env]); }); it('returns default environment variables', () => { expect(getChildProcessEnv()).toMatchInlineSnapshot(` diff --git a/lib/util/exec/env.ts b/lib/util/exec/env.ts index 55b557c1fc70c310506fa90c267a55ac405f4bb5..453c74abd4819dccad2d0c18d548b2ad0dafc82c 100644 --- a/lib/util/exec/env.ts +++ b/lib/util/exec/env.ts @@ -17,7 +17,7 @@ export function getChildProcessEnv( return Object.assign(env, process.env); } const envVars = [...basicEnvVars, ...customEnvVars]; - envVars.forEach(envVar => { + envVars.forEach((envVar) => { if (typeof process.env[envVar] !== 'undefined') { env[envVar] = process.env[envVar]; } diff --git a/lib/util/exec/index.ts b/lib/util/exec/index.ts index 4dc0fa3fea5611e62bb3a5762508ee4e5202ba7a..edab9dfa5fe80c43f3be53fe0cbac4a760d13071 100644 --- a/lib/util/exec/index.ts +++ b/lib/util/exec/index.ts @@ -89,7 +89,7 @@ function dockerEnvVars( ): string[] { const extraEnvKeys = Object.keys(extraEnv || {}); return extraEnvKeys.filter( - key => typeof childEnv[key] === 'string' && childEnv[key].length > 0 + (key) => typeof childEnv[key] === 'string' && childEnv[key].length > 0 ); } @@ -159,7 +159,7 @@ export async function exec( logger.trace({ err }, 'rawExec err'); clearTimeout(timer); if (useDocker) { - await removeDockerContainer(docker.image).catch(removeErr => { + await removeDockerContainer(docker.image).catch((removeErr) => { throw new Error( `Error: "${removeErr.message}" - Original Error: "${err.message}"` ); diff --git a/lib/util/got/cache-get.ts b/lib/util/got/cache-get.ts index 8b934f7cd74853423b41442d125e651c885c34c2..803a789ac22cb8115d87f391853a85cdf80391f0 100644 --- a/lib/util/got/cache-get.ts +++ b/lib/util/got/cache-get.ts @@ -27,12 +27,12 @@ export default create({ ) .digest('hex'); if (!global.repoCache[cacheKey] || options.useCache === false) { - global.repoCache[cacheKey] = next(options).catch(err => { + global.repoCache[cacheKey] = next(options).catch((err) => { delete global.repoCache[cacheKey]; throw err; }); } - return global.repoCache[cacheKey].then(response => ({ + return global.repoCache[cacheKey].then((response) => ({ ...response, body: clone(response.body), })); diff --git a/lib/util/got/index.spec.ts b/lib/util/got/index.spec.ts index 3f8de68ada8500917576188546345834a59cf52d..514abab0ae58fcc316be2e3760f4acbe5e73d9e1 100644 --- a/lib/util/got/index.spec.ts +++ b/lib/util/got/index.spec.ts @@ -34,10 +34,7 @@ describe(getName(__filename), () => { } function mock(opts?: nock.Options, times = 1) { - return nock(baseUrl, opts) - .get('/some') - .times(times) - .reply(200, {}); + return nock(baseUrl, opts).get('/some').times(times).reply(200, {}); } it('uses bearer auth', async () => { @@ -120,7 +117,7 @@ describe(getName(__filename), () => { let data = ''; - stream.on('data', c => { + stream.on('data', (c) => { data += c; }); diff --git a/lib/util/host-rules.ts b/lib/util/host-rules.ts index dc9c4a2dfb916e02cd1808f502d8f3d73ff14a98..0fa7745daaf45744047e3c7dbc5be8636605d64e 100644 --- a/lib/util/host-rules.ts +++ b/lib/util/host-rules.ts @@ -18,7 +18,7 @@ export function add(params: HostRule): void { } hostRules.push(params); const confidentialFields = ['password', 'token']; - confidentialFields.forEach(field => { + confidentialFields.forEach((field) => { const secret = params[field]; if (secret && secret.length > 3) { sanitize.add(secret); @@ -95,45 +95,45 @@ export function find(search: HostRuleSearch): HostRule { let res = ({} as any) as HostRule; // First, apply empty rule matches hostRules - .filter(rule => isEmptyRule(rule)) - .forEach(rule => { + .filter((rule) => isEmptyRule(rule)) + .forEach((rule) => { res = merge(res, rule); }); // Next, find hostType-only matches hostRules - .filter(rule => isHostTypeRule(rule) && matchesHostType(rule, search)) - .forEach(rule => { + .filter((rule) => isHostTypeRule(rule) && matchesHostType(rule, search)) + .forEach((rule) => { res = merge(res, rule); }); // Next, find domainName-only matches hostRules - .filter(rule => isDomainNameRule(rule) && matchesDomainName(rule, search)) - .forEach(rule => { + .filter((rule) => isDomainNameRule(rule) && matchesDomainName(rule, search)) + .forEach((rule) => { res = merge(res, rule); }); // Next, find hostName-only matches hostRules - .filter(rule => isHostNameRule(rule) && matchesHostName(rule, search)) - .forEach(rule => { + .filter((rule) => isHostNameRule(rule) && matchesHostName(rule, search)) + .forEach((rule) => { res = merge(res, rule); }); // Next, find baseUrl-only matches hostRules - .filter(rule => isBaseUrlRule(rule) && matchesBaseUrl(rule, search)) - .forEach(rule => { + .filter((rule) => isBaseUrlRule(rule) && matchesBaseUrl(rule, search)) + .forEach((rule) => { res = merge(res, rule); }); // Finally, find combination matches hostRules .filter( - rule => + (rule) => isMultiRule(rule) && matchesHostType(rule, search) && (matchesDomainName(rule, search) || matchesHostName(rule, search) || matchesBaseUrl(rule, search)) ) - .forEach(rule => { + .forEach((rule) => { res = merge(res, rule); }); delete res.hostType; @@ -145,8 +145,8 @@ export function find(search: HostRuleSearch): HostRule { export function hosts({ hostType }: { hostType: string }): string[] { return hostRules - .filter(rule => rule.hostType === hostType) - .map(rule => { + .filter((rule) => rule.hostType === hostType) + .map((rule) => { if (rule.hostName) { return rule.hostName; } @@ -159,7 +159,7 @@ export function hosts({ hostType }: { hostType: string }): string[] { } export function findAll({ hostType }: { hostType: string }): HostRule[] { - return hostRules.filter(rule => rule.hostType === hostType); + return hostRules.filter((rule) => rule.hostType === hostType); } export function clear(): void { diff --git a/lib/util/http/index.spec.ts b/lib/util/http/index.spec.ts index 27ea216f3463270d2a801e591b428836d658f217..5ab2db72adddf811a4b51e4c595155c57e8b87da 100644 --- a/lib/util/http/index.spec.ts +++ b/lib/util/http/index.spec.ts @@ -12,58 +12,44 @@ describe(getName(__filename), () => { nock.cleanAll(); }); it('get', async () => { - nock(baseUrl) - .get('/test') - .reply(200); + nock(baseUrl).get('/test').reply(200); expect(await http.get('http://renovate.com/test')).toMatchSnapshot(); expect(nock.isDone()).toBe(true); }); it('getJson', async () => { - nock(baseUrl) - .get('/') - .reply(200, '{ "test": true }'); + nock(baseUrl).get('/').reply(200, '{ "test": true }'); expect(await http.getJson('http://renovate.com')).toMatchSnapshot(); }); it('postJson', async () => { - nock(baseUrl) - .post('/') - .reply(200, {}); + nock(baseUrl).post('/').reply(200, {}); expect( await http.postJson('http://renovate.com', { body: {}, baseUrl }) ).toMatchSnapshot(); expect(nock.isDone()).toBe(true); }); it('putJson', async () => { - nock(baseUrl) - .put('/') - .reply(200, {}); + nock(baseUrl).put('/').reply(200, {}); expect( await http.putJson('http://renovate.com', { body: {}, baseUrl }) ).toMatchSnapshot(); expect(nock.isDone()).toBe(true); }); it('patchJson', async () => { - nock(baseUrl) - .patch('/') - .reply(200, {}); + nock(baseUrl).patch('/').reply(200, {}); expect( await http.patchJson('http://renovate.com', { body: {}, baseUrl }) ).toMatchSnapshot(); expect(nock.isDone()).toBe(true); }); it('deleteJson', async () => { - nock(baseUrl) - .delete('/') - .reply(200, {}); + nock(baseUrl).delete('/').reply(200, {}); expect( await http.deleteJson('http://renovate.com', { body: {}, baseUrl }) ).toMatchSnapshot(); expect(nock.isDone()).toBe(true); }); it('headJson', async () => { - nock(baseUrl) - .head('/') - .reply(200, {}); + nock(baseUrl).head('/').reply(200, {}); expect( await http.headJson('http://renovate.com', { body: {}, baseUrl }) ).toMatchSnapshot(); @@ -71,9 +57,7 @@ describe(getName(__filename), () => { }); it('stream', async () => { - nock(baseUrl) - .get('/some') - .reply(200, {}); + nock(baseUrl).get('/some').reply(200, {}); const stream = http.stream('/some', { baseUrl, @@ -82,7 +66,7 @@ describe(getName(__filename), () => { let data = ''; - stream.on('data', c => { + stream.on('data', (c) => { data += c; }); diff --git a/lib/util/ignore.ts b/lib/util/ignore.ts index b1ffcdf29b09c7087b5c43d479bb40be5f0990e6..b6d6f41f6a4cee92763487c9a7615e85d1627481 100644 --- a/lib/util/ignore.ts +++ b/lib/util/ignore.ts @@ -2,10 +2,7 @@ import { logger } from '../logger'; export function isSkipComment(comment?: string): boolean { if (/^(renovate|pyup):/.test(comment)) { - const command = comment - .split('#')[0] - .split(':')[1] - .trim(); + const command = comment.split('#')[0].split(':')[1].trim(); if (command === 'ignore') { return true; } diff --git a/lib/util/modules.ts b/lib/util/modules.ts index c44ab2f585bce3917964cab58af8d3a9e5e31866..ba4bfe3625cb4f9d58bcb2ca118623085112a856 100644 --- a/lib/util/modules.ts +++ b/lib/util/modules.ts @@ -33,9 +33,9 @@ export function loadModules<T>( const moduleNames: string[] = fs .readdirSync(dirname, { withFileTypes: true }) - .filter(dirent => dirent.isDirectory()) - .map(dirent => dirent.name) - .filter(name => !name.startsWith('__')) + .filter((dirent) => dirent.isDirectory()) + .map((dirent) => dirent.name) + .filter((name) => !name.startsWith('__')) .filter(filter) .sort(); diff --git a/lib/util/package-rules.ts b/lib/util/package-rules.ts index 533068aef2f7856e3b1a0ed826ee640776015138..5d1c77c2204e5d3c39cd5cb1c0bd6f025bfcb82f 100644 --- a/lib/util/package-rules.ts +++ b/lib/util/package-rules.ts @@ -81,7 +81,7 @@ function matchesRule(inputConfig: Config, packageRule: PackageRule): boolean { } if (paths.length) { const isMatch = paths.some( - rulePath => + (rulePath) => packageFile.includes(rulePath) || minimatch(packageFile, rulePath, { dot: true }) ); @@ -93,7 +93,7 @@ function matchesRule(inputConfig: Config, packageRule: PackageRule): boolean { if (depTypeList.length) { const isMatch = depTypeList.includes(depType) || - (depTypes && depTypes.some(dt => depTypeList.includes(dt))); + (depTypes && depTypes.some((dt) => depTypeList.includes(dt))); if (!isMatch) { return false; } @@ -182,7 +182,7 @@ function matchesRule(inputConfig: Config, packageRule: PackageRule): boolean { } if (sourceUrlPrefixes.length) { const isMatch = sourceUrlPrefixes.some( - prefix => sourceUrl && sourceUrl.startsWith(prefix) + (prefix) => sourceUrl && sourceUrl.startsWith(prefix) ); if (!isMatch) { return false; @@ -239,7 +239,7 @@ export function applyPackageRules<T extends Config>(inputConfig: T): T { { dependency: config.depName, packageRules }, `Checking against ${packageRules.length} packageRules` ); - packageRules.forEach(packageRule => { + packageRules.forEach((packageRule) => { // This rule is considered matched if there was at least one positive match and no negative matches if (matchesRule(config, packageRule)) { // Package rule config overrides any existing config diff --git a/lib/util/sanitize.ts b/lib/util/sanitize.ts index a6e104b7ab4747c47e04df3e6cea7bdf69fdbaf9..e2e8e90bb4cccd3fa18723bf5c429361f0f8df45 100644 --- a/lib/util/sanitize.ts +++ b/lib/util/sanitize.ts @@ -5,7 +5,7 @@ export function sanitize(input: string): string { return input; } let output: string = input; - secrets.forEach(secret => { + secrets.forEach((secret) => { while (output.includes(secret)) { output = output.replace(secret, '**redacted**'); } diff --git a/lib/util/template/index.spec.ts b/lib/util/template/index.spec.ts index 2b0bb28958eb2f020974c33b22cd73afccb4e15a..b8b45ccd25c15b306335fe41e6961126ae743eed 100644 --- a/lib/util/template/index.spec.ts +++ b/lib/util/template/index.spec.ts @@ -3,9 +3,9 @@ import { getOptions } from '../../config/definitions'; describe('util/template', () => { it('has valid exposed config options', () => { - const allOptions = getOptions().map(option => option.name); + const allOptions = getOptions().map((option) => option.name); const missingOptions = template.exposedConfigOptions.filter( - option => !allOptions.includes(option) + (option) => !allOptions.includes(option) ); expect(missingOptions).toEqual([]); }); diff --git a/lib/util/template/index.ts b/lib/util/template/index.ts index 7e8e0dbf49904e620d4886ef9cc9003dc0f397cb..f21b284e7860bdfaf599ad13f44d24264836318d 100644 --- a/lib/util/template/index.ts +++ b/lib/util/template/index.ts @@ -86,7 +86,7 @@ function getFilteredObject(input: any): any { for (const field of allAllowed) { const value = obj[field]; if (is.array(value)) { - res[field] = value.map(element => getFilteredObject(element)); + res[field] = value.map((element) => getFilteredObject(element)); } else if (is.object(value)) { res[field] = getFilteredObject(value); } else if (!is.undefined(value)) { diff --git a/lib/versioning/cargo/index.ts b/lib/versioning/cargo/index.ts index cbe0c628b13bd792f97d1f5261d7a9d6788f2400..cf605c34ddceba7fcf47ef4897a77e0fef405931 100644 --- a/lib/versioning/cargo/index.ts +++ b/lib/versioning/cargo/index.ts @@ -36,7 +36,7 @@ function npm2cargo(input: string): string { // Note: this doesn't remove the ^ const res = input .split(' ') - .map(str => str.trim()) + .map((str) => str.trim()) .filter(notEmpty); const operators = ['^', '~', '=', '>', '<', '<=', '>=']; for (let i = 0; i < res.length - 1; i += 1) { @@ -65,12 +65,7 @@ const minSatisfyingVersion = (versions: string[], range: string): string => const isSingleVersion = (constraint: string): string | boolean => constraint.trim().startsWith('=') && - isVersion( - constraint - .trim() - .substring(1) - .trim() - ); + isVersion(constraint.trim().substring(1).trim()); function getNewValue({ currentValue, diff --git a/lib/versioning/composer/index.ts b/lib/versioning/composer/index.ts index ac65a39e8c0ff15a7a7a0f218d53409315907859..cc5d0de45416eb0d19cf1b40cdcc8788514387be 100644 --- a/lib/versioning/composer/index.ts +++ b/lib/versioning/composer/index.ts @@ -125,10 +125,7 @@ function getNewValue({ } } if (currentValue.includes(' || ')) { - const lastValue = currentValue - .split('||') - .pop() - .trim(); + const lastValue = currentValue.split('||').pop().trim(); const replacementValue = getNewValue({ currentValue: lastValue, rangeStrategy, diff --git a/lib/versioning/docker/index.spec.ts b/lib/versioning/docker/index.spec.ts index 0baa895e19066de72e15bc6e831a61957a2dfafe..a1bbb55d1974ea86f61abe453b17cae4c5b351b8 100644 --- a/lib/versioning/docker/index.spec.ts +++ b/lib/versioning/docker/index.spec.ts @@ -79,7 +79,7 @@ describe('docker.', () => { describe('maxSatisfyingVersion(versions, range)', () => { it('should support all versions length', () => { [docker.minSatisfyingVersion, docker.maxSatisfyingVersion].forEach( - max => { + (max) => { const versions = [ '0.9.8', '1.1.1', @@ -109,7 +109,7 @@ describe('docker.', () => { ['1.2.3', '1.3.4'], ['2.0.1', '1.2.3'], ['1.2.3', '0.9.5'], - ].forEach(pair => { + ].forEach((pair) => { expect(docker.sortVersions(pair[0], pair[1])).toBe( semver.sortVersions(pair[0], pair[1]) ); diff --git a/lib/versioning/gradle/index.spec.ts b/lib/versioning/gradle/index.spec.ts index 36b6071e0bfcca4bcf5886df009a8a18ad5d7ca8..0fb0631b1a71b0e0d9f716bd04664d062713843c 100644 --- a/lib/versioning/gradle/index.spec.ts +++ b/lib/versioning/gradle/index.spec.ts @@ -81,7 +81,7 @@ describe('versioning/gradle/compare', () => { '1.2.++', ]; it('filters out incorrect prefix ranges', () => { - invalidPrefixRanges.forEach(rangeStr => { + invalidPrefixRanges.forEach((rangeStr) => { const range = parsePrefixRange(rangeStr); expect(range).toBeNull(); }); @@ -105,7 +105,7 @@ describe('versioning/gradle/compare', () => { '[1.3,1.2]', ]; it('filters out incorrect maven-based ranges', () => { - invalidMavenBasedRanges.forEach(rangeStr => { + invalidMavenBasedRanges.forEach((rangeStr) => { const range = parseMavenBasedRange(rangeStr); expect(range).toBeNull(); }); diff --git a/lib/versioning/hex/index.ts b/lib/versioning/hex/index.ts index 711b3c760123424f18de5552cf338c1483f2de0a..1309bfd0e693219b4e808f3bc149601a219a4907 100644 --- a/lib/versioning/hex/index.ts +++ b/lib/versioning/hex/index.ts @@ -19,8 +19,8 @@ function hex2npm(input: string): string { function npm2hex(input: string): string { const res = input .split(' ') - .map(str => str.trim()) - .filter(str => str !== ''); + .map((str) => str.trim()) + .filter((str) => str !== ''); let output = ''; const operators = ['^', '=', '>', '<', '<=', '>=', '~']; for (let i = 0; i < res.length; i += 1) { diff --git a/lib/versioning/index.spec.ts b/lib/versioning/index.spec.ts index 9cebaf8a0fe11eb5bf3135a6fc65be2de3b1c2af..9d76c42f5cd118e9b2dddb4e084b1afe54a703ce 100644 --- a/lib/versioning/index.spec.ts +++ b/lib/versioning/index.spec.ts @@ -10,7 +10,7 @@ import { } from './common'; const supportedSchemes = getOptions().find( - option => option.name === 'versioning' + (option) => option.name === 'versioning' ).allowedValues; describe('allVersioning.get(versioning)', () => { @@ -70,7 +70,7 @@ describe('allVersioning.get(versioning)', () => { 'valueOf', ]; const npmApi = Object.keys(allVersioning.get(semverVersioning.id)) - .filter(val => !optionalFunctions.includes(val)) + .filter((val) => !optionalFunctions.includes(val)) .sort(); function getAllPropertyNames(obj: any): string[] { @@ -78,7 +78,7 @@ describe('allVersioning.get(versioning)', () => { let o = obj; do { - Object.getOwnPropertyNames(o).forEach(prop => { + Object.getOwnPropertyNames(o).forEach((prop) => { if (!props.includes(prop)) { props.push(prop); } @@ -95,7 +95,7 @@ describe('allVersioning.get(versioning)', () => { allVersioning.get(supportedScheme) ) .filter( - val => !optionalFunctions.includes(val) && !val.startsWith('_') + (val) => !optionalFunctions.includes(val) && !val.startsWith('_') ) .sort(); @@ -127,7 +127,9 @@ describe('allVersioning.get(versioning)', () => { const api = new DummyScheme(); const schemeKeys = getAllPropertyNames(api) - .filter(val => !optionalFunctions.includes(val) && !val.startsWith('_')) + .filter( + (val) => !optionalFunctions.includes(val) && !val.startsWith('_') + ) .sort(); expect(schemeKeys).toEqual(npmApi); diff --git a/lib/versioning/ivy/index.spec.ts b/lib/versioning/ivy/index.spec.ts index e0cb19722cf7fd52dcaa29328ae571c252cacf2a..65b31bd5388e9591e64e28e05d839612adb20b2a 100644 --- a/lib/versioning/ivy/index.spec.ts +++ b/lib/versioning/ivy/index.spec.ts @@ -49,7 +49,7 @@ describe('versioning/ivy/match', () => { ']1.0,)', '(,2.0]', '(,2.0[', - ].forEach(value => { + ].forEach((value) => { expect(parseDynamicRevision(value)).toEqual({ type: REV_TYPE_RANGE, value, diff --git a/lib/versioning/loose/generic.ts b/lib/versioning/loose/generic.ts index 1e2641eb4da19b0214af1b43dd75d729685a6c05..49b5fc39bf2f5af9ff0f501ec7e1685d14f3e2c3 100644 --- a/lib/versioning/loose/generic.ts +++ b/lib/versioning/loose/generic.ts @@ -75,10 +75,10 @@ export const comparer = ( // we don't not have ranges, so versions has to be equal function maxSatisfyingVersion(versions: string[], range: string): string { - return versions.find(v => equals(v, range)) || null; + return versions.find((v) => equals(v, range)) || null; } function minSatisfyingVersion(versions: string[], range: string): string { - return versions.find(v => equals(v, range)) || null; + return versions.find((v) => equals(v, range)) || null; } function getNewValue(newValueConfig: NewValueConfig): string { const { toVersion } = newValueConfig || {}; @@ -178,11 +178,11 @@ export abstract class GenericVersioningApi< } maxSatisfyingVersion(versions: string[], range: string): string | null { - return versions.find(v => this.equals(v, range)) || null; + return versions.find((v) => this.equals(v, range)) || null; } minSatisfyingVersion(versions: string[], range: string): string | null { - return versions.find(v => this.equals(v, range)) || null; + return versions.find((v) => this.equals(v, range)) || null; } // eslint-disable-next-line class-methods-use-this diff --git a/lib/versioning/loose/index.spec.ts b/lib/versioning/loose/index.spec.ts index 0cc80d5e5be72994a9050feb884c96063fd7ca56..781c5f07933cde5463392a1fbe9c7b35441e3842 100644 --- a/lib/versioning/loose/index.spec.ts +++ b/lib/versioning/loose/index.spec.ts @@ -2,7 +2,7 @@ import loose from '.'; describe('loose.', () => { describe('isVersion', () => { - ['1.1', '1.3.RC2', '2.1-rc2'].forEach(version => { + ['1.1', '1.3.RC2', '2.1-rc2'].forEach((version) => { it(version, () => { expect(loose.isVersion(version)).toMatchSnapshot(); }); @@ -22,10 +22,10 @@ describe('loose.', () => { '0.8a', '3.1.0.GA', '3.0.0-beta.3', - ].forEach(version => { + ].forEach((version) => { expect(loose.isValid(version)).toBe(version); }); - ['foo', '1.2.3.4.5.6.7'].forEach(version => { + ['foo', '1.2.3.4.5.6.7'].forEach((version) => { expect(loose.isValid(version)).toBeNull(); }); }); diff --git a/lib/versioning/loose/utils.spec.ts b/lib/versioning/loose/utils.spec.ts index 6a2cd4ccbcb5d81c87b7cd78ead54b883cac21a8..f48f266708af1f6b7f02a40dc3aac5a4008b883a 100644 --- a/lib/versioning/loose/utils.spec.ts +++ b/lib/versioning/loose/utils.spec.ts @@ -18,7 +18,7 @@ describe('loose/utils', () => { let o = obj; do { - Object.getOwnPropertyNames(o).forEach(prop => { + Object.getOwnPropertyNames(o).forEach((prop) => { if (!props.includes(prop)) { props.push(prop); } @@ -44,9 +44,9 @@ describe('loose/utils', () => { const api = new DummyScheme(); const schemeKeys = getAllPropertyNames(api) - .filter(val => !optionalFunctions.includes(val) && !val.startsWith('_')) + .filter((val) => !optionalFunctions.includes(val) && !val.startsWith('_')) .filter( - val => !['minSatisfyingVersion', 'maxSatisfyingVersion'].includes(val) + (val) => !['minSatisfyingVersion', 'maxSatisfyingVersion'].includes(val) ) .sort(); diff --git a/lib/versioning/maven/compare.ts b/lib/versioning/maven/compare.ts index b1d7ba554784a1bb056786881b8bee187d009b32..a06b0a1c91d9395fcc51b1670ea1d2ac4b490e9d 100644 --- a/lib/versioning/maven/compare.ts +++ b/lib/versioning/maven/compare.ts @@ -117,7 +117,7 @@ function tokenize(versionStr: string): Token[] { let buf: Token[] = []; let result: Token[] = []; let leadingZero = true; - iterateTokens(versionStr.toLowerCase().replace(/^v/i, ''), token => { + iterateTokens(versionStr.toLowerCase().replace(/^v/i, ''), (token) => { if (token.prefix === PREFIX_HYPHEN) { buf = []; } @@ -308,7 +308,7 @@ function parseRange(rangeStr: string): any { let result: Range[] = []; let interval = emptyInterval(); - commaSplit.forEach(subStr => { + commaSplit.forEach((subStr) => { if (!result) { return; } @@ -432,7 +432,7 @@ function rangeToStr(fullRange: Range[]): string | null { } } - const intervals = fullRange.map(val => + const intervals = fullRange.map((val) => [ val.leftBracket, valToStr(val.leftValue), diff --git a/lib/versioning/maven/index.spec.ts b/lib/versioning/maven/index.spec.ts index e3336632ed0751002d70a4be8a73587c2ffd35d9..0a3604161cfc734cec7c2bdacc278211b8dc43de 100644 --- a/lib/versioning/maven/index.spec.ts +++ b/lib/versioning/maven/index.spec.ts @@ -129,7 +129,7 @@ describe('versioning/maven/compare', () => { '[,1.0]', ]; it('filters out incorrect ranges', () => { - invalidRanges.forEach(rangeStr => { + invalidRanges.forEach((rangeStr) => { const range = parseRange(rangeStr); expect(range).toBeNull(); expect(rangeToStr(range)).toBeNull(); @@ -225,7 +225,7 @@ describe('versioning/maven/compare', () => { }, ], }; - Object.keys(presetRanges).forEach(rangeStr => { + Object.keys(presetRanges).forEach((rangeStr) => { const presetValue = presetRanges[rangeStr]; const fullRange = parseRange(rangeStr); expect(presetValue).toEqual(fullRange); diff --git a/lib/versioning/nuget/index.spec.ts b/lib/versioning/nuget/index.spec.ts index a2ca12a93d5f078602f136946c2824c07772ce0b..c206da1a58f1a4a31239cae80b348ff9683e36f4 100644 --- a/lib/versioning/nuget/index.spec.ts +++ b/lib/versioning/nuget/index.spec.ts @@ -12,7 +12,7 @@ describe('nuget.', () => { '17.04', '3.0.0.beta', '5.1.2-+', - ].forEach(version => { + ].forEach((version) => { it(version, () => { expect(nuget.isVersion(version)).toMatchSnapshot(); expect(nuget.isValid(version)).toMatchSnapshot(); @@ -27,7 +27,7 @@ describe('nuget.', () => { '2.0.2-pre20191018090318', '1.0.0+c30d7625', '2.3.4-beta+1990ef74', - ].forEach(version => { + ].forEach((version) => { it(version, () => { expect(nuget.isStable(version)).toMatchSnapshot(); }); diff --git a/lib/versioning/pep440/range.ts b/lib/versioning/pep440/range.ts index 03d81350047a101ae1f8f62c2ce0ac1c2f26f99b..cb7ea658dbdb2aa64fc1773948822803d289d82d 100644 --- a/lib/versioning/pep440/range.ts +++ b/lib/versioning/pep440/range.ts @@ -74,13 +74,13 @@ export function getNewValue({ toVersion, }); } - if (ranges.some(range => range.operator === '===')) { + if (ranges.some((range) => range.operator === '===')) { // the operator "===" is used for legacy non PEP440 versions logger.warn('Arbitrary equality not supported: ' + currentValue); return null; } let result = ranges - .map(range => { + .map((range) => { // used to exclude versions, // we assume that's for a good reason if (range.operator === '!=') { diff --git a/lib/versioning/poetry/index.ts b/lib/versioning/poetry/index.ts index 7539bc13f0685254ac91ff95761d7429c24e9c7c..54ea07d90d7a4adf09a3823e63c91485460ad77b 100644 --- a/lib/versioning/poetry/index.ts +++ b/lib/versioning/poetry/index.ts @@ -19,7 +19,7 @@ function notEmpty(s: string): boolean { function poetry2npm(input: string): string { const versions = input .split(',') - .map(str => str.trim()) + .map((str) => str.trim()) .filter(notEmpty); return versions.join(' '); } @@ -31,7 +31,7 @@ function npm2poetry(input: string): string { // Note: this doesn't remove the ^ const res = input .split(' ') - .map(str => str.trim()) + .map((str) => str.trim()) .filter(notEmpty); const operators = ['^', '~', '=', '>', '<', '<=', '>=']; for (let i = 0; i < res.length - 1; i += 1) { @@ -61,12 +61,7 @@ const minSatisfyingVersion = (versions: string[], range: string): string => const isSingleVersion = (constraint: string): string | boolean => (constraint.trim().startsWith('=') && - isVersion( - constraint - .trim() - .substring(1) - .trim() - )) || + isVersion(constraint.trim().substring(1).trim())) || isVersion(constraint.trim()); function handleShort( diff --git a/lib/versioning/regex/index.ts b/lib/versioning/regex/index.ts index a2ed1f49b7cb71ba680c87c63efb9e7f1c156cde..79a8a29d694d43724fe581fc41061620a5e22b33 100644 --- a/lib/versioning/regex/index.ts +++ b/lib/versioning/regex/index.ts @@ -108,14 +108,14 @@ export class RegExpVersioningApi extends GenericVersioningApi<RegExpVersion> { maxSatisfyingVersion(versions: string[], range: string): string | null { return maxSatisfying( - versions.map(v => asSemver(this._parse(v))), + versions.map((v) => asSemver(this._parse(v))), asSemver(this._parse(range)) ); } minSatisfyingVersion(versions: string[], range: string): string | null { return minSatisfying( - versions.map(v => asSemver(this._parse(v))), + versions.map((v) => asSemver(this._parse(v))), asSemver(this._parse(range)) ); } diff --git a/lib/versioning/ruby/index.ts b/lib/versioning/ruby/index.ts index bcf49c1a4c8f857d55b6f5335f88e09493f05434..334e27b46d0a6cb89e5e5036b7aeaafda84aa757 100644 --- a/lib/versioning/ruby/index.ts +++ b/lib/versioning/ruby/index.ts @@ -62,8 +62,8 @@ function isStable(version: string): boolean { export const isValid = (input: string): boolean => input .split(',') - .map(piece => vtrim(piece.trim())) - .every(range => { + .map((piece) => vtrim(piece.trim())) + .every((range) => { const { version, operator } = parseRange(range); return operator diff --git a/lib/versioning/ruby/strategies/replace.ts b/lib/versioning/ruby/strategies/replace.ts index 8ac365029699b184af595c1a8c1534f0489b1aa7..632e32ba3b550ba8f5a98f7a81f7c2f158778e28 100644 --- a/lib/versioning/ruby/strategies/replace.ts +++ b/lib/versioning/ruby/strategies/replace.ts @@ -7,7 +7,7 @@ function countInstancesOf(str: string, char: string): number { } function isMajorRange(range: string): boolean { - const splitRange = range.split(',').map(part => part.trim()); + const splitRange = range.split(',').map((part) => part.trim()); return ( splitRange.length === 1 && splitRange[0].startsWith('~>') && @@ -16,7 +16,7 @@ function isMajorRange(range: string): boolean { } function isCommonRubyMajorRange(range: string): boolean { - const splitRange = range.split(',').map(part => part.trim()); + const splitRange = range.split(',').map((part) => part.trim()); return ( splitRange.length === 2 && splitRange[0].startsWith('~>') && @@ -26,7 +26,7 @@ function isCommonRubyMajorRange(range: string): boolean { } function isCommonRubyMinorRange(range: string): boolean { - const splitRange = range.split(',').map(part => part.trim()); + const splitRange = range.split(',').map((part) => part.trim()); return ( splitRange.length === 2 && splitRange[0].startsWith('~>') && @@ -62,16 +62,13 @@ export default ({ to, range }: { range: string; to: string }): string => { } else { const lastPart = range .split(',') - .map(part => part.trim()) + .map((part) => part.trim()) .pop(); const lastPartPrecision = lastPart.split('.').length; const toPrecision = to.split('.').length; let massagedTo: string = to; if (!lastPart.startsWith('<') && toPrecision > lastPartPrecision) { - massagedTo = to - .split('.') - .slice(0, lastPartPrecision) - .join('.'); + massagedTo = to.split('.').slice(0, lastPartPrecision).join('.'); } const newLastPart = bump({ to: massagedTo, range: lastPart }); newRange = range.replace(lastPart, newLastPart); diff --git a/lib/versioning/ruby/version.ts b/lib/versioning/ruby/version.ts index edad649cefbd3c0b255eac72d4a24a6683b13789..a6914561f59f78bd6006736122020e76b616d848 100644 --- a/lib/versioning/ruby/version.ts +++ b/lib/versioning/ruby/version.ts @@ -17,25 +17,14 @@ const parse = (version: string): RubyVersion => ({ }); const adapt = (left: string, right: string): string => - left - .split('.') - .slice(0, right.split('.').length) - .join('.'); + left.split('.').slice(0, right.split('.').length).join('.'); const floor = (version: string): string => - [ - ...create(version) - .release() - .getSegments() - .slice(0, -1), - 0, - ].join('.'); + [...create(version).release().getSegments().slice(0, -1), 0].join('.'); // istanbul ignore next const incrementLastSegment = (version: string): string => { - const segments = create(version) - .release() - .getSegments(); + const segments = create(version).release().getSegments(); const nextLast = parseInt(last(segments), 10) + 1; return [...segments.slice(0, -1), nextLast].join('.'); @@ -84,9 +73,7 @@ const increment = (from: string, to: string): string => { // istanbul ignore next const decrement = (version: string): string => { - const segments = create(version) - .release() - .getSegments(); + const segments = create(version).release().getSegments(); const nextSegments = segments .reverse() .reduce((accumulator: number[], segment: number, index: number) => { diff --git a/lib/versioning/swift/index.ts b/lib/versioning/swift/index.ts index 345a640aabf73c9cae2ed258f05b5bb90a301d74..2c2139a2ec4a07b34e8c3cf73fd67257b919d19b 100644 --- a/lib/versioning/swift/index.ts +++ b/lib/versioning/swift/index.ts @@ -31,12 +31,12 @@ export const isValid = (input: string): boolean => export const isVersion = (input: string): boolean => !!valid(input); const maxSatisfyingVersion = (versions: string[], range: string): string => maxSatisfying( - versions.map(v => v.replace(/^v/, '')), + versions.map((v) => v.replace(/^v/, '')), toSemverRange(range) ); const minSatisfyingVersion = (versions: string[], range: string): string => minSatisfying( - versions.map(v => v.replace(/^v/, '')), + versions.map((v) => v.replace(/^v/, '')), toSemverRange(range) ); const isLessThanRange = (version: string, range: string): boolean => diff --git a/lib/versioning/versioning-metadata.spec.ts b/lib/versioning/versioning-metadata.spec.ts index 4b7e8f96c4e535be8580dd39346af693d8a18998..cb45472d2e428eeb429e1deff7dbee5137177b21 100644 --- a/lib/versioning/versioning-metadata.spec.ts +++ b/lib/versioning/versioning-metadata.spec.ts @@ -3,7 +3,7 @@ import { readdir, readFile } from 'fs-extra'; describe('versioning metadata', () => { it('readme no markdown headers', async () => { const allVersioning = (await readdir('lib/versioning')).filter( - item => !item.includes('.') + (item) => !item.includes('.') ); for (const versioning of allVersioning) { let readme: string; @@ -22,7 +22,7 @@ describe('versioning metadata', () => { }); it('contains mandatory fields', async () => { const allVersioning = (await readdir('lib/versioning')).filter( - item => !item.includes('.') && !item.startsWith('_') + (item) => !item.includes('.') && !item.startsWith('_') ); for (const versioning of allVersioning) { diff --git a/lib/workers/branch/auto-replace.ts b/lib/workers/branch/auto-replace.ts index 1313dc92175ca79e7f665bcb0c8e035672dbbcb5..726329fce88acdf0b6ba5b4736d885b49dadbb0b 100644 --- a/lib/workers/branch/auto-replace.ts +++ b/lib/workers/branch/auto-replace.ts @@ -38,7 +38,7 @@ export async function confirmIfDepUpdated( } function getDepsSignature(deps): string { - return deps.map(dep => `${dep.depName}${dep.lookupName}`).join(','); + return deps.map((dep) => `${dep.depName}${dep.lookupName}`).join(','); } export async function checkBranchDepsMatchBaseDeps( diff --git a/lib/workers/branch/commit.ts b/lib/workers/branch/commit.ts index 23c08fbcfb75d297f8309a9eecef7233f9272cc5..3d03f7be4e59c1d970a85bf982b4e6cbb7a2aae8 100644 --- a/lib/workers/branch/commit.ts +++ b/lib/workers/branch/commit.ts @@ -10,9 +10,9 @@ export async function commitFilesToBranch( let updatedFiles = config.updatedPackageFiles.concat(config.updatedArtifacts); // istanbul ignore if if (is.nonEmptyArray(config.excludeCommitPaths)) { - updatedFiles = updatedFiles.filter(f => { + updatedFiles = updatedFiles.filter((f) => { const filename = f.name === '|delete|' ? f.contents.toString() : f.name; - const matchesExcludePaths = config.excludeCommitPaths.some(path => + const matchesExcludePaths = config.excludeCommitPaths.some((path) => minimatch(filename, path, { dot: true }) ); if (matchesExcludePaths) { diff --git a/lib/workers/branch/get-updated.spec.ts b/lib/workers/branch/get-updated.spec.ts index 931a8f33a5db4c9245a4eff58583c66d0ca4c675..b7b958a4108c8830542011199060766316367edf 100644 --- a/lib/workers/branch/get-updated.spec.ts +++ b/lib/workers/branch/get-updated.spec.ts @@ -86,7 +86,7 @@ describe('workers/branch/get-updated', () => { }, }, ]); - config.upgrades.forEach(upgrade => { + config.upgrades.forEach((upgrade) => { upgrade.autoReplace = true; // eslint-disable-line no-param-reassign }); const res = await getUpdatedPackageFiles(config); @@ -140,7 +140,7 @@ describe('workers/branch/get-updated', () => { }, }, ]); - config.upgrades.forEach(upgrade => { + config.upgrades.forEach((upgrade) => { upgrade.autoReplace = true; // eslint-disable-line no-param-reassign }); const res = await getUpdatedPackageFiles(config); diff --git a/lib/workers/branch/get-updated.ts b/lib/workers/branch/get-updated.ts index 69f227f9fbf4e20cdeb7c5b0953c40900fc31114..dcd65dcc7854dd44d1ed6d136b68500a6b5c86b5 100644 --- a/lib/workers/branch/get-updated.ts +++ b/lib/workers/branch/get-updated.ts @@ -104,7 +104,7 @@ export async function getUpdatedPackageFiles( } } } - const updatedPackageFiles = Object.keys(updatedFileContents).map(name => ({ + const updatedPackageFiles = Object.keys(updatedFileContents).map((name) => ({ name, contents: updatedFileContents[name], })); diff --git a/lib/workers/branch/index.ts b/lib/workers/branch/index.ts index c2e9d522cbe450454f178ac6f5a850af6dfee1a9..43ed1e9c79276c4deb296db924edf830e9a8a2a3 100644 --- a/lib/workers/branch/index.ts +++ b/lib/workers/branch/index.ts @@ -58,8 +58,8 @@ export async function processBranch( ): Promise<ProcessBranchResult> { const config: BranchConfig = { ...branchConfig }; const dependencies = config.upgrades - .map(upgrade => upgrade.depName) - .filter(v => v) // remove nulls (happens for lock file maintenance) + .map((upgrade) => upgrade.depName) + .filter((v) => v) // remove nulls (happens for lock file maintenance) .filter((value, i, list) => list.indexOf(value) === i); // remove duplicates logger.debug( { dependencies }, @@ -237,7 +237,7 @@ export async function processBranch( if ( config.upgrades.some( - upgrade => upgrade.stabilityDays && upgrade.releaseTimestamp + (upgrade) => upgrade.stabilityDays && upgrade.releaseTimestamp ) ) { // Only set a stability status check if one or more of the updates contain @@ -308,7 +308,7 @@ export async function processBranch( if (config.updatedArtifacts && config.updatedArtifacts.length) { logger.debug( { - updatedArtifacts: config.updatedArtifacts.map(f => + updatedArtifacts: config.updatedArtifacts.map((f) => f.name === '|delete|' ? `${f.contents} (delete)` : f.name ), }, @@ -335,7 +335,7 @@ export async function processBranch( if (is.nonEmptyArray(commands)) { for (const cmd of commands) { if ( - !config.allowedPostUpgradeCommands.some(pattern => + !config.allowedPostUpgradeCommands.some((pattern) => regEx(pattern).test(cmd) ) ) { @@ -578,7 +578,7 @@ export async function processBranch( content += ' - you rename this PR\'s title to start with "rebase!" to trigger it manually'; content += '\n\nThe artifact failure details are included below:\n\n'; - config.artifactErrors.forEach(error => { + config.artifactErrors.forEach((error) => { content += `##### File name: ${error.lockFile}\n\n`; content += `\`\`\`\n${error.stderr}\n\`\`\`\n\n`; }); diff --git a/lib/workers/branch/lock-files/index.spec.ts b/lib/workers/branch/lock-files/index.spec.ts index 004fce02a1b3f695cda4b1703ed6eac61e52777e..fcd300e9c3cdf5949dd2aa456497fe07953078f9 100644 --- a/lib/workers/branch/lock-files/index.spec.ts +++ b/lib/workers/branch/lock-files/index.spec.ts @@ -20,7 +20,7 @@ const lerna = mocked(_lerna); const hostRules = mocked(_hostRules); const platform = mocked(_platform); -hostRules.find = jest.fn(_ => ({ +hostRules.find = jest.fn((_) => ({ token: 'abc', })); diff --git a/lib/workers/branch/lock-files/yarn.spec.ts b/lib/workers/branch/lock-files/yarn.spec.ts index 0c23560e8bee85a38ca20dfc77453934b5ee545b..aa2351fd1f213b10a55662309f1b3ee48c42a637 100644 --- a/lib/workers/branch/lock-files/yarn.spec.ts +++ b/lib/workers/branch/lock-files/yarn.spec.ts @@ -21,7 +21,7 @@ const yarnHelper = mocked(_yarnHelper); // TODO: figure out snapshot similarity for each CI platform const fixSnapshots = (snapshots: ExecSnapshots): ExecSnapshots => - snapshots.map(snapshot => ({ + snapshots.map((snapshot) => ({ ...snapshot, cmd: snapshot.cmd.replace(/^.*\/yarn.*?\.js\s+/, '<yarn> '), })); diff --git a/lib/workers/branch/schedule.ts b/lib/workers/branch/schedule.ts index c46d3b794f50ebe43d09ba7296bcd81a4b14e751..a81981d79fd4bf42c75b953c9e0bb1f221cb2de5 100644 --- a/lib/workers/branch/schedule.ts +++ b/lib/workers/branch/schedule.ts @@ -33,7 +33,7 @@ export function hasValidSchedule( return [true]; } // check if any of the schedules fail to parse - const hasFailedSchedules = schedule.some(scheduleText => { + const hasFailedSchedules = schedule.some((scheduleText) => { const massagedText = fixShortHours( scheduleMappings[scheduleText] || scheduleText ); @@ -43,13 +43,13 @@ export function hasValidSchedule( // It failed to parse return true; } - if (parsedSchedule.schedules.some(s => s.m)) { + if (parsedSchedule.schedules.some((s) => s.m)) { message = `Invalid schedule: "${scheduleText}" should not specify minutes`; return true; } if ( !parsedSchedule.schedules.some( - s => s.M || s.d !== undefined || s.D || s.t_a !== undefined || s.t_b + (s) => s.M || s.d !== undefined || s.D || s.t_a !== undefined || s.t_b ) ) { message = `Invalid schedule: "${scheduleText}" has no months, days of week or time of day`; @@ -113,12 +113,12 @@ export function isScheduledNow(config): boolean { // Support a single string but massage to array for processing logger.debug(`Checking ${configSchedule.length} schedule(s)`); // We run if any schedule matches - const isWithinSchedule = configSchedule.some(scheduleText => { + const isWithinSchedule = configSchedule.some((scheduleText) => { const massagedText = scheduleMappings[scheduleText] || scheduleText; const parsedSchedule = later.parse.text(fixShortHours(massagedText)); logger.debug({ parsedSchedule }, `Checking schedule "${scheduleText}"`); // Later library returns array of schedules - return parsedSchedule.schedules.some(schedule => { + return parsedSchedule.schedules.some((schedule) => { // Check if months are defined if (schedule.M) { const currentMonth = parseInt(now.format('M'), 10); @@ -144,7 +144,7 @@ export function isScheduledNow(config): boolean { 'Friday', 'Saturday', ]; - const scheduledDays = schedule.d.map(day => dowMap[day]); + const scheduledDays = schedule.d.map((day) => dowMap[day]); logger.trace({ scheduledDays }, `scheduledDays`); if (!scheduledDays.includes(currentDay)) { logger.debug( diff --git a/lib/workers/global/index.spec.ts b/lib/workers/global/index.spec.ts index 121973eea276b9a2ac9517e69a3ca34c84a1ca3c..2db44a3051d08ad6d0a74592411e9a25bf06f0c0 100644 --- a/lib/workers/global/index.spec.ts +++ b/lib/workers/global/index.spec.ts @@ -21,7 +21,7 @@ describe('lib/workers/global', () => { beforeEach(() => { jest.resetAllMocks(); configParser.parseConfigs = jest.fn(); - platform.initPlatform.mockImplementation(input => Promise.resolve(input)); + platform.initPlatform.mockImplementation((input) => Promise.resolve(input)); }); it('handles config warnings and errors', async () => { configParser.parseConfigs.mockResolvedValueOnce({ diff --git a/lib/workers/global/index.ts b/lib/workers/global/index.ts index 17cb88821919af7e8531b5774ff06dbddaf6f3af..c58a20cf766a0f203b80de609c9d93915f7c392a 100644 --- a/lib/workers/global/index.ts +++ b/lib/workers/global/index.ts @@ -79,7 +79,7 @@ export async function start(): Promise<0 | 1> { await setUtilConfig(repoConfig); if (repoConfig.hostRules) { hostRules.clear(); - repoConfig.hostRules.forEach(rule => hostRules.add(rule)); + repoConfig.hostRules.forEach((rule) => hostRules.add(rule)); repoConfig.hostRules = []; } await repositoryWorker.renovateRepository(repoConfig); diff --git a/lib/workers/pr/body/index.ts b/lib/workers/pr/body/index.ts index 028f2550aec1856a6bec7e8c22356f43b1a38f29..1c6a4c4622ead7cb7915bdcdf10bf05e3f3102cd 100644 --- a/lib/workers/pr/body/index.ts +++ b/lib/workers/pr/body/index.ts @@ -11,7 +11,7 @@ import { getControls } from './controls'; import { BranchConfig } from '../../common'; function massageUpdateMetadata(config: BranchConfig): void { - config.upgrades.forEach(upgrade => { + config.upgrades.forEach((upgrade) => { /* eslint-disable no-param-reassign */ const { homepage, sourceUrl, sourceDirectory, changelogUrl } = upgrade; let depNameLinked = upgrade.depName; diff --git a/lib/workers/pr/body/notes.ts b/lib/workers/pr/body/notes.ts index 672bd1d827cd54f3ca7d6c944adfaefab36d4c11..cd78073ae9efb13c81b751ad6f8c618449039b4a 100644 --- a/lib/workers/pr/body/notes.ts +++ b/lib/workers/pr/body/notes.ts @@ -26,7 +26,7 @@ export function getPrNotes(config: BranchConfig): string { export function getPrExtraNotes(config: BranchConfig): string { let res = ''; - if (config.upgrades.some(upgrade => upgrade.gitRef)) { + if (config.upgrades.some((upgrade) => upgrade.gitRef)) { res += emojify( ':abcd: If you wish to disable git hash updates, add `":disableDigestUpdates"` to the extends array in your config.\n\n' ); diff --git a/lib/workers/pr/body/updates-table.ts b/lib/workers/pr/body/updates-table.ts index 0f109ccc05caa081db46642c72fe3cc538875bbc..a459a391fe4c31cd028747a5073c06202516204c 100644 --- a/lib/workers/pr/body/updates-table.ts +++ b/lib/workers/pr/body/updates-table.ts @@ -36,7 +36,7 @@ function getNonEmptyColumns( export function getPrUpdatesTable(config: BranchConfig): string { const tableDefinitions = getTableDefinition(config); - const tableValues = config.upgrades.map(upgrade => { + const tableValues = config.upgrades.map((upgrade) => { const res: Record<string, string> = {}; for (const column of tableDefinitions) { const { header, value } = column; diff --git a/lib/workers/pr/changelog/release-notes.spec.ts b/lib/workers/pr/changelog/release-notes.spec.ts index 9c2e3d22d9d1eca89dbd5d1934dd57df626812c1..5c5846d9178ff8e5328c7d5ece1636429e66a9d8 100644 --- a/lib/workers/pr/changelog/release-notes.spec.ts +++ b/lib/workers/pr/changelog/release-notes.spec.ts @@ -58,7 +58,7 @@ describe('workers/pr/release-notes', () => { }); it.each([[''], ['v'], ['other-']])( 'gets release notes with body', - async prefix => { + async (prefix) => { ghGot.mockResolvedValueOnce({ body: [ { tag_name: `${prefix}1.0.0` }, diff --git a/lib/workers/pr/changelog/release-notes.ts b/lib/workers/pr/changelog/release-notes.ts index 330404b0c7f7a8abdb52d89918961b9bdb2eb342..2a091742ed2fd732ea3878bbcf6d1d967aea0886 100644 --- a/lib/workers/pr/changelog/release-notes.ts +++ b/lib/workers/pr/changelog/release-notes.ts @@ -33,7 +33,7 @@ export async function getReleaseList( body: string; }[] >(url); - return res.body.map(release => ({ + return res.body.map((release) => ({ url: release.html_url, id: release.id, tag: release.tag_name, @@ -85,7 +85,7 @@ export async function getReleaseNotes( logger.trace(`getReleaseNotes(${repository}, ${version}, ${depName})`); const releaseList = await getReleaseList(githubApiBaseURL, repository); let releaseNotes: ChangeLogNotes | null = null; - releaseList.forEach(release => { + releaseList.forEach((release) => { if ( release.tag === version || release.tag === `v${version}` || @@ -111,7 +111,7 @@ function sectionize(text: string, level: number): string[] { const sections: [number, number][] = []; const lines = text.split('\n'); const tokens = markdown.parse(text, undefined); - tokens.forEach(token => { + tokens.forEach((token) => { if (token.type === 'heading_open') { const lev = +token.tag.substr(1); if (lev <= level) { @@ -162,8 +162,8 @@ export async function getReleaseNotesMd( apiPrefix += `repos/${repository}/contents/`; const filesRes = await ghGot<{ name: string }[]>(apiPrefix); const files = filesRes.body - .map(f => f.name) - .filter(f => changelogFilenameRegex.test(f)); + .map((f) => f.name) + .filter((f) => changelogFilenameRegex.test(f)); if (!files.length) { logger.trace('no changelog file found'); return null; diff --git a/lib/workers/pr/changelog/releases.ts b/lib/workers/pr/changelog/releases.ts index e1b7bf1d1bb8bdbf41c59ec543bebab1e2d180e8..f17fc34603b20b172d5220a7be76e1d575c51146 100644 --- a/lib/workers/pr/changelog/releases.ts +++ b/lib/workers/pr/changelog/releases.ts @@ -33,15 +33,15 @@ export async function getInRangeReleases( const version = get(versioning); const releases = pkgReleases - .filter(release => version.isCompatible(release.version, fromVersion)) + .filter((release) => version.isCompatible(release.version, fromVersion)) .filter( - release => + (release) => version.equals(release.version, fromVersion) || version.isGreaterThan(release.version, fromVersion) ) - .filter(release => !version.isGreaterThan(release.version, toVersion)) + .filter((release) => !version.isGreaterThan(release.version, toVersion)) .filter( - release => + (release) => version.isStable(release.version) || matchesUnstable(version, fromVersion, release.version) || matchesUnstable(version, toVersion, release.version) diff --git a/lib/workers/pr/changelog/source-github.ts b/lib/workers/pr/changelog/source-github.ts index acf1143da8c31acc0544d734fad800d38840dd4d..a14206a4cfe0ddb9372125799c4cefffe34beb1c 100644 --- a/lib/workers/pr/changelog/source-github.ts +++ b/lib/workers/pr/changelog/source-github.ts @@ -31,7 +31,7 @@ async function getTags( logger.debug({ repository }, 'repository has no Github tags'); } - return tags.map(tag => tag.name).filter(Boolean); + return tags.map((tag) => tag.name).filter(Boolean); } catch (err) { logger.debug({ sourceRepo: repository }, 'Failed to fetch Github tags'); logger.debug({ err }); @@ -98,7 +98,7 @@ export async function getChangeLogJSON({ } // This extra filter/sort should not be necessary, but better safe than sorry const validReleases = [...releases] - .filter(release => version.isVersion(release.version)) + .filter((release) => version.isVersion(release.version)) .sort((a, b) => version.sortVersions(a.version, b.version)); if (validReleases.length < 2) { @@ -114,8 +114,8 @@ export async function getChangeLogJSON({ } const regex = new RegExp(`${depName}[@-]`); const tagName = tags - .filter(tag => version.isVersion(tag.replace(regex, ''))) - .find(tag => version.equals(tag.replace(regex, ''), release.version)); + .filter((tag) => version.isVersion(tag.replace(regex, ''))) + .find((tag) => version.equals(tag.replace(regex, ''), release.version)); if (tagName) { return tagName; } diff --git a/lib/workers/pr/index.spec.ts b/lib/workers/pr/index.spec.ts index bad71f576779cce3efc77eb0418c2454e966db04..6bf59c556f7c80ab95382c867ce02a26974a59d1 100644 --- a/lib/workers/pr/index.spec.ts +++ b/lib/workers/pr/index.spec.ts @@ -147,7 +147,7 @@ describe('workers/pr', () => { displayNumber: 'New Pull Request', } as never); config.upgrades = [config]; - platform.getPrBody = jest.fn(input => input); + platform.getPrBody = jest.fn((input) => input); platform.getBranchPr = jest.fn(); platform.getBranchStatus = jest.fn(); }); @@ -377,9 +377,7 @@ describe('workers/pr', () => { }); it('should return unmodified existing PR if only whitespace changes', async () => { const modifiedPr = JSON.parse( - JSON.stringify(existingPr) - .replace(' ', ' ') - .replace('\n', '\r\n') + JSON.stringify(existingPr).replace(' ', ' ').replace('\n', '\r\n') ); platform.getBranchPr.mockResolvedValueOnce(modifiedPr); config.semanticCommitScope = null; diff --git a/lib/workers/pr/index.ts b/lib/workers/pr/index.ts index 7aa318f893b3f5e849b5394dea149689ef5b9ce7..27f6103d521c514f34b9729275433da6f0d0d15e 100644 --- a/lib/workers/pr/index.ts +++ b/lib/workers/pr/index.ts @@ -209,7 +209,7 @@ export async function ensurePr( ) { commitRepos.push(upgrade.githubName); if (logJSON.versions) { - logJSON.versions.forEach(version => { + logJSON.versions.forEach((version) => { const release = { ...version }; upgrade.releases.push(release); }); @@ -232,7 +232,7 @@ export async function ensurePr( // Update the config object Object.assign(config, upgrades[0]); - config.hasReleaseNotes = config.upgrades.some(upg => upg.hasReleaseNotes); + config.hasReleaseNotes = config.upgrades.some((upg) => upg.hasReleaseNotes); const releaseNoteRepos = []; for (const upgrade of config.upgrades) { @@ -347,7 +347,7 @@ export async function ensurePr( if (err.body.errors && err.body.errors.length) { if ( err.body.errors.some( - error => + (error) => error.message && error.message.startsWith('A pull request already exists') ) diff --git a/lib/workers/repository/error.spec.ts b/lib/workers/repository/error.spec.ts index a753ebf4e729aacf4db54eba9463e65f3551c0b8..fb65d3df5e67dbd7e03674b2d13d8a876a18df1a 100644 --- a/lib/workers/repository/error.spec.ts +++ b/lib/workers/repository/error.spec.ts @@ -65,7 +65,7 @@ describe('workers/repository/error', () => { PLATFORM_AUTHENTICATION_ERROR, REPOSITORY_TEMPORARY_ERROR, ]; - errors.forEach(err => { + errors.forEach((err) => { it(`errors ${err}`, async () => { const res = await handleError(config, new Error(err)); expect(res).toEqual(err); diff --git a/lib/workers/repository/extract/file-match.ts b/lib/workers/repository/extract/file-match.ts index 15790652ef770b11832e87e124e43659c6feea2e..7bcf808bb11558f54acf0cb4535514640c333b04 100644 --- a/lib/workers/repository/extract/file-match.ts +++ b/lib/workers/repository/extract/file-match.ts @@ -8,9 +8,9 @@ export function getIncludedFiles( if (!(includePaths && includePaths.length)) { return fileList; } - return fileList.filter(file => + return fileList.filter((file) => includePaths.some( - includePath => + (includePath) => file === includePath || minimatch(file, includePath, { dot: true }) ) ); @@ -24,9 +24,9 @@ export function filterIgnoredFiles( return fileList; } return fileList.filter( - file => + (file) => !ignorePaths.some( - ignorePath => + (ignorePath) => file.includes(ignorePath) || minimatch(file, ignorePath, { dot: true }) ) @@ -42,7 +42,9 @@ export function getMatchingFiles( for (const fileMatch of fileMatchList) { logger.debug(`Using file match: ${fileMatch} for manager ${manager}`); const re = new RegExp(fileMatch); - matchedFiles = matchedFiles.concat(fileList.filter(file => re.test(file))); + matchedFiles = matchedFiles.concat( + fileList.filter((file) => re.test(file)) + ); } // filter out duplicates return [...new Set(matchedFiles)]; diff --git a/lib/workers/repository/finalise/prune.ts b/lib/workers/repository/finalise/prune.ts index 1d8885c931d8faef602c3de5dada9c0b6b40582f..eab62820ece29cc7f531c3f18f755288c3910bf3 100644 --- a/lib/workers/repository/finalise/prune.ts +++ b/lib/workers/repository/finalise/prune.ts @@ -91,10 +91,10 @@ export async function pruneStaleBranches( logger.debug({ branchList, renovateBranches }, 'Branch lists'); const lockFileBranch = `${config.branchPrefix}lock-file-maintenance`; renovateBranches = renovateBranches.filter( - branch => branch !== lockFileBranch + (branch) => branch !== lockFileBranch ); const remainingBranches = renovateBranches.filter( - branch => !branchList.includes(branch) + (branch) => !branchList.includes(branch) ); logger.debug(`remainingBranches=${remainingBranches}`); if (remainingBranches.length === 0) { diff --git a/lib/workers/repository/finalise/validate.ts b/lib/workers/repository/finalise/validate.ts index 1e1ce7a95785c13ceb30074289e364e7bf89d639..d32074f3d45d23d9e77b66107bd5da5ceb6be890 100644 --- a/lib/workers/repository/finalise/validate.ts +++ b/lib/workers/repository/finalise/validate.ts @@ -10,13 +10,13 @@ import { BranchStatus } from '../../../types'; async function getRenovatePrs(branchPrefix: string): Promise<Pr[]> { return (await platform.getPrList()) - .filter(pr => pr.state === PR_STATE_OPEN) - .filter(pr => pr.branchName && !pr.branchName.startsWith(branchPrefix)) - .filter(pr => new RegExp('renovate', 'i').test(pr.title)); + .filter((pr) => pr.state === PR_STATE_OPEN) + .filter((pr) => pr.branchName && !pr.branchName.startsWith(branchPrefix)) + .filter((pr) => new RegExp('renovate', 'i').test(pr.title)); } async function getRenovateFiles(prNo: number): Promise<string[]> { - return (await platform.getPrFiles(prNo)).filter(file => + return (await platform.getPrFiles(prNo)).filter((file) => configFileNames.includes(file) ); } @@ -78,7 +78,7 @@ export async function validatePrs(config: RenovateConfig): Promise<void> { const { errors } = await migrateAndValidate(config, toValidate); if (errors && errors.length) { validations = validations.concat( - errors.map(error => ({ + errors.map((error) => ({ file, message: error.message, })) @@ -93,7 +93,7 @@ export async function validatePrs(config: RenovateConfig): Promise<void> { const topic = `Renovate Configuration Errors`; if (validations.length) { const content = validations - .map(v => `\`${v.file}\`: ${v.message}`) + .map((v) => `\`${v.file}\`: ${v.message}`) .join('\n\n'); await platform.ensureComment({ number: pr.number, diff --git a/lib/workers/repository/init/config.ts b/lib/workers/repository/init/config.ts index 3086412e22dcb68b71e68cb9ddb7bbe1c6fa9f25..66cfcfb844d3a5ac4908dcd8687c93acf18cf8c8 100644 --- a/lib/workers/repository/init/config.ts +++ b/lib/workers/repository/init/config.ts @@ -125,7 +125,7 @@ export async function mergeRenovateConfig( error.validationError = 'The renovate configuration file contains some invalid settings'; error.validationMessage = migratedConfig.errors - .map(e => e.message) + .map((e) => e.message) .join(', '); throw error; } diff --git a/lib/workers/repository/init/vulnerability.ts b/lib/workers/repository/init/vulnerability.ts index b2ef0b4ef8b20888e00c4220f5d93c6fdfa04bbc..c3c7be661731c2d3d5fc8120508f5f8b18eaaa4d 100644 --- a/lib/workers/repository/init/vulnerability.ts +++ b/lib/workers/repository/init/vulnerability.ts @@ -117,16 +117,16 @@ export async function detectVulnerabilityAlerts( let prBodyNotes = []; try { prBodyNotes = ['### GitHub Vulnerability Alerts'].concat( - val.advisories.map(advisory => { + val.advisories.map((advisory) => { let content = '#### '; let heading; - if (advisory.identifiers.some(id => id.type === 'CVE')) { + if (advisory.identifiers.some((id) => id.type === 'CVE')) { heading = advisory.identifiers - .filter(id => id.type === 'CVE') - .map(id => id.value) + .filter((id) => id.type === 'CVE') + .map((id) => id.value) .join(' / '); } else { - heading = advisory.identifiers.map(id => id.value).join(' / '); + heading = advisory.identifiers.map((id) => id.value).join(' / '); } if (advisory.references.length) { heading = `[${heading}](${advisory.references[0].url})`; diff --git a/lib/workers/repository/master-issue.ts b/lib/workers/repository/master-issue.ts index a1fc371d0fceabbabe9650d8102bc201b42b98f5..ff828f2b1ad307439e9f6fd2dbcfe1f3231f6a24 100644 --- a/lib/workers/repository/master-issue.ts +++ b/lib/workers/repository/master-issue.ts @@ -13,7 +13,7 @@ function getListItem(branch: BranchConfig, type: string, pr?: Pr): string { item += branch.prTitle; } const uniquePackages = [ - ...new Set(branch.upgrades.map(upgrade => '`' + upgrade.depName + '`')), + ...new Set(branch.upgrades.map((upgrade) => '`' + upgrade.depName + '`')), ]; if (uniquePackages.length < 2) { return item + '\n'; @@ -29,7 +29,7 @@ export async function ensureMasterIssue( !( config.masterIssue || branches.some( - branch => branch.masterIssueApproval || branch.masterIssuePrApproval + (branch) => branch.masterIssueApproval || branch.masterIssuePrApproval ) ) ) { @@ -38,7 +38,7 @@ export async function ensureMasterIssue( logger.debug('Ensuring master issue'); if ( !branches.length || - branches.every(branch => branch.res === 'automerged') + branches.every((branch) => branch.res === 'automerged') ) { if (config.masterIssueAutoclose) { logger.debug('Closing master issue'); @@ -66,7 +66,7 @@ export async function ensureMasterIssue( } let issueBody = `This [master issue](https://renovatebot.com/blog/master-issue) contains a list of Renovate updates and their statuses.\n\n`; const pendingApprovals = branches.filter( - branch => branch.res === 'needs-approval' + (branch) => branch.res === 'needs-approval' ); if (pendingApprovals.length) { issueBody += '## Pending Approval\n\n'; @@ -77,7 +77,7 @@ export async function ensureMasterIssue( issueBody += '\n'; } const awaitingSchedule = branches.filter( - branch => branch.res === 'not-scheduled' + (branch) => branch.res === 'not-scheduled' ); if (awaitingSchedule.length) { issueBody += '## Awaiting Schedule\n\n'; @@ -89,7 +89,7 @@ export async function ensureMasterIssue( issueBody += '\n'; } const rateLimited = branches.filter( - branch => branch.res && branch.res.endsWith('pr-hourly-limit-reached') + (branch) => branch.res && branch.res.endsWith('pr-hourly-limit-reached') ); if (rateLimited.length) { issueBody += '## Rate Limited\n\n'; @@ -101,7 +101,7 @@ export async function ensureMasterIssue( issueBody += '\n'; } const errorList = branches.filter( - branch => branch.res && branch.res.endsWith('error') + (branch) => branch.res && branch.res.endsWith('error') ); if (errorList.length) { issueBody += '## Errored\n\n'; @@ -113,7 +113,7 @@ export async function ensureMasterIssue( issueBody += '\n'; } const awaitingPr = branches.filter( - branch => branch.res === 'needs-pr-approval' + (branch) => branch.res === 'needs-pr-approval' ); if (awaitingPr.length) { issueBody += '## PR Creation Approval Required\n\n'; @@ -124,7 +124,7 @@ export async function ensureMasterIssue( } issueBody += '\n'; } - const prEdited = branches.filter(branch => branch.res === 'pr-edited'); + const prEdited = branches.filter((branch) => branch.res === 'pr-edited'); if (prEdited.length) { issueBody += '## Edited/Blocked\n\n'; issueBody += `These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, check the box below.\n\n`; @@ -134,7 +134,7 @@ export async function ensureMasterIssue( } issueBody += '\n'; } - const prPending = branches.filter(branch => branch.res === 'pending'); + const prPending = branches.filter((branch) => branch.res === 'pending'); if (prPending.length) { issueBody += '## Pending Status Checks\n\n'; issueBody += `These updates await pending status checks. To force their creation now, check the box below.\n\n`; @@ -154,7 +154,9 @@ export async function ensureMasterIssue( 'automerged', 'pr-edited', ]; - const inProgress = branches.filter(branch => !otherRes.includes(branch.res)); + const inProgress = branches.filter( + (branch) => !otherRes.includes(branch.res) + ); if (inProgress.length) { issueBody += '## Open\n\n'; issueBody += @@ -173,7 +175,7 @@ export async function ensureMasterIssue( issueBody += '\n'; } const alreadyExisted = branches.filter( - branch => branch.res && branch.res.endsWith('already-existed') + (branch) => branch.res && branch.res.endsWith('already-existed') ); if (alreadyExisted.length) { issueBody += '## Closed/Ignored\n\n'; diff --git a/lib/workers/repository/onboarding/pr/config-description.ts b/lib/workers/repository/onboarding/pr/config-description.ts index 34850ab68c68bbca4447b07c5315d839b5d81f31..e306a8109e1487c7757208f3d8daba6dec0ff714 100644 --- a/lib/workers/repository/onboarding/pr/config-description.ts +++ b/lib/workers/repository/onboarding/pr/config-description.ts @@ -41,7 +41,7 @@ export function getConfigDesc( logger.debug({ length: descriptionArr.length }, 'Found description array'); let desc = `\n### Configuration Summary\n\nBased on the default config's presets, Renovate will:\n\n`; desc += ` - Start dependency updates only once this onboarding PR is merged\n`; - descriptionArr.forEach(d => { + descriptionArr.forEach((d) => { desc += ` - ${d}\n`; }); desc += '\n'; diff --git a/lib/workers/repository/onboarding/pr/errors-warnings.ts b/lib/workers/repository/onboarding/pr/errors-warnings.ts index 0da1730ab152b6876fa96dce15391b80d5a30d58..a395aa7a883957fa33979b676847676184cf2511 100644 --- a/lib/workers/repository/onboarding/pr/errors-warnings.ts +++ b/lib/workers/repository/onboarding/pr/errors-warnings.ts @@ -9,7 +9,7 @@ export function getWarnings(config: RenovateConfig): string { } let warningText = `\n# Warnings (${config.warnings.length})\n\n`; warningText += `Please correct - or verify that you can safely ignore - these warnings before you merge this PR.\n\n`; - config.warnings.forEach(w => { + config.warnings.forEach((w) => { warningText += `- \`${w.depName}\`: ${w.message}\n`; }); warningText += '\n---\n'; @@ -23,7 +23,7 @@ export function getErrors(config: RenovateConfig): string { } errorText = `\n# Errors (${config.errors.length})\n\n`; errorText += `Renovate has found errors that you should fix (in this branch) before finishing this PR.\n\n`; - config.errors.forEach(e => { + config.errors.forEach((e) => { errorText += `- \`${e.depName}\`: ${e.message}\n`; }); errorText += '\n---\n'; @@ -65,12 +65,12 @@ export function getDepWarnings( `\n---\n\n### :warning: Dependency Lookup Warnings :warning:\n\n` ); warningText += `Please correct - or verify that you can safely ignore - these lookup failures before you merge this PR.\n\n`; - warnings.forEach(w => { + warnings.forEach((w) => { warningText += `- \`${w}\`\n`; }); warningText += '\nFiles affected: ' + - warningFiles.map(f => '`' + f + '`').join(', ') + + warningFiles.map((f) => '`' + f + '`').join(', ') + '\n\n'; } catch (err) { // istanbul ignore next diff --git a/lib/workers/repository/onboarding/pr/index.spec.ts b/lib/workers/repository/onboarding/pr/index.spec.ts index 0f0c8ee3b7d6caabd829069c9bccbc9175fe5fbf..0381cbea4097a1e9e3af8550633c644cb010ca31 100644 --- a/lib/workers/repository/onboarding/pr/index.spec.ts +++ b/lib/workers/repository/onboarding/pr/index.spec.ts @@ -21,7 +21,7 @@ describe('workers/repository/onboarding/pr', () => { }; packageFiles = { npm: [{ packageFile: 'package.json' }] }; branches = []; - platform.getPrBody = jest.fn(input => input); + platform.getPrBody = jest.fn((input) => input); platform.createPr.mockReturnValue({}); }); let createPrBody: string; diff --git a/lib/workers/repository/onboarding/pr/index.ts b/lib/workers/repository/onboarding/pr/index.ts index 7f6ea08ee76fd64c7c2a6d2afe03b6725f5384c5..686ec5e5229fd1d65a559140aa20723cc4af7cdc 100644 --- a/lib/workers/repository/onboarding/pr/index.ts +++ b/lib/workers/repository/onboarding/pr/index.ts @@ -53,7 +53,7 @@ If you need any further assistance then you can also [request help here](${confi let files = []; for (const [manager, managerFiles] of Object.entries(packageFiles)) { files = files.concat( - managerFiles.map(file => ` * \`${file.packageFile}\` (${manager})`) + managerFiles.map((file) => ` * \`${file.packageFile}\` (${manager})`) ); } prBody = diff --git a/lib/workers/repository/process/deprecated.ts b/lib/workers/repository/process/deprecated.ts index 40843211b5610d94af56494b1fe63d815e1175b0..4aafdb1bf476b74cdf8cfd24710711cefa1cd785 100644 --- a/lib/workers/repository/process/deprecated.ts +++ b/lib/workers/repository/process/deprecated.ts @@ -53,7 +53,7 @@ export async function raiseDeprecationWarnings( issueTitleList.push(issueTitle); let issueBody = deprecationMessage; issueBody += `\n\nAffected package file(s): ${depPackageFiles - .map(f => '`' + f + '`') + .map((f) => '`' + f + '`') .join(', ')}`; issueBody += `\n\nIf you don't care about this, you can close this issue and not be warned about \`${depName}\`'s deprecation again. If you would like to completely disable all future deprecation warnings then add the following to your config:\n\n\`\`\`\n"suppressNotifications": ["deprecationWarningIssues"]\n\`\`\`\n\n`; // istanbul ignore if @@ -74,7 +74,7 @@ export async function raiseDeprecationWarnings( const issueList = await platform.getIssueList(); if (issueList && issueList.length) { const deprecatedIssues = issueList.filter( - i => i.title.startsWith(issueTitlePrefix) && i.state === 'open' + (i) => i.title.startsWith(issueTitlePrefix) && i.state === 'open' ); for (const i of deprecatedIssues) { if (!issueTitleList.includes(i.title)) { diff --git a/lib/workers/repository/process/fetch.spec.ts b/lib/workers/repository/process/fetch.spec.ts index ed2911d9e1d6ef29203c0ef94db8c652dab739c2..ac720c44e45c06f20dbae6669c338367708e1620 100644 --- a/lib/workers/repository/process/fetch.spec.ts +++ b/lib/workers/repository/process/fetch.spec.ts @@ -83,7 +83,7 @@ describe('workers/repository/process/fetch', () => { ], }; // TODO: fix types - npm.getPackageUpdates = jest.fn(_ => ['a', 'b'] as never); + npm.getPackageUpdates = jest.fn((_) => ['a', 'b'] as never); lookupUpdates.mockResolvedValue(['a', 'b'] as never); await fetchUpdates(config, packageFiles); expect(packageFiles).toMatchSnapshot(); diff --git a/lib/workers/repository/process/fetch.ts b/lib/workers/repository/process/fetch.ts index d4b9aa11bad31966f173f1b444d08635a2041caf..918d5cb9df80718507b597a072f9660c0e2614ac 100644 --- a/lib/workers/repository/process/fetch.ts +++ b/lib/workers/repository/process/fetch.ts @@ -64,7 +64,7 @@ async function fetchDepUpdates( logger.trace( { dependency: depName }, `${dep.updates.length} result(s): ${dep.updates.map( - upgrade => upgrade.newValue + (upgrade) => upgrade.newValue )}` ); } @@ -87,7 +87,7 @@ async function fetchManagerPackagerFileUpdates( const { packageFile } = pFile; const packageFileConfig = mergeChildConfig(managerConfig, pFile); const { manager } = packageFileConfig; - const queue = pFile.deps.map(dep => (): Promise<void> => + const queue = pFile.deps.map((dep) => (): Promise<void> => fetchDepUpdates(packageFileConfig, dep) ); logger.trace( @@ -104,7 +104,7 @@ async function fetchManagerUpdates( manager: string ): Promise<void> { const managerConfig = getManagerConfig(config, manager); - const queue = packageFiles[manager].map(pFile => (): Promise<void> => + const queue = packageFiles[manager].map((pFile) => (): Promise<void> => fetchManagerPackagerFileUpdates(config, managerConfig, pFile) ); logger.trace( @@ -139,7 +139,7 @@ export async function fetchUpdates( stats.depCount += depCount; } logger.info({ stats }, `Extraction statistics`); - const allManagerJobs = managers.map(manager => + const allManagerJobs = managers.map((manager) => fetchManagerUpdates(config, packageFiles, manager) ); await Promise.all(allManagerJobs); diff --git a/lib/workers/repository/process/index.ts b/lib/workers/repository/process/index.ts index c187f32d487f32bf295e82eff1bd614dedebe310..84ecb782ba54c1cddca411874cb1c06d4ae17a04 100644 --- a/lib/workers/repository/process/index.ts +++ b/lib/workers/repository/process/index.ts @@ -18,7 +18,7 @@ export async function processRepo( config.prCreation === 'approval' || (config.packageRules && config.packageRules.some( - rule => rule.masterIssueApproval || rule.prCreation === 'approval' + (rule) => rule.masterIssueApproval || rule.prCreation === 'approval' )) ) { config.masterIssueTitle = @@ -29,7 +29,7 @@ export async function processRepo( const checked = issue.body.match(new RegExp(checkMatch, 'g')); if (checked && checked.length) { const re = new RegExp(checkMatch); - checked.forEach(check => { + checked.forEach((check) => { const [, type, branchName] = re.exec(check); config.masterIssueChecks[branchName] = type; }); diff --git a/lib/workers/repository/process/limits.ts b/lib/workers/repository/process/limits.ts index 77ad824ee27c4fdf61662a9f51f35aa099b81104..06177e534a8537534a3a49c4680969efbe8d2740 100644 --- a/lib/workers/repository/process/limits.ts +++ b/lib/workers/repository/process/limits.ts @@ -16,7 +16,7 @@ export async function getPrHourlyRemaining( logger.debug('currentHourStart=' + currentHourStart); try { const soFarThisHour = prList.filter( - pr => + (pr) => pr.branchName !== config.onboardingBranch && moment(pr.createdAt).isAfter(currentHourStart) ); diff --git a/lib/workers/repository/process/lookup/filter.ts b/lib/workers/repository/process/lookup/filter.ts index afa0e1b0cfe13b49281f84d111bed122dc9c1dbe..d8c5c50649b80261141f140a89e7a15ea6c2d1bc 100644 --- a/lib/workers/repository/process/lookup/filter.ts +++ b/lib/workers/repository/process/lookup/filter.ts @@ -35,15 +35,17 @@ export function filterVersions( } // Leave only versions greater than current - let filteredVersions = versions.filter(v => + let filteredVersions = versions.filter((v) => version.isGreaterThan(v, fromVersion) ); // Don't upgrade from non-deprecated to deprecated - const fromRelease = releases.find(release => release.version === fromVersion); + const fromRelease = releases.find( + (release) => release.version === fromVersion + ); if (ignoreDeprecated && fromRelease && !fromRelease.isDeprecated) { - filteredVersions = filteredVersions.filter(v => { - const versionRelease = releases.find(release => release.version === v); + filteredVersions = filteredVersions.filter((v) => { + const versionRelease = releases.find((release) => release.version === v); if (versionRelease.isDeprecated) { logger.debug( `Skipping ${config.depName}@${v} because it is deprecated` @@ -56,7 +58,7 @@ export function filterVersions( if (allowedVersions) { if (version.isValid(allowedVersions)) { - filteredVersions = filteredVersions.filter(v => + filteredVersions = filteredVersions.filter((v) => version.matches(v, allowedVersions) ); } else if ( @@ -67,7 +69,7 @@ export function filterVersions( { depName: config.depName }, 'Falling back to npm semver syntax for allowedVersions' ); - filteredVersions = filteredVersions.filter(v => + filteredVersions = filteredVersions.filter((v) => semver.satisfies(semver.coerce(v), allowedVersions) ); } else { @@ -90,7 +92,7 @@ export function filterVersions( if (!version.isStable(fromVersion)) { // Allow unstable only in current major return filteredVersions.filter( - v => + (v) => version.isStable(v) || (version.getMajor(v) === version.getMajor(fromVersion) && version.getMinor(v) === version.getMinor(fromVersion) && @@ -99,7 +101,7 @@ export function filterVersions( } // Normal case: remove all unstable - filteredVersions = filteredVersions.filter(v => version.isStable(v)); + filteredVersions = filteredVersions.filter((v) => version.isStable(v)); // Filter the latest @@ -116,5 +118,7 @@ export function filterVersions( if (version.isGreaterThan(fromVersion, latestVersion)) { return filteredVersions; } - return filteredVersions.filter(v => !version.isGreaterThan(v, latestVersion)); + return filteredVersions.filter( + (v) => !version.isGreaterThan(v, latestVersion) + ); } diff --git a/lib/workers/repository/process/lookup/index.spec.ts b/lib/workers/repository/process/lookup/index.spec.ts index d20f6ebfb46a15212988b3baf1a0ef694a363399..41a1d5bb6adb44f7f263f57cf7d6667c8bed81ac 100644 --- a/lib/workers/repository/process/lookup/index.spec.ts +++ b/lib/workers/repository/process/lookup/index.spec.ts @@ -46,9 +46,7 @@ describe('workers/repository/process/lookup', () => { config.depName = 'q'; config.datasource = datasourceNpm.id; config.rollbackPrs = true; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('returns rollback for ranged version', async () => { @@ -56,9 +54,7 @@ describe('workers/repository/process/lookup', () => { config.depName = 'q'; config.datasource = datasourceNpm.id; config.rollbackPrs = true; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('supports minor and major upgrades for tilde ranges', async () => { @@ -66,9 +62,7 @@ describe('workers/repository/process/lookup', () => { config.rangeStrategy = 'pin'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('supports lock file updates mixed with regular updates', async () => { @@ -77,9 +71,7 @@ describe('workers/repository/process/lookup', () => { config.depName = 'q'; config.datasource = datasourceNpm.id; config.lockedVersion = '0.4.0'; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('returns multiple updates if grouping but separateMajorMinor=true', async () => { @@ -88,9 +80,7 @@ describe('workers/repository/process/lookup', () => { config.rangeStrategy = 'pin'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); const res = await lookup.lookupUpdates(config); expect(res.updates).toMatchSnapshot(); expect(res.updates).toHaveLength(2); @@ -102,9 +92,7 @@ describe('workers/repository/process/lookup', () => { config.depName = 'q'; config.separateMinorPatch = true; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); const res = await lookup.lookupUpdates(config); expect(res.updates).toMatchSnapshot(); expect(res.updates).toHaveLength(3); @@ -116,9 +104,7 @@ describe('workers/repository/process/lookup', () => { config.separateMajorMinor = false; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); const res = await lookup.lookupUpdates(config); expect(res.updates).toMatchSnapshot(); expect(res.updates).toHaveLength(1); @@ -129,9 +115,7 @@ describe('workers/repository/process/lookup', () => { config.rangeStrategy = 'pin'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); const res = await lookup.lookupUpdates(config); expect(res.updates).toMatchSnapshot(); expect(res.updates).toHaveLength(1); @@ -142,9 +126,7 @@ describe('workers/repository/process/lookup', () => { config.rangeStrategy = 'pin'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('returns both updates if automerging minor', async () => { @@ -153,9 +135,7 @@ describe('workers/repository/process/lookup', () => { config.rangeStrategy = 'pin'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('enforces allowedVersions', async () => { @@ -163,9 +143,7 @@ describe('workers/repository/process/lookup', () => { config.allowedVersions = '<1'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toHaveLength(1); }); it('falls back to semver syntax allowedVersions', async () => { @@ -174,9 +152,7 @@ describe('workers/repository/process/lookup', () => { config.depName = 'q'; config.versioning = dockerVersioning.id; // this doesn't make sense but works for this test config.datasource = datasourceNpm.id; // this doesn't make sense but works for this test - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toHaveLength(1); }); it('skips invalid allowedVersions', async () => { @@ -184,9 +160,7 @@ describe('workers/repository/process/lookup', () => { config.allowedVersions = 'less than 1'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); await expect(lookup.lookupUpdates(config)).rejects.toThrow( Error(CONFIG_VALIDATION) ); @@ -196,9 +170,7 @@ describe('workers/repository/process/lookup', () => { config.rangeStrategy = 'pin'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); const res = await lookup.lookupUpdates(config); expect(res.updates).toMatchSnapshot(); expect(res.updates).toHaveLength(2); @@ -213,9 +185,7 @@ describe('workers/repository/process/lookup', () => { config.rangeStrategy = 'pin'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); const res = await lookup.lookupUpdates(config); expect(res.updates).toMatchSnapshot(); expect(res.updates[0].updateType).toEqual('patch'); @@ -231,9 +201,7 @@ describe('workers/repository/process/lookup', () => { config.rangeStrategy = 'pin'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); const res = await lookup.lookupUpdates(config); expect(res.updates).toMatchSnapshot(); expect(res.updates[0].updateType).toEqual('minor'); @@ -244,9 +212,7 @@ describe('workers/repository/process/lookup', () => { config.rangeStrategy = 'pin'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('returns patch minor and major', async () => { @@ -255,9 +221,7 @@ describe('workers/repository/process/lookup', () => { config.rangeStrategy = 'pin'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); const res = await lookup.lookupUpdates(config); expect(res.updates).toHaveLength(3); expect(res.updates).toMatchSnapshot(); @@ -268,9 +232,7 @@ describe('workers/repository/process/lookup', () => { config.rangeStrategy = 'pin'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('disables major release separation (minor)', async () => { @@ -279,9 +241,7 @@ describe('workers/repository/process/lookup', () => { config.rangeStrategy = 'pin'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('uses minimum version for vulnerabilityAlerts', async () => { @@ -289,9 +249,7 @@ describe('workers/repository/process/lookup', () => { config.vulnerabilityAlert = true; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); const res = (await lookup.lookupUpdates(config)).updates; expect(res).toMatchSnapshot(); expect(res).toHaveLength(1); @@ -301,9 +259,7 @@ describe('workers/repository/process/lookup', () => { config.rangeStrategy = 'pin'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('ignores pinning for ranges when other upgrade exists', async () => { @@ -311,9 +267,7 @@ describe('workers/repository/process/lookup', () => { config.rangeStrategy = 'pin'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades minor ranged versions', async () => { @@ -321,9 +275,7 @@ describe('workers/repository/process/lookup', () => { config.rangeStrategy = 'pin'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('widens minor ranged versions if configured', async () => { @@ -331,9 +283,7 @@ describe('workers/repository/process/lookup', () => { config.rangeStrategy = 'widen'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('replaces minor complex ranged versions if configured', async () => { @@ -341,9 +291,7 @@ describe('workers/repository/process/lookup', () => { config.rangeStrategy = 'replace'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('widens major ranged versions if configured', async () => { @@ -371,9 +319,7 @@ describe('workers/repository/process/lookup', () => { config.rangeStrategy = 'pin'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('uses the locked version for pinning', async () => { @@ -382,9 +328,7 @@ describe('workers/repository/process/lookup', () => { config.rangeStrategy = 'pin'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('ignores minor ranged versions when not pinning', async () => { @@ -392,9 +336,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '^1.0.0'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toHaveLength(0); }); it('upgrades tilde ranges', async () => { @@ -402,9 +344,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '~1.3.0'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades .x minor ranges', async () => { @@ -412,9 +352,7 @@ describe('workers/repository/process/lookup', () => { config.rangeStrategy = 'pin'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades tilde ranges without pinning', async () => { @@ -422,9 +360,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '~1.3.0'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades .x major ranges without pinning', async () => { @@ -432,9 +368,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '0.x'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades .x minor ranges without pinning', async () => { @@ -442,9 +376,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '1.3.x'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades .x complex minor ranges without pinning', async () => { @@ -452,9 +384,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '1.2.x - 1.3.x'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades shorthand major ranges without pinning', async () => { @@ -462,9 +392,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '0'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades shorthand minor ranges without pinning', async () => { @@ -472,9 +400,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '1.3'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades multiple tilde ranges without pinning', async () => { @@ -482,9 +408,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '~0.7.0'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades multiple caret ranges without pinning', async () => { @@ -492,9 +416,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '^0.7.0'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('supports complex ranges', async () => { @@ -502,9 +424,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '^0.7.0 || ^0.8.0'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); const res = await lookup.lookupUpdates(config); expect(res.updates).toHaveLength(2); expect(res.updates[0]).toMatchSnapshot(); @@ -554,9 +474,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '~1.2.0 || ~1.3.0'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('returns nothing for greater than ranges', async () => { @@ -564,9 +482,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '>= 0.7.0'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toHaveLength(0); }); it('upgrades less than equal ranges without pinning', async () => { @@ -574,9 +490,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '<= 0.7.2'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades less than ranges without pinning', async () => { @@ -584,9 +498,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '< 0.7.2'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades less than major ranges', async () => { @@ -594,9 +506,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '< 1'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades less than equal minor ranges', async () => { @@ -604,9 +514,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '<= 1.3'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades equal minor ranges', async () => { @@ -614,9 +522,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '=1.3.1'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades less than equal major ranges', async () => { @@ -625,9 +531,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '<= 1'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades major less than equal ranges', async () => { @@ -635,9 +539,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '<= 1.0.0'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); const res = await lookup.lookupUpdates(config); expect(res.updates).toMatchSnapshot(); expect(res.updates[0].newValue).toEqual('<= 1.4.1'); @@ -647,9 +549,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '< 1.0.0'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); const res = await lookup.lookupUpdates(config); expect(res.updates).toMatchSnapshot(); expect(res.updates[0].newValue).toEqual('< 2.0.0'); @@ -659,9 +559,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '>= 0.5.0 < 1.0.0'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); const res = await lookup.lookupUpdates(config); expect(res.updates).toMatchSnapshot(); expect(res.updates[0].newValue).toEqual('>= 0.5.0 < 2.0.0'); @@ -671,9 +569,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '>= 0.5.0 <0.8'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); const res = await lookup.lookupUpdates(config); expect(res.updates).toMatchSnapshot(); expect(res.updates[0].newValue).toEqual('>= 0.5.0 <0.10'); @@ -684,9 +580,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '>= 0.5.0 <= 0.8.0'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); const res = await lookup.lookupUpdates(config); expect(res.updates).toMatchSnapshot(); expect(res.updates[0].newValue).toEqual('>= 0.5.0 <= 0.9.7'); @@ -697,9 +591,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '<= 0.8.0 >= 0.5.0'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); const res = await lookup.lookupUpdates(config); expect(res.updates).toMatchSnapshot(); }); @@ -708,18 +600,14 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '1.4.1'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('should ignore unstable versions if the current version is stable', async () => { config.currentValue = '2.5.16'; config.depName = 'vue'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/vue') - .reply(200, vueJson); + nock('https://registry.npmjs.org').get('/vue').reply(200, vueJson); expect((await lookup.lookupUpdates(config)).updates).toHaveLength(0); }); it('should allow unstable versions if the ignoreUnstable=false', async () => { @@ -727,9 +615,7 @@ describe('workers/repository/process/lookup', () => { config.ignoreUnstable = false; config.depName = 'vue'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/vue') - .reply(200, vueJson); + nock('https://registry.npmjs.org').get('/vue').reply(200, vueJson); const res = await lookup.lookupUpdates(config); expect(res.updates).toMatchSnapshot(); expect(res.updates).toHaveLength(1); @@ -884,9 +770,7 @@ describe('workers/repository/process/lookup', () => { config.rangeStrategy = 'replace'; config.depName = 'next'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/next') - .reply(200, nextJson); + nock('https://registry.npmjs.org').get('/next').reply(200, nextJson); const res = await lookup.lookupUpdates(config); expect(res.updates).toHaveLength(0); }); @@ -895,9 +779,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '^1.0.0'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('supports in-range tilde updates', async () => { @@ -905,9 +787,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '~1.0.0'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('supports in-range tilde patch updates', async () => { @@ -916,9 +796,7 @@ describe('workers/repository/process/lookup', () => { config.depName = 'q'; config.separateMinorPatch = true; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('supports in-range gte updates', async () => { @@ -926,9 +804,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '>=1.0.0'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('supports majorgte updates', async () => { @@ -936,9 +812,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '>=0.9.0'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('rejects in-range unsupported operator', async () => { @@ -946,9 +820,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '>1.0.0'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('rejects non-fully specified in-range updates', async () => { @@ -956,9 +828,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '1.x'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('rejects complex range in-range updates', async () => { @@ -966,9 +836,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '^0.9.0 || ^1.0.0'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('replaces non-range in-range updates', async () => { @@ -977,9 +845,7 @@ describe('workers/repository/process/lookup', () => { config.packageFile = 'package.json'; config.rangeStrategy = 'bump'; config.currentValue = '1.0.0'; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('handles github 404', async () => { @@ -987,9 +853,7 @@ describe('workers/repository/process/lookup', () => { config.datasource = datasourceGithubTags.id; config.packageFile = 'package.json'; config.currentValue = '1.0.0'; - nock('https://pypi.org') - .get('/pypi/foo/json') - .reply(404); + nock('https://pypi.org').get('/pypi/foo/json').reply(404); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('handles pypi 404', async () => { @@ -1008,9 +872,7 @@ describe('workers/repository/process/lookup', () => { config.packageFile = 'composer.json'; config.currentValue = '1.0.0'; config.registryUrls = ['https://packagist.org']; - nock('https://packagist.org') - .get('/packages/foo/bar.json') - .reply(404); + nock('https://packagist.org').get('/packages/foo/bar.json').reply(404); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('handles unknown datasource', async () => { @@ -1031,9 +893,7 @@ describe('workers/repository/process/lookup', () => { config.depName = 'q'; // TODO: we are using npm as source to test pep440 config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); const res = await lookup.lookupUpdates(config); expect(res.updates).toMatchSnapshot(); }); @@ -1041,9 +901,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '1.3.0'; config.depName = 'q'; config.datasource = datasourceNpm.id; - nock('https://registry.npmjs.org') - .get('/q') - .reply(200, qJson); + nock('https://registry.npmjs.org').get('/q').reply(200, qJson); const res = await lookup.lookupUpdates(config); expect(res).toMatchSnapshot(); expect(res.sourceUrl).toBeDefined(); @@ -1055,9 +913,7 @@ describe('workers/repository/process/lookup', () => { const returnJson = JSON.parse(JSON.stringify(qJson)); returnJson.name = 'q2'; returnJson.versions['1.4.1'].deprecated = 'true'; - nock('https://registry.npmjs.org') - .get('/q2') - .reply(200, returnJson); + nock('https://registry.npmjs.org').get('/q2').reply(200, returnJson); const res = await lookup.lookupUpdates(config); expect(res).toMatchSnapshot(); expect(res.updates[0].toVersion).toEqual('1.4.0'); @@ -1073,9 +929,7 @@ describe('workers/repository/process/lookup', () => { repository: { url: null, directory: 'test' }, }; - nock('https://registry.npmjs.org') - .get('/q3') - .reply(200, returnJson); + nock('https://registry.npmjs.org').get('/q3').reply(200, returnJson); const res = await lookup.lookupUpdates(config); expect(res).toMatchSnapshot(); expect(res.updates[0].toVersion).toEqual('1.4.1'); @@ -1113,7 +967,7 @@ describe('workers/repository/process/lookup', () => { const res = await lookup.lookupUpdates(config); expect(res).toMatchSnapshot(); }); - ['8.1.0', '8.1', '8'].forEach(currentValue => { + ['8.1.0', '8.1', '8'].forEach((currentValue) => { it('skips uncompatible versions for ' + currentValue, async () => { config.currentValue = currentValue; config.depName = 'node'; diff --git a/lib/workers/repository/process/lookup/index.ts b/lib/workers/repository/process/lookup/index.ts index 999e2e707d832ace2f4cc0b2878877b1886751d5..ec6c024f24e29738e4647674610cc14f36177ead 100644 --- a/lib/workers/repository/process/lookup/index.ts +++ b/lib/workers/repository/process/lookup/index.ts @@ -93,10 +93,10 @@ function getFromVersion( return currentValue.replace(/=/g, '').trim(); } logger.trace(`currentValue ${currentValue} is range`); - let useVersions = allVersions.filter(v => version.matches(v, currentValue)); + let useVersions = allVersions.filter((v) => version.matches(v, currentValue)); if (latestVersion && version.matches(latestVersion, currentValue)) { useVersions = useVersions.filter( - v => !version.isGreaterThan(v, latestVersion) + (v) => !version.isGreaterThan(v, latestVersion) ); } if (rangeStrategy === 'pin') { @@ -188,8 +188,8 @@ export async function lookupUpdates( const { latestVersion, releases } = dependency; // Filter out any results from datasource that don't comply with our versioning let allVersions = releases - .map(release => release.version) - .filter(v => version.isVersion(v)); + .map((release) => release.version) + .filter((v) => version.isVersion(v)); // istanbul ignore if if (allVersions.length === 0) { const message = `Found no results from datasource that look like a version`; @@ -208,14 +208,14 @@ export async function lookupUpdates( return res; } allVersions = allVersions.filter( - v => + (v) => v === taggedVersion || (v === currentValue && version.isGreaterThan(taggedVersion, currentValue)) ); } // Check that existing constraint can be satisfied - const allSatisfyingVersions = allVersions.filter(v => + const allSatisfyingVersions = allVersions.filter((v) => version.matches(v, currentValue) ); if (config.rollbackPrs && !allSatisfyingVersions.length) { @@ -236,8 +236,8 @@ export async function lookupUpdates( rangeStrategy = 'bump'; } const nonDeprecatedVersions = releases - .filter(release => !release.isDeprecated) - .map(release => release.version); + .filter((release) => !release.isDeprecated) + .map((release) => release.version); const fromVersion = getFromVersion( config, @@ -274,7 +274,7 @@ export async function lookupUpdates( dependency.latestVersion, allVersions, releases - ).filter(v => + ).filter((v) => // Leave only compatible versions version.isCompatible(v, currentValue) ); @@ -325,7 +325,7 @@ export async function lookupUpdates( if (!version.isVersion(update.newValue)) { update.isRange = true; } - const updateRelease = releases.find(release => + const updateRelease = releases.find((release) => version.equals(release.version, toVersion) ); // TODO: think more about whether to just Object.assign this @@ -336,7 +336,7 @@ export async function lookupUpdates( 'checksumUrl', 'newDigest', ]; - releaseFields.forEach(field => { + releaseFields.forEach((field) => { if (updateRelease[field] !== undefined) { update[field] = updateRelease[field]; } @@ -379,7 +379,7 @@ export async function lookupUpdates( } } else if (config.pinDigests) { // Create a pin only if one doesn't already exists - if (!res.updates.some(update => update.updateType === 'pin')) { + if (!res.updates.some((update) => update.updateType === 'pin')) { // pin digest res.updates.push({ updateType: 'pin', @@ -433,14 +433,14 @@ export async function lookupUpdates( } // Strip out any non-changed ones res.updates = res.updates - .filter(update => update.newDigest !== null) + .filter((update) => update.newDigest !== null) .filter( - update => + (update) => update.newValue !== config.currentValue || update.isLockfileUpdate || (update.newDigest && !update.newDigest.startsWith(config.currentDigest)) ); - if (res.updates.some(update => update.updateType === 'pin')) { + if (res.updates.some((update) => update.updateType === 'pin')) { for (const update of res.updates) { if (update.updateType !== 'pin' && update.updateType !== 'rollback') { update.blockedByPin = true; diff --git a/lib/workers/repository/process/lookup/rollback.ts b/lib/workers/repository/process/lookup/rollback.ts index 53cc2d2f13aca6961a4cea0af652ab2f91951e9c..8232a0c5c94070c830daa48499d80592aea3059a 100644 --- a/lib/workers/repository/process/lookup/rollback.ts +++ b/lib/workers/repository/process/lookup/rollback.ts @@ -23,7 +23,7 @@ export function getRollbackUpdate( ); return null; } - const lessThanVersions = versions.filter(v => + const lessThanVersions = versions.filter((v) => version.isLessThanRange(v, currentValue) ); // istanbul ignore if diff --git a/lib/workers/repository/process/write.ts b/lib/workers/repository/process/write.ts index 48a6d7e971ef3aab44eff76425fbe6f95b4bb04f..a95e3619cb089b5067070da9192ac38bf8856d36 100644 --- a/lib/workers/repository/process/write.ts +++ b/lib/workers/repository/process/write.ts @@ -19,11 +19,11 @@ export async function writeUpdates( `Processing ${branches.length} branch${ branches.length !== 1 ? 'es' : '' }: ${branches - .map(b => b.branchName) + .map((b) => b.branchName) .sort() .join(', ')}` ); - branches = branches.filter(branchConfig => { + branches = branches.filter((branchConfig) => { if (branchConfig.blockedByPin) { logger.debug(`Branch ${branchConfig.branchName} is blocked by a Pin PR`); return false; diff --git a/lib/workers/repository/updates/branchify.ts b/lib/workers/repository/updates/branchify.ts index e599dfacadd75254ee331a9ee9e1a03b6f813b83..9ab9f15a7267303e3a487f9b47057a85ac931e9f 100644 --- a/lib/workers/repository/updates/branchify.ts +++ b/lib/workers/repository/updates/branchify.ts @@ -38,7 +38,7 @@ export async function branchifyUpgrades( const updates = await flattenUpdates(config, packageFiles); logger.debug( `${updates.length} flattened updates found: ${updates - .map(u => u.depName) + .map((u) => u.depName) .join(', ')}` ); const errors: ValidationMessage[] = []; @@ -106,7 +106,7 @@ export async function branchifyUpgrades( removeMeta(['branch']); logger.debug(`config.repoIsOnboarded=${config.repoIsOnboarded}`); const branchList = config.repoIsOnboarded - ? branches.map(upgrade => upgrade.branchName) + ? branches.map((upgrade) => upgrade.branchName) : config.branchList; // istanbul ignore next try { diff --git a/lib/workers/repository/updates/flatten.spec.ts b/lib/workers/repository/updates/flatten.spec.ts index a75a12a83ef02e13fa86d7b4ee30b49aa1b984ae..0a444a57fae0651f5630bf0d9d71f2356fdadcff 100644 --- a/lib/workers/repository/updates/flatten.spec.ts +++ b/lib/workers/repository/updates/flatten.spec.ts @@ -75,7 +75,7 @@ describe('workers/repository/updates/flatten', () => { const res = await flattenUpdates(config, packageFiles); expect(res).toHaveLength(9); expect( - res.filter(r => r.updateType === 'lockFileMaintenance') + res.filter((r) => r.updateType === 'lockFileMaintenance') ).toHaveLength(2); }); }); diff --git a/lib/workers/repository/updates/flatten.ts b/lib/workers/repository/updates/flatten.ts index 7356951751b06b8c14c9200e768aa5dbe2784652..fe8c0882d5bc37ccb406d0d6919f8790eef1ea1d 100644 --- a/lib/workers/repository/updates/flatten.ts +++ b/lib/workers/repository/updates/flatten.ts @@ -13,7 +13,7 @@ import { getDefaultConfig } from '../../../datasource'; // Return only rules that contain an updateType function getUpdateTypeRules(packageRules: PackageRule[]): PackageRule[] { - return packageRules.filter(rule => is.nonEmptyArray(rule.updateTypes)); + return packageRules.filter((rule) => is.nonEmptyArray(rule.updateTypes)); } export async function flattenUpdates( @@ -112,6 +112,6 @@ export async function flattenUpdates( } } return updates - .filter(update => update.enabled) - .map(update => filterConfig(update, 'branch')); + .filter((update) => update.enabled) + .map((update) => filterConfig(update, 'branch')); } diff --git a/lib/workers/repository/updates/generate.ts b/lib/workers/repository/updates/generate.ts index 1e6078cfdea1924bcd96b8dfae5253a4f8ca4464..32cfc898e51e46ef55ae1ea25fced19894cb18dc 100644 --- a/lib/workers/repository/updates/generate.ts +++ b/lib/workers/repository/updates/generate.ts @@ -73,7 +73,7 @@ export function generateBranchConfig( const depNames = []; const newValue = []; const toVersions = []; - branchUpgrades.forEach(upg => { + branchUpgrades.forEach((upg) => { if (!depNames.includes(upg.depName)) { depNames.push(upg.depName); } @@ -306,21 +306,23 @@ export function generateBranchConfig( // Now assign first upgrade's config as branch config config = { ...config, ...config.upgrades[0], releaseTimestamp }; // TODO: fixme config.canBeUnpublished = config.upgrades.some( - upgrade => upgrade.canBeUnpublished + (upgrade) => upgrade.canBeUnpublished ); config.reuseLockFiles = config.upgrades.every( - upgrade => upgrade.updateType !== 'lockFileMaintenance' + (upgrade) => upgrade.updateType !== 'lockFileMaintenance' ); config.masterIssueApproval = config.upgrades.some( - upgrade => upgrade.masterIssueApproval + (upgrade) => upgrade.masterIssueApproval ); config.masterIssuePrApproval = config.upgrades.some( - upgrade => upgrade.prCreation === 'approval' + (upgrade) => upgrade.prCreation === 'approval' + ); + config.automerge = config.upgrades.every((upgrade) => upgrade.automerge); + config.blockedByPin = config.upgrades.every( + (upgrade) => upgrade.blockedByPin ); - config.automerge = config.upgrades.every(upgrade => upgrade.automerge); - config.blockedByPin = config.upgrades.every(upgrade => upgrade.blockedByPin); const tableRows = config.upgrades - .map(upgrade => getTableValues(upgrade)) + .map((upgrade) => getTableValues(upgrade)) .filter(Boolean); if (tableRows.length) { let table = []; diff --git a/package.json b/package.json index 6b6748fba57c3c5977905b6b9bb11a3006e5898e..d2f317e0e8e4b525163b330cdbe5240a73dd515b 100644 --- a/package.json +++ b/package.json @@ -245,7 +245,7 @@ "nock": "12.0.3", "npm-run-all": "4.1.5", "patch-package": "6.2.2", - "prettier": "1.19.1", + "prettier": "2.0.4", "pretty-quick": "2.0.1", "rimraf": "3.0.2", "semantic-release": "17.0.4", diff --git a/test/execUtil.ts b/test/execUtil.ts index d583c2c3f8eb2dce54050765c808083d3ba19a8a..d1ea80aac1cdea5d3745264f0f4a02fc5c015d99 100644 --- a/test/execUtil.ts +++ b/test/execUtil.ts @@ -52,7 +52,7 @@ export function mockExecSequence( execResults: ExecResult[] ): ExecSnapshots { const snapshots = []; - execResults.forEach(execResult => { + execResults.forEach((execResult) => { execFn.mockImplementationOnce((cmd, options, callback) => { snapshots.push(execSnapshot(cmd, options)); if (execResult instanceof Error) { diff --git a/test/newline-snapshot-serializer.ts b/test/newline-snapshot-serializer.ts index 0aa1c818f02892c44443069565b0b2f76a2be82b..86d72856e0e4c59159449fbbe1721e05739c213f 100644 --- a/test/newline-snapshot-serializer.ts +++ b/test/newline-snapshot-serializer.ts @@ -4,7 +4,7 @@ export function print(val: any): string { return JSON.stringify(val); } export function test(val: any): boolean { - if (['prBody', 'prTitle'].some(str => str === prev)) { + if (['prBody', 'prTitle'].some((str) => str === prev)) { return typeof val === 'string' && val.includes('\n'); } prev = val; diff --git a/test/static-files.spec.ts b/test/static-files.spec.ts index 946164b1abfa861c039ba792668c00ed3004fc5b..3a9d945fbab41e2f30c5086ea0d3e74e12bbc465 100644 --- a/test/static-files.spec.ts +++ b/test/static-files.spec.ts @@ -5,8 +5,8 @@ const glob = util.promisify(require('glob')); const ignoredExtensions = ['js', 'ts', 'md', 'pyc', 'DS_Store', 'map', 'snap']; function filterFiles(files: string[]): string[] { - return files.filter(file => - ignoredExtensions.every(extension => !file.endsWith(`.${extension}`)) + return files.filter((file) => + ignoredExtensions.every((extension) => !file.endsWith(`.${extension}`)) ); } diff --git a/test/util.ts b/test/util.ts index 0683f2f91da6497644a36416bd0b7d66f44f386c..4134b2a494437f5445db5f813e6082ca738c05f9 100644 --- a/test/util.ts +++ b/test/util.ts @@ -65,7 +65,7 @@ export const replacingSerializer = ( search: string, replacement: string ): jest.SnapshotSerializerPlugin => ({ - test: value => typeof value === 'string' && value.includes(search), + test: (value) => typeof value === 'string' && value.includes(search), serialize: (val, config, indent, depth, refs, printer) => { const replaced = (val as string).replace(search, replacement); return printer(replaced, config, indent, depth, refs); diff --git a/test/website-docs.spec.ts b/test/website-docs.spec.ts index 560b4438d21ccea8631dd7583b68c31fcfe6ec6b..b199495d11a831f048a536050e910d9b69f2eb6f 100644 --- a/test/website-docs.spec.ts +++ b/test/website-docs.spec.ts @@ -25,22 +25,22 @@ describe('docs', () => { ); const headers = doc .match(/\n## (.*?)\n/g) - .map(match => match.substring(4, match.length - 1)); + .map((match) => match.substring(4, match.length - 1)); const selfHostHeaders = selfHostDoc .match(/\n## (.*?)\n/g) - .map(match => match.substring(4, match.length - 1)); + .map((match) => match.substring(4, match.length - 1)); const expectedOptions = options - .filter(option => option.stage !== 'global') - .filter(option => option.releaseStatus !== 'unpublished') - .filter(option => !option.admin) - .filter(option => !option.parent) - .filter(option => !option.autogenerated) - .map(option => option.name) + .filter((option) => option.stage !== 'global') + .filter((option) => option.releaseStatus !== 'unpublished') + .filter((option) => !option.admin) + .filter((option) => !option.parent) + .filter((option) => !option.autogenerated) + .map((option) => option.name) .sort(); const selfHostExpectedOptions = options - .filter(option => option.admin || option.stage === 'global') - .map(option => option.name) + .filter((option) => option.admin || option.stage === 'global') + .map((option) => option.name) .sort(); it('has doc headers sorted alphabetically', () => { @@ -57,13 +57,13 @@ describe('docs', () => { }); const headers3 = doc .match(/\n### (.*?)\n/g) - .map(match => match.substring(5, match.length - 1)); + .map((match) => match.substring(5, match.length - 1)); headers3.sort(); const expectedOptions3 = options - .filter(option => option.stage !== 'global') - .filter(option => !option.admin) - .filter(option => option.parent) - .map(option => option.name) + .filter((option) => option.stage !== 'global') + .filter((option) => !option.admin) + .filter((option) => option.parent) + .map((option) => option.name) .sort(); expectedOptions3.sort(); it('has headers for every required sub-option', () => { @@ -72,8 +72,8 @@ describe('docs', () => { // Checking relatedOptions field in definitions const relatedOptionsMatrix = options - .filter(option => option.relatedOptions) - .map(option => option.relatedOptions) + .filter((option) => option.relatedOptions) + .map((option) => option.relatedOptions) .sort(); let relatedOptions: string[] = [].concat(...relatedOptionsMatrix); // Converts the matrix to an 1D array @@ -100,11 +100,11 @@ describe('docs', () => { }, }); - const allOptionNames = options.map(option => option.name).sort(); + const allOptionNames = options.map((option) => option.name).sort(); // Lists through each option in the relatedOptions array to be able to locate the exact element which causes error, in case of one it('has valid relateOptions values', () => { - relatedOptions.forEach(relOption => { + relatedOptions.forEach((relOption) => { expect(allOptionNames).toContainOption(relOption); }); }); diff --git a/tools/dispatch-release.mjs b/tools/dispatch-release.mjs index 2a3f5b250da7d565309fb8427920af42582cb37b..f8d418afddca37d3d369a60ab4204017fa6fd9f9 100644 --- a/tools/dispatch-release.mjs +++ b/tools/dispatch-release.mjs @@ -32,7 +32,7 @@ shell.echo(`Dispatching version: ${version}`); }, }, }); -})().catch(e => { +})().catch((e) => { // Ignore for now shell.echo(e.toString()); }); diff --git a/tools/eslint-gh-reporter.ts b/tools/eslint-gh-reporter.ts index 98dd272308d633c26aeaa1d476e98a0cc296ca61..e353ebe1c89586b2cd924c85e45215b89729a343 100644 --- a/tools/eslint-gh-reporter.ts +++ b/tools/eslint-gh-reporter.ts @@ -23,7 +23,7 @@ function getPath(path: string): string { return relative(ROOT, path).replace(/\\/g, '/'); } -const formatter: CLIEngine.Formatter = results => { +const formatter: CLIEngine.Formatter = (results) => { try { for (const { filePath, messages } of results) { const file = getPath(filePath); diff --git a/tools/generate-imports.ts b/tools/generate-imports.ts index c3f5bb8da68ed7dc40b199606b7af9770f90d173..8d26c7ef190099bcfcd73271b2fdac9fdc5a0a7c 100644 --- a/tools/generate-imports.ts +++ b/tools/generate-imports.ts @@ -13,9 +13,9 @@ if (!fs.existsSync('lib')) { function findModules(dirname: string): string[] { return fs .readdirSync(dirname, { withFileTypes: true }) - .filter(dirent => dirent.isDirectory()) - .map(dirent => dirent.name) - .filter(name => !name.startsWith('__')) + .filter((dirent) => dirent.isDirectory()) + .map((dirent) => dirent.name) + .filter((name) => !name.startsWith('__')) .sort(); } async function updateFile(file: string, code: string): Promise<void> { @@ -41,7 +41,7 @@ async function generate({ let imports = ''; let maps = ''; for (const ds of findModules(`lib/${path}`).filter( - n => !excludes?.includes(n) + (n) => !excludes?.includes(n) )) { const name = _.camelCase(ds); imports += `import * as ${name} from './${ds}';\n`; @@ -92,8 +92,8 @@ export default api; await Promise.all( shell .find('lib/**/*.generated.ts') - .filter(f => !newFiles.has(f)) - .map(file => fs.remove(file)) + .filter((f) => !newFiles.has(f)) + .map((file) => fs.remove(file)) ); } catch (e) { shell.echo(e.toString()); diff --git a/tools/jest-gh-reporter.ts b/tools/jest-gh-reporter.ts index 017f897a4d2ed9a741e4670220ee35ca689110cd..8898ebfe60eea3bd0c404c71a1d306378855780e 100644 --- a/tools/jest-gh-reporter.ts +++ b/tools/jest-gh-reporter.ts @@ -52,10 +52,10 @@ class GitHubReporter extends BaseReporter { return; } - for (const suite of testResult.testResults.filter(s => !s.skipped)) { + for (const suite of testResult.testResults.filter((s) => !s.skipped)) { const file = getPath(suite); for (const test of suite.testResults.filter( - t => !ignoreStates.has(t.status) + (t) => !ignoreStates.has(t.status) )) { const message = stripAnsi(test.failureMessages?.join('\n ')) || diff --git a/yarn.lock b/yarn.lock index 7ee22b31bb40b643c8504598e35eb09537e5aad9..d77bdaee6c9ade4e945c1a080e273a0dcc70cc4a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7676,10 +7676,10 @@ prepend-http@^2.0.0: resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897" integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc= -prettier@1.19.1: - version "1.19.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" - integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== +prettier@2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.4.tgz#2d1bae173e355996ee355ec9830a7a1ee05457ef" + integrity sha512-SVJIQ51spzFDvh4fIbCLvciiDMCrRhlN3mbZvv/+ycjvmF5E73bKdGfU8QDLNmjYJf+lsGnDBC4UUnvTe5OO0w== pretty-format@^25.2.1, pretty-format@^25.3.0: version "25.3.0"