Skip to content

refactor: remove unnecessary eslint-disable and @ts-ignore#9439

Merged
chenshuai2144 merged 2 commits intoant-design:masterfrom
zzjiaxiang:remove-lint
Feb 10, 2026
Merged

refactor: remove unnecessary eslint-disable and @ts-ignore#9439
chenshuai2144 merged 2 commits intoant-design:masterfrom
zzjiaxiang:remove-lint

Conversation

@zzjiaxiang
Copy link
Contributor

@zzjiaxiang zzjiaxiang commented Feb 8, 2026

Summary by CodeRabbit

发布说明

  • 代码质量改进

    • 移除了大量 ESLint/TypeScript 抑制指令,增强静态检查覆盖面。
  • 行为调整 / 修复

    • 验证码流程中移除部分错误日志输出,错误处理路径调整(不再输出 console.error)。
    • 保留了部分字段属性(如 emptyText/ref),可能影响字段渲染行为。
  • 其他优化

    • 改进了列表项键值赋值与若干属性访问写法,简化代码样式。

…components

- Cleaned up code by removing redundant eslint-disable comments related to array index keys and other rules in various components.
- Improved code readability and maintainability by ensuring adherence to linting rules without compromising functionality.
- Ensured that all components remain functional and visually consistent after the removal of these comments.
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Feb 8, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 8, 2026

📝 Walkthrough

Walkthrough

本次提交主要移除大量 ESLint/TypeScript 抑制注释(如 exhaustive-deps、react/no-array-index-key、@ts-ignore 等),同时包含少量行为相关改动:保留了部分 props(emptyText/ref)、移除 Captcha 的 console.error、nanoid 增加了 window?.crypto?.randomUUID 检查、ListToolBar 明确添加了 keys、以及 Table 中删除 _timestamp 的写法微调。

Changes

Cohort / File(s) Summary
React Hooks exhaustive-deps 抑制移除
src/form/BaseForm/BaseForm.tsx, src/form/components/FormItem/index.tsx, src/form/components/List/index.tsx, src/form/components/SchemaForm/index.tsx, src/form/layouts/DrawerForm/index.tsx, src/form/layouts/LightFilter/index.tsx, src/form/layouts/ModalForm/index.tsx, src/form/layouts/StepsForm/StepForm.tsx, src/layout/components/FooterToolbar/index.tsx, src/layout/components/PageContainer/index.tsx, src/layout/components/SettingDrawer/BlockCheckbox.tsx, src/layout/components/SettingDrawer/index.tsx, src/layout/components/SiderMenu/BaseMenu.tsx, src/layout/components/SiderMenu/SiderMenu.tsx, src/layout/components/SiderMenu/index.tsx, src/provider/index.tsx, src/table/Store/Provide.tsx, src/table/Table.tsx, src/table/components/ColumnSetting/index.tsx, src/table/components/EditableTable/index.tsx, src/table/useFetchData.tsx, src/utils/hooks/useDebounceValue/index.ts, src/utils/hooks/useDeepCompareEffect/index.ts, src/utils/useEditableArray/index.tsx, src/utils/useEditableMap/index.tsx
删除多处在 useEffect/useMemo 等 hook 依赖数组前的 react-hooks/exhaustive-deps 抑制注释,依赖数组本身未改。
Array index key 抑制移除
src/card/components/Actions/index.tsx, src/card/components/CheckCard/Group.tsx, src/field/components/Options/index.tsx, src/form/components/SchemaForm/layoutType/StepsForm.tsx, src/layout/components/AppsLogoComponents/DefaultContent.tsx, src/layout/components/AppsLogoComponents/SimpleContent.tsx, src/layout/components/GlobalHeader/ActionsContent.tsx, src/skeleton/components/Descriptions/index.tsx, src/skeleton/components/List/index.tsx
移除 react/no-array-index-key 的 eslint-disable 注释;多数列表仍以数组索引作为 key(实现未变,lint 约束恢复)。
TypeScript 抑制移除
src/card/components/Card/index.tsx, src/field/components/Checkbox/index.tsx, src/form/components/DatePicker/index.tsx, src/form/components/FormItem/warpField.tsx, src/form/components/Radio/index.tsx, src/form/components/Text/index.tsx, src/layout/components/Header/index.tsx, src/layout/components/TopNavHeader/index.tsx, src/utils/nanoid/index.ts, src/utils/proFieldParsingText/index.tsx
删除多处 // @ts-ignore`` / 类型抑制注释,允许 TypeScript 进行正常校验;nanoid 同时调整为尝试使用 `window?.crypto?.randomUUID`。
属性保留 / 参数处理变更
src/field/PureProField.tsx, src/field/AllProField.tsx, src/field/components/Select/SearchSelect/index.tsx, src/field/components/Switch/index.tsx, src/field/components/Options/index.tsx
删除对 props.emptyTextprops.ref 的清理代码(在 PureProField 中),导致这些属性被保留传递;同时移除若干 lint 抑制注释。
错误日志移除
src/form/components/Captcha/index.tsx
从两个 catch 块中移除 console.error 调用及对应抑制注释,改为静默错误处理。
ListToolBar - 显式 keys
src/table/components/ListToolBar/index.tsx
为 actions 与 设置项渲染新增显式 key(使用 index),并移除相关 eslint-disable 注释。
Table: 删除 _timestamp 写法微调
src/table/Table.tsx
改为直接删除 actionParams._timestamp(从之前的类型断言删除改写),同时移除若干 hook lint 抑制注释。
小范围清理与导入/访问优化
src/form/layouts/DrawerForm/index.tsx, src/form/layouts/ModalForm/index.tsx, src/form/components/UploadDragger/index.tsx, src/descriptions/useFetchData.tsx, src/layout/ProLayout.tsx, src/layout/components/GlobalHeader/ActionsContent.tsx, src/layout/components/Header/index.tsx, src/layout/components/TopNavHeader/index.tsx, src/layout/components/AppsLogoComponents/..., src/layout/utils/getMenuData.ts, src/provider/useStyle/index.ts, src/table/utils/cellRenderToFromItem.tsx, src/table/components/ListToolBar/index.tsx, src/utils/isDeepEqualReact/index.ts, src/utils/merge/index.ts, src/utils/proFieldParsingText/index.tsx, src/utils/useEditableMap/index.tsx
若干文件中移除各类 ESLint 注释、简化属性访问(括号改点号)、合并/简化导入、删除顶部或模块级别的 eslint-disable 注释,功能等价或仅做类型/lint 影响。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 我把注释一一拔,
代码庭院更见花,
Lint 的枷锁今朝拆,
静默日志轻风撒,
铃铛声里新行发 ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确反映了PR的主要变更内容——移除不必要的ESLint禁用指令和@ts-ignore注释。

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉


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.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @zzjiaxiang, 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 is a significant refactoring effort aimed at enhancing the overall code quality and maintainability of the project. It systematically removes various unnecessary ESLint disable comments and TypeScript @ts-ignore directives that were previously suppressing warnings or errors. This cleanup ensures that the codebase now more closely adheres to best practices for linting and type safety, leading to a more robust and easier-to-understand system without altering any functional logic.

