Skip to content

chore: adopt markdownlint and markdown-table-formatter for *.md#15831

Merged
matifali merged 94 commits into
mainfrom
atif/bye-bye-prettier
Jan 3, 2025
Merged

chore: adopt markdownlint and markdown-table-formatter for *.md#15831
matifali merged 94 commits into
mainfrom
atif/bye-bye-prettier

Conversation

@matifali

@matifali matifali commented Dec 11, 2024

Copy link
Copy Markdown
Member

Removed dependence on prettier in favor of markdownlint and markdown-table-formatter for markdown files.

- Restrict triggers to main branch and pull requests
- Remove automatic fix option in markdownlint-cli2 command
@matifali matifali marked this pull request as draft December 11, 2024 15:47
@matifali matifali removed the request for review from EdwardAngert December 11, 2024 15:47
@matifali matifali force-pushed the atif/bye-bye-prettier branch 2 times, most recently from 3d065a5 to 4cd592b Compare December 11, 2024 15:52
- Update `setup-node` action to specify pnpm version.
- Remove redundant node_modules installation command.
- Use specific commit hashes for action versions in workflows.
- Adjust paths in Makefile for better file management.
@matifali matifali force-pushed the atif/bye-bye-prettier branch from cd5fcdc to 0d41834 Compare December 31, 2024 12:51

@EdwardAngert EdwardAngert left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

amazing- thanks @matifali !

🚀

@EdwardAngert EdwardAngert added the docs Area: coder.com/docs label Dec 31, 2024
@matifali matifali requested a review from mafredri January 2, 2025 04:54

@johnstcn johnstcn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I note a number of heading changes (e.g. # => ##) -- are we sure this won't break any existing documentation links?

@matifali

matifali commented Jan 2, 2025

Copy link
Copy Markdown
Member Author

I note a number of heading changes (e.g. # => ##) -- are we sure this won't break any existing documentation links?

There is a Markdown rule against having multiple H1 headings in a file. Yes, it will not break Markdown anchors, which are independent of heading levels.
@EdwardAngert can confirm this.

- name: lint
if: steps.changed-files.outputs.any_changed == 'true'
run: |
pnpm exec markdownlint-cli2 ${{ steps.changed-files.outputs.all_changed_files }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This works now but could at some point fail with a shell error: argument list too long. Using xargs is one option and maybe markdown-lint has some other built-in function.

If a file has spaces that would also be problematic.

if: steps.changed-files.outputs.any_changed == 'true'
run: |
# markdown-table-formatter requires a space separated list of files
echo ${{ steps.changed-files.outputs.all_changed_files }} | tr ',' '\n' | pnpm exec markdown-table-formatter --check

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same as before, you could just add xargs in front of pnpm here. You could use null instead of newline (tr , ’\0’, xargs -0) for additional safety. For ultimate safety, store files in env via yaml and echo the env in addition to null handling and all bases are covered.

@EdwardAngert EdwardAngert Jan 2, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I like this - seems like it might make it easier to debug issues later too

something like a commented out debug line that writes the env contents into a file? is that possible/useful?

I'm not sure what it would specifically look like or if it's a cat or echo (printf?) thing, but something like:

cat <<< "$changed-files" > "list-changed-files.txt"

@matifali matifali Jan 3, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@mafredri I am leaving the suggestions here out of this PR. I need to learn the risks here and can address them in a follow-up PR. I also welcome you taking a jab at this.

Comment thread .markdownlint.json Outdated
@@ -0,0 +1,18 @@
{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this file support json comment syntax? If yes, might be nice to detail why we change some of these rules. Otherwise it's could be nice to stick to stock settings as close as possible, given that it has sane defaults.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Will add comments and convert to *.jsonc.

Comment thread site/package.json
@@ -20,7 +20,7 @@
"playwright:install": "playwright install --with-deps chromium",
"playwright:test": "playwright test --config=e2e/playwright.config.ts",
"playwright:test-ui": "playwright test --config=e2e/playwright.config.ts --ui $([[ \"$CODER\" == \"true\" ]] && echo --ui-port=7500 --ui-host=0.0.0.0)",
"gen:provisioner": "protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./e2e/ --ts_proto_opt=outputJsonMethods=false,outputEncodeMethods=encode-no-creation,outputClientImpl=false,nestJs=false,outputPartialMethods=false,fileSuffix=Generated,suffix=hey -I ../provisionersdk/proto ../provisionersdk/proto/provisioner.proto && pnpm exec prettier --ignore-path '/dev/null' --cache --write './e2e/provisionerGenerated.ts'",
"gen:provisioner": "protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./e2e/ --ts_proto_opt=outputJsonMethods=false,outputEncodeMethods=encode-no-creation,outputClientImpl=false,nestJs=false,outputPartialMethods=false,fileSuffix=Generated,suffix=hey -I ../provisionersdk/proto ../provisionersdk/proto/provisioner.proto",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see prettier was removed here, but no alternative given it its place?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

./e2e/provisionerGenerated.ts is a generated file so should not format I guess.
This is already in the ignore list of biome.

"e2e/**/*Generated.ts",

Comment thread .vscode/extensions.json
@@ -56,7 +56,7 @@ OPTIONS:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These files must not be changed, probably best to not touch anything in any testdata folder. Although, if they changed as a result of changing the Go files then that's OK.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

What is the best way to do that?
These files are generated from code and so does the API and CLI docs. And to make the docs follow the rules this is an artifact.

I will further explore how best to deal with this.

Comment thread coderd/apidoc/docs.go Outdated
Comment thread docs/reference/api/workspaces.md
WARN = 3,
ERROR = 4,
UNRECOGNIZED = -1,
TRACE = 0,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This file is incorrectly indented. It'll be annoying if a developer is making local changes here and the whole file is reformatted.

Comment thread scripts/examplegen/main.go
@EdwardAngert

Copy link
Copy Markdown
Contributor

@johnstcn

I note a number of heading changes (e.g. # => ##) -- are we sure this won't break any existing documentation links?

@matifali

There is a Markdown rule against having multiple H1 headings in a file. Yes, it will not break Markdown anchors, which are independent of heading levels. @EdwardAngert can confirm this.

+1 to what @matifali says here - totally reasonable question and good catch though. Whatever the number of # in the markdown, they all anchor as a single # in the URL (which is why there's another rule against duplicate headings - it would just link to the first instance). If we have a table of contents on any pages, those might potentially look a little different, but it shouldn't affect anything in terms of navigation

@matifali matifali force-pushed the atif/bye-bye-prettier branch from c82df5a to fe265eb Compare January 2, 2025 19:11
Added path exclusions to resolve issues with table formatting in `api/schema.md` and `api/templates.md`.
@bpmct

bpmct commented Jan 3, 2025

Copy link
Copy Markdown
Member

wow

@matifali matifali enabled auto-merge (squash) January 3, 2025 12:10
@matifali matifali disabled auto-merge January 3, 2025 12:13
Comment thread site/biome.jsonc
"out/",
"test-results/",
"e2e/**/*Generated.ts",
"src/api/*Generated.ts",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

removing as we want to lint/fmt these files.

@matifali matifali enabled auto-merge (squash) January 3, 2025 13:05
@matifali matifali merged commit 94f5d52 into main Jan 3, 2025
@matifali matifali deleted the atif/bye-bye-prettier branch January 3, 2025 13:13
@github-actions github-actions Bot locked and limited conversation to collaborators Jan 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

docs Area: coder.com/docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants