Skip to content

fix: scope jest, lint, prettier, and tsc to ignore .worktrees directory#7131

Open
diegolmello wants to merge 1 commit intodevelopfrom
fix/scope-worktree-commands
Open

fix: scope jest, lint, prettier, and tsc to ignore .worktrees directory#7131
diegolmello wants to merge 1 commit intodevelopfrom
fix/scope-worktree-commands

Conversation

@diegolmello
Copy link
Copy Markdown
Member

@diegolmello diegolmello commented Apr 12, 2026

Proposed changes

Avoid running test/lint/typecheck commands on sibling git worktrees by ignoring the standard .worktrees/ directory in all four tools:

  • jest: Added /(^|\\/)\.worktrees\\// to testPathIgnorePatterns
  • eslint: Added .worktrees/ to .eslintignore
  • prettier: Added .worktrees/ to .prettierignore
  • tsc: Added **/.worktrees/** to tsconfig.json exclude

How to test or reproduce

Run any of the four commands from a worktree inside .worktrees/ and verify only files from the current worktree are processed.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)

Checklist

  • I have read the CONTRIBUTING doc
  • Lint and unit tests pass locally with my changes

Avoid running test/lint/typecheck commands on sibling git worktrees by
ignoring the standard .worktrees/ directory in all four tools.
@diegolmello diegolmello requested a deployment to approve_e2e_testing April 12, 2026 15:45 — with GitHub Actions Waiting
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 12, 2026

Walkthrough

This PR adds .worktrees/ directory exclusion across development tooling configurations. ESLint, Prettier, Jest, and TypeScript are configured to ignore files within .worktrees/ directories, preventing linting, formatting, testing, and type-checking of those files.

Changes

Cohort / File(s) Summary
Development Tool Ignore Patterns
.eslintignore, .prettierignore, jest.config.js, tsconfig.json
Added .worktrees/ directory exclusion across ESLint, Prettier, Jest, and TypeScript configurations. ESLint and Prettier use simple directory patterns, Jest uses updated regex patterns with explicit path matching, and TypeScript adds a glob exclusion to the exclude list.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested labels

type: chore

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and accurately summarizes the main change: adding .worktrees directory to ignore patterns for jest, lint, prettier, and tsc tooling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@diegolmello diegolmello requested a deployment to official_android_build April 12, 2026 15:49 — with GitHub Actions Waiting
@diegolmello diegolmello requested a deployment to experimental_ios_build April 12, 2026 15:49 — with GitHub Actions Waiting
@diegolmello diegolmello requested a deployment to experimental_android_build April 12, 2026 15:49 — with GitHub Actions Waiting
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@jest.config.js`:
- Line 2: The regex in testPathIgnorePatterns currently has a leading literal
slash which prevents the ^ anchor from matching; update the pattern in
jest.config.js for testPathIgnorePatterns (the entry currently
'/(^|\\/)\\.worktrees\\//') to remove the leading slash so it reads
'(^|\\/)\\.worktrees\\/' (or an equivalent pattern that matches either
start-of-string or a path separator before .worktrees, e.g.,
'^(.*/)?\\.worktrees\\/') so .worktrees paths are correctly ignored.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d0d8346b-bad7-4bf2-b025-71b6ac0116e5

📥 Commits

Reviewing files that changed from the base of the PR and between 7bc94c3 and 4cf17ab.

📒 Files selected for processing (4)
  • .eslintignore
  • .prettierignore
  • jest.config.js
  • tsconfig.json
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: ESLint and Test / run-eslint-and-test
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{js,jsx,ts,tsx,json}

📄 CodeRabbit inference engine (CLAUDE.md)

Configure Prettier with tabs, single quotes, 130 character width, no trailing commas, arrow parens avoid, and bracket same line

Files:

  • tsconfig.json
  • jest.config.js
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Use ESLint with @rocket.chat/eslint-config base configuration including React, React Native, TypeScript, and Jest plugins

Files:

  • jest.config.js
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,ts,jsx,tsx}: Use descriptive names for functions, variables, and classes that clearly convey their purpose
Write comments that explain the 'why' behind code decisions, not the 'what'
Keep functions small and focused on a single responsibility
Use const by default, let when reassignment is needed, and avoid var
Prefer async/await over .then() chains for handling asynchronous operations
Use explicit error handling with try/catch blocks for async operations
Avoid deeply nested code; refactor complex logic into helper functions

Files:

  • jest.config.js
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
Repo: RocketChat/Rocket.Chat.ReactNative PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-07T17:49:17.538Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Use ESLint with rocket.chat/eslint-config base configuration including React, React Native, TypeScript, and Jest plugins
Learnt from: CR
Repo: RocketChat/Rocket.Chat.ReactNative PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-07T17:49:17.538Z
Learning: Run yarn prettier-lint and TZ=UTC yarn test for modified files before committing
Learnt from: CR
Repo: RocketChat/Rocket.Chat.ReactNative PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-07T17:49:17.538Z
Learning: Applies to **/*.{js,jsx,ts,tsx,json} : Configure Prettier with tabs, single quotes, 130 character width, no trailing commas, arrow parens avoid, and bracket same line
📚 Learning: 2026-04-07T17:49:25.836Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat.ReactNative PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-07T17:49:25.836Z
Learning: Applies to **/*.{ts,tsx} : Use TypeScript for type safety; add explicit type annotations to function parameters and return types

Applied to files:

  • tsconfig.json
