Skip to content

Releases: emkguts/quokka

v2.13.1

19 May 17:09

Choose a tag to compare

Fixes

  • Fix Enum.reduce/3 in a pipe being incorrectly rewritten to a nonexistent two-argument Enum.sum call. Piped lhs |> Enum.reduce(acc, reducer) was styled as Enum.reduce/2 and could emit invalid Enum.sum(acc) when the reducer was a simple sum. Fixes #160.
  • Fix autosort stealing comments from earlier in the module when sorting multi-line maps. Comments such as # credo:disable-for-next-line in unrelated code could be detached from the lines they suppress. Fixes #161.

v2.13.0

18 May 20:55

Choose a tag to compare

Breaking Changes

  • Sorting is now split into two independent mechanisms. See Autosort for the full comparison.
    • Config autosort (maps, defstructs, schemas): controlled by autosort: [...] and the :autosort style in :only or :exclude.
    • # quokka:sort (per-value, opt-in): always runs; not affected by :only, :exclude, or exclude: [:autosort].
  • If you use :only or :exclude to limit which styles run, replace :comment_directives with :autosort to control config-driven sorting. The autosort: [...] option is unchanged.

Improvements

  • Added support for plugins; see Quokka.Plugin docs for details on creating your own formatting rules.
  • Overhaul config-driven autosort: extracted into a dedicated style with its own docs. Maps with comments are now autosorted (comments stay with their keys). Use # quokka:skip-sort on the line above a value to opt out.
  • Support # quokka:sort for struct field keys in @type definitions (e.g. @type t :: %__MODULE__{...}).
  • Respect Credo's Credo.Check.Readability.OnePipePerLine — breaks pipe chains so each |> is on its own line when the check is enabled.
  • Respect Credo's Credo.Check.Refactor.CondStatements configuration. Set the check to false to disable cond simplification.
  • Module directive skip comments (# quokka:skip-module-directives, # quokka:skip-module-directive-reordering, etc.) now work inside defimpl blocks. Module directives in defimpl and defprotocol are reordered when no skip comment is present.
  • Respect Credo's Credo.Check.Readability.StrictModuleLayout ignore_module_attributes and ignore: [:module_attribute] options. When a module contains an ignored module attribute, Quokka preserves the original directive order for that module rather than hoisting directives above the attribute (which could be referenced by an earlier-ordered directive such as @moduledoc). Fixes #137.
  • Rewrite Enum.reduce/2,3 calls that simply sum their two arguments to Enum.sum/1 (part of inefficient function rewrites).
  • Rewrite Enum.drop/2 + Enum.take/2 to Enum.slice/3 when both arguments are non-negative integer literals (part of inefficient function rewrites).

Fixes

  • Fix alias duplication in # quokka:skip-module-directive-reordering mode when an existing alias was also referenced from non-alias content.
  • Fix crash when formatting empty modules (e.g. a defmodule with no body inside a quote block).
  • Fix autosort so comments above map keys are preserved correctly after sorting.

Deprecations

  • :comment_directives is no longer a valid :only or :exclude style. Use :autosort to control config-driven sorting instead. # quokka:sort always runs and cannot be disabled. exclude: [:comment_directives] has no effect and logs a warning; only: [:comment_directives] no longer enables config autosort — add :autosort if you need it.

v2.12.1

12 Feb 15:59

Choose a tag to compare

Fixes

  • Fix crash when checking pipe start validity

v2.12.0

08 Feb 23:05

Choose a tag to compare

Breaking Changes

  • Multi-alias sorting now matches Credo.Check.Readability.AliasOrder behavior by comparing the first child's full path instead of parent module only. This fixes compatibility with Credo 1.7.13+, which fixed a bug that now properly checks multi-alias ordering. Projects using Credo 1.7.12 or earlier may see new alias ordering changes when formatting. Upgrading to Credo 1.7.13+ is recommended for proper alias order checking.

Improvements

  • Automatically fix Credo.Check.Refactor.UtcNowTruncate by rewriting DateTime.utc_now() |> DateTime.truncate(precision) to DateTime.utc_now(precision).
  • Transform Timex.today() to Date.utc_today().
  • Rewrite Map/Keyword.get(lhs, key, nil) to Map/Keyword.get(lhs, key).
  • Consecutive Keyword.drop or Keyword.delete rewrite to Keyword.drop as part of inefficient function rewrites.
  • Respect Credo's NegativeConditionsWithElse configuration.
  • Add comment directive # quokka:skip-module-directive-reordering for skipping module directive reordering to skip module directive reordering but still lift aliases, multi-alias expansion, etc.
  • Support piped function exclusions in SinglePipe rewrite.
  • Support rewriting pipes within a case ... do block to instead pipe into case. Add exclude: [:pipe_into_case] to opt out of this behavior.

Fixes

  • Fix invalid inefficient function rewrites on Map.reduce arguments.
  • Sort nested module directives (e.g., alias A.{B, E, C} will be sorted to alias A.{B, C, E}).

Upgrades

  • Upgrade credo to 1.7.16
  • Add Elixir 1.19.1 and OTP 28.1.1 to CI checks

Deprecations

  • Soft deprecate quokka:skip-module-reordering in favor of quokka:skip-module-directives.

v2.11.2

27 Aug 13:27

Choose a tag to compare

Fixes

  • Fix crash in sorting when schema definition occurs through a macro.

v2.11.1

26 Aug 16:17

Choose a tag to compare

Fixes

  • Improved error handling
  • Handle rewriting anonymous function captures of variables

v2.11.0

20 Aug 22:28

Choose a tag to compare

Improvements

  • Support :only config option for Credo.Check.Design.AliasUsage.
  • Rewrite multiple Map.delete to Map.drop.
  • Rewrite &my_func(&1) => &my_func/1 where relevant.
  • Rewrite Enum.filter(fun) |> List.first([default]) => Enum.find([default], fun)

Fixes

  • Set default Elixir version as empty string for language server compatibility.
  • Do not dealias within moduledocs depending on the module layout order.
  • Properly autosort embedded schema.
  • Strict module layout styling fail for non-existent keys.

v2.10.0

29 Jul 15:57

Choose a tag to compare

Improvements

  • Rewrite refute not => assert

v2.9.1

13 Jul 20:39

Choose a tag to compare

Fixes

  • Include ranges in numeric sorting.

v2.9.0

13 Jul 17:41

Choose a tag to compare

Improvements

  • Rewrite inefficient Repo existence checks (Repo.one => Repo.exists? where appropriate)

New rewrite type: tests

Quokka will style your tests. For now, the main rewrite is assert not gets rewritten to refute. If you don't want this rewrite, add exclude: [:tests].

Fixes

  • In autosort, sort numeric keys naturally (ie, 1, 2, 10 instead of 1, 10, 2).
  • Update mix.exs changelog link to use hexdocs.