Skip to content
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

Use prettier #1470

Merged
merged 35 commits into from
Mar 18, 2022
Merged

Use prettier #1470

merged 35 commits into from
Mar 18, 2022

Conversation

ewels
Copy link
Member

@ewels ewels commented Mar 17, 2022

PR checklist

  • This comment contains a description of changes (with reason)
  • CHANGELOG.md is updated
  • If you've fixed a bug or added code that should be tested, add tests!
  • Documentation in docs is updated

Copy link
Contributor

@edmundmiller edmundmiller left a comment

Choose a reason for hiding this comment

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

Looks like a great start!

@codecov

This comment was marked as resolved.

@ewels
Copy link
Member Author

ewels commented Mar 17, 2022

I tried having 2 space indentation for everything, but 4 spaces for markdown files:

printWidth: 120
tabWidth: 2
overrides:
  - files:
      - "*.md"
    options:
      tabWidth: 4

But Prettier apparently has a weird bug where doing this results in markdown lists with indentation after the bullet:

-   Updated `nf-core download` to work with latest DSL2 syntax for containers ([#1379](https://github.com/nf-core/tools/issues/1379))
-   Made `nf-core modules create` detect repository type with explicit `.nf-core.yml` instead of random readme stuff ([#1391](https://github.com/nf-core/tools/pull/1391))
-   Added a Gitpod environment and Dockerfile ([#1384](https://github.com/nf-core/tools/pull/1384))
    -   Adds conda, Nextflow, nf-core, pytest-workflow, mamba, and pip to base Gitpod Docker image.

should be:

- Updated `nf-core download` to work with latest DSL2 syntax for containers ([#1379](https://github.com/nf-core/tools/issues/1379))
- Made `nf-core modules create` detect repository type with explicit `.nf-core.yml` instead of random readme stuff ([#1391](https://github.com/nf-core/tools/pull/1391))
- Added a Gitpod environment and Dockerfile ([#1384](https://github.com/nf-core/tools/pull/1384))
    - Adds conda, Nextflow, nf-core, pytest-workflow, mamba, and pip to base Gitpod Docker image.

This is discussed in prettier/prettier#5019 but is not yet resolved.

Anyway, I can't remember why we wanted 4-space indentation in markdown now? I think it was GitHub rendering, but I just checked this PR and it seems to render fine. I found some GitHub issues suggesting that this used to be a problem on GitHub but since they changed markdown renderers (years ago now) it's not. So maybe this fixed itself?

Anyway, TLDR is that everything is 2-space indentation now, including markdown. Hopefully this doesn't break too much stuff.

@ewels
Copy link
Member Author

ewels commented Mar 17, 2022

I don't understand why the CI tests can't find the repository type 🤔

@ewels
Copy link
Member Author

ewels commented Mar 17, 2022

ohh it's because it's not within the pipeline repo 🤦🏻

Ok then we should probably also make the error message more obvious here 😅

@ewels ewels added the WIP Work in progress label Mar 17, 2022
@ewels ewels marked this pull request as draft March 17, 2022 23:32
@ewels
Copy link
Member Author

ewels commented Mar 17, 2022

Right, that'll do for tonight.

Still want to do a sanity check that the output from the pipeline template is basically (functionally) still the same and that I haven't accidentally broken anything in the GitHub actions workflows for example. But basically ready for review and testing now I think....??

edmundmiller added a commit to nf-core/modules that referenced this pull request Mar 18, 2022
@ewels ewels removed the WIP Work in progress label Mar 18, 2022
@ewels ewels marked this pull request as ready for review March 18, 2022 08:29
@ewels ewels linked an issue Mar 18, 2022 that may be closed by this pull request
@ewels
Copy link
Member Author

ewels commented Mar 18, 2022

Ok, updated to keep 4-space indentation for JSON files to make the diff as small as possible so that template merges are not a nightmare.

Also fixed some other linting errors in created pipelines.

@@ -30,13 +30,13 @@ input:

## TODO nf-core: Add a description of all of the variables used as output
output:
{% if has_meta -%}
#{% if has_meta -%} Only when we have meta
Copy link
Member

Choose a reason for hiding this comment

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

was commenting the line here intended?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes - Prettier breaks if it can't parse the YAML files. Sticking the Jinja templating stuff either in quotes or on comment lines means that the template is still valid YAML and so prettier can format it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Note that this is a YAML comment and Jinja ignores it. If we wanted a Jinja comment that's done with {# jinja here #}. So the YAML comment # here has no effect.

Copy link
Contributor

Choose a reason for hiding this comment

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

https://prettier.io/docs/en/ignore.html#yaml
I think this is what we need.

@ggabernet
Copy link
Member

The changes due to the new linter look good to me, not too many changes are needed!

Copy link
Member

@apeltzer apeltzer left a comment

Choose a reason for hiding this comment

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

Had to partially re-review after starting yesterday already and some changes came in later 👍🏻 Looks very good to me, lets hope its not too much effort when the template updates are coming in ;-)

@ewels ewels merged commit 3abb7ef into nf-core:dev Mar 18, 2022
@ewels ewels deleted the use-prettier branch March 18, 2022 10:55
ewels added a commit to nf-core/modules that referenced this pull request Mar 18, 2022
* style: Add prettier config files

* build: Add prettier vscode extension

* ci: Replace markdownlint and yamllint with prettier

* style: Run prettier

* style: Use indent of 2 for markdown as well

nf-core/tools#1470 (comment)

* style: Fix indent

* style: Let editorconfig take over tab widths

* style: yaml => yml

* ci: Run prettier once

Co-authored-by: Phil Ewels <[email protected]>

Co-authored-by: Phil Ewels <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Rewrite YAML + Markdown linting, use Prettier
4 participants