Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions .github/workflows/PreCommit.yml
Copy link
Copy Markdown
Member Author

@penelopeysm penelopeysm May 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@digital-carver I took this one from your PR, #984, if that's OK, I had to change it anyway and hopefully it'll make it easier to handle merge conflicts.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# This workflow runs pre-commit on the JuliaFormatter repo itself, i.e.,
# checks that this repo is formatted.
name: Pre-Commit

# needed to allow julia-actions/cache to delete old caches that it has created
Expand All @@ -20,15 +22,20 @@ jobs:

steps:
- uses: actions/checkout@v6

# Note: Pkg App support only in >= 1.12
- uses: julia-actions/setup-julia@v3

- uses: julia-actions/cache@v3

- run: mkdir -p "${HOME}/.julia/environments/apps"
- name: Install local JuliaFormatter as Pkg app
run: julia --project -e 'using Pkg; Pkg.instantiate(); Pkg.Apps.develop(; path=pwd())'

- uses: astral-sh/setup-uv@v8.1.0
- run: uv tool install pre-commit
- run: |
- uses: actions/setup-python@v6
with:
python-version: '3.x'

- name: Run pre-commit hooks
run: |
export PATH=$PATH:${HOME}/.julia/bin/
pre-commit run --all-files --show-diff-on-failure --color always
pipx run pre-commit run --all-files --show-diff-on-failure --color always
46 changes: 46 additions & 0 deletions .github/workflows/PreCommitHooks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This workflow tests that the pre-commit hook works as expected.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I reverted the jlfmt pre-commit hook, we only have the 'old' hook to test, i.e. the one that calls julia -e 'using JuliaFormatter' .... Once we add the jlfmt hook back, this will be useful for also testing its behaviour.

name: PreCommitHooks
on:
push:
tags:
- '*'
branches:
- 'master'
pull_request:
branches:
- 'master'

jobs:
pre-commit:
name: julia-formatter hook
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6
with:
persist-credentials: false

- uses: julia-actions/setup-julia@v3
with:
version: '1'

- name: Install checked out JuliaFormatter in global env
run: |
julia -e 'using Pkg; Pkg.add(; path=".")'

- uses: actions/setup-python@v6
with:
python-version: '3.x'

- name: Test pre-commit hook
working-directory: .github/workflows/pre-commit
run: |
# Run pre-commit hook, check that it fails.
# pre-commit try-repo will fail if the hook makes changes
pipx run pre-commit try-repo ../../../ julia-formatter --files main.jl --verbose && exit 1
Comment thread
pfitzseb marked this conversation as resolved.

# Check that the file was changed.
git diff --exit-code main.jl && exit 1

# Check that running the hook again succeeds.
pipx run pre-commit try-repo ../../../ julia-formatter --files main.jl --verbose
3 changes: 3 additions & 0 deletions .github/workflows/pre-commit/main.jl
Comment thread
pfitzseb marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function f(x )
return x+1
end
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ repos:
always_run: false
types: [file]
files: \.(jl|[jq]?md)$
exclude: '^test/'
exclude: '^(test/|\.github/)'
language: "system"
- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes
- id: check-useless-excludes
2 changes: 1 addition & 1 deletion .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- id: julia-formatter
name: "Julia Formatter"
entry: "jlfmt --inplace"
entry: "julia -e 'import JuliaFormatter: format; format(ARGS)'"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cf. #968.

pass_filenames: true
always_run: false
types: [file]
Expand Down
8 changes: 0 additions & 8 deletions HELP.md

This file was deleted.

4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "JuliaFormatter"
uuid = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
version = "3.0"
authors = ["Dominique Luna <dluna132@gmail.com>"]
version = "2.3.0"
authors = ["Dominique Luna <dluna132@gmail.com> and contributors"]

