Skip to content

ci: add CodeRabbit configuration for template-ui - #98

Open
NP-compete wants to merge 1 commit into
redhat-data-and-ai:mainfrom
NP-compete:ci/coderabbit-setup-main
Open

ci: add CodeRabbit configuration for template-ui#98
NP-compete wants to merge 1 commit into
redhat-data-and-ai:mainfrom
NP-compete:ci/coderabbit-setup-main

Conversation

@NP-compete

Copy link
Copy Markdown
Member

Summary

  • Add .coderabbit.yaml with assertive profile for correctness-only automated reviews
  • Add 6 ast-grep rules for TypeScript/React patterns: no console.log, no dangerouslySetInnerHTML (XSS), no useEffect without deps, no direct process.env, no explicit any types, no floating promises
  • Configure auto review with draft/bot exclusions, slop detection, post-merge changelog, issue enrichment with auto-labeling, and cross-repo knowledge base (template-agent, template-mcp)

This PR targets main so CodeRabbit picks up the config from the default branch.

Test plan

  • Verify CodeRabbit triggers on new PRs after merge
  • Confirm ast-grep rules fire on matching patterns
  • Check slop detection flags AI-generated content

Configure CodeRabbit with assertive profile for correctness-only reviews.
Includes ast-grep rules for TypeScript/React patterns (XSS, floating
promises, console.log, useEffect deps, any types, direct env access),
auto review with draft/bot exclusions, slop detection, post-merge
changelog, issue enrichment with auto-labeling, and cross-repo
knowledge base linking.

Signed-off-by: Soham Dutta <19648293+NP-compete@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Adds a complete CodeRabbit configuration with review defaults, automation, path-based instructions, lint and security tooling, changelog updates, chat replies, issue enrichment, knowledge sources, and guideline patterns. Adds six TypeScript rules covering explicit any, console.log, dangerouslySetInnerHTML, direct environment access, dependency-less useEffect, and unhandled promises.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding CodeRabbit configuration for template-ui.
Description check ✅ Passed The description matches the changeset and clearly describes the CodeRabbit config and rule additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
🚀 Post-Merge Actions
  • Update changelog

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.44.1)

ast-grep could not parse rule config: /ast-grep-rules/../git/.coderabbit/rules/no-dangerously-set-innerhtml.yml


Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.coderabbit.yaml:
- Line 44: Update the dotenv exclusion pattern in the ignore configuration from
the root-only form to a recursive pattern that excludes matching .env files in
all directories, using !**/.env*.

In @.coderabbit/rules/no-console-log.yml:
- Around line 3-10: Remove the access-token logging statement from the client
router around the token log at line 30, rather than replacing console.log with a
structured logger. Preserve the surrounding request and authentication behavior
while ensuring the token value is never logged.

In @.coderabbit/rules/no-unhandled-promise.yml:
- Around line 6-18: Replace the structural AST pattern in the
no-unhandled-promise rule with a type-aware floating-promise check that
identifies calls returning promises without requiring then, catch, or finally
handling. Ensure it covers async arrow callbacks as well as async function
declarations, while excluding intentional void-returning calls such as
logger.info().
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a9926e80-64a1-46ab-a5f5-69334bb62168

📥 Commits

Reviewing files that changed from the base of the PR and between 582750b and fb54e8e.

📒 Files selected for processing (7)
  • .coderabbit.yaml
  • .coderabbit/rules/no-any-type-annotation.yml
  • .coderabbit/rules/no-console-log.yml
  • .coderabbit/rules/no-dangerously-set-innerhtml.yml
  • .coderabbit/rules/no-direct-env-access.yml
  • .coderabbit/rules/no-empty-useeffect-deps.yml
  • .coderabbit/rules/no-unhandled-promise.yml
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • redhat-data-and-ai/template-agent (manual)
  • redhat-data-and-ai/template-mcp (manual)

Comment thread .coderabbit.yaml
- "!**/package-lock.json"
- "!**/.gitignore"
- "!**/LICENSE"
- "!.env*"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

npx --yes --package=minimatch node <<'NODE'
const mod = require('minimatch');
const minimatch = mod.minimatch ?? mod;
const path = 'apps/api/.env.production';
console.log(minimatch(path, '.env*'));
console.log(minimatch(path, '**/.env*'));
NODE

