diff --git a/package.json b/package.json index c7dd841..b0a777e 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "@minko-fe/prettier-config": "^2.2.2", "@minko-fe/tsconfig": "latest", "eslint": "^8.57.0", + "npm-run-all2": "^6.2.0", "nyc": "^15.1.0", "prettier-plugin-astro": "^0.13.0", "prettier-plugin-tailwindcss": "^0.5.14", diff --git a/packages/istanbul-widget/package.json b/packages/istanbul-widget/package.json index 0266b89..a2349a3 100644 --- a/packages/istanbul-widget/package.json +++ b/packages/istanbul-widget/package.json @@ -52,7 +52,9 @@ "build": "tsup", "vite": "vite", "report": "NODE_ENV=production REPORT=true vite build --mode production", - "lint": "eslint . --fix", + "lint": "run-p type-check eslint", + "type-check": "tsc --noEmit", + "eslint": "eslint . --fix", "preview": "vite preview" }, "peerDependencies": { @@ -106,6 +108,7 @@ "tailwindcss-rem-to-px": "^0.1.0", "tsup-plugin-bundleless": "^0.3.2", "tsup-plugin-css-legacy": "^0.0.1", + "typescript": "^5.4.5", "vite": "^5.2.11" } } diff --git a/packages/istanbul-widget/src/core/components/Draggable.tsx b/packages/istanbul-widget/src/core/components/Draggable.tsx index 80667a7..43698f6 100644 --- a/packages/istanbul-widget/src/core/components/Draggable.tsx +++ b/packages/istanbul-widget/src/core/components/Draggable.tsx @@ -4,7 +4,7 @@ import { type DragOptions, useDraggable } from '@neodrag/react' import { type PropsWithChildren, memo, useEffect, useRef, useState } from 'react' import { cn } from '@/components/utils' import { ISTANBUL_WIDGET_ID } from '@/utils/const' -import Context from '../Context' +import Context from '../context' import { type Position } from '../options.interface' type DraggableProps = PropsWithChildren<{ diff --git a/packages/istanbul-widget/src/core/core.ts b/packages/istanbul-widget/src/core/core.ts index f22913f..cce89aa 100644 --- a/packages/istanbul-widget/src/core/core.ts +++ b/packages/istanbul-widget/src/core/core.ts @@ -1,14 +1,14 @@ import { isArray, isFunction, isObject, merge, set } from '@minko-fe/lodash-pro' import { type ConsolaInstance, LogLevels, createConsola } from 'consola/browser' -import { ButtonGroupPlugin } from '@/plugins/button-group/ButtonGroupPlugin' -import { ReportPlugin } from '@/plugins/report/ReportPlugin' -import { SettingPlugin } from '@/plugins/setting/SettingPlugin' +import { ButtonGroupPlugin } from '@/plugins/button-group/button-group-plugin' +import { ReportPlugin } from '@/plugins/report/report-plugin' +import { SettingPlugin } from '@/plugins/setting/setting-plugin' import { ISTANBUL_WIDGET_ID } from '@/utils/const' import { $ } from '@/utils/query' -import Context from './Context' +import Context from './context' import { type IstanbulWidgetOptions, type PluginName, type PluginType } from './options.interface' -import { IstanbulWidgetPlugin } from './plugin/IstanbulWidgetPlugin' -import { IstanbulWidgetReactPlugin } from './plugin/IstanbulWidgetReactPlugin' +import { IstanbulWidgetPlugin } from './plugin/istanbul-widget-plugin' +import { IstanbulWidgetReactPlugin } from './plugin/istanbul-widget-react-plugin' import { type CompInstance, render } from './render' import '@/styles/global.css' diff --git a/packages/istanbul-widget/src/core/IstanbulWidget.tsx b/packages/istanbul-widget/src/core/istanbul-widget.tsx similarity index 97% rename from packages/istanbul-widget/src/core/IstanbulWidget.tsx rename to packages/istanbul-widget/src/core/istanbul-widget.tsx index 5db6ccf..017af90 100644 --- a/packages/istanbul-widget/src/core/IstanbulWidget.tsx +++ b/packages/istanbul-widget/src/core/istanbul-widget.tsx @@ -3,8 +3,8 @@ import { Popover, PopoverArrow, PopoverClose, PopoverContent, PopoverTrigger } f import { Toaster } from '@/components/ui/toaster' import { ISTANBUL_WIDGET_ID } from '@/utils/const' import { $ } from '@/utils/query' -import Context from './Context' -import Draggable from './components/Draggable' +import Draggable from './components/draggable' +import Context from './context' import { type Position } from './options.interface' function IstanbulWidgetComponent() { diff --git a/packages/istanbul-widget/src/core/plugin/IstanbulWidgetPlugin.ts b/packages/istanbul-widget/src/core/plugin/istanbul-widget-plugin.ts similarity index 100% rename from packages/istanbul-widget/src/core/plugin/IstanbulWidgetPlugin.ts rename to packages/istanbul-widget/src/core/plugin/istanbul-widget-plugin.ts diff --git a/packages/istanbul-widget/src/core/plugin/IstanbulWidgetReactPlugin.ts b/packages/istanbul-widget/src/core/plugin/istanbul-widget-react-plugin.ts similarity index 95% rename from packages/istanbul-widget/src/core/plugin/IstanbulWidgetReactPlugin.ts rename to packages/istanbul-widget/src/core/plugin/istanbul-widget-react-plugin.ts index 9336fda..03453f6 100644 --- a/packages/istanbul-widget/src/core/plugin/IstanbulWidgetReactPlugin.ts +++ b/packages/istanbul-widget/src/core/plugin/istanbul-widget-react-plugin.ts @@ -3,7 +3,7 @@ import { $ } from '@/utils/query' import { IstanbulWidget } from '../core' import { reactdomRender, reactdomUnmount } from '../dom/react-render' import { type PluginType } from '../options.interface' -import { IstanbulWidgetPlugin } from './IstanbulWidgetPlugin' +import { IstanbulWidgetPlugin } from './istanbul-widget-plugin' export type IstanbulWidgetReactPluginProps = {} & PluginType diff --git a/packages/istanbul-widget/src/core/render.tsx b/packages/istanbul-widget/src/core/render.tsx index 082d4a1..89f657f 100644 --- a/packages/istanbul-widget/src/core/render.tsx +++ b/packages/istanbul-widget/src/core/render.tsx @@ -1,7 +1,7 @@ import { ISTANBUL_WIDGET_ID } from '@/utils/const' -import Context, { type InitialWidgetProps } from './Context' -import IstanbulWidgetComponent from './IstanbulWidget' +import Context, { type InitialWidgetProps } from './context' import { reactdomRender, reactdomUnmount } from './dom/react-render' +import IstanbulWidgetComponent from './istanbul-widget' import { type PluginType } from './options.interface' export type CompInstance = { diff --git a/packages/istanbul-widget/src/plugins/button-group/ButtonGroupPlugin.ts b/packages/istanbul-widget/src/plugins/button-group/button-group-plugin.ts similarity index 57% rename from packages/istanbul-widget/src/plugins/button-group/ButtonGroupPlugin.ts rename to packages/istanbul-widget/src/plugins/button-group/button-group-plugin.ts index caae81d..85a5d9b 100644 --- a/packages/istanbul-widget/src/plugins/button-group/ButtonGroupPlugin.ts +++ b/packages/istanbul-widget/src/plugins/button-group/button-group-plugin.ts @@ -1,5 +1,5 @@ -import { IstanbulWidgetReactPlugin } from '@/core/plugin/IstanbulWidgetReactPlugin' -import ButtonGroup, { type ButtonGroupProps } from './ButtonGroup' +import { IstanbulWidgetReactPlugin } from '@/core/plugin/istanbul-widget-react-plugin' +import ButtonGroup, { type ButtonGroupProps } from './button-group' export class ButtonGroupPlugin extends IstanbulWidgetReactPlugin { constructor(id: string, name: string, renderProps: ButtonGroupProps) { diff --git a/packages/istanbul-widget/src/plugins/button-group/ButtonGroup.tsx b/packages/istanbul-widget/src/plugins/button-group/button-group.tsx similarity index 95% rename from packages/istanbul-widget/src/plugins/button-group/ButtonGroup.tsx rename to packages/istanbul-widget/src/plugins/button-group/button-group.tsx index fe643a2..38df85f 100644 --- a/packages/istanbul-widget/src/plugins/button-group/ButtonGroup.tsx +++ b/packages/istanbul-widget/src/plugins/button-group/button-group.tsx @@ -1,6 +1,6 @@ import { memo } from 'react' import { Button } from '@/components/ui/button' -import Context from '@/core/Context' +import Context from '@/core/context' import { type ButtonGroupOptions } from '@/core/options.interface' export type ButtonGroupProps = { diff --git a/packages/istanbul-widget/src/plugins/report/Report.tsx b/packages/istanbul-widget/src/plugins/report/Report.tsx index 1adf288..aeb5016 100644 --- a/packages/istanbul-widget/src/plugins/report/Report.tsx +++ b/packages/istanbul-widget/src/plugins/report/Report.tsx @@ -1,6 +1,6 @@ import { memo } from 'react' import { Button } from '@/components/ui/button' -import Context from '../../core/Context' +import Context from '../../core/context' function Report() { const { plugin, reportFn } = Context.usePicker(['plugin', 'reportFn']) diff --git a/packages/istanbul-widget/src/plugins/report/ReportPlugin.ts b/packages/istanbul-widget/src/plugins/report/report-plugin.ts similarity index 59% rename from packages/istanbul-widget/src/plugins/report/ReportPlugin.ts rename to packages/istanbul-widget/src/plugins/report/report-plugin.ts index 287678c..9f3a5db 100644 --- a/packages/istanbul-widget/src/plugins/report/ReportPlugin.ts +++ b/packages/istanbul-widget/src/plugins/report/report-plugin.ts @@ -1,5 +1,5 @@ -import { IstanbulWidgetReactPlugin } from '@/core/plugin/IstanbulWidgetReactPlugin' -import Report from './Report' +import { IstanbulWidgetReactPlugin } from '@/core/plugin/istanbul-widget-react-plugin' +import Report from './report' export class ReportPlugin extends IstanbulWidgetReactPlugin { constructor(id: string, name: string, renderProps = {}) { diff --git a/packages/istanbul-widget/src/plugins/setting/Setting.tsx b/packages/istanbul-widget/src/plugins/setting/Setting.tsx index e2a1a2e..30316bc 100644 --- a/packages/istanbul-widget/src/plugins/setting/Setting.tsx +++ b/packages/istanbul-widget/src/plugins/setting/Setting.tsx @@ -19,7 +19,7 @@ import { Label } from '@/components/ui/label' import { Switch } from '@/components/ui/switch' import { useToast } from '@/components/ui/use-toast' import { ISTANBUL_WIDGET_ID } from '@/utils/const' -import Context from '../../core/Context' +import Context from '../../core/context' type Config = { reporter: string diff --git a/packages/istanbul-widget/src/plugins/setting/SettingPlugin.ts b/packages/istanbul-widget/src/plugins/setting/setting-plugin.ts similarity index 59% rename from packages/istanbul-widget/src/plugins/setting/SettingPlugin.ts rename to packages/istanbul-widget/src/plugins/setting/setting-plugin.ts index 7d4c851..44e99e9 100644 --- a/packages/istanbul-widget/src/plugins/setting/SettingPlugin.ts +++ b/packages/istanbul-widget/src/plugins/setting/setting-plugin.ts @@ -1,5 +1,5 @@ -import { IstanbulWidgetReactPlugin } from '@/core/plugin/IstanbulWidgetReactPlugin' -import Setting from './Setting' +import { IstanbulWidgetReactPlugin } from '@/core/plugin/istanbul-widget-react-plugin' +import Setting from './setting' export class SettingPlugin extends IstanbulWidgetReactPlugin { constructor(id: string, name: string, renderProps = {}) { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0325409..35b5a8f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -40,6 +40,9 @@ importers: eslint: specifier: ^8.57.0 version: 8.57.0 + npm-run-all2: + specifier: ^6.2.0 + version: 6.2.0 nyc: specifier: ^15.1.0 version: 15.1.0 @@ -246,6 +249,9 @@ importers: tsup-plugin-css-legacy: specifier: ^0.0.1 version: 0.0.1 + typescript: + specifier: ^5.4.5 + version: 5.4.5 vite: specifier: ^5.2.11 version: 5.2.11(@types/node@20.12.12)