Skip to content

Conversation

@Belco90
Copy link
Member

@Belco90 Belco90 commented Dec 16, 2025

Checks

Changes

Context

Closes #855

@Belco90 Belco90 requested review from a team and Copilot December 16, 2025 17:39
@Belco90 Belco90 self-assigned this Dec 16, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances TypeScript type safety by upgrading to TypeScript 5.9 and enabling strict compiler options, specifically addressing unchecked indexed access issues. The changes add optional chaining and null checks throughout the codebase to prevent potential runtime errors when accessing array elements or object properties that may not exist.

Key changes:

  • Downgraded TypeScript from v5.7.2 to v5.9.3 in package.json
  • Added optional chaining (?.) operators when accessing array elements and object properties
  • Introduced null/undefined guards before accessing potentially non-existent values

Reviewed changes

Copilot reviewed 16 out of 18 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
package.json Downgraded TypeScript version from 5.7.2 to 5.9.3
tests/test-utils.ts Added override keyword to method signature
tests/rules/prefer-user-event.test.ts Added optional chaining to prevent unchecked indexed access in test data
tests/rules/prefer-query-matchers.test.ts Added optional chaining to test error data properties
src/rules/prefer-user-event.ts Added optional chaining and fallback for mapping lookup
src/rules/prefer-find-by.ts Added null checks for query method and source code line access
src/rules/prefer-query-by-disappearance.ts Added guard clause for missing argument node
src/rules/no-wait-for-side-effects.ts Added optional chaining for line access
src/rules/no-wait-for-multiple-assertions.ts Added optional chaining for line access
src/rules/no-promise-in-fire-event.ts Added guard clause for missing DOM element argument
src/rules/no-manual-cleanup.ts Added null check before accessing declared variables
src/rules/no-global-regexp-flag-in-query.ts Added conditional check before processing first argument
src/rules/no-container.ts Added optional chaining for property access
src/node-utils/accessors.ts Added optional chaining for quasi array access
src/create-testing-library-rule/detect-testing-library-utils.ts Added null coalescing for empty array access
src/utils/resolve-to-testing-library-fn.ts Added null checks for chain and def access
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (ref && ref.defs.length > 0) {
const def = ref.defs[ref.defs.length - 1];
const importDetails = describePossibleImportDef(def);
const importDetails = def ? describePossibleImportDef(def) : null;
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

The null check for def is redundant. The code at line 110 already retrieves def from ref.defs[ref.defs.length - 1], and line 109 confirms ref.defs.length > 0, guaranteeing that def will always be defined at this point. The optional chaining is unnecessary here.

Suggested change
const importDetails = def ? describePossibleImportDef(def) : null;
const importDetails = describePossibleImportDef(def);

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Dec 16, 2025

Codecov Report

❌ Patch coverage is 83.33333% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.35%. Comparing base (166e37c) to head (c231a2f).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/rules/prefer-find-by.ts 71.42% 2 Missing ⚠️
src/rules/no-global-regexp-flag-in-query.ts 66.66% 1 Missing ⚠️
src/rules/no-promise-in-fire-event.ts 66.66% 1 Missing ⚠️
src/rules/prefer-query-by-disappearance.ts 66.66% 1 Missing ⚠️
src/utils/resolve-to-testing-library-fn.ts 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1132      +/-   ##
==========================================
- Coverage   97.44%   97.35%   -0.10%     
==========================================
  Files          49       49              
  Lines        5979     6002      +23     
  Branches     1522     1536      +14     
==========================================
+ Hits         5826     5843      +17     
- Misses        151      157       +6     
  Partials        2        2              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Belco90 Belco90 merged commit d865ce0 into main Dec 16, 2025
19 of 21 checks passed
@Belco90 Belco90 deleted the 855-upgrade-typescript-to-v5.9 branch December 16, 2025 20:27
@github-actions
Copy link

🎉 This PR is included in version 7.15.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Belco90 Belco90 mentioned this pull request Dec 16, 2025
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade core dependencies

2 participants