Skip to content

chore: run eslint over test files and fix surfaced errors#374

Merged
zombieJ merged 2 commits into
react-component:masterfrom
aojunhao123:chore/lint-cover-tests
Jul 15, 2026
Merged

chore: run eslint over test files and fix surfaced errors#374
zombieJ merged 2 commits into
react-component:masterfrom
aojunhao123:chore/lint-cover-tests

Conversation

@aojunhao123

Copy link
Copy Markdown
Contributor

Summary

The lint script only scanned src/, so the jest config block for tests/** in eslint.config.mjs never actually ran — test files were effectively unlinted. This extends the script to cover tests/ and fixes the errors that surface once it does:

  • lint script: eslint src/eslint src/ tests/ --ext .tsx,.ts,.jsx,.js, so the existing (but dead) jest config block finally applies. CI runs ut lint → this same script, so coverage extends to CI automatically.
  • tests/utils/domHook.js: the property set() used return foo() for control flow, but a setter's return value is silently discarded (no-setter-return) → rewritten as if/else, behavior unchanged.
  • tests/scroll.test.js: deltaY: 99999999999999999999 lost precision at runtime (no-loss-of-precision) → 1e20, same magnitude, still scrolls past the end.
  • Dropped dead eslint-disable no-param-reassign directives in domHook.js and useScrollTo.tsx (the rule isn't enabled, so they were flagged as unused).

Result: npm run lint reports 0 errors across src/ + tests/ (14 pre-existing react-hooks/exhaustive-deps warnings in src/ are unchanged — those deps are intentionally omitted).

Test plan

  • npm run lint — 0 errors
  • npm test — 279/279 passing

🤖 Generated with Claude Code

The `lint` script only scanned `src/`, so the jest config block for
`tests/**` in eslint.config.mjs never actually ran. Extend the script to
cover `tests/` and fix the 3 errors it surfaces:

- domHook.js: setter used `return` for control flow, but a setter's return
  value is silently discarded (no-setter-return) -> use if/else
- scroll.test.js: oversized deltaY literal lost precision
  (no-loss-of-precision) -> 1e20, same magnitude
- drop dead `eslint-disable no-param-reassign` directives in domHook.js and
  useScrollTo.tsx (the rule isn't enabled)
@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown

@aojunhao123 is attempting to deploy a commit to the afc163's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6cb0774a-c146-4262-bba0-8c49b471770a

📥 Commits

Reviewing files that changed from the base of the PR and between 167e60c and 2cfb5d8.

📒 Files selected for processing (4)
  • package.json
  • src/hooks/useScrollTo.tsx
  • tests/scroll.test.js
  • tests/utils/domHook.js
 __________________________________________________
< I want to be a VS Code extension when I grow up. >
 --------------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request updates the linting configuration in package.json to include the tests directory and additional file extensions, removes obsolete ESLint disable comments, simplifies a large number representation in tests, and refactors the spyElementPrototypes utility in tests/utils/domHook.js. Feedback on these changes suggests removing the deprecated --ext option from the ESLint command and adding a safety guard check in domHook.js to prevent potential runtime TypeError crashes when calling originDescriptor.set.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread package.json
"deploy": "npm run gh-pages",
"gh-pages": "npm run compile && cross-env GH_PAGES=1 npm run docs:build && npm run docs:deploy",
"lint": "eslint src/ --ext .tsx,.ts",
"lint": "eslint src/ tests/ --ext .tsx,.ts,.jsx,.js",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

In ESLint v9+ (and flat config mode, which is active here via eslint.config.mjs), the --ext command-line option has been deprecated and removed. Running eslint with --ext will result in a fatal error. Since flat config automatically determines which files to lint based on the files patterns in your configuration, you can safely remove the --ext option entirely.

Suggested change
"lint": "eslint src/ tests/ --ext .tsx,.ts,.jsx,.js",
"lint": "eslint src tests",

Comment thread tests/utils/domHook.js
Comment on lines 23 to 27
if (spyProp.set) {
return spyProp.set.call(this, originDescriptor, value);
spyProp.set.call(this, originDescriptor, value);
} else {
originDescriptor.set(value);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

If originDescriptor is undefined (which happens if the property did not exist on Element.prototype originally) or if it is a data descriptor (which does not have a set method), calling originDescriptor.set(value) will throw a TypeError at runtime. Adding a guard check for originDescriptor?.set prevents potential test crashes.

Suggested change
if (spyProp.set) {
return spyProp.set.call(this, originDescriptor, value);
spyProp.set.call(this, originDescriptor, value);
} else {
originDescriptor.set(value);
}
if (spyProp.set) {
spyProp.set.call(this, originDescriptor, value);
} else if (originDescriptor && originDescriptor.set) {
originDescriptor.set(value);
}

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.87%. Comparing base (167e60c) to head (606b7d8).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
tests/utils/domHook.js 60.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #374      +/-   ##
==========================================
- Coverage   96.99%   96.87%   -0.12%     
==========================================
  Files          19       19              
  Lines         831      832       +1     
  Branches      205      206       +1     
==========================================
  Hits          806      806              
- Misses         25       26       +1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zombieJ zombieJ merged commit 8385d80 into react-component:master Jul 15, 2026
8 of 12 checks passed
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
putComment timed out

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Caution

Review failed

An error occurred during the review process. Please try again later.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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.

2 participants