chore(ava): rewrite all import path to relative path - #843
Conversation
Summary of ChangesHello @leondt1, 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 focuses on a significant refactoring effort to standardize module imports across the project. By converting all absolute import paths to relative ones, the change aims to simplify the module resolution mechanism and eliminate the dependency on TypeScript path aliases. This should lead to a more consistent and potentially more robust build process by reducing configuration complexity. 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
|
There was a problem hiding this comment.
Code Review
本次 PR 主要将项目中的路径别名(如 @ava/...)重构为了相对路径,这是一个比较大的工程性改动。整体来看,路径的替换是准确的。
我注意到在重构过程中,不同地方的导入风格存在一些不一致。有些地方改为了从模块的入口文件(barrel file, 如 index.ts)导入,而另一些地方则改为了从更具体的源文件导入。为了提升代码的可维护性和可读性,建议在整个项目中统一导入风格。我在具体的代码文件中提出了一些建议,希望能帮助统一风格,例如优先从具体的源文件导入,以减少对桶文件的依赖,避免潜在的循环依赖问题。
此外,在 site/examples/advice/advise-with-rules/demo/index.jsx 文件中,React 的导入被移除了,这是一个很好的优化,符合现代 React 的实践。
总体来说,这次重构做得不错,统一风格后代码会更清晰。
| @@ -1,15 +1,14 @@ | |||
| import { logError, isOpenAi, isTbox, requestLLM, safeJsonParse } from '@ava/utils'; | |||
| import { logError, isOpenAi, isTbox, requestLLM, safeJsonParse } from '../../../utils'; | |||
|
|
||
| import { assert, isArray, isObject, isBasicType } from '@ava/utils'; | ||
| import { getAllRelationFeatures } from '@ava/extract/features'; | ||
| import { assert, isArray, isObject, isBasicType } from '../../utils'; |
There was a problem hiding this comment.
在本次重构中,许多地方的导入路径都改为了相对路径。注意到这里从 ../../utils 导入了多个辅助函数,而这些函数实际上来自 ../../utils/common 和 ../../utils/isType。在项目的其他地方(例如 src/utils/statistics/ 目录下的文件),导入方式是直接从更具体的文件(如 ../common)导入。为了保持项目范围内导入风格的一致性,建议将此处的导入也拆分为从具体文件导入。这有助于提高代码的可维护性,并减少因使用桶文件(barrel files)可能引起的循环依赖风险。
| import { assert, isArray, isObject, isBasicType } from '../../utils'; | |
| import { assert } from '../../utils/common'; | |
| import { isArray, isObject, isBasicType } from '../../utils/isType'; |
|
|
||
| import { ChangePointItem } from './types'; | ||
|
|
||
| import { standardDeviation, cdf } from './index'; |
There was a problem hiding this comment.
| import { isEqual } from 'lodash'; | ||
|
|
||
| import { isArray, isNumber, nOnes, range } from '@ava/utils'; | ||
| import { isArray, isNumber, nOnes, range } from '../../../src/utils'; |
PR includes
将所有路径重写为相对路径