Skip to content

Commit

Permalink
feat: migrate setup to pnpm, vitest and tsup
Browse files Browse the repository at this point in the history
  • Loading branch information
thebuilder committed Jul 5, 2024
1 parent 46f8fe5 commit 3ef176c
Show file tree
Hide file tree
Showing 94 changed files with 916 additions and 16,698 deletions.
29 changes: 13 additions & 16 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@ on: [push, pull_request]

jobs:
build:
name: Build
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x, 16.x]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
- run: corepack enable
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: npm install, build, and test
run: |
yarn
yarn build
yarn test
env:
CI: true
node-version: 20
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm build
- name: Test
run: pnpm test
5 changes: 0 additions & 5 deletions .prettierrc

This file was deleted.

7 changes: 0 additions & 7 deletions babel.config.js

This file was deleted.

52 changes: 52 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
"files": {
"ignore": [
".idea/**",
"node_modules/**",
"dist/**",
"coverage/**",
"storybook-static/**",
"pnpm-lock.yaml"
]
},
"organizeImports": {
"enabled": true
},
"formatter": {
"enabled": true,
"indentStyle": "space"
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"complexity": {
"noForEach": "off"
},
"style": {
"noVar": "off"
},
"a11y": {
"noSvgWithoutTitle": "off"
}
}
},
"overrides": [
{
"include": ["**/*.test.ts", "**/*.test.tsx"],
"linter": {
"rules": {
"style": {
"noUnusedTemplateLiteral": "off"
}
}
}
}
],
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
}
}
6 changes: 3 additions & 3 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
extends: ["@commitlint/config-conventional"],
rules: {
// Scopes are case insensitive (rather than lower case), most notably to support React components, e.g. fix(Button):
'scope-case': [0],
"scope-case": [0],
},
}
};
8 changes: 0 additions & 8 deletions jest.config.js

This file was deleted.