Highlights

  • ESLint Disable Comments Removed: Numerous eslint-disable comments have been removed across the codebase. This includes specific rule suppressions such as react/no-array-index-key, react-hooks/exhaustive-deps, no-param-reassign, no-console, no-underscore-dangle, prefer-const, no-restricted-syntax, @typescript-eslint/no-unused-vars, and @typescript-eslint/no-use-before-define. Several file-level /* eslint-disable ... */ directives were also removed.
  • TypeScript Ignore Directives Removed: Multiple @ts-ignore directives have been eliminated. This indicates an improvement in type safety and better alignment with TypeScript's strictness, or that the underlying type issues have been resolved.
  • Enhanced Code Quality and Maintainability: The removal of these suppressions contributes to a cleaner, more readable, and more maintainable codebase. It promotes stricter adherence to linting rules and type checks, reducing potential hidden issues and improving developer experience.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/card/components/Actions/index.tsx
    • Removed // eslint-disable-next-line react/no-array-index-key.
  • src/card/components/Card/index.tsx
    • Removed // @ts-ignore.
  • src/card/components/CheckCard/Group.tsx
    • Removed // eslint-disable-next-line react/no-array-index-key.
  • src/card/components/CheckCard/index.tsx
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
  • src/descriptions/useFetchData.tsx
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
  • src/field/AllProField.tsx
    • Removed // eslint-disable-next-line no-param-reassign.
    • Removed // eslint-disable-next-line no-param-reassign.
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
  • src/field/PureProField.tsx
    • Removed // eslint-disable-next-line no-param-reassign.
    • Removed // eslint-disable-next-line @typescript-eslint/no-use-before-define.
    • Removed // eslint-disable-next-line no-param-reassign.
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
  • src/field/components/Checkbox/index.tsx
    • Removed //@ts-ignore.
  • src/field/components/Options/index.tsx
    • Removed // eslint-disable-next-line react/no-array-index-key.
    • Removed // eslint-disable-next-line react/no-array-index-key.
    • Removed // @ts-ignore.
  • src/field/components/Select/SearchSelect/index.tsx
    • Removed // eslint-disable-next-line @typescript-eslint/no-unused-vars.
  • src/field/components/Switch/index.tsx
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
  • src/form/BaseForm/BaseForm.tsx
    • Removed file-level /* eslint-disable react-hooks/exhaustive-deps */.
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
  • src/form/components/Captcha/index.tsx
    • Removed // eslint-disable-next-line no-console.
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
    • Removed // eslint-disable-next-line no-console.
  • src/form/components/DatePicker/index.tsx
    • Removed // @ts-ignore.
    • Removed // eslint-disable-next-line no-param-reassign.
  • src/form/components/FormItem/index.tsx
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
  • src/form/components/FormItem/warpField.tsx
    • Removed // @ts-ignore and // eslint-disable-next-line no-param-reassign.
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
    • Removed // @ts-ignore.
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
    • Removed // @ts-ignore (twice).
  • src/form/components/List/index.tsx
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
  • src/form/components/Radio/index.tsx
    • Removed // @ts-ignore and // eslint-disable-next-line no-param-reassign.
  • src/form/components/SchemaForm/index.tsx
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
  • src/form/components/SchemaForm/layoutType/StepsForm.tsx
    • Removed // eslint-disable-next-line react/no-array-index-key.
  • src/form/components/Select/index.tsx
    • Removed // @ts-ignore and // eslint-disable-next-line no-param-reassign.
  • src/form/components/Text/index.tsx
    • Removed // @ts-ignore and // eslint-disable-next-line no-param-reassign.
  • src/form/components/UploadDragger/index.tsx
    • Removed // @ts-ignore.
  • src/form/helpers/grid.tsx
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps (twice).
  • src/form/layouts/DrawerForm/index.tsx
    • Removed // eslint-disable-next-line @typescript-eslint/dot-notation.
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
  • src/form/layouts/LightFilter/index.tsx
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
  • src/form/layouts/ModalForm/index.tsx
    • Removed // eslint-disable-next-line @typescript-eslint/dot-notation.
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
  • src/form/layouts/QueryFilter/index.tsx
    • Removed file-level /* eslint-disable no-param-reassign */.
  • src/form/layouts/StepsForm/StepForm.tsx
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
  • src/layout/ProLayout.tsx
    • Removed useRef import.
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
    • Removed // @ts-ignore.
  • src/layout/components/AppsLogoComponents/DefaultContent.tsx
    • Removed // eslint-disable-next-line react/no-array-index-key (twice).
  • src/layout/components/AppsLogoComponents/SimpleContent.tsx
    • Removed // eslint-disable-next-line react/no-array-index-key (twice).
  • src/layout/components/FooterToolbar/index.tsx
    • Removed file-level /* eslint-disable react-hooks/exhaustive-deps */.
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
  • src/layout/components/GlobalHeader/ActionsContent.tsx
    • Removed // eslint-disable-next-line react/no-array-index-key.
    • Removed //@ts-ignore.
  • src/layout/components/Header/index.tsx
    • Removed // @ts-ignore.
  • src/layout/components/PageContainer/index.tsx
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
  • src/layout/components/SettingDrawer/BlockCheckbox.tsx
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
  • src/layout/components/SettingDrawer/index.tsx
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
  • src/layout/components/SiderMenu/BaseMenu.tsx
    • Removed // eslint-disable-next-line react/no-is-mounted.
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps (twice).
  • src/layout/components/SiderMenu/SiderMenu.tsx
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
  • src/layout/components/SiderMenu/index.tsx
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
  • src/layout/components/TopNavHeader/index.tsx
    • Removed // @ts-ignore.
  • src/layout/utils/getMenuData.ts
    • Removed // eslint-disable-next-line no-param-reassign.
  • src/provider/index.tsx
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps (twice).
  • src/provider/useStyle/index.ts
    • Removed // eslint-disable-next-line prefer-const.
  • src/skeleton/components/Descriptions/index.tsx
    • Removed // eslint-disable-next-line react/no-array-index-key (3 times).
  • src/skeleton/components/List/index.tsx
    • Removed // eslint-disable-next-line react/no-array-index-key (twice).
  • src/table/Store/Provide.tsx
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps (twice).
  • src/table/Table.tsx
    • Removed // eslint-disable-next-line no-underscore-dangle.
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps (4 times).
  • src/table/components/ColumnSetting/index.tsx
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
  • src/table/components/EditableTable/index.tsx
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
  • src/table/components/ListToolBar/index.tsx
    • Removed // eslint-disable-next-line react/no-array-index-key (twice).
  • src/table/useFetchData.tsx
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps (3 times).
  • src/table/utils/cellRenderToFromItem.tsx
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
  • src/table/utils/index.ts
    • Removed // eslint-disable-next-line no-param-reassign.
  • src/utils/hooks/useDebounceValue/index.ts
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps.
  • src/utils/hooks/useDeepCompareEffect/index.ts
    • Removed // eslint-disable-next-line react-hooks/exhaustive-deps (twice).
  • src/utils/isDeepEqualReact/index.ts
    • Removed multiple file-level /* eslint-disable ... */ directives.
    • Removed // eslint-disable-next-line prefer-const.
  • src/utils/merge/index.ts
    • Removed file-level /* eslint-disable prefer-rest-params */.
    • Removed // eslint-disable-next-line no-restricted-syntax.
  • src/utils/nanoid/index.ts
    • Removed file-level /* eslint-disable prefer-const */.
    • Removed // eslint-disable-next-line no-param-reassign.
    • Removed // @ts-ignore (twice).
  • src/utils/proFieldParsingText/index.tsx
    • Removed // @ts-ignore.
  • src/utils/useEditableArray/index.tsx
    • Removed file-level /* eslint-disable react-hooks/exhaustive-deps */.
  • src/utils/useEditableMap/index.tsx
    • Removed file-level /* eslint-disable react-hooks/exhaustive-deps */.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 primarily focuses on code quality improvements by removing numerous ESLint disable comments across various files. Specifically, it removes react-hooks/exhaustive-deps comments from many useEffect and useMemo hooks, react/no-array-index-key comments from several list rendering components, @ts-ignore comments to improve type safety, and no-param-reassign comments to prevent direct mutation of function parameters. Additionally, no-console and other general ESLint disable comments are removed. The review comments highlight that while removing exhaustive-deps is good, the underlying issues of stale closures for functions like fetchList in useFetchData.tsx need to be addressed by wrapping them in useRefFunction. It also points out missing dependencies in useEffect hooks, such as props.countDown in Captcha/index.tsx and props.onPageChange, location in ProLayout.tsx. Furthermore, the reviewer suggests refactoring code that uses delete on props objects (e.g., emptyText, ref) to instead create new objects without the unwanted properties, promoting immutability.

}
fetchList();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [...(effects || []), manual]);
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Removing the eslint-disable-next-line react-hooks/exhaustive-deps comment is good, but the underlying issue should be addressed. The fetchList function is redefined on every render, and it's not included in the useEffect dependency array. This can lead to stale closures.

