Skip to content

Releases: JuliaEditorSupport/JuliaFormatter.jl

v2.11.0

Choose a tag to compare

@github-actions github-actions released this 21 Jul 12:38
40c9de3

JuliaFormatter v2.11.0

Diff since v2.10.2

Added a new formatting option, enforce_triplequoted_docstrings, which controls whether single-quoted docstrings are expanded to triple-quoted docstrings.
By default this option is true, which is consistent with preexisting behaviour.
This option is only relevant if format_docstrings is also true (otherwise docstrings will always be ignored). (#1203, #1204)

When encountering invalid Julia code in docstrings JuliaFormatter will avoid formatting the code instead of crashing. (#1206, #1207)

When invalid formatting options are passed to format_text() and similar functions, JuliaFormatter now emits an info message.
(Note that for the CLI, specifying invalid arguments will cause an error.) (#1205, #1213)

Merged pull requests:

Closed issues:

  • Don't triple-quote short docstrings. (#1203)
  • warn if kwargs to format are unused (#1205)
  • format_docstring fails if any Julia code blocks are unparseable (#1206)

v2.10.2

Choose a tag to compare

@github-actions github-actions released this 19 Jul 07:32
47b7618

JuliaFormatter v2.10.2

Diff since v2.10.1

Documentation improvements only.

Merged pull requests:

Closed issues:

  • Minor gripe about formatting result (#31)
  • How to disable formatting of function calls? (#144)
  • overwrite = false should return contents of file (#167)
  • More options for full control instead of styles (#212)
  • Format long one-line boolean checks to if statements (#222)
  • Unfortunate comment intendation in if else block (#253)
  • Syntax errors should output location (#276)
  • Add integration tests for BlueStyle on a repo (#301)
  • Ability to turn off formatting for a directory? (#302)
  • Specifying optlevel for faster package loading (#356)
  • Invalid substitution of import with using (#398)
  • Tool to show errors at command line? (#400)
  • piping with |> inside a function gives weird behavior (#403)
  • Feature Request: Add a compact style for ccall-wrapper functions (#407)
  • use JuliaFormatter for pretty printing Julia expression (#414)
  • always_use_return extra indentation on first format (#428)
  • Array indexing (#466)
  • Show full location of parsing errors (including file name) (#469)
  • Space added around macro keywords assignment even with whitespace_in_kwargs = false (#492)
  • Ask Before Changes (#505)
  • JuliaFormatter is confused by literal number before broadcast operator (#537)
  • Large array literal split into one line per element (#563)
  • Strips inline comment and concatenates lines (#564)
  • Error message not helpful (#571)
  • SciML roll out of SciML Style (#610)
  • Simple way to create custom styles (#683)
  • Default formatting removes semi colon, breaking code (#774)
  • Does not format string interpolations (#834)
  • Ignore indentation effect of a specific block (#889)
  • separate_kwargs_with_semicolon has no effect inside macro calls, including @testset (#952)
  • Document formatting options according to their effect (#1102)
  • Unnecessary brackets are inserted in ranges (#1126)

v2.10.1

Choose a tag to compare

@github-actions github-actions released this 27 Jun 13:33
c8c21f5

JuliaFormatter v2.10.1

Diff since v2.10.0

Improve handling of inline comments at the top-level of a block. (#1194, #1195)

Merged pull requests:

Closed issues:

  • Formatting output changed in minor version increment (#1013)
  • Multi-line comments are merged into previous line (#1194)

v2.10.0

Choose a tag to compare

@github-actions github-actions released this 26 Jun 14:49
24c872c

JuliaFormatter v2.10.0

Diff since v2.9.3

Added a new formatting option, max_iterations, which controls the number of rounds of formatting that JuliaFormatter will apply.
This is a way to suppress non-idempotent formatting, at the cost of poorer performance.
Note that in principle this should not be necessary as ideally JuliaFormatter would produce idempotent formatting in a single pass.
However, depending on the style and options being used, this is not always possible.
This defaults to 1 for most styles, and 4 for SciMLStyle (note that this is pre-existing behaviour, but now it can be configured). (#1181, #1182)

Disabled syntax transformations inside macros and Expr objects by default.
Syntax transformations can never happen inside Expr objects because that causes the resulting Expr to be different from the original.
For macros, JuliaFormatter errs on the side of caution and does not apply syntax transformations inside macros, since macros can inspect and transform the code that is passed to them, and changing this code can lead to the macro performing different things.
There is a new formatting option, transform_syntax_in_macros, which can be set to true to re-enable syntax transformations inside macros if desired. (#1124, #1187)

Fixed a bug where whitespace around binary operators was not being respected, leading to a change in the meaning of the code. (#788, #1188)

Fixed a bug where Blue and YAS styles would over-aggressively un-nest contents, leading to comments being joined with source code. (#922, #1189)

Merged pull requests:

Closed issues:

  • Any broken symlink will break formatting (#671)
  • Formatting Requires Two format Calls for Long, Indented Comprehension (#727)
  • Valid julia expression not parsed properly (#788)
  • incorrect formatting of comments - Version 2 (#881)
  • Parsing error with BlueStyle, @kwdef default value and comment (#922)
  • Multiline strings + display width interaction Part 2 (#991)
  • Do not change things inside Exprs (#1124)
  • Regression tests run too quickly (#1138)
  • emojis and alignment (#1166)
  • Really specific newlines get swallowed between comments in vcat node (#1168)
  • Empty function (#1170)
  • Line comment after inline comment creates havoc (#1172)
  • disallow_single_arg_nesting logic is ?? (#1174)
  • Another chained ternary (#1177)
  • separate_kwargs_with_semicolon fails if there's a comment on the first line (#1179)
  • Add extra_iters option to suppress idempotence bugs (#1181)

v2.9.3

Choose a tag to compare

@github-actions github-actions released this 20 Jun 14:57
1b07c2f

JuliaFormatter v2.9.3

Diff since v2.9.2

Fixed a bug where even if Windows line endings were specified (either via normalize_line_endings="windows" or if the original file had Windows line endings), calling format() on the file would still append a final Unix trailing newline to the file. (#1156)

Improved the output of jlfmt --diff to show the full name of the file being formatted, instead of just the base name. (#1152, #1157)

Fixed a bug where expansion of chained ternary expressions with BlueStyle would cause incorrect indentation for parenthesised blocks (e.g. (p; q)). (#1159, #1158)

Fixed a bug where defining a function such as -(x) = ... (where the function is an operator, and there is only one argument) would cause separate_kwargs_with_semicolon to not be triggered for the first function call on the RHS of the function definition. (#1161, #1158)

Fixed a bug where macros with dots would be incorrectly formatted, e.g. Base.@. would be transformed to Base..@. (#1163, #1164)

Merged pull requests:

Closed issues:

  • jlfmt --diff does not print helpful file names (#1152)
  • More Blue idempotence failures on these files (#1155)
  • chained ternary idempotence (#1159)
  • separate_kwargs_with_semicolon doesn't fire sometimes (#1161)
  • Chained ternary expansion inside generator expression not idempotent (#1162)
  • Pathological macros (#1163)

v2.9.2

Choose a tag to compare

@github-actions github-actions released this 19 Jun 21:17
39c6098

JuliaFormatter v2.9.2

Diff since v2.9.1

Fixed a bug where pipe_to_function_call would remove parentheses from the argument of a function call even if the argument was an assignment, changing the meaning of the code. (#1147, #1148)

Fixed a bug where BlueStyle formatting of array literals which exceeded the margin was not idempotent. (#1149, #1150)

Fixed a bug where short_to_long_function_def would not apply the correct indentation to the function body, leading to non-idempotent formatting. (#1127, #1151)

Fixed a bug where formatting a begin ... end block that had nothing but whitespace or comments inside it would be non-idempotent, or delete comments inside it. (#1153, #1154)

Closed issues:

  • short to long function def has bad indentation (#1127)
  • pipe_to_function_call invalid transformation (#1147)
  • Weird idempotence issue with matrices in BlueStyle (#1149)
  • Empty blocks are not handled well (#1153)

v2.9.1

Choose a tag to compare

@github-actions github-actions released this 19 Jun 13:53
76ad802

JuliaFormatter v2.9.1

Diff since v2.9.0

Fixed a bug where separate_kwargs_with_semicolon would cause a change in the meaning of function calls such as f(p, q=r, s). (#625, #1141)

Fixed a bug where separate_kwargs_with_semicolon would not be triggered in certain cases, for example in the RHS of a short-form function definition, or in the default values of a function definition.
This bug also led to lack of idempotence in a number of cases (e.g. when a short-form function definition f(x, y) = g(x, y=z) was expanded to a long-form function definition, the second pass would then reformat the body of the function). (#1133, #1140, #1141)

Fixed a bug where comments in chained ternary expressions were not being handled correctly when expanded with BlueStyle, leading to invalid Julia code. (#1142, #1143)

Fixed a bug where keyword argument names that were operators were not being parenthesised when whitespace_in_kwargs = false, leading to invalid Julia code. (#1144, #1145)

Fixed a bug where short_to_long_function would trigger even inside macros or Expr objects, leading to a change in the meaning of the code. (#1124, #1145)

Fixed a bug where import_to_using would be triggered inside macros or Expr objects, leading to a change in the meaning of the code. (#1124, #1146)

Fixed a bug where import_to_using would be triggered for relative imports (e.g. import ..x, ..y), leading to a change in the meaning of the code.
This was previously fixed for single imports (e.g. import ..x), but not for multiple imports (e.g. import ..x, ..y). (#664, #723, #1146)

Merged pull requests:

Closed issues:

  • Misplaced semicolon in arbitrarily ordered keywords. (#625)
  • short to long function def + semicolon to kwarg idempotence (#1133)
  • separate_kwargs_with_semicolon doesn't fire even when it probably should (#1140)
  • BlueStyle chained ternary fails to format when comments precede some operation (#1142)
  • Apparently you can have < as a valid keyword argument? (#1144)

v2.9.0

Choose a tag to compare

@github-actions github-actions released this 18 Jun 20:58
49f36b0

JuliaFormatter v2.9.0

Diff since v2.8.5

Improved CLI exit codes (and error messages):

  • if the app errors, returns 2
  • if --check is enabled and files are not currently formatted, returns 1
  • if --check is enabled and files are already formatted, returns 0
  • otherwise returns 0.

Deprecated format_file(args...; kwargs...); format(args...; kwargs...) has exactly the same behaviour and can be used as a drop-in substitute. (#1137)

Added missing formatting options to the CLI app (previously only a subset of these could be specified on the command line). (#1135)

For all old formatting options, added aliases that used hyphens instead of underscores, and expect the actual value on the right-hand side of the = sign.
For example, what was previously --always_use_return and --no-always_use_return should now be specified as --always-use-return=true and --always-use-return=false.
This is done to improve consistency with .JuliaFormatter.toml and also generalisability to other types of options.
The underscore versions are still supported for backwards compatibility, but the hyphenated versions should be preferred going forwards. (#1135)

For all formatting options that require a value (e.g. --margin=80), also allow the value to be space-separated (i.e. --margin 80). (#1135)

Added an --ignore-config option to the CLI app, which will ignore any .JuliaFormatter.toml files and use only the options specified on the command line. (#1135)

Added a throw_on_error keyword argument to JuliaFormatter.format(), which causes any formatting errors to propagate to the caller. (#1130, #1136, #1139)

Merged pull requests:

Closed issues:

  • Inconsistent white-space around binary operators (#59)
  • Feature request: Options as a function argument have higher priority compared to config file (#639)
  • Refactor CLI arg parsing (#1031)
  • FormatBot still doesn't catch the case where formatting doesn't even work (#1130)
  • TagBot: Manual intervention needed for releases (#1134)
  • Fix format() API (#1136)

v2.8.5

Choose a tag to compare

@penelopeysm penelopeysm released this 17 Jun 13:05
aa86f82

Fixed more bugs where BlueStyle's chained-ternary-to-if conversion would lead to loss of idempotence. (#1131, #1132).

What's Changed

Full Changelog: v2.8.4...v2.8.5

v2.8.4

Choose a tag to compare

@github-actions github-actions released this 17 Jun 01:46
2864ae3

JuliaFormatter v2.8.4

Diff since v2.8.3

Disabled short_circuit_to_if for x && y and x || y statements at the end of a block (since the value of the expression is in fact being used).
This includes if there is a comment at the end of the function. (#887, #1129, #1128)

Fixed a bug where x && y would be expanded to if x; y; end with short_circuit_to_if=true even when the value of x && y was being used (e.g. as an argument to a function call), which would change the meaning of the code if x was false. (#1123, #1122)

Fixed a bug where indentation of x && y and x || y expressions were overly context-sensitive, leading to inconsistent and sometimes non-idempotent formatting. (#1121, #1122)

Fixed a bug where always_use_return would sometimes cause lack of idempotence.
(Note however that this option can still cause lack of idempotence if and only if combined with short_to_long_function_def.)
Furthermore, as a consequence of this fix, return will get prepended to throw(...) if that is the final expression in the function.
This differs from previous behaviour: if you do not want this, consider adding return nothing at the end of your function after the throw(...) statement, or just disable the always_use_return option. (#1125, #1128)

Closed issues:

  • unstable number of spaces between in do block before comment (#908)
  • range indexing idempotence (#1118)
  • blue idempotence on binary chain (#1121)
  • short_circuit_to_if considered harmful (#1123)
  • Properly fix always_use_return for the sake of proper idempotence (#1125)
  • short_circuit_to_if doesn't recognise comments (#1129)