From 536bebadd216e12b42e1896c98e263d1882df8c6 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 23 Jan 2024 15:06:31 +0300 Subject: [PATCH] add linting --- code-server/README.md | 2 +- lint.ts | 14 ++++++++++++++ package.json | 2 +- vault-github/README.md | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/code-server/README.md b/code-server/README.md index 9123112..54916a9 100644 --- a/code-server/README.md +++ b/code-server/README.md @@ -30,7 +30,7 @@ module "code-server" { source = "registry.coder.com/modules/code-server/coder" version = "1.0.1" agent_id = coder_agent.example.id - install_version = "1.0.1" + install_version = "4.8.3" } ``` diff --git a/lint.ts b/lint.ts index 12e733c..2328b48 100644 --- a/lint.ts +++ b/lint.ts @@ -62,6 +62,7 @@ for (const dir of dirs) { let h1 = false; let code = false; let paragraph = false; + let version = false; for (const token of tokens) { if (token.type === "heading" && token.depth === 1) { @@ -77,6 +78,16 @@ for (const dir of dirs) { } if (token.type === "code") { code = true; + if (token.lang !== "hcl") { + version = true; + continue; + } + let text = token.text; + // check if text contains version + if (text.includes("version")) { + version = true; + continue; + } continue; } } @@ -89,6 +100,9 @@ for (const dir of dirs) { if (!code) { error(dir.name, "missing example code block after paragraph"); } + if (!version) { + error(dir.name, "missing version in code block"); + } } if (badExit) { diff --git a/package.json b/package.json index 7bd46ef..a8778dc 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "fmt": "bun x prettier --plugin prettier-plugin-sh -w **/*.sh .sample/run.sh new.sh **/*.ts **/*.md *.md && terraform fmt **/*.tf .sample/main.tf", "fmt:ci": "bun x prettier --plugin prettier-plugin-sh --check **/*.sh .sample/run.sh new.sh **/*.ts **/*.md *.md && terraform fmt -check **/*.tf .sample/main.tf", "lint": "bun run lint.ts", - "update-version": "LATEST_TAG=$(git describe --abbrev=0 --tags | sed 's/^v//') && find . -name 'README.md' -exec sed -i \"s/version\\s*=\\s*\\\"[0-9]*\\.[0-9]*\\.[0-9]*\\\"/version = \\\"$LATEST_TAG\\\"/g\" {} \\;" + "update-version": "LATEST_TAG=$(git describe --abbrev=0 --tags | sed 's/^v//') && find . -name 'README.md' -exec sed -i \"s/\\( version \\s*=\\s*\\\"\\)[0-9]*\\.[0-9]*\\.[0-9]*\\(\\\"\\)/\\1$LATEST_TAG\\2/g\" {} \\;" }, "devDependencies": { "bun-types": "^1.0.18", diff --git a/vault-github/README.md b/vault-github/README.md index 1b43e94..bde9638 100644 --- a/vault-github/README.md +++ b/vault-github/README.md @@ -73,6 +73,6 @@ module "vault" { version = "1.0.1" agent_id = coder_agent.example.id vault_addr = "https://vault.example.com" - vault_cli_version = "1.0.1" + vault_cli_version = "1.15.0" } ```