To fix this, you can wrap fetchList in useRefFunction to ensure it's a stable reference. This utility is already available in the project.

const fetchList = useRefFunction(async () => {
  // ... function body
});

}
return () => clearInterval(interval);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [timing]);
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The useEffect hook depends on props.countDown, but it's not included in the dependency array. This can lead to using a stale value of countDown if the prop changes. Please add props.countDown to the dependency array.

Suggested change
}, [timing]);
}, [timing, props.countDown]);

useEffect(() => {
props.onPageChange?.(props.location);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [location.pathname, location.pathname?.search]);
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The useEffect hook depends on props.onPageChange and props.location, but they are not included in the dependency array. This can lead to stale closures. Instead of depending on location.pathname, you can depend on location directly.

Suggested change
}, [location.pathname, location.pathname?.search]);
}, [location, props.onPageChange]);

}

// eslint-disable-next-line no-param-reassign
delete props.emptyText;
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Mutating function arguments like the props object is generally a bad practice as it can lead to unexpected side effects in other parts of the application that might be using the same object. Instead of using delete, it's safer to create a new object without the emptyText property, for example by using object destructuring.

valueTypeMap && valueTypeMap[valueType as string];
if (customValueTypeConfig) {
// eslint-disable-next-line no-param-reassign
delete props.ref;
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Mutating function arguments like the props object is generally a bad practice as it can lead to unexpected side effects. Instead of using delete, it's safer to create a new object without the ref property, for example by using object destructuring.

}