98 changes: 18 additions & 80 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
{
"description": "Collection of React Hooks",
"private": true,
"files": [
"lib/*"
],
"files": ["lib/*"],
"repository": {
"type": "git",
"url": "https://github.com/charlie-tango/hooks.git"
},
"scripts": {
"clean": "lerna clean",
"build": "lerna run build --stream",
"build:storybook": "lerna run build:storybook --scope @charlietango/storybook",
"dev": "lerna run dev --scope @charlietango/storybook",
"lint": "lerna run lint --stream --parallel",
"build": "pnpm -r build",
"dev": "pnpm --filter @charlietango/storybook dev",
"lint": "biome check . --fix",
"new-hook": "node tools/new-hook",
"update-readme": "node tools/update-readme",
"release": "cross-env HUSKY_BYPASS=true lerna publish",
"pretty": "prettier '**/*.{js,ts,tsx,md,json,yml,html}' --write",
"test": "lerna run test --stream --parallel"
"release": "cross-env HUSKY_BYPASS=true pnpm publish",
"test": "vitest"
},
"husky": {
"hooks": {
Expand All @@ -37,92 +32,35 @@
"git add README.md",
"git add packages/hooks/readme.md"
],
"*.{js,json,css,md,mdx,ts,tsx}": [
"prettier --write"
],
"src/**/*.{ts,tsx}": [
"eslint",
"jest --findRelatedTests"
]
},
"eslintConfig": {
"extends": [
"react-app"
],
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"react-hooks"
],
"rules": {
"@typescript-eslint/no-angle-bracket-type-assertion": "off",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"no-unused-vars": "off",
"no-console": "error"
},
"settings": {
"react": {
"version": "detect"
}
}
"*.{js,json,css,md,mdx,ts,tsx}": ["prettier --write"],
"src/**/*.{ts,tsx}": ["eslint", "jest --findRelatedTests"]
},
"dependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
"peerDependencies": {
"react": "^15.0.0 || ^16.0.0 || ^17.0.0"
},
"devDependencies": {
"@babel/cli": "^7.7.4",
"@babel/core": "^7.7.4",
"@babel/plugin-transform-runtime": "^7.7.4",
"@babel/preset-env": "^7.7.4",
"@babel/preset-react": "^7.7.4",
"@babel/preset-typescript": "^7.7.4",
"@biomejs/biome": "^1.8.3",
"@commitlint/cli": "^16.2.3",
"@commitlint/config-conventional": "^16.2.1",
"@testing-library/dom": "^8.13.0",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.0.1",
"@testing-library/react-hooks": "^8.0.0",
"@testing-library/user-event": "^14.1.0",
"@types/jest": "^27.4.1",
"@types/react": "^18.0.5",
"@types/styled-components": "^5.0.0",
"@typescript-eslint/eslint-plugin": "^5.19.0",
"@typescript-eslint/parser": "^5.19.0",
"@testing-library/dom": "^10.3.1",
"@testing-library/react": "^16.0.0",
"@testing-library/user-event": "^14.5.2",
"@types/react": "^18.3.3",
"ansi-colors": "^4.0.1",
"babel-eslint": "^10.0.3",
"babel-jest": "^27.5.1",
"babel-loader": "^8.0.5",
"cross-env": "^7.0.0",
"eslint": "^8.13.0",
"eslint-config-react-app": "^7.0.1",
"eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.17.0",
"eslint-plugin-react-hooks": "^4.0.4",
"execa": "^6.1.0",
"globby": "^11.0.4",
"happy-dom": "^14.12.3",
"husky": "^4.2.3",
"inquirer": "^8.2.2",
"jest": "^27.5.1",
"lerna": "^4.0.0",
"lint-staged": "^12.3.7",
"lodash": "^4.17.11",
"mkdirp": "^1.0.3",
"ora": "^6.1.0",
"prettier": "^2.6.2",
"react-test-renderer": "^18.0.0",
"rollup": "^1.27.8",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-node-resolve": "^5.1.0",
"typescript": "^4.0.3"
"tsup": "^8.1.0",
"typescript": "^5.5.3",
"vitest": "^1.6.0"
},
"workspaces": [
"packages/*"
]
"workspaces": ["packages/*"]
}
44 changes: 22 additions & 22 deletions packages/hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,45 @@
"description": "Collection of React Hooks grouped into @charlietango/hooks",
"private": false,
"sideEffects": false,
"main": "lib/hooks.cjs.js",
"module": "lib/hooks.esm.js",
"typings": "lib/hooks.d.ts",
"files": [
"lib/*"
],
"type": "commonjs",
"main": "./lib/hooks.js",
"module": "./lib/hooks.mjs",
"types": "./lib/hooks.d.ts",
"exports": {
".": {
"types": "./lib/hooks.d.mts",
"require": "./lib/hooks.js",
"default": "./lib/hooks.mjs"
}
},
"license": "MIT",
"keywords": ["react", "hooks"],
"files": ["lib/*"],
"repository": {
"type": "git",
"url": "https://github.com/charlie-tango/hooks.git"
},
"license": "MIT",
"keywords": [
"react",
"hooks"
],
"scripts": {
"lint": "eslint . --ext js,ts,tsx",
"lint": "biome check . --fix",
"prebuild": "rm -rf lib",
"build": "rollup -c ../../tools/rollup.config.js",
"postbuild": "tsc --noEmit false",
"prepublish": "yarn build",
"pretty": "prettier '**/*.{js,ts,tsx,md,json,yml,html}' --write",
"test": "jest"
},
"jest": {
"preset": "../../jest.config.js"
"build": "tsup src/hooks.ts",
"prepublish": "pnpm build",
"test": "vitest"
},
"publishConfig": {
"access": "public"
},
"devDependencies": {
"@biomejs/biome": "^1.8.3",
"tsup": "^8.1.0"
},
"dependencies": {
"@charlietango/use-client-hydrated": "^1.10.0",
"@charlietango/use-element-size": "^2.2.0",
"@charlietango/use-focus-trap": "^1.4.0",
"@charlietango/use-id": "^1.10.0",
"@charlietango/use-interaction": "^1.10.0",
"@charlietango/use-lazy-ref": "^1.12.0",
"@charlietango/use-media": "^1.6.0",
"@charlietango/use-native-lazy-loading": "^1.10.0",
"@charlietango/use-script": "^2.3.0",
"@charlietango/use-toggle": "^1.4.0",
"@charlietango/use-window-size": "^1.7.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/hooks.test.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
it('should include hooks', () => {})
it("should include hooks", () => {});
18 changes: 9 additions & 9 deletions packages/hooks/src/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export { default as useElementSize } from '@charlietango/use-element-size'
export { default as useFocusTrap } from '@charlietango/use-focus-trap'
export { default as useMedia } from '@charlietango/use-media'
export { default as useScript } from '@charlietango/use-script'
export { default as useToggle } from '@charlietango/use-toggle'
export { default as useWindowSize } from '@charlietango/use-window-size'
export { default as useInteraction } from '@charlietango/use-interaction'
export { default as useClientHydrated } from '@charlietango/use-client-hydrated'
export { default as useLazyRef } from '@charlietango/use-lazy-ref'
export { default as useElementSize } from "@charlietango/use-element-size";
export { default as useFocusTrap } from "@charlietango/use-focus-trap";
export { default as useMedia } from "@charlietango/use-media";
export { default as useScript } from "@charlietango/use-script";
export { default as useToggle } from "@charlietango/use-toggle";
export { default as useWindowSize } from "@charlietango/use-window-size";
export { default as useInteraction } from "@charlietango/use-interaction";
export { default as useClientHydrated } from "@charlietango/use-client-hydrated";
export { default as useLazyRef } from "@charlietango/use-lazy-ref";
3 changes: 1 addition & 2 deletions packages/hooks/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@
"noEmit": false
},
"include": ["src/**/*.*"],
"exclude": ["lib", "**/*.story.tsx", "**/*.test.*"],
"files": ["../../types/story-types.d.ts"]
"exclude": ["lib"]
}
31 changes: 31 additions & 0 deletions packages/storybook/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { StorybookConfig } from "@storybook/react-vite";

const config: StorybookConfig = {
framework: "@storybook/react-vite",
stories: [
"../stories/*.@(story|stories).@(ts|tsx|js|jsx|mdx)",
],
addons: ["@storybook/addon-essentials"],
core: {
builder: "@storybook/builder-vite",
},
typescript: {
reactDocgen: "react-docgen", // or false if you don't need docgen at all
},
/**
* In preparation for the vite build plugin, add the needed config here.
*/
async viteFinal(config) {
if (config.optimizeDeps) {
config.optimizeDeps.include = [
...(config.optimizeDeps.include ?? []),
"@storybook/theming",
"@storybook/addon-essentials/docs/mdx-react-shim",
"@storybook/addon-actions",
];
}
return config;
},
};

export default config;
10 changes: 10 additions & 0 deletions packages/storybook/.storybook/manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { addons } from "@storybook/manager-api";
import { themes } from "@storybook/theming";

addons.setConfig({
theme: {
...themes.normal,
brandTitle: "Hooks",
brandUrl: "https://github.com/charlie-tango/hooks",
},
});
Loading

0 comments on commit 3ef176c

Please sign in to comment.