Skip to content
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

fix: npm run build, lint, test failure in 3.0 #2680

Merged
merged 4 commits into from
Oct 30, 2024
Merged

Conversation

Alex-huxiyang
Copy link
Collaborator

@Alex-huxiyang Alex-huxiyang commented Oct 30, 2024

🤔 这个变动的性质是?

  • 新特性提交
  • 日常 bug 修复
  • 站点、文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • TypeScript 定义更新
  • 包体积优化
  • 性能优化
  • 功能增强
  • 国际化改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他改动(是关于什么的改动?)

🔗 相关 Issue

💡 需求背景和解决方案

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • fork仓库代码是否为最新避免文件冲突
  • Files changed 没有 package.json lock 等无关文件

Summary by CodeRabbit

  • 新功能

    • 更新了 Avatar 组件,移除了 alt 属性,可能影响可访问性。
    • AvatarCropper 组件的触摸事件处理方式进行了改进,以增强与 Taro 事件系统的兼容性。
    • 更新了 Popup 组件,禁用了 Android 返回按钮和覆盖点击事件的处理。
    • Uploader 组件的按钮属性进行了简化,移除了 nativeType 属性。
    • 更新了 Range 组件的拖动状态初始化,简化了状态管理。
    • 更新了 CSS 变量,增加了新的命名约定和样式选项。
  • Bug 修复

    • 扩展了 Uploader 组件的测试,增加了文件删除确认的场景覆盖。
  • 文档

    • 更新了 .eslintignore.prettierignore 文件,新增了对特定文件的忽略规则。

Copy link

coderabbitai bot commented Oct 30, 2024

Warning

Rate limit exceeded

@Alex-huxiyang has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 0 minutes and 41 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Files that changed from the base of the PR and between d85c901 and 75cadf4.

Walkthrough

此拉取请求包含对多个组件的修改,包括 AvatarAvatarCropperPopupRangeUploader。主要变更包括移除 Avatar 组件中的 alt 属性,调整 AvatarCropper 组件的触摸事件处理类型,更新 Popup 组件的事件处理程序以禁用某些功能,简化 Range 组件的状态初始化,以及对 Uploader 组件的按钮属性进行修改。这些更改旨在优化组件的属性管理和事件处理。

Changes

文件路径 变更摘要
src/packages/avatar/avatar.taro.tsx 移除了 Avatar 组件中的 alt 属性,保持其他属性和功能不变。
src/packages/avatarcropper/avatarcropper.taro.tsx 修改了 onTouchStartonTouchMoveonTouchEnd 事件处理程序的类型,从 React.TouchEvent<HTMLDivElement> 更改为 CommonEventFunction
src/packages/configprovider/types.ts 更新了 NutCSSVariables 类型,移除了多个变量并添加了新的 CSS 变量。
src/packages/popup/popup.rn.tsx 注释掉了 ModalTouchableOpacity 组件的 onRequestCloseonPress 事件处理程序,禁用了相关功能。
src/packages/range/range.taro.tsx 简化了 dragStatus 状态的初始化,从逻辑或表达式更改为简单字符串赋值。
src/packages/range/range.tsx 同样简化了 dragStatus 状态的初始化,确保其开始时为 'start'
src/packages/uploader/tests/uploader.spec.tsx 移除了与图像源 URL 相关的断言,扩展了 before-delete 属性的测试场景。
src/packages/uploader/uploader.taro.tsx 移除了 Button 组件的 nativeType 属性,保持其他逻辑和功能不变。
.eslintignore 新增了 src/packages/nutui.react.build.rn.ts 以忽略 ESLint 检查。
.prettierignore 新增了 src/packages/nutui.react.build.rn.ts 以忽略 Prettier 格式化。

Suggested reviewers

  • oasis-cloud

🐇 在草地上跳跃,组件变得更轻盈,
属性简化如春风,功能依旧灵动。
触摸事件更通用,样式更新不再愁,
上传按钮更简洁,用户体验更美好!
一切皆为更好的明天,兔子欢快地歌唱! 🎶


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Oct 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (V3.0@aba2e6b). Learn more about missing BASE report.
Report is 1 commits behind head on V3.0.

