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

Lint YAML especially .hlint.yaml. #5797

Merged
merged 8 commits into from Jul 31, 2022

Conversation

philderbeast
Copy link
Contributor

The vscode editor showed problems with .hlint.yaml. I was able to reproduce these before fixing them by installing and configuring yamllint for which I added a GitHub action. In reviewing .hlint.yaml I saw that we should have been adding our errors before any ignores. Added a comment introducing why we have the "Use alternative" ignore. The ignore for "Too strict maybe" was repeated so I reduced this duplication collecting the within modules together. For YAML linting I'm ignoring most of .gitub/workflows/, doc and test folders.

I pulled the hlint action out of the unit-tests action and used haskell/actions/setup-hlint for the set up.

@mpilgrem
Copy link
Member

Looking at the files that have changed, some of them seem to have changed largely because indentation has been added or increased. May I ask, what is the rationale for those changes?

@philderbeast
Copy link
Contributor Author

philderbeast commented Jul 29, 2022

what is the rationale for those changes?

Within vscode I used format document (is that by the YAML extension?). I also have the linter extension. This fixed the linting problems in files other than .hlint.yaml, see c65226b.

@philderbeast
Copy link
Contributor Author

This is what I first saw in vscode (or something similar), problems with the HLint configuration:

Screen Shot 2022-07-29 at 3 39 19 PM

@mpilgrem
Copy link
Member

mpilgrem commented Jul 29, 2022

On the linting of YAML, as you can see, historically, the stylistic preference here has been what I think yamllint refers to as indentation: {spaces: 2, indent-sequences: false}.

@philderbeast
Copy link
Contributor Author

I use package.dhall with the same hpack phraseology. With dhall I get a formatter included out of the box.

> dhall-hpack-cabal --force
generated plugins-for-blobs.cabal
> dhall format package.dhall

The option of formatting package.yaml is new to me. I would guess the historical stylistic preference is to not use an automatic formatter and go with whatever is easiest to type or, if you're like me, copy an existing package.yaml from another project before adding and removing items.

@mpilgrem mpilgrem merged commit e8fdb2d into commercialhaskell:master Jul 31, 2022
@mpilgrem
Copy link
Member

Thanks! I've merged that, with a little tinkering. It seemed to me sensible to apply it to all of the YAML files in the respository. It also seemed to me sensible to combine all linting (yamllint, HLint) into a single 'linting' workflow. I did change the .yamllint.yaml to be tolerant of (in fact, require) an indentation style that followed what was already used in the repository. I dealt with the truthy problem by turning it off for the keys (it was only GitHub Actions' on: key that was tripping it).

@philderbeast
Copy link
Contributor Author

I did change the .yamllint.yaml to be tolerant of (in fact, require) an indentation style that followed what was already used in the repository.

@mpilgrem the github workflow sample code uses indented arrays.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants