diff --git a/.eslintignore b/.eslintignore index ca9cd8a..63f6cdc 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,4 @@ -/dist -/src/vendor -/pnpm-lock.yaml -/jotai \ No newline at end of file +dist +examples +node_modules +website diff --git a/.github/workflows/lint-and-type.yml b/.github/workflows/lint-and-type.yml new file mode 100644 index 0000000..eab3066 --- /dev/null +++ b/.github/workflows/lint-and-type.yml @@ -0,0 +1,31 @@ +name: lint and type + +on: + push: + branches: [main] + pull_request: + types: [opened, synchronize] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup pnpm + uses: pnpm/action-setup@v2 + with: + version: 8 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: pnpm + - name: Install dependencies + run: pnpm install --frozen-lockfile --prefer-offline + - name: Prettier + run: pnpm run prettier:ci + - name: Lint + run: pnpm run eslint:ci + - name: Type + run: pnpm run typecheck diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..5691705 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,27 @@ +name: test + +on: + push: + branches: [main] + pull_request: + types: [opened, synchronize] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup pnpm + uses: pnpm/action-setup@v2 + with: + version: 8 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: pnpm + - name: Install dependencies + run: pnpm install --frozen-lockfile --prefer-offline + - name: Run Tests + run: pnpm run test diff --git a/examples/demo-01/src/App.tsx b/examples/demo-01/src/App.tsx index bca4cf4..bb8f9d4 100644 --- a/examples/demo-01/src/App.tsx +++ b/examples/demo-01/src/App.tsx @@ -1,65 +1,69 @@ -import { atom } from 'jotai'; -import { useAtomValueWithSchedule, useAtomWithSchedule, ImmediatePriority, LowPriority } from 'jotai-scheduler'; -import { useAtom, useAtomValue } from 'jotai'; +import { atom, useAtom, useAtomValue } from 'jotai' +import { + useAtomValueWithSchedule, + useAtomWithSchedule, + ImmediatePriority, + LowPriority, +} from 'jotai-scheduler' -import './App.css'; +import './App.css' -const anAtom = atom(0); +const anAtom = atom(0) const simulateHeavyRender = () => { - const start = performance.now(); + const start = performance.now() while (performance.now() - start < 500) {} -}; +} -const Header = () => { - simulateHeavyRender(); +function Header() { + simulateHeavyRender() // const num = useAtomValue(anAtom); - console.log('Header Component Render'); + console.log('Header Component Render') const num = useAtomValueWithSchedule(anAtom, { priority: LowPriority, - }); - return
Header-{num}
; -}; + }) + return
Header-{num}
+} -const Footer = () => { - simulateHeavyRender(); +function Footer() { + simulateHeavyRender() // const num = useAtomValue(anAtom); - console.log('Footer Component Render'); + console.log('Footer Component Render') const num = useAtomValueWithSchedule(anAtom, { priority: LowPriority, - }); - return
Footer-{num}
; -}; + }) + return
Footer-{num}
+} -const Sidebar = () => { - simulateHeavyRender(); +function Sidebar() { + simulateHeavyRender() // const num = useAtomValue(anAtom); - console.log('Sidebar Component Render'); - const num = useAtomValueWithSchedule(anAtom); - return
Sidebar-{num}
; -}; + console.log('Sidebar Component Render') + const num = useAtomValueWithSchedule(anAtom) + return
Sidebar-{num}
+} -const Content = () => { - simulateHeavyRender(); +function Content() { + simulateHeavyRender() // const [num, setNum] = useAtom(anAtom); - console.log('Content Component Render'); + console.log('Content Component Render') const [num, setNum] = useAtomWithSchedule(anAtom, { priority: ImmediatePriority, - }); + }) return (
Content-{num}
- ); -}; + ) +} export function App() { return ( @@ -71,5 +75,5 @@ export function App() {