From f2b92f2db26ff34a7675213db419bfaf9e1a00c5 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Sat, 27 Jan 2024 16:44:42 +0300 Subject: [PATCH] add linting --- git-clone/README.md | 21 +++++++++++++++------ lint.ts | 17 +++++++---------- vscode-web/README.md | 2 +- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/git-clone/README.md b/git-clone/README.md index e883bd4..054e30c 100644 --- a/git-clone/README.md +++ b/git-clone/README.md @@ -20,17 +20,23 @@ module "git-clone" { } ``` -To use with [Git Authentication](https://coder.com/docs/v2/latest/admin/git-providers), add the provider by ID to your template: +## Examples + +### Custom Path ```tf -data "coder_git_auth" "github" { - id = "github" +module "git-clone" { + source = "registry.coder.com/modules/git-clone/coder" + version = "1.0.2" + agent_id = coder_agent.example.id + url = "https://github.com/coder/coder" + base_dir = "~/projects/coder" } ``` -## Examples +### Git Authentication -### Custom Path +To use with [Git Authentication](https://coder.com/docs/v2/latest/admin/git-providers), add the provider by ID to your template: ```tf module "git-clone" { @@ -38,6 +44,9 @@ module "git-clone" { version = "1.0.2" agent_id = coder_agent.example.id url = "https://github.com/coder/coder" - base_dir = "~/projects/coder" +} + +data "coder_git_auth" "github" { + id = "github" } ``` diff --git a/lint.ts b/lint.ts index 2328b48..01c2afd 100644 --- a/lint.ts +++ b/lint.ts @@ -62,7 +62,7 @@ for (const dir of dirs) { let h1 = false; let code = false; let paragraph = false; - let version = false; + let version = true; for (const token of tokens) { if (token.type === "heading" && token.depth === 1) { @@ -78,15 +78,12 @@ for (const dir of dirs) { } if (token.type === "code") { code = true; - if (token.lang !== "hcl") { - version = true; - continue; + if (token.lang === "tf" && !token.text.includes("version")) { + version = false; + error(dir.name, "missing version in tf code block"); } - let text = token.text; - // check if text contains version - if (text.includes("version")) { - version = true; - continue; + if (token.lang === "hcl") { + error(dir.name, "HCL code blocks are not allowed, use tf"); } continue; } @@ -101,7 +98,7 @@ for (const dir of dirs) { error(dir.name, "missing example code block after paragraph"); } if (!version) { - error(dir.name, "missing version in code block"); + error(dir.name, "missing version in tf code block"); } } diff --git a/vscode-web/README.md b/vscode-web/README.md index 55b12ef..64aeec0 100644 --- a/vscode-web/README.md +++ b/vscode-web/README.md @@ -26,7 +26,7 @@ module "vscode-web" { ### Install VS Code Web to a custom folder -```tf +```hcl module "vscode-web" { source = "registry.coder.com/modules/vscode-web/coder" version = "1.0.2"