// eslint-disable-next-line no-param-reassign
delete props.emptyText;
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Mutating function arguments like the props object is generally a bad practice as it can lead to unexpected side effects. Instead of using delete, it's safer to create a new object without the emptyText property, for example by using object destructuring.


if (customValueTypeConfig) {
// eslint-disable-next-line no-param-reassign
delete props.ref;
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Mutating function arguments like the props object is generally a bad practice as it can lead to unexpected side effects. Instead of using delete, it's safer to create a new object without the ref property, for example by using object destructuring.

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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (5)
src/form/layouts/DrawerForm/index.tsx (1)

185-193: ⚠️ Potential issue | 🟠 Major

移除 eslint-disable 后,此 useEffect 缺少多个依赖项,ESLint 将会报警告。

回调体中引用了 onOpenChangesetDrawerWidthresizeInfo?.minWidth,但依赖数组仅为 [propsOpen, open, resizableDrawer]。之前的 eslint-disable 就是用来抑制这些缺失依赖的警告。

与 ModalForm 存在同样的问题——单纯删除抑制注释而不补全依赖,会导致 ESLint 检查失败。建议:

  1. 补全依赖数组(注意 onOpenChange 可通过 useRefFunction 包装保持引用稳定,setDrawerWidth 作为 useState 的 setter 引用本身是稳定的,可安全添加);
  2. 或者确认项目 CI 配置对该规则的严格程度。
♻️ 建议补全依赖数组
   useEffect(() => {
     if (open && propsOpen) {
       onOpenChange?.(true);
     }
 
     if (resizableDrawer) {
       setDrawerWidth(resizeInfo?.minWidth);
     }
-  }, [propsOpen, open, resizableDrawer]);
+  }, [propsOpen, open, resizableDrawer, onOpenChange, setDrawerWidth, resizeInfo?.minWidth]);

Based on learnings: "Pass all ESLint and TypeScript checks".

src/utils/nanoid/index.ts (1)

29-32: ⚠️ Potential issue | 🟡 Minor

使用严格相等判断 typeof 结果

typeof crypto.randomUUID == 'function' 建议改为严格相等,避免潜在的类型转换风险。

✅ 建议修改
-    typeof crypto.randomUUID == 'function'
+    typeof crypto.randomUUID === 'function'
src/utils/useEditableArray/index.tsx (1)

762-765: ⚠️ Potential issue | 🟡 Minor

移除顶层 eslint-disable 后,空依赖数组可能触发 react-hooks/exhaustive-deps 警告。

buildDataSourceKeyIndexMap 虽然通过 useRefFunction 返回了稳定引用,但 ESLint 的 exhaustive-deps 规则无法识别这一点,会将其标记为缺失依赖。移除文件顶部的 eslint-disable 后,此处会产生 lint 告警。

建议将 buildDataSourceKeyIndexMap 加入依赖数组(因为它本身是稳定引用,不会导致额外重渲染),或者添加行级别的 // eslint-disable-next-line react-hooks/exhaustive-deps 注释。

建议修改
   const initDataSourceKeyIndexMap = useMemo(
     () => buildDataSourceKeyIndexMap(),
-    [],
+    // buildDataSourceKeyIndexMap is a stable ref from useRefFunction
+    // eslint-disable-next-line react-hooks/exhaustive-deps
+    [],
   );

Based on learnings: "Pass all ESLint and TypeScript checks".

src/utils/useEditableMap/index.tsx (1)

264-300: ⚠️ Potential issue | 🟡 Minor

actionRenderuseCallback 依赖数组不完整,移除顶层 eslint-disable 后会触发 lint 告警。

useCallback 内部引用了 saveTextcancelTextdeleteTextintlsetEditableRowKeysprops.actionRender 等变量,但依赖数组中未包含。之前由文件级别的 eslint-disable react-hooks/exhaustive-deps 抑制了此告警。

建议补全依赖数组,或在此处添加行级 eslint-disable-next-line 并附上原因注释。其中 saveText/cancelText/deleteText 依赖于 intl(locale 变化时会更新),遗漏可能导致国际化切换后操作按钮文案未更新。

建议补全依赖
   const actionRender = useCallback(
     (key: RecordKey, config?: ActionTypeText<RecordType>) => {
       // ...
     },
-    [editableKeys, props.dataSource, cancelEditable, onCancel, onSave],
+    [editableKeys, props.dataSource, cancelEditable, onCancel, onSave, saveText, cancelText, deleteText, setEditableRowKeys, intl, props.actionRender],
   );

Based on learnings: "Pass all ESLint and TypeScript checks".

src/utils/isDeepEqualReact/index.ts (1)

14-14: ⚠️ Potential issue | 🟠 Major

使用严格相等比较 !== 替代松散相等比较 !=

既然已移除 eqeqeq 的 ESLint 禁用指令,代码应遵循严格相等比较规范。虽然在此上下文中 length 是数字类型,但使用 !== 更符合最佳实践。

运行以下脚本验证 ESLint 检查是否通过:

#!/bin/bash
# 描述:验证移除 lint 指令后是否仍通过 ESLint 检查

# 仅检查此文件的 ESLint 状态
npx eslint src/utils/isDeepEqualReact/index.ts --format=json
🔧 建议的修复
-      if (length != b.length) return false;
+      if (length !== b.length) return false;
-      if (length != b.length) return false;
+      if (length !== b.length) return false;

Also applies to: 38-38

🧹 Nitpick comments (3)
src/table/Table.tsx (1)

437-437: 移除 as any 的做法正确,但多余的括号可以一并清理。

