-
Notifications
You must be signed in to change notification settings - Fork 26
chore: sync upstream #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: sync upstream #120
Conversation
Updated to React 19
Fix: vertical swiping does not work
Replace enquire.js with window.matchMedia
fix unslick issues in vertical
fixed akiran#2414: No clones when there is one slide or unslick=true
Remove extra post clones
Clone tests
|
Warning Rate limit exceeded@afc163 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 2 minutes and 3 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough移除旧的多个 Jest 测试与测试工具,迁移至 React createRoot API,引入 Playwright CT 测试与相关脚手架,调整滑块克隆与媒体查询逻辑,并新增/修改若干测试工具与测试期望值。 Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45-60 minutes 需要重点检查的地方:
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
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. Comment |
Summary of ChangesHello @afc163, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request performs a comprehensive synchronization with upstream changes, focusing on modernizing the project's core dependencies and testing infrastructure. It upgrades React to version 19 and integrates Playwright for robust component testing, replacing older Jest-based utilities. Significant improvements have been made to the slider's cloning logic for better performance and accuracy, alongside a key behavioral adjustment to the 'unslick' condition. These changes collectively enhance the stability, maintainability, and future-readiness of the project. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
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 appears to be a large synchronization with an upstream repository, involving major dependency updates (including React 19 and Playwright for testing), refactoring of the testing suite, and changes to the slider's core logic, particularly around responsive handling and slide cloning. The changes aim to improve performance and align behavior with the original slick carousel.
My review focuses on a few regressions and potential issues introduced with these changes. I've identified a regression in responsive handling that could cause a flash of incorrect styles, pointed out some issues with dependency versions in package.json, and suggested improvements to test descriptions and code cleanup by removing obsolete API calls. Overall, the direction of the changes is positive, but these key issues should be addressed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
🧹 Nitpick comments (4)
docs/single-demo.js (1)
10-43: 考虑移除注释代码。这段被注释的
SimpleSlider实现代码(34 行)现在已经有对应的导入可用。如果不再需要此内联实现作为参考,建议移除以保持代码整洁。src/utils/innerSliderUtils.js (1)
791-800:getPostClones与getPreClones逻辑对齐,避免右侧克隆过多现在在
unslick或非infinite时直接返回 0;其余情况下,variableWidth仍返回slideCount,普通模式则与getPreClones一样返回slidesToShow + (centerMode ? 1 : 0)。这样左右两侧克隆节点数保持对称,既减少了不必要的 DOM 体积,也解释了多处测试中 slides / clones 期望值随之下降的原因。可以在未来考虑抽一个内部 helper 复用这段“计算克隆数”的逻辑,以降低两处实现后续改动时可能的偏差风险,但目前实现已足够清晰。playwright-tests/features/responsive/responsive.spec.tsx (1)
13-37: 避免依赖固定的waitForTimeout,改用具有自动等待能力的断言多次使用
page.waitForTimeout(100)等固定延时,在不同机器或负载下容易造成测试不稳定。这里可以直接对 locator 使用 Playwright 自带的自动轮询断言,既减少代码量,又更可靠,例如:[建议示例]
- await expect(await activeSlidesCount(component)).toEqual(4); + await expect( + component.locator(".slick-slide.slick-active") + ).toHaveCount(4);其他宽度下的断言也可以同样改成对 locator 的
toHaveCount,从而去掉显式的waitForTimeout调用。__tests__/regression/fix-1813.test.js (1)
34-61: 新的回归用例很好地覆盖了 slidesToShow === slidesCount 时的 unslick 行为
MultipleItems场景下,测试 9 个 slide 全部 active 且同时没有 arrows/dots,和文件顶部“slides <= slidesToShow 时会启用 unslick”的注释是一致的,回归点表达得比较清晰。如果这些被注释掉的旧用例(导航、dots 交互等)后续不打算再启用,可以考虑在后续重构时直接删除,或者改为
describe.skip/it.skip来保留行为意图而不是整段注释,便于维护。Also applies to: 62-163
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (34)
.gitignore(1 hunks)__tests__/jQSlickUtils.js(0 hunks)__tests__/mount/centerMode.test.js(0 hunks)__tests__/mount/lazyLoad.test.js(0 hunks)__tests__/mount/live.test.js(0 hunks)__tests__/mount/simple.test.js(0 hunks)__tests__/reactSlickUtils.js(0 hunks)__tests__/regression/fix-1813.test.js(4 hunks)__tests__/regression/fix-2315.test.js(1 hunks)__tests__/regression/fix-2414.test.js(1 hunks)docs/index.js(1 hunks)docs/single-demo.js(1 hunks)examples/__tests__/CentreMode.test.js(1 hunks)examples/__tests__/MultipleItems.test.js(1 hunks)examples/__tests__/SimpleSlider.test.js(1 hunks)examples/__tests__/UnevenSets.test.js(1 hunks)examples/__tests__/sample.test.js(0 hunks)gulpfile.js(2 hunks)jest.config.js(1 hunks)package.json(5 hunks)playwright-ct.config.js(1 hunks)playwright-tests/features/responsive/responsive.spec.tsx(1 hunks)playwright-tests/features/responsive/responsive.story.tsx(1 hunks)playwright-tests/regression/fix-1930/fix-1930.spec.tsx(1 hunks)playwright-tests/regression/fix-1930/fix-1930.story.tsx(1 hunks)playwright-tests/sample/sample.spec.tsx(1 hunks)playwright-tests/sample/sample.story.tsx(1 hunks)playwright/index.html(1 hunks)playwright/index.jsx(1 hunks)src/default-props.js(1 hunks)src/slider.js(1 hunks)src/track.js(2 hunks)src/utils/innerSliderUtils.js(1 hunks)test-utils.js(1 hunks)
💤 Files with no reviewable changes (7)
- tests/reactSlickUtils.js
- examples/tests/sample.test.js
- tests/mount/live.test.js
- tests/mount/centerMode.test.js
- tests/jQSlickUtils.js
- tests/mount/lazyLoad.test.js
- tests/mount/simple.test.js
🧰 Additional context used
🧬 Code graph analysis (10)
gulpfile.js (1)
playwright-ct.config.js (1)
require(2-2)
docs/index.js (1)
docs/docs.js (1)
Docs(6-21)
__tests__/regression/fix-2315.test.js (1)
test-utils.js (1)
getSlidesCount(3-5)
playwright-tests/sample/sample.spec.tsx (1)
playwright-tests/sample/sample.story.tsx (1)
App(3-5)
playwright-tests/regression/fix-1930/fix-1930.spec.tsx (1)
playwright-tests/regression/fix-1930/fix-1930.story.tsx (2)
VerticalModeFinite(4-21)VerticalModeInfinite(23-40)
examples/__tests__/MultipleItems.test.js (1)
test-utils.js (2)
getSlidesCount(3-5)getClonesCount(11-13)
playwright-tests/regression/fix-1930/fix-1930.story.tsx (1)
src/slider.js (1)
Slider(9-219)
__tests__/regression/fix-2414.test.js (2)
__tests__/TestComponents.js (1)
GenericSliderComponent(4-9)test-utils.js (4)
getActiveSlidesCount(15-17)getClonesCount(11-13)hasArrows(92-97)hasDots(88-90)
src/track.js (1)
src/utils/innerSliderUtils.js (7)
getPostClones(791-800)getPostClones(791-800)spec(166-179)spec(180-180)spec(342-362)spec(441-455)spec(694-708)
docs/single-demo.js (1)
docs/index.js (2)
container(7-7)root(8-8)
🪛 ESLint
playwright-tests/features/responsive/responsive.spec.tsx
[error] 11-11: 'React' must be in scope when using JSX
(react/react-in-jsx-scope)
playwright-tests/sample/sample.spec.tsx
[error] 12-12: 'React' must be in scope when using JSX
(react/react-in-jsx-scope)
playwright-tests/regression/fix-1930/fix-1930.spec.tsx
[error] 11-11: 'React' must be in scope when using JSX
(react/react-in-jsx-scope)
[error] 21-21: 'React' must be in scope when using JSX
(react/react-in-jsx-scope)
__tests__/regression/fix-2414.test.js
[error] 3-3: 'fireEvent' is defined but never used.
(no-unused-vars)
[error] 6-6: 'getCurrentSlideContent' is defined but never used.
(no-unused-vars)
[error] 7-7: 'getSlidesCount' is defined but never used.
(no-unused-vars)
__tests__/regression/fix-1813.test.js
[error] 16-16: 'getCurrentSlide' is defined but never used.
(no-unused-vars)
[error] 17-17: 'getSlidesCount' is defined but never used.
(no-unused-vars)
docs/single-demo.js
[error] 5-5: 'Slider' is defined but never used.
(no-unused-vars)
[error] 6-6: 'MultipleItems' is defined but never used.
(no-unused-vars)
[error] 7-7: 'SimpleSlider' is defined but never used.
(no-unused-vars)
[error] 8-8: 'CenterMode' is defined but never used.
(no-unused-vars)
🔇 Additional comments (23)
playwright/index.jsx (1)
1-2: 验证空文件是否符合预期。该文件仅包含注释,没有实际的可执行代码或样式导入。请确认这是否是有意为之的初始设置状态,还是需要实现实际的样式导入和主题初始化逻辑。
gulpfile.js (1)
33-39: 实现正确!这个新的 gulp 任务正确地实现了将 JavaScript 文件复制并重命名为 JSX 扩展名的功能,以支持 Playwright CT 测试工作流。实现遵循了标准的 gulp 模式,逻辑清晰。
jest.config.js (1)
9-9: 配置更新正确。将忽略模式从
e2e-tests更新为playwright-tests与本次 PR 引入的新 Playwright CT 测试基础设施保持一致。.gitignore (1)
23-27: 忽略模式添加正确。新增的忽略模式适合 Playwright CT 测试基础设施:
- 测试结果和报告目录(test-results、playwright-report、blob-report)
- Playwright 缓存目录
- 由 gulp 任务生成的 src-jsx 目录
playwright/index.html (1)
1-12: HTML 脚手架实现正确。这个 Playwright CT 测试页面的 HTML 结构标准且完整,包含了必要的元信息、根 div 元素和模块脚本导入。
docs/index.js (1)
4-15: React 18+ API 迁移正确。代码已正确迁移到 React 18+ 的
createRootAPI:
- 正确导入
createRootfromreact-dom/client- 遵循了创建容器、创建根、调用
root.render()的标准模式- 保留了
React.StrictMode包装器这与 React 19 的升级路径一致。
docs/single-demo.js (1)
56-64: React 18+ API 迁移正确。
createRootAPI 的迁移实现正确,与 React 19 的最佳实践一致。examples/__tests__/UnevenSets.test.js (1)
85-86: I'll help you verify the test expectation values. Let me start by examining the test file and understanding the context of these changes.
<function_calls>
#!/bin/bashFirst, let's look at the test file around lines 85-86 to understand the context
cat -n examples/tests/UnevenSets.test.js | sed -n '75,95p'
</function_calls>
#!/bin/bashSearch for totalSlides and clonedSlides patterns in test files
echo "=== Searching for totalSlides expectations ==="
rg -n "expect(totalSlides)" examples/tests/ -A 1 -B 1echo -e "\n=== Searching for clonedSlides expectations ==="
rg -n "expect(clonedSlides)" examples/tests/ -A 1 -B 1
</function_calls>
<function_calls>
#!/bin/bashCheck git history for these specific lines to understand why they changed
cd examples/tests && git log -p --follow -S "expect(totalSlides).toEqual(14)" -- UnevenSets.test.js | head -100 || echo "Git history not available, trying alternative approach"
</function_calls>
<function_calls>
#!/bin/bashLet's find the implementation being tested
First, understand what UnevenSets test is testing
cat -n examples/tests/UnevenSets.test.js | head -30
</function_calls>
<function_calls>
#!/bin/bashLook for the actual implementation file that UnevenSets.test.js is testing
rg -n "import.*UnevenSets" examples/tests/UnevenSets.test.js -A 2 -B 2
Also search for UnevenSets implementation
fd -name "nevenSets" -o -name "unevenSets" | grep -v tests
</function_calls>
<function_calls>
#!/bin/bashGet the full test function containing lines 85-86
cat -n examples/tests/UnevenSets.test.js | sed -n '60,100p'
</function_calls>
<function_calls>
#!/bin/bashSearch for the actual implementation in examples directory
find examples -name ".js" -not -path "tests*" -not -path "node_modules" | head -20
</function_calls>Let me analyze the structure more carefully:
<function_calls>
#!/bin/bashList all files in examples directory
ls -la examples/ | head -30
</function_calls>
<function_calls>
#!/bin/bashCheck for the actual implementation - look for imports in the test file more carefully
head -50 examples/tests/UnevenSets.test.js
</function_calls>
<function_calls>
#!/bin/bashLet's also check if there's recent commit information
git log --oneline -20 -- examples/tests/UnevenSets.test.js 2>/dev/null || echo "No git history"
</function_calls>Based on the information I need to gather, let me run comprehensive verification:
<function_calls>
#!/bin/bashGet complete context of the test
wc -l examples/tests/UnevenSets.test.js
echo "---"
cat -n examples/tests/UnevenSets.test.js | sed -n '1,120p'
</function_calls>package.json (1)
27-30: Playwright CT 测试脚本与依赖新增整体合理,但建议在 CI 中补一轮验证新增的
test-ct/test-clear/prepare-playwright脚本与@playwright/experimental-ct-react、gulp-rename、React 19 等 devDependencies 对齐,看起来配置完整、没有明显问题。需要注意的主要是两点:
playwright test -c playwright-ct.config.js所需的playwrightCLI 是否会通过当前依赖链正确安装;rm -rf ./playwright/.cache是否确实对应你们 Playwright 配置下的实际缓存目录。建议在干净环境(CI 或本地重新安装 node_modules)跑一次
npm test和npm run test-ct,确认新脚本在默认场景下可以顺利通过。Also applies to: 55-90, 109-110
__tests__/regression/fix-2315.test.js (1)
33-33: 更新 slidesCount 期望值以匹配新的克隆逻辑这里将期望改为
8与当前实现(例如 6 个实际 slide 加上两侧各 1 个克隆)更一致,有助于防止因为克隆规则调整导致的假阳性,整体测试流程保持不变。examples/__tests__/CentreMode.test.js (1)
20-21: CenterMode 计数期望已与新的克隆规则对齐
totalSlides = 14、clonedSlides = 8对应 6 个实际 slide、pre/post 各 4 个克隆,符合centerMode下getPreClones/getPostClones的对称逻辑,修改合理。src/default-props.js (1)
53-53: 新增verticalSwiping默认值提升配置一致性为
defaultProps补上verticalSwiping: false,让swipeMove/swipeEnd等逻辑始终拿到显式布尔值,同时也被validSettings/filterSettings正确识别,行为与之前“未传则视为 false”的语义保持向后兼容。playwright-tests/sample/sample.story.tsx (1)
1-5: 用于 Playwright CT 的最小示例组件实现简单可靠
App只是渲染静态文本"Learn React",无状态、无副作用,非常适合作为 Playwright 组件测试的 smoke story,不存在明显问题。src/slider.js (1)
203-208: 自动unslick条件放宽,更贴近“slide 数量不足时直接展示静态内容”的预期现在当
settings !== "unslick"且newChildren.length <= settings.slidesToShow时,会设置settings.unslick = true,不再依赖infinite标志。这能避免在实际 slide 数不超过可见数量时仍生成多余的克隆节点和导航控件,更符合大多数使用场景的直觉。这是一个行为层面的改变,建议在包含
responsive + infinite组合配置的几个示例页上手动走一遍,确认:
- slide 数量刚好等于或略小于
slidesToShow时布局/导航行为符合预期;- 从小屏断点切回大屏断点时,
unslick状态切换不会引入异常闪烁或状态残留。examples/__tests__/MultipleItems.test.js (1)
22-27: MultipleItems 测试期望已与新的克隆计数逻辑保持一致说明文案和断言从“更大的 clones 数量”调整为“9 个实际 slides,(3 pre + 3 post) 共 6 个克隆,总计 15 个
.slick-slide”,与getPreClones/getPostClones在slidesToShow = 3、infinite = true场景下的对称规则一致。其余关于激活 slides、dots 的行为断言保持不变,整体覆盖面良好。test-utils.js (1)
88-97: LGTM!新增的工具函数实现正确。这两个工具函数
hasDots和hasArrows逻辑清晰,可以有效检测滑块控件的存在性,并已被回归测试使用。examples/__tests__/SimpleSlider.test.js (1)
19-26: 测试预期已更新以反映上游变更。测试用例正确反映了滑块克隆逻辑的变更:总滑块数从 13 减少到 8,克隆数从 7 减少到 2。这与同步上游的 PR 目标一致。
playwright-tests/features/responsive/responsive.story.tsx (1)
1-71: LGTM!响应式滑块 Story 实现合理。该组件正确配置了多个响应式断点,并提供了清晰的测试用例。断点设置(1024、600、480)覆盖了常见的设备尺寸。
playwright-tests/regression/fix-1930/fix-1930.spec.tsx (1)
1-26: 验证 JSX 转换配置。ESLint 在第 11 行和第 21 行提示使用 JSX 时需要 React 在作用域内。如果项目使用旧版 JSX 转换,需要添加
import React from "react"。如果已配置现代 JSX 转换,可以更新 ESLint 规则或忽略此警告。此问题与
playwright-tests/sample/sample.spec.tsx中的问题相同,请一并验证项目的 JSX 转换配置。playwright-tests/regression/fix-1930/fix-1930.story.tsx (1)
1-40: LGTM!边界情况测试设计合理。这两个组件故意配置
slidesToShow: 3但仅提供 2 个滑块,用于测试修复 akiran#1930(当滑块数量少于 slidesToShow 时垂直模式的高度问题)。测试预期轨道高度为 200(2 个滑块 × 100 高度),符合修复后的行为。playwright-ct.config.js (1)
1-47: LGTM!Playwright 组件测试配置合理。配置文件正确设置了组件测试所需的各项参数,包括测试目录、超时时间、并行执行和 CI 优化。ctPort 设置为 3100 避免了端口冲突。
src/track.js (1)
8-9: 基于getPostClones的 post-clone 生成逻辑与 pre-clone 对称,整体实现合理新引入的
getPostClones(spec)与已有的getPreClones(spec)一样,对需要生成的克隆数量做了明确上限控制,且仍然叠加了key < endIndex的 lazy-load 边界判断和外层spec.infinite && !spec.unslick等条件。这样既减少不必要的 post clones,又保持了与 pre clones 对称的行为,看起来没有逻辑漏洞。Also applies to: 170-191
playwright-tests/features/responsive/responsive.spec.tsx (1)
1-2: Based on my verification, I can now provide the final analysis:Key Findings:
Playwright tests are not linted: The
npm run lintcommand runseslint srconly, which excludes theplaywright-testsdirectory entirely.Playwright CT React handles JSX automatically: Playwright's experimental-ct-react framework provides built-in JSX transformation support without requiring explicit React imports in test files.
Consistent pattern across the codebase: Multiple spec files (
responsive.spec.tsx,fix-1930.spec.tsx,sample.spec.tsx) all omit the React import in spec files, while story files (regular React components) do import React.Babel configuration: The
.babelrc.jsuses@babel/preset-react(old JSX transform), but this is handled by Playwright's built-in compilation for CT tests.
Output
React import not required in Playwright Component Testing spec files
Playwright's experimental-ct-react automatically handles JSX transformation in test files without requiring an explicit React import. The
responsive.spec.tsxfile follows the correct pattern already established across the codebase—spec files omit React imports while story files (regular React components) include them. Additionally, playwright-tests are excluded from linting (the npm lint command targets onlysrc), so no ESLint violations would occur. No changes are needed.
| getCurrentSlide, | ||
| getSlidesCount, | ||
| hasArrows, | ||
| hasDots |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# First, find and read the test file to examine the imports and usage
fd "fix-1813.test.js" -type fRepository: ant-design/react-slick
Length of output: 236
🏁 Script executed:
#!/bin/bash
# Correct fd command to find the test file
fd "fix-1813.test.js"Repository: ant-design/react-slick
Length of output: 103
🏁 Script executed:
#!/bin/bash
# Read the test file with line numbers
cat -n __tests__/regression/fix-1813.test.js | head -60Repository: ant-design/react-slick
Length of output: 2225
🏁 Script executed:
#!/bin/bash
# Get full file line count
wc -l __tests__/regression/fix-1813.test.jsRepository: ant-design/react-slick
Length of output: 107
🏁 Script executed:
#!/bin/bash
# Search for getCurrentSlide usage in the test file
echo "=== Searching for getCurrentSlide ==="
rg "getCurrentSlide" __tests__/regression/fix-1813.test.js -n
echo ""
echo "=== Searching for getSlidesCount ==="
rg "getSlidesCount" __tests__/regression/fix-1813.test.js -nRepository: ant-design/react-slick
Length of output: 184
🏁 Script executed:
#!/bin/bash
# Read the full test file to see complete context
cat -n __tests__/regression/fix-1813.test.jsRepository: ant-design/react-slick
Length of output: 5651
Remove unused getCurrentSlide and getSlidesCount imports to fix ESLint no-unused-vars warnings
These imports are not used anywhere in the test file. Neither appears in the active test cases (lines 35–61) nor in the commented-out test code (lines 62–163). Removing them will resolve ESLint no-unused-vars errors without affecting test coverage.
getButtons,
getButtonsLength,
getClonesCount,
- getCurrentSlide,
- getSlidesCount,
hasArrows,
hasDots
} from "../../test-utils";📝 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.
| getCurrentSlide, | |
| getSlidesCount, | |
| hasArrows, | |
| hasDots | |
| getButtons, | |
| getButtonsLength, | |
| getClonesCount, | |
| hasArrows, | |
| hasDots | |
| } from "../../test-utils"; |
🧰 Tools
🪛 ESLint
[error] 16-16: 'getCurrentSlide' is defined but never used.
(no-unused-vars)
[error] 17-17: 'getSlidesCount' is defined but never used.
(no-unused-vars)
🤖 Prompt for AI Agents
In __tests__/regression/fix-1813.test.js around lines 16 to 19, the imports
getCurrentSlide and getSlidesCount are unused and trigger ESLint no-unused-vars
warnings; remove these two named imports from the import list so only used
imports (hasArrows, hasDots, etc.) remain, then run the linter to confirm
warnings are gone.
| import { render, fireEvent } from "@testing-library/react"; | ||
|
|
||
| import { | ||
| getCurrentSlideContent, | ||
| getSlidesCount, | ||
| getActiveSlidesCount, | ||
| getClonesCount, | ||
| hasArrows, | ||
| hasDots | ||
| } from "../../test-utils"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
移除未使用的导入。
代码导入了 fireEvent、getCurrentSlideContent 和 getSlidesCount,但在测试中从未使用这些函数。建议移除这些未使用的导入以保持代码整洁。
应用此 diff 移除未使用的导入:
-import { render, fireEvent } from "@testing-library/react";
+import { render } from "@testing-library/react";
import {
- getCurrentSlideContent,
- getSlidesCount,
getActiveSlidesCount,
getClonesCount,
hasArrows,
hasDots
} from "../../test-utils";📝 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.
| import { render, fireEvent } from "@testing-library/react"; | |
| import { | |
| getCurrentSlideContent, | |
| getSlidesCount, | |
| getActiveSlidesCount, | |
| getClonesCount, | |
| hasArrows, | |
| hasDots | |
| } from "../../test-utils"; | |
| import { render } from "@testing-library/react"; | |
| import { | |
| getActiveSlidesCount, | |
| getClonesCount, | |
| hasArrows, | |
| hasDots | |
| } from "../../test-utils"; |
🧰 Tools
🪛 ESLint
[error] 3-3: 'fireEvent' is defined but never used.
(no-unused-vars)
[error] 6-6: 'getCurrentSlideContent' is defined but never used.
(no-unused-vars)
[error] 7-7: 'getSlidesCount' is defined but never used.
(no-unused-vars)
🤖 Prompt for AI Agents
In __tests__/regression/fix-2414.test.js around lines 3 to 12, remove the unused
imports to clean up the test file: delete fireEvent from the first import and
remove getCurrentSlideContent and getSlidesCount from the second import list,
leaving only the functions that are actually used (getActiveSlidesCount,
getClonesCount, hasArrows, hasDots); update the import lines accordingly so
there are no dangling or unused imports.
| const { container } = render(<SliderWithOneSlide />); | ||
| expect(getClonesCount(container)).toEqual(0); | ||
| }); | ||
| it("should no have dots and arrows", function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修正测试描述中的语法错误。
测试描述中存在拼写错误:"should no have" 应为 "should not have"。
应用此 diff 修正语法错误:
- it("should no have dots and arrows", function() {
+ it("should not have dots and arrows", function() {- it("should no have dots and arrows", function() {
+ it("should not have dots and arrows", function() {Also applies to: 57-57
🤖 Prompt for AI Agents
In __tests__/regression/fix-2414.test.js around lines 41 and 57, the test
description contains a typo: "should no have" should be corrected to "should not
have"; update both occurrences to use "should not have" so the test descriptions
read correctly and grammatically.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #120 +/- ##
==========================================
- Coverage 45.86% 45.07% -0.80%
==========================================
Files 8 8
Lines 992 994 +2
Branches 317 320 +3
==========================================
- Hits 455 448 -7
- Misses 439 446 +7
- Partials 98 100 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Chores
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.