This GitHub Action scans your codebase for disallowed comments or pragmas and fails the workflow if any forbidden occurrences are found, unless explicitly allowed in a whitelist file.
The following code comments/pragmas are disallowed by default:
// ts-expect// ts-ignore// eslint-disable
These patterns are commonly used to suppress TypeScript or ESLint errors and should be avoided unless explicitly whitelisted.
- Recursively scans all
.js,.jsx,.ts,.tsxfiles in your repository - Detects forbidden patterns listed above
- Supports an allow-list file to whitelist specific occurrences
- Configurable working directory and allow-list path
| Name | Description | Default |
|---|---|---|
| allow-list | Whitelist file for allowed occurrences | .github/allowed-code-exceptions.txt |
| working-directory | Directory to scan for code files | . |
Each line in the allow-list file should be in the format:
<filepath>:<line-number>:<pattern>
Example:
src/index.js:10:ts-ignore
Add the following to your workflow YAML:
- name: BlackList Code
uses: cossth/blacklisted-code-action@v1
with:
allow-list: .github/allowed-code-exceptions.txt # optional
working-directory: src # optionalname: Check for Blacklisted Code
on: [push, pull_request]
jobs:
blacklist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: BlackList Code
uses: cossth/blacklisted-code-action@v1
with:
allow-list: .github/allowed-code-exceptions.txt- If disallowed comments/pragmas are found (not whitelisted), the action fails and lists all violations.
- If no disallowed comments/pragmas are found, the action passes.
ISC
Shubham Sharma