Releases: JuliaEditorSupport/JuliaFormatter.jl
Release list
v2.11.0
JuliaFormatter v2.11.0
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:
- Opting out of
enforce_triplequote_docstring. (#1204) (@iago-lito) - Avoid formatting invalid code in docstrings (#1207) (@penelopeysm)
- Update GHA for default branch change (#1208) (@penelopeysm)
- Make FormatBot use jlfmt + convert to local script (#1209) (@penelopeysm)
- FormatBot testing (#1210) (@penelopeysm)
- [skip ci] GHA fixes (#1211) (@penelopeysm)
- [skip ci] more GHA fixes (#1212) (@penelopeysm)
- Emit info message when passing unused kwargs (#1213) (@penelopeysm)
Closed issues:
v2.10.2
JuliaFormatter v2.10.2
Documentation improvements only.
Merged pull requests:
- Bump actions/cache from 6.0.0 to 6.1.0 (#1196) (@dependabot[bot])
- Add more docs on gha (#1197) (@penelopeysm)
- More docs on how to use a local pre-commit hook (#1198) (@penelopeysm)
- Bump julia-actions/julia-runtest from 1.11.5 to 1.12.0 (#1199) (@dependabot[bot])
- Add testing on 1.13 (#1201) (@penelopeysm)
- Fix docs and bump a patch (#1202) (@penelopeysm)
Closed issues:
- Minor gripe about formatting result (#31)
- How to disable formatting of function calls? (#144)
overwrite = falseshould 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
importwithusing(#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_returnextra 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_semicolonhas 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
JuliaFormatter v2.10.1
Improve handling of inline comments at the top-level of a block. (#1194, #1195)
Merged pull requests:
- Fix inline comment whitespace handling (#1195) (@penelopeysm)
Closed issues:
v2.10.0
JuliaFormatter v2.10.0
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:
- Update regression workflow (#1165) (@penelopeysm)
- Use textwidth() instead of length() (#1167) (@penelopeysm)
- Fix array in array bug (#1169) (@penelopeysm)
- fix empty function def (#1171) (@penelopeysm)
- fix comment (#1173) (@penelopeysm)
- Disable pipe_to_function_call in CI (#1176) (@penelopeysm)
- fix chained ternary + standalone shortcircuit interaction (#1178) (@penelopeysm)
- Fix semicolon coming after comment when
separate_kwargs_with_semicolon=true(#1180) (@penelopeysm) - Iters (#1182) (@penelopeysm)
- Bump actions/checkout from 6 to 7 (#1183) (@dependabot[bot])
- Bump julia-actions/julia-runtest from 1.11.4 to 1.11.5 (#1184) (@dependabot[bot])
- Bump actions/cache from 5.0.5 to 6.0.0 (#1185) (@dependabot[bot])
- Add Helix instructions (#1186) (@penelopeysm)
- Disable syntax transformations by default (#1187) (@penelopeysm)
- Fix spacing around binary operators when child CST has whitespace (#1188) (@penelopeysm)
- Fix overly aggressive un-nesting (#1189) (@penelopeysm)
- Improve error display (#1190) (@penelopeysm)
- Fix format() calling _format_file on unformattable files (#1191) (@penelopeysm)
- Changelog (#1192) (@penelopeysm)
Closed issues:
- Any broken symlink will break formatting (#671)
- Formatting Requires Two
formatCalls for Long, Indented Comprehension (#727) - Valid julia expression not parsed properly (#788)
- incorrect formatting of comments - Version 2 (#881)
- Parsing error with BlueStyle,
@kwdefdefault 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
JuliaFormatter v2.9.3
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:
- fix unhelpful diff filenames (#1157) (@penelopeysm)
- More BlueStyle idempotence fixes (#1158) (@penelopeysm)
- Rein in macro
@movement (#1164) (@penelopeysm)
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_semicolondoesn't fire sometimes (#1161)- Chained ternary expansion inside generator expression not idempotent (#1162)
- Pathological macros (#1163)
v2.9.2
JuliaFormatter v2.9.2
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:
v2.9.1
JuliaFormatter v2.9.1
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:
- Fix
separate_kwargs_with_semicolonovercautiousness (#1141) (@penelopeysm) - Fix chained ternary comments with binary op conditions (#1143) (@penelopeysm)
- Parenthesise operators that are kwarg names (#1145) (@penelopeysm)
- Fix overeager
import_to_using(#1146) (@penelopeysm)
Closed issues:
- Misplaced semicolon in arbitrarily ordered keywords. (#625)
- short to long function def + semicolon to kwarg idempotence (#1133)
separate_kwargs_with_semicolondoesn'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
JuliaFormatter v2.9.0
Improved CLI exit codes (and error messages):
- if the app errors, returns 2
- if
--checkis enabled and files are not currently formatted, returns 1 - if
--checkis 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:
- Rewrite CLI argument parsing code (#1135) (@penelopeysm)
- Simplify options / config / format_text dispatch (#1137) (@penelopeysm)
- throw on format (#1139) (@penelopeysm)
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
Fixed more bugs where BlueStyle's chained-ternary-to-if conversion would lead to loss of idempotence. (#1131, #1132).
What's Changed
- Fix blue chained ternary idempotence issue by @penelopeysm in #1132
Full Changelog: v2.8.4...v2.8.5
v2.8.4
JuliaFormatter v2.8.4
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_ifconsidered harmful (#1123)- Properly fix always_use_return for the sake of proper idempotence (#1125)
- short_circuit_to_if doesn't recognise comments (#1129)