diff --git a/.github/workflows/PreCommit.yml b/.github/workflows/PreCommit.yml index 118630726..9adb32946 100644 --- a/.github/workflows/PreCommit.yml +++ b/.github/workflows/PreCommit.yml @@ -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 @@ -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 diff --git a/.github/workflows/PreCommitHooks.yml b/.github/workflows/PreCommitHooks.yml new file mode 100644 index 000000000..3c1a1c403 --- /dev/null +++ b/.github/workflows/PreCommitHooks.yml @@ -0,0 +1,46 @@ +# This workflow tests that the pre-commit hook works as expected. +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 + + # 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 diff --git a/.github/workflows/pre-commit/main.jl b/.github/workflows/pre-commit/main.jl new file mode 100644 index 000000000..eed70a9df --- /dev/null +++ b/.github/workflows/pre-commit/main.jl @@ -0,0 +1,3 @@ +function f(x ) +return x+1 +end diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f4bdd044c..a87f8a14c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 \ No newline at end of file + - id: check-useless-excludes diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 953a92134..0cde3066b 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -1,6 +1,6 @@ - id: julia-formatter name: "Julia Formatter" - entry: "jlfmt --inplace" + entry: "julia -e 'import JuliaFormatter: format; format(ARGS)'" pass_filenames: true always_run: false types: [file] diff --git a/HELP.md b/HELP.md deleted file mode 100644 index 4d9c96ea9..000000000 --- a/HELP.md +++ /dev/null @@ -1,8 +0,0 @@ -Simply put, I'm looking for a new maintainer for JuliaFormatter.jl. I no longer have the bandwidth nor the desire to keep working on this project. If you would like to be involved please reach out to me at the email in my profile. - -You can stop reading at this point if you wish. I'll write a short blurb as to why I'm making this decision. - -* I no longer have the time to meaningfully work on this project. In order for this project to progress someone else has to take the reins. -* I no longer have fun working on this project. There used to be a time where receiving an issue notification in my email was exciting. I would fix the issue, or think about the feature request, and then work on it. This gave me joy. I used really, really enjoy this. Even though this project did everything I ever wanted pre 1.0, if I could make a change that would benefit someone else it would make me happy. The whole concept of "styles" was to be as accommodating as possible. A few years in, this stopped. -* I'm making mistakes. I recently committed a change that broke pre commit CI and truth be told I was an autopilot throughout this - and not the good kind! ()Is there good kind?) I wouldn't have made these errors before , but I'm making them now. -* Realistically, I probably should have done this a couple of years ago. diff --git a/Project.toml b/Project.toml index b38498062..e1c767ab8 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "JuliaFormatter" uuid = "98e50ef6-434e-11e9-1051-2b60c6c9e899" -version = "3.0" -authors = ["Dominique Luna "] +version = "2.3.0" +authors = ["Dominique Luna and contributors"] [deps] CommonMark = "a80b9123-70ca-4bc0-993e-6e3bcb318db6" diff --git a/README.md b/README.md index 798e39914..c8667d9f5 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/make.jl b/docs/make.jl index d49b410f5..8784bf841 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -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, +) diff --git a/docs/src/custom_alignment.md b/docs/src/custom_alignment.md index 97e13e474..f30e48ee6 100644 --- a/docs/src/custom_alignment.md +++ b/docs/src/custom_alignment.md @@ -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: diff --git a/docs/src/integrations.md b/docs/src/integrations.md index 190f7d99c..f1c6cb58d 100644 --- a/docs/src/integrations.md +++ b/docs/src/integrations.md @@ -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`.) \ No newline at end of file +release and looking at the part of the URL that follows `.../releases/tag/VERSION`.) diff --git a/docs/src/style.md b/docs/src/style.md index 5114bfdac..215aa182f 100644 --- a/docs/src/style.md +++ b/docs/src/style.md @@ -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` diff --git a/docs/src/transforms.md b/docs/src/transforms.md index 88e0dede8..fcab185ae 100644 --- a/docs/src/transforms.md +++ b/docs/src/transforms.md @@ -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. @@ -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 @@ -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 @@ -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 @@ -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` diff --git a/src/fst.jl b/src/fst.jl index 7bfd6120e..ea025e75e 100644 --- a/src/fst.jl +++ b/src/fst.jl @@ -784,7 +784,7 @@ for i = 1:10 body end `always_for_in=nothing` disables this normalization behavior. -- +- """ function eq_to_in_normalization!(fst::FST, always_for_in::Bool, for_in_replacement::String) if fst.typ === Binary diff --git a/src/print.jl b/src/print.jl index 0e0775ab0..cbbe6b083 100644 --- a/src/print.jl +++ b/src/print.jl @@ -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 diff --git a/src/styles/blue/pretty.jl b/src/styles/blue/pretty.jl index caf5cf869..0c3f1a6be 100644 --- a/src/styles/blue/pretty.jl +++ b/src/styles/blue/pretty.jl @@ -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 diff --git a/src/styles/yas/nest.jl b/src/styles/yas/nest.jl index 0febaa75e..ba41ff863 100644 --- a/src/styles/yas/nest.jl +++ b/src/styles/yas/nest.jl @@ -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 diff --git a/src/styles/yas/pretty.jl b/src/styles/yas/pretty.jl index 622dff4ce..dddd3c5e9 100644 --- a/src/styles/yas/pretty.jl +++ b/src/styles/yas/pretty.jl @@ -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())) diff --git a/test/default_style.jl b/test/default_style.jl index 825338465..5e7f619eb 100644 --- a/test/default_style.jl +++ b/test/default_style.jl @@ -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 @@ -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 @@ -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/.\""", ), @@ -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, @@ -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; @@ -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 @@ -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),)""" @@ -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() diff --git a/test/files/noformat2.jl b/test/files/noformat2.jl index fce70f8df..fd1ec088a 100644 --- a/test/files/noformat2.jl +++ b/test/files/noformat2.jl @@ -1266,7 +1266,7 @@ end 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 @@ -1276,7 +1276,7 @@ end 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 @@ -2206,7 +2206,7 @@ end end""" @test fmt(str_, 4, 24) == 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, @@ -2345,7 +2345,7 @@ end @test fmt(str_, 4, 7) == str @test fmt(str_, 4, 1) == 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; @@ -2547,7 +2547,7 @@ end s = run_nest(str, length(str) - 1) @test s.line_offset == 12 - # 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),)""" @@ -2814,7 +2814,7 @@ end """) == "0.1 + 0.2\n" end - # https://github.com/domluna/JuliaFormatter.jl/issues/77 + # https://github.com/JuliaEditorSupport/JuliaFormatter.jl/issues/77 @testset "issue 77" begin str_ = """ [ a b Expr() diff --git a/test/options.jl b/test/options.jl index eec4aa39a..328a5fe93 100644 --- a/test/options.jl +++ b/test/options.jl @@ -2063,7 +2063,7 @@ # NOTE: not sure since test makes sense anymore. # It is generally not a great idea to remove the semicolons here since # it can be potentially change the semantics or lead to code errors. - # https://github.com/domluna/JuliaFormatter.jl/issues/745 + # https://github.com/JuliaEditorSupport/JuliaFormatter.jl/issues/745 @testset "matrices" begin str_ = """ T[ a b Expr(); diff --git a/test/sciml_style.jl b/test/sciml_style.jl index f8a44126f..8ed8b5799 100644 --- a/test/sciml_style.jl +++ b/test/sciml_style.jl @@ -307,7 +307,7 @@ # Test `variable_call_indent` with an inline comment after the opening parenthesis # With `variable_call_indent = false`, the comment will be eaten, - # see https://github.com/domluna/JuliaFormatter.jl/issues/609 + # see https://github.com/JuliaEditorSupport/JuliaFormatter.jl/issues/609 @test format_text(str, SciMLStyle()) == formatted_str1 @test format_text(str, SciMLStyle(); variable_call_indent = ["Dict"]) == formatted_str2 diff --git a/test/yas_style.jl b/test/yas_style.jl index c6a1c0879..86c87ad18 100644 --- a/test/yas_style.jl +++ b/test/yas_style.jl @@ -736,7 +736,7 @@ # Test `variable_call_indent` with an inline comment after the opening parenthesis # With `variable_call_indent = false`, the comment will be eaten, - # see https://github.com/domluna/JuliaFormatter.jl/issues/609 + # see https://github.com/JuliaEditorSupport/JuliaFormatter.jl/issues/609 @test format_text(str, YASStyle()) == formatted_str1 @test format_text(str, YASStyle(); variable_call_indent = ["Dict"]) == formatted_str2