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

Offer an option for YAML indent option #9355

Closed
myermian opened this issue Oct 8, 2020 · 13 comments
Closed

Offer an option for YAML indent option #9355

myermian opened this issue Oct 8, 2020 · 13 comments
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.

Comments

@myermian
Copy link

myermian commented Oct 8, 2020

I came across issue #4723 wherein the community decided on the indentation style for yaml mappings. It seems that the community voted to indent sequences, which is how the tool currently works. I recently started implementing prettier in my repositories, but this is causing a problem.

Microsoft's documentation examples are all based on "do not indent".

Example: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/runtime-parameters?view=azure-devops&tabs=script#use-parameters-in-pipelines

parameters:
- name: image
  displayName: Pool Image
  type: string
  default: ubuntu-latest
  values:
  - windows-latest
  - vs2017-win2016
  - ubuntu-latest
  - ubuntu-16.04
  - macOS-latest
  - macOS-10.14

trigger: none

jobs:
- job: build
  displayName: build
  pool: 
    vmImage: ${{ parameters.image }}
  steps:
  - script: echo building $(Build.BuildNumber) with ${{ parameters.image }}

I'm now stuck with a dilemma. Do I keep prettier "as-is", which will format all of my yml files, as well as yml code blocks in my markdown files or do I utilize prettierignore to ignore the Azure Pipeline yml files, and any markdown files related to Azure Pipelines?

One of my repositories houses over 100 yml files (Azure Pipeline YAML templates), as well as markdown files which document and give examples of those pipeline files. On top of that, I have a lot of repositories that contain an azure-pipelines.yml and azurepipelines-coverage.yml file.

I realize that Prettier is very opionionated about code formatting, but is this a possible option that can be added?

@lydell
Copy link
Member

lydell commented Oct 8, 2020

Hi!

This is Wikipedia’s definition of “dilemma”:

A dilemma is a problem offering two possibilities, neither of which is unambiguously acceptable or preferable.

I can see that you have two possibilities – to format or not to format, that is the question – but you didn’t mention the pros and cons of each choice? To me it sounds like you’re into the concept of having automatic formatting, so running Prettier on all those files is the clear winner. Without more details it’s hard for us to give any advice. What exactly is the problem you have?

@lydell lydell added the status:awaiting response Issues that require answers to questions from maintainers before action can be taken label Oct 8, 2020
@myermian
Copy link
Author

myermian commented Oct 8, 2020

Well, leaving aside if I used the word 'dilemma' properly, I will say that yes, I see two options:

  • Use prettier as-is, which will reformat all of my YAML pipeline files, as well as all of my markdown files which contain YML code blocks. I would gain other auto-formatting rules that come with prettier.
  • Set up my prettierignore file to ignore YAML pipeline (.yml) and markdown files (.md), keeping YAML sequence indentation in tact. If I go onto Azure DevOps and generate a YAML file the files are generated this way. This would keep my YAML pipeline files consistent across those environments, but I lose other formatting options since prettier is no longer applied.

My ultimate preference it the best of both worlds... to use prettier, but to have an option for YAML sequence indentation rules.

@no-response no-response bot removed the status:awaiting response Issues that require answers to questions from maintainers before action can be taken label Oct 8, 2020
@lydell
Copy link
Member

lydell commented Oct 9, 2020

I don’t see how the indent option is going to help you? You’ll still have cases where Prettier changes the generated yaml files because of other little formatting differences.

(Note: I wasn’t trying to nitpick on the word “dilemma” – I meant that it didn’t seem like you had a dilemma given the info your provided. “Use Prettier as-is” was the clear winner.)

@lydell lydell added the status:awaiting response Issues that require answers to questions from maintainers before action can be taken label Oct 9, 2020
@myermian
Copy link
Author

myermian commented Oct 9, 2020

I don’t see how the indent option is going to help you? You’ll still have cases where Prettier changes the generated yaml files because of other little formatting differences.

I thought my examples were clear, so I'm not sure what else to add to them.

@no-response no-response bot removed the status:awaiting response Issues that require answers to questions from maintainers before action can be taken label Oct 9, 2020
@lydell
Copy link
Member

lydell commented Oct 9, 2020

Ok. Since the option philosophy states that the bar for new options is very high, I’ll close this then if we don’t have a super clear reason for it.

@lydell lydell closed this as completed Oct 9, 2020
@LEI

This comment has been minimized.

@lydell

This comment has been minimized.

@LEI

This comment has been minimized.

@lydell

This comment has been minimized.

@LEI

This comment has been minimized.

@lydell

This comment has been minimized.

@LEI

This comment has been minimized.

@lydell

This comment has been minimized.

@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Feb 16, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

No branches or pull requests

3 participants