Shareable Config Presets

Renovate supports an eslint-like approach to shareable configs, which we usually refer to as “presets”. These are added/configured via the "extends" field in any configuration object.

Goals of Preset Configs

The main reason for supporting preset configs is to decrease duplication:

  1. You shouldn’t need copy/paste config across all your repositories
  2. You shouldn’t need to reinvent any config “wheels” that others have invented before

A further reason was to make Renovate configuration “self-documenting”, but adding the "description" field to all preset configs.

Implementation Approach

In order to achieve the above goals, preset configs have been implemented to allow a very modular approach - preset configs may be as small as a partial package rule or as extensive as an entire configuration, like an eslint config.

Example configs

An example of a small rule is “:preserveSemverRanges”, which has the description “Preserve (but continue to upgrade) any existing semver ranges” and simply sets the configuration option pinVersions to false.

An example of a full config is “:library”, which is Renovate’s default configuration for packages that are requiredd by other packages. In this case, it maintains semver ranges for dependencies but pins them for devDependencies, amongst other rules.

Special note: the :xyz naming convention (with : prefix) is a special shorthand for the default presets. i.e. :xyz is equivalent to default:xyz.

How to Use Preset Configs

By default, the Renovate onboarding process will suggest either the ":app" or ":library" preset configs. A typical onboarding renovate.json will therefore look like this:

{
  "extends": [":library"]
}

Let’s say you wish to modify that default behaviour, such as to schedule Renovate to process upgrades only during non-office hours. In that case you could modify the default renovate.json to be like this:

{
  "extends": [":library", "schedule:nonOfficeHours"]
}

This makes use of the schedules presets. To see all presets published by the Renovate team them browse https://github.com/singapore/renovate-config/tree/master/packages

How to Publish Preset Configs

If you manage multiple repositories and want the same custom config across all or most of them, then you might want to consider publishing your own preset config so that you can “extend” it in every applicable repository.

Let’s say that your username on npm and elsewhere is “fastcore”. In that case, you can choose between publishing your preset config package as @fastcore/renovate-config or renovate-config-fastcore. Let’s assume you choose renovate-config-fastcore as the package name:

You then need to publish the renovate-config-fastcore package where the package.json contains the field renovate-config and then put your config under the field default. For example:

{
  "name": "renovate-config-fastcore",
  "version": "0.0.1",
  ...
  "renovate-config": {
    "default": {
      "extends": [":library", "schedule:nonOfficeHours"]  
    }
  }
}

Then in each of your repositories you can add your renovate config like:

  "extends": ["fastcore"]

Any repository including this config will then adopt the rules of the default library preset but schedule it on weeknights or weekends.

Note: if you prefer to publish using the namespace @fastcore/renovate-config then you would use the @ prefix instead:

  "extends": ["@fastcore"]

Contributing to presets

Have you configured a rule that you think others might benefit from? Please consider contributing it to the renovate-config repository so that it gains higher visibility and saves others from reinventing the same thing.