[deps]
CommonMark = "a80b9123-70ca-4bc0-993e-6e3bcb318db6"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ julia> format_file("foo.jl")
julia> format_text(str)
```

Check out [the docs](https://domluna.github.io/JuliaFormatter.jl/stable/) for further description of the formatter and its options.
Check out [the docs](https://juliaeditorsupport.github.io/JuliaFormatter.jl/stable/) for further description of the formatter and its options.

## Command Line Tool

Expand Down
5 changes: 4 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ makedocs(;
warnonly = true,
)

deploydocs(; repo = "github.com/domluna/JuliaFormatter.jl.git", push_preview = true)
deploydocs(;
repo = "github.com/JuliaEditorSupport/JuliaFormatter.jl.git",
push_preview = true,
)
2 changes: 1 addition & 1 deletion docs/src/custom_alignment.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Custom Alignment

> Solution for [issue 179](https://github.com/domluna/JuliaFormatter.jl/issues/179)
> Solution for [issue 179](https://github.com/JuliaEditorSupport/JuliaFormatter.jl/issues/179)

Custom alignment is determined by a whitespace heuristic:

Expand Down
14 changes: 4 additions & 10 deletions docs/src/integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,20 @@

To learn more about `pre-commit`, [check out their docs](https://pre-commit.com).

With [Pull 674](https://github.com/domluna/JuliaFormatter.jl/pull/674), support for
With [Pull 674](https://github.com/JuliaEditorSupport/JuliaFormatter.jl/pull/674), support for
`pre-commit` was added. To add `JuliaFormatter.jl` to your own `pre-commit` workflow,
add the following to your `.pre-commit-config.yaml`.

```yaml
repos:
# ... other repos you may have
- repo: "https://github.com/domluna/JuliaFormatter.jl"
- repo: "https://github.com/JuliaEditorSupport/JuliaFormatter.jl"
rev: "v1.0.18" # or whatever the desired release is
hooks:
- id: "julia-formatter"
# ... other repos you may have
```

Note that it requires the `jlfmt` Pkg app to be installed with

```julia
pkg> app add JuliaFormatter
```

You can find a list of releases [here](https://github.com/domluna/JuliaFormatter.jl/releases).
You can find a list of releases [here](https://github.com/JuliaEditorSupport/JuliaFormatter.jl/releases).
**Be sure to use the entire version string!** (You can double-check this by opening the
release and looking at the part of the URL that follows `.../releases/tag/VERSION`.)
release and looking at the part of the URL that follows `.../releases/tag/VERSION`.)
2 changes: 1 addition & 1 deletion docs/src/style.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CurrentModule = JuliaFormatter
# Style

This is meant to give an impression of how the output of a formatted file looks like.
Additional examples can be found in the [test files](https://github.com/domluna/JuliaFormatter.jl/tree/master/test/files).
Additional examples can be found in the [test files](https://github.com/JuliaEditorSupport/JuliaFormatter.jl/tree/master/test/files).

## Initial `FST`

Expand Down
10 changes: 5 additions & 5 deletions docs/src/transforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## `for in` vs. `for =`

By default if the RHS is a range, i.e. `1:10` then `for in` is converted to `for =`. Otherwise `for =` is converted to `for in`. See [this issue](https://github.com/domluna/JuliaFormatter.jl/issues/34) for the rationale and further explanation.
By default if the RHS is a range, i.e. `1:10` then `for in` is converted to `for =`. Otherwise `for =` is converted to `for in`. See [this issue](https://github.com/JuliaEditorSupport/JuliaFormatter.jl/issues/34) for the rationale and further explanation.

Alternative to the above - setting `always_for_in` to `true`, i.e. `format_text(..., always_for_in = true)` will always convert `=` to `in` even if the RHS is a range.
`always_for_in=nothing` will leave the choice of `in` vs `=` up to the user.
Expand All @@ -23,7 +23,7 @@ func(
)
```