Repository: redhat-data-and-ai/template-ui

Length of output: 491


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- .coderabbit.yaml (relevant section) ---'
nl -ba .coderabbit.yaml | sed -n '1,120p'

echo
echo '--- search for path_filters usage ---'
rg -n 'path_filters|\.env\*|!\*\*/\.env\*|!\.env\*' .coderabbit.yaml . || true

Repository: redhat-data-and-ai/template-ui

Length of output: 252


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
import yaml

p = Path('.coderabbit.yaml')
data = yaml.safe_load(p.read_text())
print(data.get('reviews', {}).get('path_filters'))
PY

Repository: redhat-data-and-ai/template-ui

Length of output: 285


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- .coderabbit.yaml lines 1-120 ---'
sed -n '1,120p' .coderabbit.yaml | cat -n

echo
echo '--- exact env-related filters ---'
grep -nE 'env|\*\*/|path_filters' .coderabbit.yaml || true

Repository: redhat-data-and-ai/template-ui

Length of output: 5652


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
text = Path('.coderabbit.yaml').read_text().splitlines()
for i, line in enumerate(text, 1):
    if 'path_filters' in line or '.env' in line or '**/' in line:
        print(f'{i}: {line}')
PY

Repository: redhat-data-and-ai/template-ui

Length of output: 619


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '1,120p' .coderabbit.yaml | cat -n

Repository: redhat-data-and-ai/template-ui

Length of output: 5144


🌐 Web query:

CodeRabbit path_filters glob .env* nested directories minimatch docs

💡 Result:

CodeRabbit supports standard glob patterns for its path_filters configuration to control which files are included in or excluded from reviews [1][2]. These patterns follow minimatch syntax [3]. To specifically address your requirements: 1. Nested Directories: The glob pattern supports matching across any number of directory levels [4]. For example, !/.env* will effectively exclude all files starting with .env (including those in nested directories) from CodeRabbit's review scope [5]. 2. Glob Syntax: - Use the ! prefix to explicitly exclude files (e.g., !/.env*) [6][4]. - Patterns without the ! prefix are used to explicitly include files, which is useful for overriding default exclusions [6][7]. 3. Implementation: You can define these in your.coderabbit.yaml file under the reviews.path_filters section: reviews: path_filters: - "!/.env*" # Excludes all.env files regardless of location CodeRabbit applies these filters to the repository contents, and because it supports standard glob syntax, using the wildcard ensures that your.env* filter will correctly identify and apply to files within nested directories [4][2].

Citations:


🌐 Web query:

site:docs.coderabbit.ai path_filters .env* nested directories minimatch CodeRabbit

💡 Result:

In CodeRabbit configuration, path_filters use minimatch glob patterns to include or exclude specific files and directories [1][2]. To target.env files across nested directories, you can use the double asterisk glob pattern [1]. 1. Include nested.env files: To ensure.env files are included (or to override default exclusions), use a pattern like /.env*. This matches any file starting with.env in any directory [1][3]. 2. Exclude nested.env files: To exclude them, prefix the pattern with an exclamation mark (!) [1][2]. For example,!/.env* will exclude all.env files regardless of their nesting level [1]. Example usage in your.coderabbit.yaml: reviews: path_filters: - "!/.env*" # Excludes all.env files in any directory - "src/" # Explicitly includes the src directory The double asterisk is a minimatch feature that matches zero or more directories, making it the standard way to handle recursive or nested file paths within CodeRabbit configuration [1][4].

Citations:


🌐 Web query:

site:docs.coderabbit.ai "path_filters" ".env*" CodeRabbit

💡 Result:

