|
| 1 | +# Repository Management and Code Standards |
| 2 | + |
| 3 | +JupyterHub projects should take advantage of pre-commit and tools to help maintain consistent formatting within a repo to improve overall code quality, review efficiency, and readability of code. |
| 4 | +Sensible use of pre-commit to run formatting tools and code linters can add consistency and improve maintainability. |
| 5 | + |
| 6 | +## Preferred tools and pre-commit hooks |
| 7 | + |
| 8 | +The team has found the following tools and their pre-commit hooks to be useful. The following pre-commit hooks can be added to any repo when convenient, though please communicate with anyone who has an open pull request if it will lead to major conflicts: |
| 9 | + |
| 10 | + - [black](https://black.readthedocs.io/) |
| 11 | + - [prettier](https://prettier.io/) |
| 12 | + - [flake8](https://flake8.pycqa.org/en/latest/) |
| 13 | + - **TODO: standard pre-commit hooks, such as isort, etc. (To be determined and listed here)** |
| 14 | + |
| 15 | +## Applying to repos |
| 16 | + |
| 17 | +When creating a new repo, please use any pre-commit hooks and tools that are useful. |
| 18 | + |
| 19 | +When working with an existing repo, please balance the benefits of adding a tool or pre-commit hook with considerations such as |
| 20 | + - the amount of code churn |
| 21 | + - how it will improve code maintainability |
| 22 | + - the time it may add to CI runs. |
| 23 | + |
| 24 | +## Configuration of a tool |
| 25 | + |
| 26 | +In general using the default settings for tools is preferred, but use your judgment as to whether to apply a stricter or more lenient configuration for linting code. |
| 27 | +Example configurations are in: |
| 28 | + |
| 29 | + - [JupyterHub](https://github.com/jupyterhub/jupyterhub/) (a large repository which was converted and therefore has a fairly lax configuration) |
| 30 | + - [nativeauthenticator](https://github.com/jupyterhub/nativeauthenticator) (a fairly strict configuration) |
| 31 | + |
| 32 | +Other linters, autoformatters and tools can be added to other repos on an ad-hoc basis if it's not too disruptive- this is a good way to try out new tools. |
| 33 | +In general, big changes should not be made to high profile repos without prior discussion. |
| 34 | + |
| 35 | +## Proposing organization-wide use of a tool |
| 36 | + |
| 37 | +If the new tool is useful across the organisation please propose it in a new team-compass GitHub issue, outlining the advantages and disadvantages. |
0 commit comments