From d5780d248d2e8f1117381f321d4947006d55fe58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E7=85=A6=E5=BA=AD?= <990815_yxt@sina.com> Date: Thu, 21 Dec 2023 07:52:18 +0000 Subject: [PATCH 01/12] =?UTF-8?q?=E6=9B=B4=E6=96=B0Readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 71 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 48b73535..d3243555 100644 --- a/README.md +++ b/README.md @@ -8,66 +8,71 @@ ![](https://openinula-website.obs.ap-southeast-1.myhuaweicloud.com/misc/structure.png) -### 核心能力 +## 核心能力 -#### 响应式API(实验性功能,可在reactive分支查看代码或使用npm仓中experiment版本体验) +### 响应式API -* openInula 通过最小化重新渲染的范围,从而进行高效的UI渲染。这种方式避免了虚拟 DOM 的开销,使得 openInula 在性能方面表现出色。 -* openInula 通过比较变化前后的 JavaScript 对象以细粒度的依赖追踪机制来实现响应式更新,无需用户过度关注性能优化。 -* 简洁API: - 1. openInula 提供了两组简洁直观的API--响应式 API 和与 React 一致的传统 API,使得开发者可以轻松地构建复杂的交互式界面。 - 2. openInula 简洁的 API 极大降低了开发者的学习成本,开发者使用响应式API可以快速构建高效的前端界面。 +openInula 通过监听状态变量的变化,以细粒度的依赖追踪机制来实现响应式更新,避免了虚拟 DOM 的开销。通过最小化重新渲染的范围,从而进行高效的UI渲染。无需用户过度关注性能优化。 -#### 兼容 ReactAPI +>(实验性功能,可在 `reactive` 分支查看代码或使用 npm 仓中 experimental 版本体验) -* 与React保持一致、可以无缝支持 React 生态。 -* 使用传统 API 可以无缝将 React 项目切换至 openInula,React 应用可零修改切换至 openInula。 +### 兼容 React API + +提供与 React 一致的 API,完全支持 React 生态,可将 React 应用可零修改切换至 openInula。 ### openInula 配套组件 -#### 状态管理器 → inula-X +#### 状态管理器 inula-X + +inula-X 是 openInula 默认提供的状态管理器。无需额外引入三方库,就可以简单实现跨组件/页面共享状态。 -inula-X 是 openInula 默认提供的状态管理器,无需额外引入三方库,就可以简单实现跨组件/页面共享状态。 inula-X 与 Redux 相比,可创建多个 Store,不需要在 Reducer 中返回 state 并且简化了 Action 和 Reducer 的创建步骤,原生支持异步能力,组件能做到精准重渲染。inula-X 均可使用函数组件、class 组件,能提供 redux 的适配接口及支持响应式的特点。 -#### 路由 → inula-router +#### 路由 inula-router -inula-router 是 openInula 生态组建的一部分,为 openInula 提供前端路由的能力,是构建大型应用必要组件。 -inula-router 涵盖 react-router、history、connect-react-router 的功能。 +inula-router 为 openInula 提供前端路由的能力,是构建大型应用必要组件,涵盖 react-router、history、connect-react-router 的功能。 -#### 请求 → inula-request +#### 请求 inula-request -inula-request 是 openInula 生态组件,涵盖常见的网络请求方式,并提供动态轮询钩子函数给用户更便捷的定制化请求体验。 +inula-request 是 openInula 的网络请求组件,不仅涵盖常见的网络请求方式,还提供动态轮询钩子函数给用户更便捷的定制化请求体验。 -#### 国际化 → inula-intl +#### 国际化 inula-intl -inula-intl 是基于 openInula 生态组件,其主要提供了国际化功能,涵盖了基本的国际化组件和钩子函数,便于用户在构建国际化能力时方便操作。 +inula-intl 是基于 openInula 的国际化组件,涵盖了基本的国际化组件和钩子函数,允许用户更方便地构建国际化能力。 -#### 调试工具 → inula-dev-tools +#### 调试工具 inula-dev-tools inula-dev-tools 是一个为 openInula 开发者提供的强大工具集,能够方便地查看和编辑组件树、管理应用状态以及进行性能分析,极大提高了开发效率和诊断问题的便捷性。 -#### 脚手架 → inula-cli +#### 脚手架 create-inula -inula-cli 是一套针对 openInula 的编译期插件,它支持代码优化、JSX 语法转换以及代码分割,有助于提高应用的性能、可读性和可维护性。 +create-inula 是一套用于创建 openInula 项目的脚手架工具。它预置了一系列项目模板,允许开发者通过命令行按需快速生成可运行的项目代码。 -## openInula 文档 +## 参与贡献 + +我们鼓励开发者以各种方式参与代码贡献、生态拓展或文档反馈,献您的原创内容,详细请参考[贡献指南](https://docs.openinula.net/docs/%E8%B4%A1%E7%8C%AE%E6%8C%87%E5%8D%97)。 + +### 官方链接 欢迎访问 openInula 官网与文档仓库,参与 openInula 开发者文档开源项目,与我们一起完善开发者文档。 -+ openInula 官网地址:[https://www.openinula.net/](https://www.openinula.net/) -+ openInula 文档站地址:[https://docs.openinula.net/](https://docs.openinula.net/) +* openInula 官网:[https://www.openinula.net/](https://www.openinula.net/) +* openInula 文档:[https://docs.openinula.net/](https://docs.openinula.net/) +* openInula 仓库地址:[https://gitee.com/openinula/inula](https://gitee.com/openinula/inula) +* openInula 社提案备忘录(RFC):[https://gitee.com/openInula/rfcs](https://gitee.com/openInula/rfcs) -## 代码仓地址 +### 社区贡献者案例 -openInula 仓库地址:[https://gitee.com/openinula](https://gitee.com/openinula) +**[`umi-inula`](https://gitee.com/congxiaochen/inula)** -## 如何参与 +基于 umijs 与 openInula 的开发框架,集成官方组件与UI、AIGC等功能,开箱即用。 -**参与贡献** -欢迎您参与贡献,我们鼓励开发者以各种方式参与文档反馈和贡献。 +**[`voerkaiI18l`](https://github.com/zhangfisher/voerka-i18n/)** -您可以对现有文档进行评价、简单更改、反馈文档质量问题、贡献您的原创内容,详细请参考[贡献指南](https://docs.openinula.net/docs/%E8%B4%A1%E7%8C%AE%E6%8C%87%E5%8D%97)。 +适用于多框架的 JavaScript 国际化解决方案,提供对 openInula 的适配。 + +- [适配示例](https://gitee.com/link?target=https%3A%2F%2Fgithub.com%2Fzhangfisher%2Fvoerka-i18n%2Ftree%2Fmaster%2Fexamples%2Fopeninula) +- [适配文档](https://gitee.com/link?target=https%3A%2F%2Fzhangfisher.github.io%2Fvoerka-i18n%2F%23%2Fzh%2Fguide%2Fintegration%2Fopeninula) ## 许可协议 @@ -75,6 +80,8 @@ openInula 主要遵循 [Mulan Permissive Software License v2](http://license.cos ## 联系方式 -team@inulajs.org +[官方邮箱](team@inulajs.org) +微信公众号 +![](https://www.openinula.net/assets/qrcode.inula-02f99d58.jpg) From b2a08e8c6c59d616adcdbdef4881a29d9c886dbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E7=85=A6=E5=BA=AD?= <990815_yxt@sina.com> Date: Thu, 21 Dec 2023 07:56:37 +0000 Subject: [PATCH 02/12] =?UTF-8?q?=E6=9B=B4=E6=96=B0Readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d3243555..914f403b 100644 --- a/README.md +++ b/README.md @@ -80,8 +80,8 @@ openInula 主要遵循 [Mulan Permissive Software License v2](http://license.cos ## 联系方式 -[官方邮箱](team@inulajs.org) +* 官方邮箱: [team@inulajs.org](mailto:team@inulajs.org) -微信公众号 +* 微信公众号: ![](https://www.openinula.net/assets/qrcode.inula-02f99d58.jpg) From 32e509f9deced88c9b65cf2657f337c9d755708f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E7=85=A6=E5=BA=AD?= <990815_yxt@sina.com> Date: Thu, 21 Dec 2023 08:51:10 +0000 Subject: [PATCH 03/12] update README.md. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杨煦庭 <990815_yxt@sina.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 914f403b..38051ca8 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ create-inula 是一套用于创建 openInula 项目的脚手架工具。它预 基于 umijs 与 openInula 的开发框架,集成官方组件与UI、AIGC等功能,开箱即用。 -**[`voerkaiI18l`](https://github.com/zhangfisher/voerka-i18n/)** +**[`VoerkaI18n`](https://github.com/zhangfisher/voerka-i18n/)** 适用于多框架的 JavaScript 国际化解决方案,提供对 openInula 的适配。 From b026ca8786b1a27f494fff6eb1ebc33566d86e31 Mon Sep 17 00:00:00 2001 From: cgj <18700163154@163.com> Date: Thu, 28 Dec 2023 17:35:46 +0800 Subject: [PATCH 04/12] =?UTF-8?q?[comment]=E6=B7=BB=E5=8A=A0CONTRIBUTING.m?= =?UTF-8?q?d=EF=BC=8C=E5=8C=85=E5=90=AB=E4=B8=80=E4=BA=9B=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E7=9B=B8=E5=85=B3=E7=9A=84=E5=BB=BA=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CONTRIBUTING.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..46d6888f --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,53 @@ +## 代码注释 + +为提高代码的可读性,我们希望你能按照以下几条规则编写注释, + +- 核心:```不要解释是什么,而是回答为什么``` + +- 统一的注释风格 + + ``` tsx + /** + * 这是块级注释 + */ + + // 这是行内注释 + + //============================== 分隔符 ============================== + ``` + +- 注释不要重复代码内容 + + ``` tsx + // 注释和代码含义相同,无需添加 + // error是个promise + if (isPromise(error)) { + ... + } + ``` + +- 注释不要解释模糊代码 + + ``` tsx + // 最佳节点 + let n: Node | null = null; + ``` + + 直接在代码中通过名称表达清楚,可以省略掉注释 + + ``` tsx + let bestNode: Node | null = null; + ``` + + 如果添加注释则是补充性的额外信息 + + ```tsx + // 全局指针,在遍历时指向当前最佳的节点 + let bestNode: VNode | null = null; + ``` + +- 巧妙或复杂的代码要添加注释解释逻辑 + +- 对所有导出的顶层模块进行注释 + +- 注释应该是直接的,不要有不明确的表达或符号 From 444b73f7ecc84af8efe478fe1db06c325fefddb9 Mon Sep 17 00:00:00 2001 From: haiqin Date: Tue, 2 Jan 2024 15:02:11 +0800 Subject: [PATCH 05/12] fix: update got error in fallback --- .../ComponentTest/SuspenseComponent.test.js | 48 ++++++++++++------- .../src/renderer/render/SuspenseComponent.ts | 2 +- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/packages/inula/scripts/__tests__/ComponentTest/SuspenseComponent.test.js b/packages/inula/scripts/__tests__/ComponentTest/SuspenseComponent.test.js index 6c1469d3..f722a877 100644 --- a/packages/inula/scripts/__tests__/ComponentTest/SuspenseComponent.test.js +++ b/packages/inula/scripts/__tests__/ComponentTest/SuspenseComponent.test.js @@ -23,23 +23,6 @@ describe('SuspenseComponent Test', () => { return { default: component }; }); - // var EMPTY_OBJECT = {}; - // const mockCreateResource = jest.fn((component) => { - // let result = EMPTY_OBJECT; - // return () =>{ - // component().then(res => { - // LogUtils.log(res); - // result = res; - // }, reason => { - // LogUtils.log(reason); - // }); - // if(result === EMPTY_OBJECT){ - // throw component(); - // } - // return result; - // }; - // }); - it('挂载lazy组件', async () => { // 用同步的代码来实现异步操作 class LazyComponent extends Inula.Component { @@ -70,4 +53,35 @@ describe('SuspenseComponent Test', () => { expect(LogUtils.getAndClear()).toEqual([5]); expect(container.querySelector('p').innerHTML).toBe('5'); }); + + it('suspense fallback can be updated', async () => { + // 用同步的代码来实现异步操作 + class LazyComponent extends Inula.Component { + render() { + return ; + } + } + + const Lazy = Inula.lazy(() => { + // wait for 3s + return new Promise(resolve => setTimeout(resolve({ default: LazyComponent }), 3000)); + }); + + let updateFallback; + function Fallback() { + const [show, setShow] = Inula.useState(true); + updateFallback = () => setShow(!show); + return

fallback:{show ? 'show' : 'hide'}

; + } + const container = document.createElement('div'); + Inula.render( + }> + + , + container + ); + expect(container.querySelector('h1').innerHTML).toBe('fallback:show'); + updateFallback(); + expect(container.querySelector('h1').innerHTML).toBe('fallback:hide'); + }); }); diff --git a/packages/inula/src/renderer/render/SuspenseComponent.ts b/packages/inula/src/renderer/render/SuspenseComponent.ts index 8bb49a2e..bd99ae56 100644 --- a/packages/inula/src/renderer/render/SuspenseComponent.ts +++ b/packages/inula/src/renderer/render/SuspenseComponent.ts @@ -128,7 +128,7 @@ function updateFallback(processing: VNode): Array | VNode | null { if (children !== null) { // child不需要更新,跳过child处理fallback - return children[1]; + return children.next; } else { return null; } From f4d21f69a46d04c54f8a9661745fde5bb2af2cb4 Mon Sep 17 00:00:00 2001 From: haiqin Date: Tue, 2 Jan 2024 15:35:19 +0800 Subject: [PATCH 06/12] fix: fix test --- .../__tests__/ComponentTest/SuspenseComponent.test.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/inula/scripts/__tests__/ComponentTest/SuspenseComponent.test.js b/packages/inula/scripts/__tests__/ComponentTest/SuspenseComponent.test.js index f722a877..62328bd5 100644 --- a/packages/inula/scripts/__tests__/ComponentTest/SuspenseComponent.test.js +++ b/packages/inula/scripts/__tests__/ComponentTest/SuspenseComponent.test.js @@ -55,13 +55,6 @@ describe('SuspenseComponent Test', () => { }); it('suspense fallback can be updated', async () => { - // 用同步的代码来实现异步操作 - class LazyComponent extends Inula.Component { - render() { - return ; - } - } - const Lazy = Inula.lazy(() => { // wait for 3s return new Promise(resolve => setTimeout(resolve({ default: LazyComponent }), 3000)); @@ -76,7 +69,7 @@ describe('SuspenseComponent Test', () => { const container = document.createElement('div'); Inula.render( }> - + , container ); From 95f658a6e521bd19866ae56dc0728d373923cf94 Mon Sep 17 00:00:00 2001 From: haiqin Date: Tue, 2 Jan 2024 15:37:40 +0800 Subject: [PATCH 07/12] fix: fix test --- .../scripts/__tests__/ComponentTest/SuspenseComponent.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/inula/scripts/__tests__/ComponentTest/SuspenseComponent.test.js b/packages/inula/scripts/__tests__/ComponentTest/SuspenseComponent.test.js index 62328bd5..e3d5dfb1 100644 --- a/packages/inula/scripts/__tests__/ComponentTest/SuspenseComponent.test.js +++ b/packages/inula/scripts/__tests__/ComponentTest/SuspenseComponent.test.js @@ -57,7 +57,7 @@ describe('SuspenseComponent Test', () => { it('suspense fallback can be updated', async () => { const Lazy = Inula.lazy(() => { // wait for 3s - return new Promise(resolve => setTimeout(resolve({ default: LazyComponent }), 3000)); + return new Promise(resolve => setTimeout(resolve({ default: 'text' }), 3000)); }); let updateFallback; From b4bbd146e8023370239365e259ac606383d49bd3 Mon Sep 17 00:00:00 2001 From: haiqin Date: Mon, 8 Jan 2024 11:49:49 +0800 Subject: [PATCH 08/12] build: add esm format --- .gitignore | 3 +++ packages/inula-intl/babel.config.js | 9 +-------- packages/inula-intl/rollup.config.js | 4 ++++ packages/inula-request/babel.config.js | 9 +-------- packages/inula-request/rollup.config.js | 10 ++++++++-- packages/inula/scripts/rollup/rollup.config.js | 12 ++++++++++-- 6 files changed, 27 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 616f085f..8636e699 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ package-lock.json pnpm-lock.yaml /packages/**/node_modules /packages/inula-cli/lib +build +/packages/inula-router/connectRouter +/packages/inula-router/router diff --git a/packages/inula-intl/babel.config.js b/packages/inula-intl/babel.config.js index ed7275da..68d69905 100644 --- a/packages/inula-intl/babel.config.js +++ b/packages/inula-intl/babel.config.js @@ -18,14 +18,7 @@ module.exports = { presets: [ [ '@babel/preset-env', - { - targets: { - browsers: ['> 1%', 'last 2 versions', 'not ie <= 8'], - node: 'current', - }, - useBuiltIns: 'usage', - corejs: 3, - }, + { targets: { node: 'current' } }, ], [ '@babel/preset-typescript', diff --git a/packages/inula-intl/rollup.config.js b/packages/inula-intl/rollup.config.js index 185c0bc8..ede30362 100644 --- a/packages/inula-intl/rollup.config.js +++ b/packages/inula-intl/rollup.config.js @@ -38,6 +38,10 @@ export default { name: 'InulaI18n', format: 'umd', }, + { + file: path.resolve(output, 'intl.esm-browser.js'), + format: 'esm', + } ], plugins: [ nodeResolve({ diff --git a/packages/inula-request/babel.config.js b/packages/inula-request/babel.config.js index 8fbcfa69..bd709286 100644 --- a/packages/inula-request/babel.config.js +++ b/packages/inula-request/babel.config.js @@ -17,14 +17,7 @@ module.exports = { presets: [ [ '@babel/preset-env', - { - targets: { - 'browsers' : ['> 1%', 'last 2 versions', 'not ie <= 8'], - 'node': 'current' - }, - useBuiltIns: 'usage', - corejs: 3, - } + { targets: { node: 'current' }}, ], [ '@babel/preset-typescript', diff --git a/packages/inula-request/rollup.config.js b/packages/inula-request/rollup.config.js index 54689cb2..0d0a71ab 100644 --- a/packages/inula-request/rollup.config.js +++ b/packages/inula-request/rollup.config.js @@ -21,13 +21,16 @@ import { babel } from '@rollup/plugin-babel'; export default { input: './index.ts', - output: { + output: [{ file: 'dist/inulaRequest.js', format: 'umd', exports: 'named', name: 'inulaRequest', sourcemap: false, - }, + }, { + file: 'dist/inulaRequest.esm-browser.js', + format: 'esm', + }], plugins: [ resolve(), commonjs(), @@ -41,4 +44,7 @@ export default { presets: ['@babel/preset-env'] }) ], + external:[ + 'openinula' + ] }; diff --git a/packages/inula/scripts/rollup/rollup.config.js b/packages/inula/scripts/rollup/rollup.config.js index 45ee6f67..a2520c7c 100644 --- a/packages/inula/scripts/rollup/rollup.config.js +++ b/packages/inula/scripts/rollup/rollup.config.js @@ -86,6 +86,11 @@ function genConfig(mode) { name: 'Inula', format: 'umd', }, + { + file: outputResolve('esm', getOutputName(mode)), + sourcemap, + format: 'esm', + }, ], plugins: [ ...getBasicPlugins(mode), @@ -104,10 +109,13 @@ function genConfig(mode) { function genJSXRuntimeConfig(mode) { return { input: path.resolve(libDir, 'src', 'jsx-runtime.ts'), - output: { + output: [{ file: outputResolve('jsx-runtime.js'), format: 'cjs', - }, + }, { + file: outputResolve('jsx-runtime.esm-browser.js'), + format: 'esm', + }], plugins: [...getBasicPlugins(mode)], }; } From e3364831576ade83c84c4f0661321e7505ee54be Mon Sep 17 00:00:00 2001 From: haiqin Date: Tue, 9 Jan 2024 14:53:34 +0800 Subject: [PATCH 09/12] fix: revert in not complete --- packages/inula/src/renderer/hooks/UseReducerHook.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/inula/src/renderer/hooks/UseReducerHook.ts b/packages/inula/src/renderer/hooks/UseReducerHook.ts index 190d185f..1278e65e 100644 --- a/packages/inula/src/renderer/hooks/UseReducerHook.ts +++ b/packages/inula/src/renderer/hooks/UseReducerHook.ts @@ -64,13 +64,8 @@ export function TriggerAction(vNode: VNode, hook: Hook, isUseState: } } - if (vNode === getProcessingVNode()) { - // 绑定的VNode就是当前渲染的VNode时,就是在函数组件体内触发setState - markUpdatedInRender(); - } else { - // 执行vNode节点渲染 - launchUpdateFromVNode(vNode); - } + // 执行vNode节点渲染 + launchUpdateFromVNode(vNode); } export function useReducerForInit(reducer, initArg, init, isUseState?: boolean): [S, Trigger] { From b0f765f7989c5b6e77c2cbd9de6d6b716d539a22 Mon Sep 17 00:00:00 2001 From: huangxuan Date: Thu, 11 Jan 2024 17:23:29 +0800 Subject: [PATCH 10/12] =?UTF-8?q?chore:=20=E9=85=8D=E7=BD=AEgithook?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E6=8F=90=E4=BA=A4=E5=92=8C=E6=A0=A1?= =?UTF-8?q?=E9=AA=8CcommitMsg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintignore | 2 +- .eslintrc.js | 3 +- .husky/commit-msg | 4 ++ .husky/pre-commit | 4 ++ .prettierignore | 3 ++ .prettierrc.js | 26 +++++----- commitlint.config.js | 19 +++++++ package.json | 21 ++++++-- packages/create-inula/.prettierrc.js | 32 ------------ packages/inula-cli/.eslintrc.cjs | 55 -------------------- packages/inula-cli/.prettierignore | 3 -- packages/inula-cli/.prettierrc.js | 30 ----------- packages/inula-intl/.eslintrc.js | 74 --------------------------- packages/inula-intl/.prettierrc.js | 30 ----------- packages/inula-request/.eslintrc.js | 74 --------------------------- packages/inula-request/.prettierrc.js | 32 ------------ packages/inula-router/.prettierrc.js | 32 ------------ packages/inula/package.json | 1 - 18 files changed, 61 insertions(+), 384 deletions(-) create mode 100644 .husky/commit-msg create mode 100644 .husky/pre-commit create mode 100644 .prettierignore create mode 100644 commitlint.config.js delete mode 100644 packages/create-inula/.prettierrc.js delete mode 100644 packages/inula-cli/.eslintrc.cjs delete mode 100644 packages/inula-cli/.prettierignore delete mode 100644 packages/inula-cli/.prettierrc.js delete mode 100644 packages/inula-intl/.eslintrc.js delete mode 100644 packages/inula-intl/.prettierrc.js delete mode 100644 packages/inula-request/.eslintrc.js delete mode 100644 packages/inula-request/.prettierrc.js delete mode 100644 packages/inula-router/.prettierrc.js diff --git a/.eslintignore b/.eslintignore index 60feb237..8d68b1f0 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,3 @@ **/node_modules -build/ +**/build/ *.d.ts diff --git a/.eslintrc.js b/.eslintrc.js index 61851c83..5e4838ae 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -22,7 +22,7 @@ module.exports = { ], root: true, - plugins: ['jest', 'no-for-of-loops', 'no-function-declare-after-return', 'react', '@typescript-eslint'], + plugins: ['jest', 'no-function-declare-after-return', 'react', '@typescript-eslint'], parser: '@typescript-eslint/parser', parserOptions: { @@ -56,7 +56,6 @@ module.exports = { 'comma-dangle': ['error', 'only-multiline'], 'no-constant-condition': 'off', - 'no-for-of-loops/no-for-of-loops': 'error', 'no-function-declare-after-return/no-function-declare-after-return': 'error', }, globals: { diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100644 index 00000000..35ed753f --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npm run commitlint diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 00000000..9e415abc --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npm run lint-commit diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..e691697a --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +**/build +*.md +*.html \ No newline at end of file diff --git a/.prettierrc.js b/.prettierrc.js index c2622eaa..6d7ef14b 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -16,17 +16,17 @@ 'use strict'; module.exports = { - printWidth: 120, // 一行120字符数,如果超过会进行换行 - tabWidth: 2, // tab等2个空格 - useTabs: false, // 用空格缩进行 - semi: true, // 行尾使用分号 - singleQuote: true, // 字符串使用单引号 - quoteProps: 'as-needed', // 仅在需要时在对象属性添加引号 - jsxSingleQuote: false, // 在JSX中使用双引号 - trailingComma: 'es5', // 使用尾逗号(对象、数组等) - bracketSpacing: true, // 对象的括号间增加空格 - bracketSameLine: false, // 将多行JSX元素的>放在最后一行的末尾 - arrowParens: 'avoid', // 在唯一的arrow函数参数周围省略括号 - vueIndentScriptAndStyle: false, // 不缩进Vue文件中的