In CodeRabbit, path_filters are used within your configuration file (typically.coderabbit.yaml) to control which files are included in or excluded from AI-powered code reviews [1][2]. To exclude.env files from CodeRabbit reviews using path_filters, you would add a pattern prefixed with an exclamation mark (!) to your configuration [1][3]. For example: reviews: path_filters: - "!/.env*" This pattern uses glob syntax: - The! prefix instructs CodeRabbit to exclude the matching files [1][2]. - The glob matches any directory depth [3]. - The.env* wildcard ensures that all variations of environment files (e.g.,.env,.env.local,.env.development) are captured by the exclusion [4]. Note that this configuration is specific to the general AI code review process. CodeRabbit also includes a separate, automatic "Dotenv Linter" tool that specifically targets.env files; it runs on /.env and /.env.* patterns by default [4]. Configuring path_filters as shown above will prevent the primary AI review from processing those files, while the specialized Dotenv Linter may still operate independently unless otherwise managed [4].

Citations:


🌐 Web query:

site:docs.coderabbit.ai "path instructions" "path_filters" "minimatch" CodeRabbit

💡 Result:

In CodeRabbit, path_filters and path_instructions are configuration mechanisms used to control which files are reviewed and how they are handled, both of which utilize glob patterns based on the minimatch syntax [1][2]. Path Filters Path filters allow you to define which files should be included in or excluded from an AI code review [3]. This is commonly used to ignore irrelevant files such as lock files, binaries, build artifacts, or generated code to keep reviews focused [3][4]. - Syntax: Uses glob patterns [5]. - Exclusions: Patterns prefixed with "!" will exclude the matching paths from the review (e.g.,!dist/) [3][1]. - Inclusions: Patterns without the "!" prefix explicitly include paths, which can be used to override default exclusions [3]. - Configuration: Defined under the reviews.path_filters key in your.coderabbit.yaml file [3][5]. Path Instructions Path instructions provide targeted, per-path guidance for the AI, allowing you to enforce specific rules or focus areas for different parts of your codebase [3][4]. - Purpose: Useful for applying specific requirements, such as security checks for API controllers, coverage requirements for tests, or documentation standards [3]. - Configuration: Defined as an array of objects under the reviews.path_instructions key, where each object contains a path (glob pattern) and the corresponding instructions [3][5]. - Example: reviews: path_instructions: - path: "src/controllers/" instructions: | - Focus on authentication and input validation. - path: "tests/" instructions: | - Ensure descriptive test names and coverage for edge cases. Both features support standard glob syntax, where "*" matches any filename and "" matches any directory depth [1]. Because they use minimatch syntax, you can target specific directories, file types, or naming conventions with precision [1][2].

Citations:


🏁 Script executed (no clone):

#!/bin/bash
set -euo pipefail

for url in \
  'https://docs.coderabbit.ai/reference/configuration' \
  'https://docs.coderabbit.ai/configuration/path-instructions' \
  'https://docs.coderabbit.ai/reference/glossary' \
  'https://docs.coderabbit.ai/tools/dotenv'
do
  echo "### $url"
  curl -L --silent "$url" | \
    grep -nE 'path_filters|path instructions|\.env\*|!/?\.\env|\*\*/|minimatch|dotenv' | \
    head -n 40 || true
  echo
done

Length of output: 50344


🏁 Script executed (no clone):

#!/bin/bash
set -euo pipefail

log='/tmp/coderabbit-shell-logs/shell-output-id5t7x'

echo '--- path_filters references ---'
rg -n --max-count 40 'path_filters|path instructions|minimatch|\.env\*|dotenv|!/' "$log" || true

echo
echo '--- nearby context for dotenv mentions ---'
rg -n -C 3 --max-count 20 '\.env\*|dotenv' "$log" || true

Length of output: 50344


🏁 Script executed (no clone):

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
import re, urllib.request

urls = [
    "https://docs.coderabbit.ai/reference/configuration",
    "https://docs.coderabbit.ai/configuration/path-instructions",
    "https://docs.coderabbit.ai/reference/glossary",
    "https://docs.coderabbit.ai/tools/dotenv",
]

patterns = [r"\.env\*", r"path_filters", r"minimatch", r"dotenv", r"!\./env", r"!\*\*/\.env\*", r"!/\.env\*"]

for url in urls:
    print(f"### {url}")
    html = urllib.request.urlopen(url, timeout=20).read().decode("utf-8", "ignore")
    for pat in patterns:
        found = False
        for m in re.finditer(pat, html, flags=re.I):
            s = max(0, m.start() - 180)
            e = min(len(html), m.end() + 260)
            snippet = re.sub(r"\s+", " ", html[s:e])
            print(f"[{pat}] ...{snippet}...")
            found = True
            break
        if not found:
            print(f"[{pat}] <no match>")
    print()