Additional details and impacted files
@@           Coverage Diff           @@
##             V3.0    #2680   +/-   ##
=======================================
  Coverage        ?   83.95%           
=======================================
  Files           ?      221           
  Lines           ?    17849           
  Branches        ?     2679           
=======================================
  Hits            ?    14986           
  Misses          ?     2858           
  Partials        ?        5           

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

Copy link

@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: 0

🧹 Outside diff range and nitpick comments (4)
src/packages/range/range.taro.tsx (1)

Line range hint 32-584: 建议优化组件架构以提高可维护性

组件当前实现存在以下可以改进的地方:

  1. 建议将平台特定的代码(React Native、Harmony)抽离到单独的适配层
  2. 可以将触摸事件处理逻辑抽离为自定义 Hook,以简化主组件逻辑
  3. 建议将样式转换计算逻辑统一封装,减少重复代码

这些改进将有助于:

  • 提高代码的可维护性
  • 降低平台适配的复杂度
  • 简化测试流程

您是否需要我协助实现这些优化建议?

src/packages/avatarcropper/avatarcropper.taro.tsx (2)

Line range hint 452-473: 建议改进事件类型定义

目前的实现中使用 any 类型作为事件参数可能会降低类型安全性。建议使用更具体的类型定义来增强代码的可靠性。

建议按照以下方式修改:

