Skip to content

Don't lift require aliases due to our ordering rules#13

Merged
JesseHerrick merged 1 commit intomainfrom
require-alias-lifting-ordering
May 6, 2026
Merged

Don't lift require aliases due to our ordering rules#13
JesseHerrick merged 1 commit intomainfrom
require-alias-lifting-ordering

Conversation

@JesseHerrick
Copy link
Copy Markdown
Member

@JesseHerrick JesseHerrick commented May 6, 2026

Our module directive ordering is slightly different than upstream Styler. We put requires before alias always. This means that any alias lifting that also rewrites require to use the alias will cause compilation to fail. To fix this, we:

  • Don't rewrite require modules. If they're written fully qualified, leave them be.
  • Don't count require fully qualified module calls against our fully qualified module limit before lifting the alias.

Note

Low Risk
Low risk formatter change: it narrows alias-application behavior to avoid generating invalid require directives under the project’s strict ordering rules. Main impact is changed formatted output for modules that previously had require shortened via lifted aliases.

Overview
Prevents alias lifting/alias application from shortening require Foo.Bar into require Bar, since requires are ordered above alias and would otherwise reference an alias declared later (invalid Elixir).

Updates expectations and adds regression coverage to ensure require stays fully-qualified while non-directive usages are still rewritten to the lifted alias.

Reviewed by Cursor Bugbot for commit b063690. Bugbot is set up for automated code reviews on this repo. Configure here.

@remotecom remotecom force-pushed the require-alias-lifting-ordering branch from 496b62f to b063690 Compare May 6, 2026 05:03
@JesseHerrick JesseHerrick self-assigned this May 6, 2026
@JesseHerrick JesseHerrick merged commit 3fba40b into main May 6, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant