Skip to content
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

Module-first setup #8

Merged
merged 4 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

39 changes: 39 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* eslint-env node */
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
'plugin:jsx-a11y/recommended',
'prettier',
],
ignorePatterns: ['dist/'],
settings: {
'import/resolver': {
typescript: true,
},
react: { version: 'detect' },
},
rules: {
'import/no-unresolved': ['error', { ignore: ['use-valtio'] }],
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
},
};
64 changes: 0 additions & 64 deletions .eslintrc.json

This file was deleted.

2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/pnpm-lock.yaml
/dist
4 changes: 0 additions & 4 deletions .prettierrc

This file was deleted.

10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,24 @@

## [Unreleased]

### Changed

- Module-first setup #8

## [0.1.0] - 2024-03-14

### Added

- feat: usage tracking like useSnapshot #7

## [0.0.2] - 2023-01-30

### Changed

- fix: support changing path #1

## [0.0.1] - 2023-01-23

### Added

- Initial release
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ The [examples](examples) folder contains working examples.
You can run one of them with

```bash
PORT=8080 yarn run examples:01_typescript
PORT=8080 pnpm run examples:01_counter
```

and open <http://localhost:8080> in your web browser.

You can also try them in codesandbox.io:
[01](https://codesandbox.io/s/github/dai-shi/use-valtio/tree/main/examples/01_typescript)
[02](https://codesandbox.io/s/github/dai-shi/use-valtio/tree/main/examples/02_suspense)
You can also try them directly:
[01](https://stackblitz.com/github/valtiojs/use-valtio/tree/main/examples/01_counter)
[02](https://stackblitz.com/github/valtiojs/use-valtio/tree/main/examples/02_suspense)
7 changes: 0 additions & 7 deletions __tests__/01_basic_spec.tsx

This file was deleted.

9 changes: 9 additions & 0 deletions examples/01_counter/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<html>
<head>
<title>example</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
21 changes: 21 additions & 0 deletions examples/01_counter/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "example",
"version": "0.0.0",
"private": true,
"type": "module",
"dependencies": {
"react": "latest",
"react-dom": "latest",
"use-valtio": "latest",
"valtio": "latest"
},
"devDependencies": {
"@types/react": "latest",
"@types/react-dom": "latest",
"typescript": "latest",
"vite": "latest"
},
"scripts": {
"dev": "vite"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import { proxy } from 'valtio/vanilla';
import { useValtio } from 'use-valtio';

Expand Down
10 changes: 10 additions & 0 deletions examples/01_counter/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';

import App from './app';

createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
</StrictMode>,
);
14 changes: 14 additions & 0 deletions examples/01_counter/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"strict": true,
"target": "es2018",
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"skipLibCheck": true,
"allowJs": true,
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": true,
"jsx": "react-jsx"
}
}
27 changes: 0 additions & 27 deletions examples/01_typescript/package.json

This file was deleted.

8 changes: 0 additions & 8 deletions examples/01_typescript/public/index.html

This file was deleted.

9 changes: 0 additions & 9 deletions examples/01_typescript/src/index.tsx

This file was deleted.

9 changes: 9 additions & 0 deletions examples/02_suspense/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<html>
<head>
<title>example</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
30 changes: 12 additions & 18 deletions examples/02_suspense/package.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
{
"name": "use-valtio-example",
"version": "0.1.0",
"name": "example",
"version": "0.0.0",
"private": true,
"type": "module",
"dependencies": {
"react": "latest",
"react-dom": "latest",
"use-valtio": "latest",
"valtio": "latest"
},
"devDependencies": {
"@types/react": "latest",
"@types/react-dom": "latest",
"react": "canary",
"react-dom": "canary",
"react-scripts": "latest",
"typescript": "latest",
"use-valtio": "latest",
"valtio": "latest"
"vite": "latest"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
"dev": "vite"
}
}
8 changes: 0 additions & 8 deletions examples/02_suspense/public/index.html

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="react/canary" />

import React, { Suspense, use, useTransition } from 'react';
import { Suspense, use, useTransition } from 'react';

import { proxy } from 'valtio/vanilla';
import { useValtio } from 'use-valtio';
Expand Down
9 changes: 0 additions & 9 deletions examples/02_suspense/src/index.tsx

This file was deleted.

10 changes: 10 additions & 0 deletions examples/02_suspense/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';

import App from './app';

createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
</StrictMode>,
);
14 changes: 14 additions & 0 deletions examples/02_suspense/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"strict": true,
"target": "es2018",
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"skipLibCheck": true,
"allowJs": true,
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": true,
"jsx": "react-jsx"
}
}
8 changes: 8 additions & 0 deletions examples/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"module": "esnext",
"moduleResolution": "bundler"
},
"exclude": []
}
Loading
Loading