-const onTouchStart: CommonEventFunction = (event: any) => {
+const onTouchStart: CommonEventFunction = (event: CommonEvent) => {
-const onTouchMove: CommonEventFunction = (event: any) => {
+const onTouchMove: CommonEventFunction = (event: CommonEvent) => {
-const onTouchEnd: CommonEventFunction = (event: any) => {
+const onTouchEnd: CommonEventFunction = (event: CommonEvent) => {

同时需要添加以下导入:

import { CommonEvent } from '@tarojs/components'

Also applies to: 475-502, 503-544


Line range hint 452-544: 建议添加文档和测试

触摸事件处理逻辑较为复杂,建议:

  1. 添加详细的代码注释,说明各个手势操作的处理逻辑
  2. 编写单元测试,确保各种触摸场景的正确性

如果需要,我可以帮助:

  1. 生成详细的代码注释
  2. 编写相应的单元测试用例
src/packages/configprovider/types.ts (1)

Line range hint 1-347: 建议:考虑使用 TypeScript 枚举或常量对象

考虑将这些 CSS 变量重构为 TypeScript 枚举或常量对象,可以提供更好的类型安全性和代码组织性。

示例实现:

export enum NutUIThemeColor {
  Primary = 'nutuiColorPrimary',
  PrimaryDisabled = 'nutuiColorPrimaryDisabled',
  PrimaryDisabledSpecial = 'nutuiColorPrimaryDisabledSpecial',
  // ... 其他颜色变量
}

export enum NutUIFontSize {
  XXS = 'nutuiFontSizeXxs',
  XS = 'nutuiFontSizeXs',
  // ... 其他字体大小变量
}

export type NutCSSVariables = `${NutUIThemeColor}` | `${NutUIFontSize}` | // ... 其他变量类型
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between aba2e6b and ea956e3.

⛔ Files ignored due to path filters (2)
  • src/packages/hoverbutton/__test__/__snapshots__/hoverbutton.spec.tsx.snap is excluded by !**/*.snap
  • src/packages/infiniteloading/__tests__/__snapshots__/infiniteloading.spec.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (8)
  • src/packages/avatar/avatar.taro.tsx (0 hunks)
  • src/packages/avatarcropper/avatarcropper.taro.tsx (4 hunks)
  • src/packages/configprovider/types.ts (3 hunks)
  • src/packages/popup/popup.rn.tsx (2 hunks)
  • src/packages/range/range.taro.tsx (1 hunks)
  • src/packages/range/range.tsx (1 hunks)
  • src/packages/uploader/tests/uploader.spec.tsx (0 hunks)
  • src/packages/uploader/uploader.taro.tsx (1 hunks)
💤 Files with no reviewable changes (2)
  • src/packages/avatar/avatar.taro.tsx
  • src/packages/uploader/tests/uploader.spec.tsx
✅ Files skipped from review due to trivial changes (1)
  • src/packages/popup/popup.rn.tsx
🔇 Additional comments (8)
src/packages/uploader/uploader.taro.tsx (1)

508-510: Button组件属性简化可能影响表单行为

移除了Button组件的nativeType属性,这个改动虽然简化了代码,但需要注意以下几点:

  1. 在表单上下文中使用时,按钮的默认类型可能会触发表单提交
  2. 建议验证此更改在实际表单场景中的行为
src/packages/range/range.tsx (1)

96-96: 修复了 dragStatus 状态的初始化问题

'start' || 'draging' || '' 修改为 'start' 修复了无效的语法。不过需要注意以下几点:

  1. 初始状态设置为 'start' 可能会影响组件的初始渲染行为
  2. 建议验证此更改是否会影响以下场景:
    • 组件初始化时的过渡动画效果
    • 首次触摸时 onStart 回调的触发时机
✅ Verification successful

dragStatus 状态初始化的修改是安全的

根据代码分析,将 dragStatus 的初始值设置为 'start' 是正确的实现:

  1. dragStatus 在组件中有三种状态:

    • 'start':初始状态,用于触发 onStart 回调
    • 'draging':拖动过程中的状态
    • ''(空字符串):拖动结束的状态
  2. 原有的 'start' || 'draging' || '' 语法是错误的,因为这个表达式会始终返回第一个真值 'start'

  3. 代码中的状态转换逻辑完全符合将初始值设为 'start' 的设计:

    • 初始状态为 'start',首次触摸时触发 onStart
    • 拖动时更新为 'draging'
    • 拖动结束时重置为空字符串
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查是否有其他文件使用了类似的状态初始化模式
rg "'start'\s*\|\|\s*'draging'\s*\|\|\s*''" --type ts

Length of output: 73


Script:

#!/bin/bash
# Search for dragStatus usage patterns in the codebase
rg "dragStatus" -A 3 -B 3 --type ts

# Search for similar state patterns with 'start' or 'dragging'
rg "useState\(['\"](?:start|drag)" --type ts

# Look for the Range component implementation to understand state usage
ast-grep --pattern 'const Range = $_$ => {
  $$$
  useState($$$)
  $$$
}'

Length of output: 5741

src/packages/range/range.taro.tsx (1)

101-101: 修复了 dragStatus 状态的初始化逻辑

之前的实现 useState('start' || 'draging' || '') 存在逻辑错误,因为 JavaScript 的 OR 运算符会直接返回第一个真值 'start'。现在的实现更清晰地表达了意图。

src/packages/avatarcropper/avatarcropper.taro.tsx (1)

10-10: 导入声明看起来不错!

从 @tarojs/components 导入 CommonEventFunction 类型是正确的做法,与其他 Taro 相关的导入保持一致。

src/packages/configprovider/types.ts (4)

7-7: 变量命名更新符合语义化要求

nutuiColorPrimaryLight 更改为 nutuiColorPrimaryDisabledSpecial 更好地表达了该变量的用途。


33-43: 新增的颜色和背景变量分组合理

新增的颜色和背景相关变量遵循了统一的命名规范,并按照功能进行了合理分组:

  • 背景色变量
  • 遮罩层相关变量
  • 边框相关变量
  • 文本颜色变量

47-59: 字体相关变量系统完善

新增的字体相关变量构建了完整的层级体系:

  • 字体大小从 XXS 到 XXL 的递进
  • 特定数值的字体大小(10、11)
  • 字体粗细和行高变量

60-77: 间距和圆角变量体系统一

新增的间距(Spacing)和圆角(Radius)变量采用了一致的命名规范,从 XXXS 到 XXXL 形成完整的递进体系,便于维护和使用。

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.

2 participants