See [this issue](https://github.com/domluna/JuliaFormatter.jl/issues/44) for more details.
See [this issue](https://github.com/JuliaEditorSupport/JuliaFormatter.jl/issues/44) for more details.

## Trailing Semicolons

Expand All @@ -40,7 +40,7 @@ A = [
]
```

See [this issue](https://github.com/domluna/JuliaFormatter.jl/issues/77) for more details.
See [this issue](https://github.com/JuliaEditorSupport/JuliaFormatter.jl/issues/77) for more details.

## Leading and trailing 0s for float literals

Expand Down Expand Up @@ -74,7 +74,7 @@ a = 1f0
a = 1.0f0
```

See [this issue](https://github.com/domluna/JuliaFormatter.jl/issues/66) for more details.
See [this issue](https://github.com/JuliaEditorSupport/JuliaFormatter.jl/issues/66) for more details.

## Surround `where` arguments with curly brackets

Expand All @@ -88,7 +88,7 @@ foo(x::T) where T = ...
foo(x::T) where {T} = ...
```

See [this issue](https://github.com/domluna/JuliaFormatter.jl/issues/53) for more details.
See [this issue](https://github.com/JuliaEditorSupport/JuliaFormatter.jl/issues/53) for more details.

## Annotate unannotated type fields with `Any`

Expand Down
2 changes: 1 addition & 1 deletion src/fst.jl
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ for i = 1:10 body end
`always_for_in=nothing` disables this normalization behavior.
- <https://github.com/domluna/JuliaFormatter.jl/issues/34>
- <https://github.com/JuliaEditorSupport/JuliaFormatter.jl/issues/34>
"""
function eq_to_in_normalization!(fst::FST, always_for_in::Bool, for_in_replacement::String)
if fst.typ === Binary
Expand Down
2 changes: 1 addition & 1 deletion src/print.jl
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ function print_inlinecomment(io::IOBuffer, fst::FST, s::State)
if ws > 0
write(io, repeat(" ", ws))
elseif startswith(v, "#=") && endswith(v, "=#")
# hack to overcome the bug noticed in https://github.com/domluna/JuliaFormatter.jl/issues/571#issuecomment-1114446297
# hack to overcome the bug noticed in https://github.com/JuliaEditorSupport/JuliaFormatter.jl/issues/571#issuecomment-1114446297
# until multiline comments aren't moved to the end of the line.
write(io, " ")
end
Expand Down
2 changes: 1 addition & 1 deletion src/styles/blue/pretty.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ end
BlueStyle()

Formatting style based on [BlueStyle](https://github.com/invenia/BlueStyle)
and [JuliaFormatter#283](https://github.com/domluna/JuliaFormatter.jl/issues/283).
and [JuliaFormatter#283](https://github.com/JuliaEditorSupport/JuliaFormatter.jl/issues/283).

!!! note
This style is still work-in-progress, and does not yet implement all of the
Expand Down
2 changes: 1 addition & 1 deletion src/styles/yas/nest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function n_call!(
# The indent is set here to handle the edge
# case where the first argument of Call is
# nestable.
# ref https://github.com/domluna/JuliaFormatter.jl/issues/387
# ref https://github.com/JuliaEditorSupport/JuliaFormatter.jl/issues/387
fst.indent = s.line_offset + 1
end

Expand Down
2 changes: 1 addition & 1 deletion src/styles/yas/pretty.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ end
YASStyle()
Formatting style based on [YASGuide](https://github.com/jrevels/YASGuide)
and [JuliaFormatter#198](https://github.com/domluna/JuliaFormatter.jl/issues/198).
and [JuliaFormatter#198](https://github.com/JuliaEditorSupport/JuliaFormatter.jl/issues/198).
Configurable options with different defaults to [`DefaultStyle`](@ref) are:
$(list_different_defaults(YASStyle()))
Expand Down
16 changes: 8 additions & 8 deletions test/default_style.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1436,7 +1436,7 @@
begin
throw(ErrorException(\"""An error occured formatting \$filename. :-(

Please file an issue at https://github.com/domluna/JuliaFormatter.jl/issues
Please file an issue at https://github.com/JuliaEditorSupport/JuliaFormatter.jl/issues
with a link to a gist containing the contents of the file. A gist
can be created at https://gist.github.com/.\"""))
end
Expand All @@ -1446,7 +1446,7 @@
begin
throw(ErrorException(\"""An error occured formatting \$filename. :-(

Please file an issue at https://github.com/domluna/JuliaFormatter.jl/issues
Please file an issue at https://github.com/JuliaEditorSupport/JuliaFormatter.jl/issues
with a link to a gist containing the contents of the file. A gist
can be created at https://gist.github.com/.\"""))
end
Expand All @@ -1460,7 +1460,7 @@
ErrorException(
\"""An error occured formatting $filename. :-(

Please file an issue at https://github.com/domluna/JuliaFormatter.jl/issues
Please file an issue at https://github.com/JuliaEditorSupport/JuliaFormatter.jl/issues
with a link to a gist containing the contents of the file. A gist
can be created at https://gist.github.com/.\""",
),
Expand Down Expand Up @@ -2727,7 +2727,7 @@
@test fmt(str_) == str_
@test fmt(str_, 2, 1) == str

# https://github.com/domluna/JuliaFormatter.jl/issues/9#issuecomment-481607068
# https://github.com/JuliaEditorSupport/JuliaFormatter.jl/issues/9#issuecomment-481607068
str = """
this_is_a_long_variable_name = Dict{Symbol,Any}(
:numberofpointattributes => NAttributes,
Expand Down Expand Up @@ -2902,7 +2902,7 @@
arg3"""
@test fmt(str_, 4, 19) == str

# https://github.com/domluna/JuliaFormatter.jl/issues/60
# https://github.com/JuliaEditorSupport/JuliaFormatter.jl/issues/60
str_ = """
function write_subproblem_to_file(
node::Node, filename::String;
Expand Down Expand Up @@ -2955,7 +2955,7 @@
end"""
@test fmt(str, 4, 1) == str

# https://github.com/domluna/JuliaFormatter.jl/issues/453
# https://github.com/JuliaEditorSupport/JuliaFormatter.jl/issues/453
str = """
bar = Dict(
:foo => \"""A triple quoted literal string
Expand Down Expand Up @@ -3126,7 +3126,7 @@
_, s = run_nest(str, 73)
@test s.line_offset == 9

# https://github.com/domluna/JuliaFormatter.jl/issues/9#issuecomment-481607068
# https://github.com/JuliaEditorSupport/JuliaFormatter.jl/issues/9#issuecomment-481607068
str = """this_is_a_long_variable_name = Dict{Symbol,Any}(:numberofpointattributes => NAttributes,
:numberofpointmtrs => NMTr, :numberofcorners => NSimplex, :firstnumber => Cint(1),
:mesh_dim => Cint(3),)"""
Expand Down Expand Up @@ -3497,7 +3497,7 @@
""") == "0.1 + 0.2\n"
end

# https://github.com/domluna/JuliaFormatter.jl/issues/77
# https://github.com/JuliaEditorSupport/JuliaFormatter.jl/issues/77
@testset "matrices" begin
str_ = """
[ a b expr()
Expand Down
Loading
Loading