-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configure & activate JuliaFormatter #946
Draft
clizbe
wants to merge
9
commits into
spine-tools:master
Choose a base branch
from
clizbe:517_activate_julia_formatter
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
aaafa99
First commit to check formatter
clizbe f171462
Add second copy for testing
clizbe b4af7e8
Update JF.toml
clizbe 45cbb91
Updated JF.toml and Contributing to include JF
clizbe e6a6557
Removed pre-commit from CONTRIBUTING
clizbe 4883624
Add pre-commit-config.yaml
clizbe 3cfe835
Check pre-commit running
clizbe fb3d19e
Check pre-commit running
clizbe c234411
Remove markdown link check
clizbe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
margin = 120 | ||
margin = 119 | ||
always_for_in = true | ||
whitespace_in_kwargs = false | ||
remove_extra_newlines = true | ||
whitespace_ops_in_indices = true | ||
format_docstrings = true | ||
whitespace_in_kwargs = false | ||
format_docstrings = false | ||
separate_kwargs_with_semicolon = false | ||
verbose = true | ||
whitespace_typedefs = false | ||
join_lines_based_on_source = true | ||
surround_whereop_typeparameters = true | ||
trailing_comma = "nothing" | ||
align_conditional = true | ||
annotate_untyped_fields_with_any = true | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
hooks: | ||
- id: check-json | ||
- id: check-toml | ||
- id: check-yaml | ||
- id: end-of-file-fixer | ||
- id: file-contents-sorter | ||
files: .JuliaFormatter.toml | ||
args: [--unique] | ||
- id: mixed-line-ending | ||
args: [--fix=lf] | ||
- id: no-commit-to-branch | ||
- id: pretty-format-json | ||
args: [--autofix, --indent=4] | ||
- id: trailing-whitespace | ||
- repo: https://github.com/domluna/JuliaFormatter.jl | ||
rev: v1.0.35 | ||
hooks: | ||
- id: julia-formatter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,28 +10,43 @@ Thanks for taking the plunge! | |
|
||
* Feel free to open, or comment on, an issue and solicit feedback early on, especially if you're unsure about aligning with design goals and direction, or if relevant historical comments are ambiguous | ||
* When developing a new functionality or modifying an existing one, considering the following to work on (possibly in one pull request) | ||
+ Add the new functionality or modifying an existing one | ||
+ Pair the new functionality with tests, and bug fixes with tests that fail pre-fix. Increasing test coverage as you go is always nice | ||
+ Update the documentation (seen implementation details in the documentation for some advanced features) | ||
* Add the new functionality or modifying an existing one | ||
* Pair the new functionality with tests, and bug fixes with tests that fail pre-fix. Increasing test coverage as you go is always nice | ||
* Update the documentation (seen implementation details in the documentation for some advanced features) | ||
* Aim for atomic commits, if possible, e.g. `change 'foo' behavior like so` & `'bar' handles such and such corner case`, rather than `update 'foo' and 'bar'` & `fix typo` & `fix 'bar' better` | ||
* Pull requests will be tested against release and development branches of Julia, so using `Pkg.test("SpineOpt")` as you develop can be helpful | ||
* The style guidelines outlined below are not the personal style of most contributors, but for consistency throughout the project, we should adopt them | ||
* If you'd like to join our monthly developer meetings, just send us a message ([email protected]) | ||
|
||
## Style Guidelines | ||
|
||
* Include spaces | ||
+ After commas | ||
+ Around operators: `=`, `<:`, comparison operators, and generally around others | ||
+ But not after opening parentheses or before closing parentheses | ||
* Use four spaces for indentation (test data files and Makefiles excepted) | ||
* Don't leave trailing whitespace at the end of lines | ||
* Don't go over the 119 per-line character limit | ||
* Avoid squashing code blocks onto one line, e.g. `for foo in bar; baz += qux(foo); end` | ||
* Don't explicitly parameterize types unless it's necessary | ||
* Never leave things without type qualifications. Use an explicit `::Any`. | ||
* Order method definitions from most specific to least specific type constraints | ||
* If you'd like to join our monthly developer meetings, just send us a message (<[email protected]>) | ||
|
||
## Using JuliaFormatter | ||
|
||
We use [JuliaFormatter.jl](https://github.com/domluna/JuliaFormatter.jl) for code | ||
formatting and style. | ||
|
||
To install it, open Julia REPL, for example, by typing in the | ||
command line: | ||
|
||
```bash | ||
julia | ||
``` | ||
|
||
> **Note**: | ||
> `julia` must be part of your environment variables to call it from the | ||
> command line. | ||
|
||
Then press <kbd>]</kbd> to enter the package mode. | ||
In the package mode, enter the following: | ||
|
||
```julia | ||
pkg> activate | ||
pkg> add JuliaFormatter | ||
``` | ||
|
||
In VSCode, you can activate "Format on Save" for `JuliaFormatter`. | ||
To do so, open VSCode Settings (<kbd>Ctrl</kbd> + <kbd>,</kbd>), then in "Search | ||
Settings", type "Format on Save" and tick the first result. | ||
|
||
## Further questions | ||
|
||
* For developers there is some additional information in the implementation details (e.g. how to write a constraint). | ||
* You can talk to your fellow developers over gitter if the above is insufficient. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
annotate_untyped_fields_with_any = true? I think this should be false.
trailing_comma = "nothing"? we could have true here I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we can set untyped_fields to false.
For the trailing_comma, I set it to nothing because it seems we like using it in some cases and not in others, and I assumed there was a reason. But if there's no reason we can just enforce it. :)