-
Notifications
You must be signed in to change notification settings - Fork 263
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: 组件库基于 jdTaro 的改造&&所有端demo合成一个 #2476
Conversation
Walkthrough此次更改涉及多个文件的修改,主要集中在 ESLint 忽略规则、构建脚本、配置管理及新增的 React 组件。这些更改旨在提升项目代码的质量和维护性,同时增强 Taro 框架的兼容性,反映出项目结构的重组与功能的扩展。 Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant App
participant BuildSystem
participant ESLint
User->>App: 触发构建请求
App->>BuildSystem: 更新配置和脚本
BuildSystem->>ESLint: 处理文件的 ESLint 忽略规则
ESLint-->>BuildSystem: 文件处理完成
BuildSystem-->>User: 构建完成
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (2)
Files skipped from review as they are similar to previous changes (1)
Additional comments not posted (2)
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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: 43
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: 43
Outside diff range, codebase verification and nitpick comments (1)
packages/nutui-taro-demo/src/app.ts (1)
10-10
: 移除注释的console.log语句如果不再需要调试信息,建议移除注释的console.log语句。
- // console.log(NutUI) + // Remove this line if debugging is no longer needed.
@@ -0,0 +1 @@ | |||
export default <></>; |
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.
避免使用不必要的Fragment
当前代码中使用了一个不必要的Fragment。建议直接返回空元素。
- export default <></>;
+ export default null;
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.
export default <></>; | |
export default null; |
Tools
Biome
[error] 1-1: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
(lint/complexity/noUselessFragments)
@@ -0,0 +1 @@ | |||
export default <></>; |
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.
移除不必要的Fragment
当前代码中使用的Fragment是多余的,可以直接返回空元素。
- export default <></>;
+ export default null;
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.
export default <></>; | |
export default null; |
Tools
Biome
[error] 1-1: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
(lint/complexity/noUselessFragments)
@@ -0,0 +1 @@ | |||
export default <></>; |
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.
避免使用不必要的Fragment
如果Fragment只包含一个子元素,或者它是HTML元素的子元素,并且不是带键的Fragment,那么它就是多余的。
- export default <></>;
+ export default null;
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.
export default <></>; | |
export default null; |
Tools
Biome
[error] 1-1: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
(lint/complexity/noUselessFragments)
@@ -0,0 +1 @@ | |||
export default <></>; |
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.
避免使用不必要的Fragment。
如果Fragment只包含一个子元素,或者它是一个HTML元素的子元素,并且不是一个带键的Fragment,那么它就是多余的。
- export default <></>;
+ export default null;
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.
export default <></>; | |
export default null; |
Tools
Biome
[error] 1-1: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
(lint/complexity/noUselessFragments)
@@ -0,0 +1 @@ | |||
export default <></>; |
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.
避免使用不必要的Fragment
当前代码中使用了一个不必要的Fragment。建议直接返回空元素。
- export default <></>;
+ export default null;
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.
export default <></>; | |
export default null; |
Tools
Biome
[error] 1-1: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
(lint/complexity/noUselessFragments)
@@ -0,0 +1 @@ | |||
export default <></>; |
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.
避免使用不必要的Fragment
如果Fragment只包含一个子元素,或者它是一个HTML元素的子元素,并且不是带键的Fragment,那么它是多余的。建议直接导出空元素。
- export default <></>;
+ export default null;
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.
export default <></>; | |
export default null; |
Tools
Biome
[error] 1-1: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
(lint/complexity/noUselessFragments)
@@ -0,0 +1 @@ | |||
export default <></>; |
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.
避免使用不必要的 Fragment。
如果 Fragment 仅包含一个子元素,或者它是 HTML 元素的子元素且不是带键的 Fragment,则它是多余的。
- export default <></>;
+ export default null;
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.
export default <></>; | |
export default null; |
Tools
Biome
[error] 1-1: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
(lint/complexity/noUselessFragments)
@@ -0,0 +1 @@ | |||
export default <></>; |
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.
避免使用不必要的Fragment
当前代码中使用的Fragment是多余的,因为它只包含一个子元素。
- export default <></>;
+ export default null;
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.
export default <></>; | |
export default null; |
Tools
Biome
[error] 1-1: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
(lint/complexity/noUselessFragments)
@@ -0,0 +1 @@ | |||
export default <></>; |
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.
避免使用不必要的Fragment
此处的Fragment是多余的,因为它没有包含任何子元素。
- export default <></>;
+ export default null;
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.
export default <></>; | |
export default null; |
Tools
Biome
[error] 1-1: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
(lint/complexity/noUselessFragments)
@@ -0,0 +1 @@ | |||
export default <></>; |
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.
避免使用不必要的Fragment
如果Fragment只包含一个子元素,或者它是一个HTML元素的子元素,并且不是一个带键的Fragment,那么这个Fragment是多余的。
- export default <></>;
+ export default null;
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.
export default <></>; | |
export default null; |
Tools
Biome
[error] 1-1: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
(lint/complexity/noUselessFragments)
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: 6
Outside diff range, codebase verification and nitpick comments (9)
packages/nutui-taro-demo/src/business/pages/avatarcropper/index.tsx (1)
1-1
: 避免使用不必要的Fragment当前文件仅导出一个空的Fragment,这是不必要的,可以直接删除Fragment。
- export default <></>; + export default null;Tools
Biome
[error] 1-1: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
(lint/complexity/noUselessFragments)
packages/nutui-taro-demo/src/business/pages/barrage/index.tsx (1)
1-1
: 避免使用不必要的Fragment当前文件仅导出一个空的Fragment,这是不必要的,可以直接删除Fragment。
- export default <></>; + export default null;Tools
Biome
[error] 1-1: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
(lint/complexity/noUselessFragments)
packages/nutui-taro-demo/src/business/pages/card/index.tsx (1)
1-1
: 避免使用不必要的Fragment当前文件仅导出一个空的Fragment,这是不必要的,可以直接删除Fragment。
- export default <></>; + export default null;Tools
Biome
[error] 1-1: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
(lint/complexity/noUselessFragments)
packages/nutui-taro-demo/src/dentry/pages/checkbox/index.tsx (1)
1-1
: 避免使用不必要的Fragment此处的Fragment是多余的,因为它没有包含任何子元素。
- export default <></>; + export default null;Tools
Biome
[error] 1-1: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
(lint/complexity/noUselessFragments)
packages/nutui-taro-demo/src/dentry/pages/datepicker/index.tsx (1)
1-1
: 避免使用不必要的Fragment此处的Fragment是多余的,因为它没有包含任何子元素。
- export default <></>; + export default null;Tools
Biome
[error] 1-1: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
(lint/complexity/noUselessFragments)
packages/nutui-taro-demo/src/dentry/pages/form/index.tsx (1)
1-1
: 避免使用不必要的Fragment此处的Fragment是多余的,因为它没有包含任何子元素。
- export default <></>; + export default null;Tools
Biome
[error] 1-1: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
(lint/complexity/noUselessFragments)
packages/nutui-taro-demo/src/dentry/pages/textarea/index.tsx (1)
1-1
: 避免使用不必要的Fragment。当前的Fragment是多余的,因为它只包含一个子元素。可以直接导出
null
或一个空组件。- export default <></>; + export default null;Tools
Biome
[error] 1-1: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
(lint/complexity/noUselessFragments)
packages/nutui-taro-demo/src/dentry/pages/uploader/index.tsx (1)
1-1
: 避免使用不必要的Fragment。当前的Fragment是多余的,因为它只包含一个子元素。可以直接导出
null
或一个空组件。- export default <></>; + export default null;Tools
Biome
[error] 1-1: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
(lint/complexity/noUselessFragments)
packages/nutui-taro-demo/src/exhibition/pages/animate/index.tsx (1)
1-1
: 避免使用不必要的Fragment。当前的Fragment是多余的,因为它只包含一个子元素。可以直接导出
null
或一个空组件。- export default <></>; + export default null;Tools
Biome
[error] 1-1: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
(lint/complexity/noUselessFragments)
@@ -0,0 +1 @@ | |||
export default <></>; |
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.
避免使用不必要的 Fragment
如果 Fragment 只包含一个子元素,或者它是一个 HTML 元素的子元素,并且不是一个带键的 Fragment,那么它是多余的。建议直接导出空元素。
- export default <></>;
+ export default null;
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.
export default <></>; | |
export default null; |
Tools
Biome
[error] 1-1: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
(lint/complexity/noUselessFragments)
@@ -0,0 +1 @@ | |||
export default <></>; |
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.
避免使用不必要的Fragment
当前的Fragment是多余的,因为它没有包含任何子元素。
- export default <></>;
+ export default null;
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.
export default <></>; | |
export default null; |
Tools
Biome
[error] 1-1: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
(lint/complexity/noUselessFragments)
@@ -0,0 +1 @@ | |||
export default <></>; |
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.
移除不必要的Fragment
此文件仅导出一个空的Fragment,这是多余的。建议移除Fragment或者添加实际内容。
- export default <></>;
+ // Add actual content or remove this file if not needed.
Committable suggestion was skipped due to low confidence.
Tools
Biome
[error] 1-1: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
(lint/complexity/noUselessFragments)
@@ -0,0 +1 @@ | |||
export default <></>; |
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.
避免使用不必要的Fragment
当前的Fragment是多余的,因为它没有包含任何子元素。
- export default <></>;
+ export default null;
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.
export default <></>; | |
export default null; |
Tools
Biome
[error] 1-1: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
(lint/complexity/noUselessFragments)
@@ -0,0 +1 @@ | |||
export default <></>; |
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.
移除不必要的Fragment
此文件仅导出一个空的Fragment,这是多余的。建议移除Fragment或者添加实际内容。
- export default <></>;
+ // Add actual content or remove this file if not needed.
Committable suggestion was skipped due to low confidence.
Tools
Biome
[error] 1-1: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
(lint/complexity/noUselessFragments)
@@ -0,0 +1 @@ | |||
export default <></>; |
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.
避免使用不必要的Fragment
当前的Fragment是多余的,因为它没有包含任何子元素。
- export default <></>;
+ export default null;
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.
export default <></>; | |
export default null; |
Tools
Biome
[error] 1-1: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
(lint/complexity/noUselessFragments)
} | ||
|
||
.index-header .info .h5-h1 { | ||
&_header { |
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.
_ 建议统一改为 -
const gotoNext = (name: string, enName: string) => { | ||
// 跳转到目的页面,打开新页面 | ||
Taro.navigateTo({ | ||
url: `/${enName}/pages/${name.toLocaleLowerCase()}/index`, | ||
}) | ||
} | ||
|
||
const onShareAppMessage = (res) => { |
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.
没有这个方法,应该是无法触发 分享~~
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.
没有这个方法,应该是无法触发 分享~~
已还原
@@ -839,7 +839,7 @@ | |||
"author": "szg2008" | |||
}, | |||
{ | |||
"version": "3.0.0", | |||
"version": "2.0.0", |
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.
这个合并了~~ 可以合一下dev
packages/nutui-taro-demo/.gitignore
Outdated
@@ -4,12 +4,5 @@ deploy_versions/ | |||
.rn_temp/ | |||
node_modules/ | |||
.DS_Store | |||
src/base/ |
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.
这个是不是 后边就不用关注了·~
现在只是需要在开发中的原因?
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.
需要,因为兼容RN未适配的组件不开入口
已修改
const { remove, ensureDir } = require('fs-extra') | ||
const fs = require('fs') | ||
|
||
const home = os.homedir() |
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.
改到项目的相对路径比较好~~
另外这个所有人都可以访问吗。所有人都可以执行成功么
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: 7
Outside diff range, codebase verification and nitpick comments (3)
scripts/taro/generate-taro-pages.js (3)
Line range hint
41-43
:
错误处理不当在
fs.mkdirSync
的回调中处理错误是无效的,建议直接捕获异常。- fs.mkdirSync(dirPath, { recursive: true }, (err) => { - console.log('mkdir error', err) - }) + try { + fs.mkdirSync(dirPath, { recursive: true }) + } catch (err) { + console.log('mkdir error', err) + }
Line range hint
69-69
:
硬编码的文件路径建议将文件路径作为可配置参数传递,以提高代码的灵活性和可维护性。
const dirPath = path.join(__dirname, process.env.APP_DIR || `../../packages/nutui-taro-demo/src`)
Line range hint
75-75
:
潜在的fse.outputFile
问题在
fse.outputFile
中,fileString
未被修改,建议使用修改后的lines
数组。const newFileString = lines.join('\n') fse.outputFile(filePath, newFileString, 'utf8', (error) => { if (error) console.log('Error', error) })
scripts/harmony/clone-jdharmony.js
Outdated
const temp = `${process.cwd()}/packages` | ||
|
||
async function cloneJdHarmony() { | ||
const remote = '[email protected]:DongDesign/JDHarmony.git' |
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.
硬编码的git远程URL
建议将远程URL作为函数参数传递,以提高代码的灵活性和可维护性。
async function cloneJdHarmony(remote = '[email protected]:DongDesign/JDHarmony.git', branch = 'master') {
// ...
}
const harmonyPathNew = path.join(temp, 'nutui-jdharmony') | ||
await remove(harmonyPathNew) | ||
await ensureDir(harmonyPathNew) | ||
fs.renameSync(harmonyPath, harmonyPathNew) |
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.
避免使用同步的fs.renameSync
建议使用异步方法fs.rename
来避免阻塞事件循环。
await fs.promises.rename(harmonyPath, harmonyPathNew)
|
||
// 判断temp目录是否存在JDHarmony文件夹,如果不存在不存在则执行clone() | ||
|
||
const harmonyPath = path.join(temp, 'nutui-jdharmony') |
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.
硬编码的目录路径
建议将目录路径作为可配置参数传递,以提高代码的灵活性和可维护性。
const harmonyPath = path.join(temp, process.env.HARMONY_DIR || 'nutui-jdharmony')
if (!fs.existsSync(harmonyPath)) { | ||
clone() | ||
console.log(`Clone JDHarmony successfully.`) |
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.
潜在的竞争条件
在检查目录是否存在和创建目录之间可能存在竞争条件,建议使用fs-extra
的ensureDir
方法。
const harmonyPath = path.join(temp, 'nutui-jdharmony')
ensureDir(harmonyPath).then(() => {
console.log(`JDHarmony already exists.`)
}).catch(() => {
clone().then(() => {
console.log(`Clone JDHarmony successfully.`)
})
})
@@ -17,7 +28,7 @@ const createIndexConfig = (enName, package) => { | |||
if (package.show && package.taro) { | |||
const name = package.name | |||
const nameLc = package.name.toLowerCase() | |||
let content = `export default { | |||
const content = `export default { |
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.
硬编码的文件路径
建议将文件路径作为可配置参数传递,以提高代码的灵活性和可维护性。
const dirPath = path.join(__dirname, process.env.DEMO_DIR || `../../packages/nutui-taro-demo/src/${enName}/pages/${nameLc}`)
Tools
Biome
[error] 31-31: Illegal use of reserved keyword
package
as an identifier in strict mode(parse)
const demoContent = adaptedArray.includes(nameLc) | ||
? `import Demo from '@/packages/${nameLc}/demo.taro'; |
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.
潜在的竞争条件
在生成配置文件和生成demo文件之间可能存在竞争条件,建议使用异步方法并链式调用。
fs.promises.writeFile(filePath, content)
.then(() => {
console.log(`生成index.config.ts文件成功`)
return fs.promises.writeFile(demoFilePath, demoContent)
})
.then(() => {
console.log(`生成 index.tsx 文件成功`)
})
.catch((err) => {
console.error('Error', err)
})
adaptedArray.push(element.name.toLowerCase()) | ||
}) | ||
}) | ||
|
||
const navs = config.nav | ||
|
||
// let fileStr = `@import '../../../styles/font/iconfont.css';` |
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.
非法使用保留关键字package
在严格模式下,package
是保留关键字,建议更换变量名。
- const createIndexConfig = (enName, package) => {
+ const createIndexConfig = (enName, pkg) => {
Committable suggestion was skipped due to low confidence.
🤔 这个变动的性质是?
🔗 相关 Issue
💡 需求背景和解决方案
☑️ 请求合并前的自查清单
Summary by CodeRabbit
新功能
修复
文档