PY

Length of output: 2467


Exclude nested dotenv files. !.env* only ignores repo-root matches, so use !**/.env* instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.coderabbit.yaml at line 44, Update the dotenv exclusion pattern in the
ignore configuration from the root-only form to a recursive pattern that
excludes matching .env files in all directories, using !**/.env*.

Comment on lines +3 to +10
message: "Use a structured logger instead of console.log() for observability"
severity: warning
rule:
pattern: console.log($$$)
not:
inside:
kind: function_declaration
regex: "test|spec|describe|it"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

sample="$(mktemp --suffix=.ts)"
cat >"$sample" <<'TS'
function testLogging() { console.log("test"); }
function handler(token: string) { console.log(token); }
TS
npx --yes `@ast-grep/cli` scan --rule .coderabbit/rules/no-console-log.yml "$sample"
rm -f "$sample"

Repository: redhat-data-and-ai/template-ui

Length of output: 645


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n## rule file\n'
cat -n .coderabbit/rules/no-console-log.yml

printf '\n## client.router.ts matches\n'
rg -n "console\.log|logger|token" src/server/router/client.router.ts src/server/router -S || true

printf '\n## client.router.ts excerpt\n'
sed -n '1,220p' src/server/router/client.router.ts

Repository: redhat-data-and-ai/template-ui

Length of output: 3509


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '## coderabbit rules\n'
find .coderabbit/rules -maxdepth 1 -type f | sort | xargs -r -I{} sh -c 'echo; echo "### {}"; cat -n "{}"'

printf '\n## sensitive log patterns\n'
rg -n "token|secret|credential|accessToken|console\.log|logger" .coderabbit/rules src/server -S || true

Repository: redhat-data-and-ai/template-ui

Length of output: 6202


Remove the token log in src/server/router/client.router.ts:30; a structured logger still leaks the access token, so this value should not be logged at all.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.coderabbit/rules/no-console-log.yml around lines 3 - 10, Remove the
access-token logging statement from the client router around the token log at
line 30, rather than replacing console.log with a structured logger. Preserve
the surrounding request and authentication behavior while ensuring the token
value is never logged.

Comment on lines +6 to +18
kind: expression_statement
has:
kind: call_expression
has:
kind: member_expression
not:
has:
kind: property_identifier
regex: "^(then|catch|finally)$"
inside:
kind: function_declaration
regex: "^async "
stopBy: end

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

sample="$(mktemp --suffix=.ts)"
cat >"$sample" <<'TS'
type Service = { save(): Promise<void>; trace(): void };
declare const service: Service;
async function named() { service.trace(); }
const callback = async () => { service.save(); };
TS
npx --yes `@ast-grep/cli` scan --rule .coderabbit/rules/no-unhandled-promise.yml "$sample"
rm -f "$sample"

Repository: redhat-data-and-ai/template-ui

Length of output: 645


🏁 Script executed:

#!/bin/bash
set -euo pipefail

git ls-files .coderabbit/rules/no-unhandled-promise.yml
echo '---'
cat -n .coderabbit/rules/no-unhandled-promise.yml
echo '---'
python3 - <<'PY'
from pathlib import Path
p = Path('.coderabbit/rules/no-unhandled-promise.yml')
print('lines', sum(1 for _ in p.open()))
PY

Repository: redhat-data-and-ai/template-ui

Length of output: 786


🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n "no-unhandled-promise|Floating promise without await" .coderabbit . || true

Repository: redhat-data-and-ai/template-ui

Length of output: 366


Replace this with a type-aware floating-promise check. The current structural rule flags void member calls like logger.info() and misses floating promises in async arrow callbacks.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.coderabbit/rules/no-unhandled-promise.yml around lines 6 - 18, Replace the
structural AST pattern in the no-unhandled-promise rule with a type-aware
floating-promise check that identifies calls returning promises without
requiring then, catch, or finally handling. Ensure it covers async arrow
callbacks as well as async function declarations, while excluding intentional
void-returning calls such as logger.info().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant