-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce config migration whitespace changes for arrays #16383
Comments
what about using prettier API to format when a prettier config is found. 🤔 the API is very simple to use. |
It's a possibility. Won't cover all use cases though. BTW prettier still passes/accepts these changes AFAICT |
on my vscode it will revert the array changes on format. 🤔 |
I assumed that because our CI is not failing. Does |
maybe, not validated. most of the time the pre-commit hill will fix that for almost all my repos |
Here is a POC for recursively restore user format when key value pairs(objects) or keys(arrays) are the same between the original config file and the migrated to be committed string. some future work can be done for doing the same for migrated keys. An edge case that is not handled is a value type change (e.g. left: json config migration if/once this approach is accepted ill had the needed tests and open a PR. |
is this still an issue since we ran prettier? I don't like the manual way. Looks pretty hacky on JSON manipulation |
@rarkins Isn't this fixed by: |
I expected this would be fixed "well enough". Not sure if the remaining edge cases are worth the complexity |
heres a "before" with a |
what if we update the renovate.json with prettier regardless of the migration, then once migration is required the diff will be minimal. |
What would you like Renovate to be able to do?
Migrate a config containing arrays without changing the white space / line returns unnecessarily. For example here:
The first change is 100% unnecessary and should be avoided. The second would be a "nice to have" if we can avoid the change.
If you have any ideas on how this should be implemented, please tell us here.
We could add a new function which attempts to "harmonize" the result with the original, focusing on arrays of strings first.
Parse and iterate through the final config, looking for arrays of strings. If the same array with same contents exists in the original, then replace the raw content for that array in the migrated config with the raw content of the original config. Of course we must make sure that the result parses and is exactly the same.
Is this a feature you are interested in implementing yourself?
No
The text was updated successfully, but these errors were encountered: