Skip to content

Update Prettier & EditorConfig files#1651

Open
uncenter wants to merge 8 commits into11ty:mainfrom
uncenter-contrib:add-prettier
Open

Update Prettier & EditorConfig files#1651
uncenter wants to merge 8 commits into11ty:mainfrom
uncenter-contrib:add-prettier

Conversation

@uncenter
Copy link
Copy Markdown
Member

@uncenter uncenter commented Jan 6, 2024

Closes #1610.

@uncenter uncenter changed the title Add prettier/editorconfigs from 11ty/eleventy, update prettier Add prettier/editorconfigs from 11ty/eleventy, format files Jan 6, 2024
@uncenter
Copy link
Copy Markdown
Member Author

I won't format the files in this PR to avoid conflicts, but we should run the command at some point...

Copy link
Copy Markdown
Member

@Snapstromegon Snapstromegon left a comment

Choose a reason for hiding this comment

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

Hi,
I'm all pro adding a formatter. Did you try running this and see if it has problems with the autogenerated files?
Also do you know whether or not this is run on any git hooks (this might lead to issues until all files in the repo are formatted)?

@uncenter
Copy link
Copy Markdown
Member Author

uncenter commented Jan 11, 2024

Also do you know whether or not this is run on any git hooks (this might lead to issues until all files in the repo are formatted)?

I don't really understand or use Git hooks but it looks to be the case:

  "lint-staged": {
    "*.{js,css,md}": [
      "prettier --write",
      "git add"
    ]
  },

I chose to avoid formatting it here because a) the diff is huge, +-30k lines, and b) I don't want to block other PRs.

Did you try running this and see if it has problems with the autogenerated files?

What do you mean by autogenerated files? If there are any we can just add them to a .prettierignore. There are some files that Prettier struggles with, quite understandably though:

Screenshot 2024-01-11 at 10 02 40 (Visual Studio Code)

That seems like an interesting approach to whatever that is!

@Snapstromegon
Copy link
Copy Markdown
Member

What do you mean by autogenerated files?

The files in https://github.com/11ty/11ty-website/tree/main/src/_data/community are generated by a GH action from the "Build With 11ty" issues.

@uncenter
Copy link
Copy Markdown
Member Author

uncenter commented Jan 11, 2024

Ah, strange. Well, we can just run the format command after that step in the workflow.

@uncenter
Copy link
Copy Markdown
Member Author

...where is that workflow?

@uncenter
Copy link
Copy Markdown
Member Author

I think you are confusing this repo with https://github.com/11ty/11ty-community/tree/main/built-with-eleventy maybe?

@Snapstromegon
Copy link
Copy Markdown
Member

I think you are confusing this repo with https://github.com/11ty/11ty-community/tree/main/built-with-eleventy maybe?

Ah yes, my mistake

@uncenter
Copy link
Copy Markdown
Member Author

Is there anything else I need to do for this PR? I've ignored that one directory I mentioned that Prettier didn't like, so the command passes now.

Copy link
Copy Markdown
Member

@Snapstromegon Snapstromegon left a comment

Choose a reason for hiding this comment

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

LGTM, but since this is a fairly fundamental change how this repo is worked on, I'd like the opinion of @zachleat on this.

@uncenter
Copy link
Copy Markdown
Member Author

FYI, the formatting config files (.prettierrc.json, .editorconfig) that I've included here are directly copied from the core @11ty/eleventy repository. So there isn't anything Zach hasn't already approved, technically.

@Snapstromegon
Copy link
Copy Markdown
Member

I think that these configs have to be seen in the context of a project/repo. E.g. editorconfig settings can vary depending on the project. I do not expect Zach to oppose this change, but it makes me more comfortable to have his approval for now.

@uncenter
Copy link
Copy Markdown
Member Author

@zachleat would you be able to take a look at this? Have some small & incremental improvements in mind for the docs that I'd love to test out but I'd like to have uniform formatting to make for minimal diffs if possible.

@uncenter
Copy link
Copy Markdown
Member Author

FYI - I've just gone through and compared each of the modified/related files to formatting in this branch and the main branch of the 11ty/eleventy repo and they are (still) consistent.

@uncenter uncenter changed the title Add prettier/editorconfigs from 11ty/eleventy, format files Update Prettier & EditorConfig files Sep 23, 2024
@uncenter
Copy link
Copy Markdown
Member Author

@zachleat any chance we could take a look at these changes and then format the repository files once merged?

@zachleat
Copy link
Copy Markdown
Member

zachleat commented May 23, 2025

Ah, sorry yeah! I’m okay with it as long as it doesn’t mess up any spaces in YAML front matter!

We should add an entry to .git-blame-ignore-revs after this gets applied too

@zachleat
Copy link
Copy Markdown
Member

zachleat commented May 23, 2025

Rather: I will merge if you can confirm it doesn’t impact YAML front matter whitespace! (and add the entry to .git-blame-ignore-revs)

@uncenter
Copy link
Copy Markdown
Member Author

Rather: I will merge if you can confirm it doesn’t impact YAML front matter whitespace!

It doesn't appear to.

(and add the entry to .git-blame-ignore-revs)

I think it'd be best for you to commit it on your end instead of making this pull request diff unreadable, and I won't know the commit SHA to ignore until then.


I should note that Prettier is running into issues with your use of {% set codeContent %}. It can't tell that this is meant to be code and removes the indentation. Can we use a more idiomatic approach such as regular Markdown code blocks with a post-processing plugin through markdown-it or something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Add prettier config

3 participants