Skip to content

Commit

Permalink
feat: support ESM and move to tsup
Browse files Browse the repository at this point in the history
  • Loading branch information
atomicpages committed Jul 6, 2024
1 parent 89428d7 commit 1e336b1
Show file tree
Hide file tree
Showing 51 changed files with 12,898 additions and 37,355 deletions.
19 changes: 19 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": [
"@djthoms/eslint-config",
"@djthoms/eslint-config/typescript",
"@djthoms/eslint-config/react",
"@djthoms/eslint-config/react-typescript",
"@djthoms/eslint-config/jest",
],
"parserOptions": {
"project": "./tsconfig.json"
},
"rules": {
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unsafe-assignment": "warn",
"@typescript-eslint/no-unsafe-member-access": "warn",
"@typescript-eslint/no-unsafe-call": "warn",
"@typescript-eslint/no-unsafe-argument": "warn",
}
}
9 changes: 0 additions & 9 deletions .eslintrc.js

This file was deleted.

14 changes: 7 additions & 7 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
version: 2
updates:
- package-ecosystem: npm
directory: '/'
directory: "/"
schedule:
interval: daily
time: '13:00'
time: "13:00"
open-pull-requests-limit: 10
ignore:
- dependency-name: '@types/node'
- dependency-name: "@types/node"
versions:
- 14.14.28
- 14.14.30
Expand All @@ -27,7 +27,7 @@ updates:
- 7.22.0
- 7.23.0
- 7.24.0
- dependency-name: '@testing-library/react-hooks'
- dependency-name: "@testing-library/react"
versions:
- 5.0.3
- 5.1.0
Expand All @@ -48,7 +48,7 @@ updates:
- dependency-name: nanoid
versions:
- 3.1.21
- dependency-name: '@types/react'
- dependency-name: "@types/react"
versions:
- 17.0.3
- dependency-name: typescript
Expand All @@ -58,9 +58,9 @@ updates:
- dependency-name: jest-image-snapshot
versions:
- 4.4.0
- dependency-name: '@djthoms/prettier-config'
- dependency-name: "@djthoms/prettier-config"
versions:
- 3.1.0
- dependency-name: '@djthoms/eslint-config'
- dependency-name: "@djthoms/eslint-config"
versions:
- 4.0.0
35 changes: 17 additions & 18 deletions .github/workflows/on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,33 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16
- name: npm install, build, and test
node-version: 20
- uses: pnpm/action-setup@v4
with:
version: 9
- name: pnpm install, build, and test
run: |
npm ci
npm t
npm run build
env:
CI: true
HUSKY_SKIP_INSTALL: 1
pnpm install-test --frozen-lockfile
pnpm run build
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: bundle
path: pkg
path: dist
checkChangesInDocs:
name: Check changes in docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check changes in stories
Expand All @@ -43,22 +42,22 @@ jobs:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16
- name: Install Dependencies
run: npm ci
- name: Download Artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: bundle
path: pkg
path: dist
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release
run: pnpm semantic-release
5 changes: 1 addition & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no lint-staged
pnpm lint-staged
4 changes: 4 additions & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"*.{ts,tsx,js}": "eslint --fix",
"*.{md,yml,yaml,json}": "prettier --write"
}
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16
lts
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@djthoms/prettier-config"
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"prettier.enable": true,
"typescript.updateImportsOnFileMove.enabled": "always",
"eslint.validate": [
"javascript",
Expand Down
19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ yarn add pretty-checkbox pretty-checkbox-react
Make sure you're on a supported version of React and React DOM:

```sh
npm i react@^16.9 react-dom@^16.9

# or use the latest and greatest react
npm i react react-dom
npm install react react-dom
```

### Using Preact?
Expand All @@ -61,7 +58,7 @@ for more? Head on over the the
[doc site](https://pretty-checkbox-react.netlify.app/).

```tsx
import { Checkbox } from 'pretty-checkbox-react';
import { Checkbox } from "pretty-checkbox-react";

function App() {
return <Checkbox>Do you agree to the terms and conditions?</Checkbox>;
Expand All @@ -74,8 +71,8 @@ Add a `ref` and get access to the input element. Uncontrolled mode allows for
seamless integration with form solutions like `react-hook-form`:

```tsx
import { useEffect, useRef } from 'react';
import { Checkbox } from 'pretty-checkbox-react';
import { useEffect, useRef } from "react";
import { Checkbox } from "pretty-checkbox-react";

function App() {
const ref = useRef(null);
Expand All @@ -97,8 +94,8 @@ function App() {
Use our awesome hooks to abstract away state logic!

```tsx
import { useCallback } from 'react';
import { Checkbox, useCheckboxState } from 'pretty-checkbox-react';
import { useCallback } from "react";
import { Checkbox, useCheckboxState } from "pretty-checkbox-react";

function App() {
const checkbox = useCheckboxState();
Expand All @@ -109,10 +106,10 @@ function App() {

if (!checkbox.state) {
// update the state manually from the `confirm` result
checkbox.setState(confirm('Do you agree to the terms and conditions?'));
checkbox.setState(confirm("Do you agree to the terms and conditions?"));
}
},
[checkbox]
[checkbox],
);

return (
Expand Down
Loading

0 comments on commit 1e336b1

Please sign in to comment.