actionParams 的类型已经是 Record<string, any>,移除 as any 完全没问题。不过 (actionParams) 的括号是之前 (actionParams as any) 的残留,可以顺手去掉。

🔧 建议的修改
-      delete (actionParams)._timestamp;
+      delete actionParams._timestamp;
src/utils/useEditableArray/index.tsx (1)

1088-1091: 此处仍保留了 @ts-ignore,与 PR 目标不一致。

PR 的目标是移除不必要的 eslint-disable@ts-ignore。此处的 @ts-ignore 是因为 ...rest: any[] 展开传入 props.onValuesChange 时类型不匹配。可以通过显式声明参数类型来消除:

建议修改
-  const propsOnValuesChange = useDebounceFn(async (...rest: any[]) => {
-    //@ts-ignore
-    props.onValuesChange?.(...rest);
+  const propsOnValuesChange = useDebounceFn(async (record: RecordType, dataSource: RecordType[]) => {
+    props.onValuesChange?.(record, dataSource);
   }, 64);
src/utils/merge/index.ts (1)

6-33: 建议改进类型定义和代码现代化。

虽然此次改动仅移除了 ESLint 抑制指令,但代码本身存在一些可以改进的地方:

  1. 类型安全问题(第 6 行):使用了 any 类型作为泛型默认值和参数类型。根据编码规范,应避免使用 any,尽可能精确定义类型。

  2. 代码现代化(第 12-13 行):使用 for...in 循环配合 hasOwnProperty 是较旧的模式,可以使用 Object.keys()Object.entries() 等现代方法。

  3. hasOwnProperty 安全性(第 13 行):直接调用 rest[i].hasOwnProperty(key) 在某些边缘情况下可能不安全(对象可能重写了 hasOwnProperty),建议使用 Object.prototype.hasOwnProperty.call(rest[i], key)

💡 可选的类型安全和现代化改进方案
 /**
  * 用于合并 n 个对象
- * `@param`  {any[]} ...rest
- * `@returns` T
+ * `@param`  {...Record<string, any>[]} rest - 要合并的对象数组
+ * `@returns` {T} 合并后的对象
  */
-const merge = <T = any>(...rest: any[]): T => {
+const merge = <T extends Record<string, any> = Record<string, any>>(
+  ...rest: Array<Partial<T> | Record<string, any>>
+): T => {
   const obj = {} as Record<string, any> as any;
-  const il = rest.length;
-  let key;
-  let i = 0;
-  for (; i < il; i += 1) {
-    for (key in rest[i]) {
-      if (rest[i].hasOwnProperty(key)) {
+  for (const item of rest) {
+    for (const key of Object.keys(item)) {
+      if (Object.prototype.hasOwnProperty.call(item, key)) {
         if (
           typeof obj[key] === 'object' &&
-          typeof rest[i][key] === 'object' &&
+          typeof item[key] === 'object' &&
           obj[key] !== undefined &&
           obj[key] !== null &&
           !Array.isArray(obj[key]) &&
-          !Array.isArray(rest[i][key])
+          !Array.isArray(item[key])
         ) {
           obj[key] = {
             ...obj[key],
-            ...rest[i][key],
+            ...item[key],
           };
         } else {
-          obj[key] = rest[i][key];
+          obj[key] = item[key];
         }
       }
     }
   }
   return obj as T;
 };

这些改进将:

  • 提供更好的类型约束和推断
  • 使用现代化的迭代方式
  • 增强 hasOwnProperty 调用的安全性

- Updated the nanoid function to streamline the UUID generation process by consolidating conditional checks.
- Improved code readability by replacing verbose checks with optional chaining and a single return statement.
- Maintained functionality by ensuring compatibility with both randomUUID and genNanoid methods.
@chenshuai2144 chenshuai2144 merged commit d13b26f into ant-design:master Feb 10, 2026
7 of 9 checks passed
@zzjiaxiang zzjiaxiang deleted the remove-lint branch February 10, 2026 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

card descriptions form layout size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants