diff --git a/.github/workflows/forbidden-words.yml b/.github/workflows/forbidden-words.yml new file mode 100644 index 0000000..e51faef --- /dev/null +++ b/.github/workflows/forbidden-words.yml @@ -0,0 +1,23 @@ +name: Forbidden Words Check + +on: + pull_request: + branches: [ "*" ] + +jobs: + check: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Install Node + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: Install dependencies + run: npm install + + - name: Run forbidden words check + run: node tools/scripts/check-forbidden-words.js diff --git a/tools/scripts/check-forbidden-words.js b/tools/scripts/check-forbidden-words.js new file mode 100644 index 0000000..7a3bdfc --- /dev/null +++ b/tools/scripts/check-forbidden-words.js @@ -0,0 +1,40 @@ +import fs from "fs"; +import path from "path"; +import forbiddenWords from "../static/forbidden-words.json" assert { type: "json" }; + + +const forbidden = forbiddenWords.forbiddenWords; +const docsDir = "./src/content/docs"; + +let hasErrors = false; + +function scanFile(filePath) { + const content = fs.readFileSync(filePath, "utf8"); + + forbidden.forEach(word => { + if (content.toLowerCase().includes(word)) { + console.log(`❌ Forbidden word "${word}" found in: ${filePath}`); + hasErrors = true; + } + }); +} + +function walk(dir) { + fs.readdirSync(dir).forEach(file => { + const fullPath = path.join(dir, file); + + if (fs.statSync(fullPath).isDirectory()) { + walk(fullPath); + } else if (file.endsWith(".md")) { + scanFile(fullPath); + } + }); +} + +walk(docsDir); + +if (hasErrors) { + process.exit(1); +} else { + console.log("✅ No forbidden words found"); +} diff --git a/tools/static/forbidden-words.json b/tools/static/forbidden-words.json new file mode 100644 index 0000000..7130011 --- /dev/null +++ b/tools/static/forbidden-words.json @@ -0,0 +1,24 @@ +{ + "forbiddenWords": [ + "obviously", + "simply", + "easily", + "just", + "basically", + "clearly", + "literally", + "actually", + "needless to say", + "as you know", + "hack", + "kludge", + "stupid", + "dumb", + "crazy", + "weird", + "awful", + "horrible", + "bad code", + "broken" + ] +}