Enable :module_directives rule in Quokka#1921
Merged
Conversation
Remove the `:module_directives` exclusion from both formatter configs so Quokka organizes module directives consistently across the project. Files that intentionally place `@config_schema` before `@moduledoc` to interpolate schema docs into the moduledoc opt out via `# quokka:skip-module-directive-reordering`. `Backpex.Field` also gets explicit `Rendered`/`Socket` aliases so `@callback` specs resolve under the preserved source order. The demo's `post_live.ex` and `product_live.ex` use the broader `# quokka:skip-module-directives` since Quokka's alias lifting of `Backpex.Fields.Number` shadowed the `Number` Hex package used by `Number.Delimit`.
Quokka's reordering left some comments attached to the wrong directive, so drop the now-misleading comments.
Member
Author
|
@Flo0807 FYI: We can further improve this once emkguts/quokka#150 gets merged. |
Flo0807
reviewed
Apr 22, 2026
Configure Credo.Check.Design.AliasUsage to skip lifting modules under Backpex.Fields and any module whose last name is Type, so field modules and Ecto types like Money.Ecto.Amount.Type stay fully qualified. Defaults are pulled from Credo via param_defaults/0 to keep stdlib exclusions intact. De-lift existing usages accordingly.
The doctest module references each target exactly once, so alias lifting just adds noise. Mark the file with the `# quokka:skip-module-directives` magic comment so Quokka leaves the fully qualified `doctest` calls alone.
The directive was a workaround for Quokka lifting `Backpex.Fields.Number` and shadowing the `Number` Hex package used by `Number.Delimit`. With `Backpex.Fields` now globally excluded from alias lifting via the Credo `AliasUsage` config, the conflict cannot recur and the workaround is unnecessary.
Flo0807
approved these changes
Apr 29, 2026
Set `if_nested_deeper_than: 2` and `if_called_more_often_than: 1` on the Credo `AliasUsage` check so Quokka only lifts aliases for modules with at least three segments and at least two usages. Keeps the two-segment Phoenix/Backpex modules (e.g. `NimbleOptions.ValidationError`, `Backpex.Field`) fully qualified, which avoids the broken `use Field` / late-alias compile error in files that opt out of directive reordering. Restore the fully qualified `Backpex.Filter` references in `test/adapters/ecto_test.exs` since that single-segment alias falls below the new threshold.
Restore fully qualified `Backpex.Fields.*` references throughout the demo. The `Backpex.Fields` namespace is excluded from alias lifting in the Credo `AliasUsage` config, so leaving these aliased was an artifact of an earlier directive-reordering pass — Quokka never removes existing aliases on its own.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enables Quokka's
:module_directivesrule project-wide (previously excluded) so module directives get organized consistently. Files that intentionally define@config_schemabefore@moduledoc(to interpolateschema docs into the moduledoc) are opted out with
# quokka:skip-module-directive-reordering.Changes
exclude: [:module_directives]from the root and demo.formatter.exs.@config_schemabefore@moduledoc.Phoenix.LiveView.Rendered/Socketaliases inBackpex.Fieldso@callbackspecs resolve under the preserved source order.# quokka:skip-module-directivestopost_live.exandproduct_live.exin the demo, where Quokka's alias lifting ofBackpex.Fields.Numbershadowed theNumberHex package used byNumber.Delimit.