Renovate: Refactor: Dedicated Location For All The Constants

Created on 2 Jan 2020  路  6Comments  路  Source: renovatebot/renovate

What would you like Renovate to be able to do?
Throughout the renovate codebase, a lot of constant is used, e.g. error type, error code, Http status code and etc. A better approach is to move them to a specific place. That will help code more readable and maintainable.

Describe the solution you'd like
Creating a directory named constants and creating files according to their category. Each file will export constants. Descriptions will be added to understand the constant if required.

Additional context
Here is the category of constants

  • [x] Errors
  • [ ] HTTP Status Codes
  • [x] Languages
  • [ ] Config Stages
  • [ ] Updates Type
  • [ ] Validation Constants
  • [ ] Migration constants eg. removed options
priority-3-normal

Most helpful comment

Let's start with any X that we new like new Error(X) currently. They can be defined in lib/constants/error-messages.ts.

All 6 comments

Let's start with the custom error codes we throw, e.g. repository-changed or registry-failure. Should we put each group into an extra file (e.g. lib/constraints/error-codes.ts) or combined into one file like lib/util/constants.ts? Any opinions @JamieMagee @ViceIce ?

I think multiple files are more readable. I think we have a lot constants. Maybe we can use typescript enum's for better compiletime checks.

Another option is to use literal types like:

export type RepositoryStatus = 'repository-changed' | 'other-state';

Let's start with any X that we new like new Error(X) currently. They can be defined in lib/constants/error-messages.ts.

:tada: This issue has been resolved in version 19.102.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

not yet finished

@rarkins @ViceIce Can you please help to point out what should we do next?
Should we go for HTTP statuses?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ChristianMurphy picture ChristianMurphy  路  4Comments

ZauberNerd picture ZauberNerd  路  4Comments

Flydiverny picture Flydiverny  路  4Comments

jycouet picture jycouet  路  4Comments

zephraph picture zephraph  路  3Comments