Skip to content

Commit

Permalink
chore: add array-test example
Browse files Browse the repository at this point in the history
  • Loading branch information
cqh963852 committed Jan 8, 2024
1 parent c484855 commit 494fad5
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 0 deletions.
13 changes: 13 additions & 0 deletions examples/array-test/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "simple-import-sort", "@idealjs/sapling"],
"rules": {
"quotes": "warn",
"simple-import-sort/imports": "warn",
"simple-import-sort/exports": "warn",
"@idealjs/sapling/no-nested-derive-call": "error",
"@idealjs/sapling/no-state-created-in-derive": "error",
"@typescript-eslint/no-unused-vars": "off"
}
}
24 changes: 24 additions & 0 deletions examples/array-test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
13 changes: 13 additions & 0 deletions examples/array-test/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + TS</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
20 changes: 20 additions & 0 deletions examples/array-test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "array-test",
"private": true,
"version": "0.1.18",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"devDependencies": {
"@idealjs/eslint-plugin-sapling": "0.1.18",
"@types/node": "^20.10.7",
"typescript": "^5.3.3",
"vite": "^5.0.11"
},
"dependencies": {
"@idealjs/sapling": "0.1.18"
}
}
1 change: 1 addition & 0 deletions examples/array-test/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions examples/array-test/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { upsert } from "@idealjs/sapling";

const Test = () => {
return [<div>A</div>, <div>B</div>];
};

const Component = () => {
return (
<div>
<div>{() => <Test />}</div>
<div>{() => [<Test />, <Test />]}</div>
<Test />
[ <Test />,<Test />,<Test />]
</div>
);
};

const root = document.getElementById("app")!;

upsert(root, <Component />);
1 change: 1 addition & 0 deletions examples/array-test/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
18 changes: 18 additions & 0 deletions examples/array-test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "dist",
"jsx": "react-jsx",
"jsxImportSource": "@idealjs/sapling",
"paths": {
"@idealjs/sapling/*": ["../../packages/core/src/*"]
}
},
"include": ["src"],
"exclude": ["node_modules"],
"references": [
{
"path": "../../packages/core"
}
]
}
12 changes: 12 additions & 0 deletions examples/array-test/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import path from "path";
import { defineConfig } from "vite";

// https://vitejs.dev/config/
export default defineConfig({
plugins: [],
resolve: {
alias: {
"@idealjs/sapling": path.resolve(__dirname, "../../packages/core/src"),
},
},
});

0 comments on commit 494fad5

Please sign in to comment.