📚 Learning: 2026-04-07T17:49:17.538Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat.ReactNative PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-07T17:49:17.538Z
Learning: Applies to **/*.{ts,tsx} : Use TypeScript with strict mode enabled and configure baseUrl to app/ for import resolution

Applied to files:

  • tsconfig.json
📚 Learning: 2026-04-07T17:49:17.538Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat.ReactNative PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-07T17:49:17.538Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Use ESLint with rocket.chat/eslint-config base configuration including React, React Native, TypeScript, and Jest plugins

Applied to files:

  • tsconfig.json
  • jest.config.js
📚 Learning: 2026-04-07T17:49:17.538Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat.ReactNative PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-07T17:49:17.538Z
Learning: Applies to **/*.{js,jsx,ts,tsx,json} : Configure Prettier with tabs, single quotes, 130 character width, no trailing commas, arrow parens avoid, and bracket same line

Applied to files:

  • tsconfig.json
  • jest.config.js
🔇 Additional comments (3)
.eslintignore (1)

8-8: LGTM: ESLint scope now correctly excludes .worktrees/.

This matches the PR intent and prevents linting sibling worktree files.

.prettierignore (1)

12-12: LGTM: Prettier ignore entry is correct.

Adding .worktrees/ here is consistent with the rest of the tooling exclusions.

tsconfig.json (1)

73-73: LGTM: TypeScript exclusion is correctly scoped.

"**/.worktrees/**" is an appropriate addition to keep tsc limited to the active worktree.

@@ -1,5 +1,5 @@
module.exports = {
testPathIgnorePatterns: ['e2e', 'node_modules'],
testPathIgnorePatterns: ['/e2e/', '/node_modules/', '/(^|\\/)\\.worktrees\\//'],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verifies current vs proposed regex behavior on representative paths.
python - <<'PY'
import re

current = re.compile(r'/(^|\/)\.worktrees\/')
proposed = re.compile(r'(^|[/\\])\.worktrees([/\\]|$)')

samples = [
    "/repo/.worktrees/feature/app/foo.test.ts",
    "/repo/app/foo.test.ts",
    r"C:\repo\.worktrees\feature\app\foo.test.ts",
]

for s in samples:
    print(s)
    print("  current :", bool(current.search(s)))
    print("  proposed:", bool(proposed.search(s)))
PY

Repository: RocketChat/Rocket.Chat.ReactNative

Length of output: 289


🏁 Script executed:

#!/bin/bash
# Check the jest.config.js file to see the current state
cd /repo && head -20 jest.config.js

Repository: RocketChat/Rocket.Chat.ReactNative

Length of output: 133


🏁 Script executed:

#!/bin/bash
# Also check if there are any Jest documentation or comments in the file
cd /repo && wc -l jest.config.js

Repository: RocketChat/Rocket.Chat.ReactNative

Length of output: 133


🏁 Script executed:

#!/bin/bash
# Find jest.config.js in the repository
git ls-files | grep -E 'jest\.config\.(js|ts|json)$'

Repository: RocketChat/Rocket.Chat.ReactNative

Length of output: 92


🏁 Script executed:

#!/bin/bash
# Read the jest.config.js file content
if [ -f "jest.config.js" ]; then
  cat -n jest.config.js
fi

Repository: RocketChat/Rocket.Chat.ReactNative

Length of output: 896


🌐 Web query:

Jest testPathIgnorePatterns regex behavior and how it matches file paths

💡 Result:

Jest's testPathIgnorePatterns is an array of regexp pattern strings matched against all test paths before executing tests. If a test path matches any pattern, the test is skipped. Key behaviors: - Patterns match against the full absolute file path of potential test files. - Uses JavaScript RegExp syntax, not glob patterns (e.g., no or !; use regex equivalents like /src/.*/state/ instead of /src//state/). - Default: ["/node_modules/"]. - Use token for project root: e.g., ["//build/", "//dist/"]. - Patterns are applied after testMatch/testRegex finds candidates, filtering them out. - Common pitfalls: confusing regex with globs causes invalid regex errors; paths include full system path, so use leading / for path starts; Windows paths may need escaping. Examples: - Ignore node_modules and build: ["/build/", "/node_modules/"] - Ignore files starting with DISABLED.: "/DISABLED\." - Negative lookahead (exclude specific subpath): "/dist/(?!e2e/sfn)" Official docs confirm: "These pattern strings match against the full path." GitHub issues and Stack Overflow examples validate regex-only behavior and full-path matching.

Citations:


Fix .worktrees Jest ignore regex; current pattern fails to match .worktrees paths.

At Line 2, the pattern '/(^|\\/)\\.worktrees\\//' starts with a literal / followed by (^|\\/), which means the leading / makes the ^ anchor impossible to match, leaving only the \/ branch. This requires a double-slash before .worktrees, so the pattern effectively never matches typical paths like /repo/.worktrees/. Tests under .worktrees/ directories will not be ignored.

Suggested patch
-	testPathIgnorePatterns: ['/e2e/', '/node_modules/', '/(^|\\/)\\.worktrees\\//'],
+	testPathIgnorePatterns: ['/e2e/', '/node_modules/', '(^|[/\\\\])\\.worktrees([/\\\\]|$)'],
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
testPathIgnorePatterns: ['/e2e/', '/node_modules/', '/(^|\\/)\\.worktrees\\//'],
testPathIgnorePatterns: ['/e2e/', '/node_modules/', '(^|[/\\\\])\\.worktrees([/\\\\]|$)'],
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@jest.config.js` at line 2, The regex in testPathIgnorePatterns currently has
a leading literal slash which prevents the ^ anchor from matching; update the
pattern in jest.config.js for testPathIgnorePatterns (the entry currently
'/(^|\\/)\\.worktrees\\//') to remove the leading slash so it reads
'(^|\\/)\\.worktrees\\/' (or an equivalent pattern that matches either
start-of-string or a path separator before .worktrees, e.g.,
'^(.*/)?\\.worktrees\\/') so .worktrees paths are correctly ignored.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant