Skip to content

Commit

Permalink
feat: add sample project
Browse files Browse the repository at this point in the history
  • Loading branch information
posaune0423 committed Sep 19, 2024
1 parent b8dbd2c commit a483565
Show file tree
Hide file tree
Showing 21 changed files with 3,167 additions and 10 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# use-haptic

<div align="center">
<a href="https://github.com/posaune0423/use-haptic/actions/workflows/ci.yml">
<img alt="CI" src="https://github.com/posaune0423/use-haptic/actions/workflows/ci.yml/badge.svg" />
</a>
<a href="https://www.npmjs.com/package/use-haptic">
<img alt="npm" src="https://img.shields.io/npm/v/use-haptic.svg?labelColor=49516F&color=8994BC" />
<img alt="npm" src="https://img.shields.io/npm/v/use-haptic.svg" />
</a>
<a href="https://npmjs.org/package/use-haptic">
<img alt="downloads" src="https://badgen.net/npm/dm/use-haptic?labelColor=49516F&color=8994BC" />
</a>
<a href="https://bundlephobia.com/result?p=use-haptic">
<img alt="tree-shakeable" src="https://badgen.net/bundlephobia/tree-shaking/use-haptic?labelColor=49516F&color=8994BC" />
</a>
<img alt="downloads" src="https://badgen.net/npm/dm/use-haptic" />
</a>
<a href="https://npmjs.org/package/use-haptic">
<img alt="types included" src="https://badgen.net/npm/types/use-haptic?labelColor=49516F&color=8994BC" />
<img alt="types included" src="https://badgen.net/npm/types/use-haptic" />
</a>
</div>

Expand Down
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"files": {
"ignoreUnknown": false,
"ignore": ["dist"]
"ignore": ["dist", "node_modules", "sample"]
},
"formatter": {
"enabled": true,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"ci": "npm run lint && npm run test",
"prepublishOnly": "npm run build"
},
"main": "lib/index.js",
"types": "lib/typescript/index.d.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": ["/src", "/dist", "/README.md", "/LICENSE"],
"license": "MIT",
"keywords": ["react-hooks", "react", "haptic", "vibration"],
Expand Down
24 changes: 24 additions & 0 deletions sample/.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?
50 changes: 50 additions & 0 deletions sample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

- Configure the top-level `parserOptions` property like this:

```js
export default tseslint.config({
languageOptions: {
// other options...
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
},
})
```

- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked`
- Optionally add `...tseslint.configs.stylisticTypeChecked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config:

```js
// eslint.config.js
import react from 'eslint-plugin-react'

export default tseslint.config({
// Set the react version
settings: { react: { version: '18.3' } },
plugins: {
// Add the react plugin
react,
},
rules: {
// other rules...
// Enable its recommended rules
...react.configs.recommended.rules,
...react.configs['jsx-runtime'].rules,
},
})
```
28 changes: 28 additions & 0 deletions sample/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'

export default tseslint.config(
{ ignores: ['dist'] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
},
)
13 changes: 13 additions & 0 deletions sample/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 + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
Loading

0 comments on commit a483565

Please sign in to comment.