Skip to content

Rework migrate options for the formatter #13841

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

Merged
merged 1 commit into from
Sep 20, 2024

Conversation

sabiwara
Copy link
Contributor

@sabiwara sabiwara commented Sep 20, 2024

This is the first step of reworking how we organize and define migration options to the formatter, which can be summarized by the following doc update:

Screenshot 2024-09-20 at 10 50 58 Screenshot 2024-09-20 at 10 51 30
  • normalize_ options become migrate_ options
  • instead of being true by default, migrate_ options will default to a new migrate option, itself defaulting to false
  • Code.quoted_to_algebra was relying on normalize_charlists_as_sigils so that charlists would be represented as sigils => should be the responsibility of the normalizer, this is now fixed
  • the biggest part of the actual diff is actually fixing tests and moving migration tests to their own file

Next steps:

  • add migrate_unless
  • add the --migrate option to mix format

assert_same ~S['']
assert_same ~S[' ']
assert_same ~S['foo']
assert_same ~S[~c""]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests were misleading since what we are actually comparing is sigils.

Copy link
Contributor Author

@sabiwara sabiwara Sep 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also fixes these warnings 🧘
Screenshot 2024-09-20 at 14 28 16

Copy link
Member

@josevalim josevalim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful. ❤️ My only remaining suggestion, which may be part of this PR or the next one, is to change the warnings for 'charlist' and <<1::integer()>> to mention they can be fixed with mix format --migrate :)

@sabiwara
Copy link
Contributor Author

My only remaining suggestion, which may be part of this PR or the next one, is to change the warnings for 'charlist' and <<1::integer()>> to mention they can be fixed with mix format --migrate :)

Great point, will add this in the PR adding --migrate!

@sabiwara sabiwara merged commit 5eddb4b into elixir-lang:main Sep 20, 2024
9 checks passed
@sabiwara sabiwara deleted the format-migrate branch September 20, 2024 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants