Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericoo committed Sep 15, 2023
0 parents commit 8c73ab8
Show file tree
Hide file tree
Showing 24 changed files with 601 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
5 changes: 5 additions & 0 deletions .changeset/perfect-tools-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'react-router-typesafe': minor
---

Patch <Await> component
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Release

on:
push:
branches:
- main

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Creating .npmrc
run: |
cat << EOF > "$HOME/.npmrc"
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Install dependencies
shell: bash
run: bun install

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: bun run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist/
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
7 changes: 7 additions & 0 deletions .prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
arrowParens: 'avoid',
printWidth: 120,
useTabs: true,
singleQuote: true,
endOfLine: 'auto',
};
18 changes: 18 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[typescript]": {
"typescript.preferences.importModuleSpecifier": "non-relative"
},
"[typescriptreact]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"window.commandCenter": true,
"editor.rulers": [120],
"workbench.tree.indent": 16
}
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# react-router-typesafe

## 1.2.0

### Minor Changes

- Add `useLoaderData` hook types
- Migrate from pnpm to bun

## 1.1.0

### Minor Changes

- Add `makeLoader`, `makeAction` utilities
Re-exported `ActionFunction, `LoaderFunction`and`redirect` for commodity

## 1.0.1

### Patch Changes

- 9706126: Fixed files exposed with package.json

## 1.0.0

### Major Changes

- Initial release
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SWR Loader

SWR Loader is a ux-centric way for achieving stale-while-revalidate in stream-capable data loaders.

## Getting Started

Install the package:

```bash
npm install swr-loader
```
Binary file added bun.lockb
Binary file not shown.
2 changes: 2 additions & 0 deletions bunfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[test]
preload = "./happydom.ts"
134 changes: 134 additions & 0 deletions eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
module.exports = {
extends: [
'prettier',
'@remix-run/eslint-config',
'plugin:import/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/typescript',
],
parser: '@typescript-eslint/parser',
plugins: ['import', 'unused-imports', 'simple-import-sort', '@typescript-eslint'],

parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: true,
tsconfigRootDir: __dirname,
},
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import/resolver': {
typescript: {
project: ['tsconfig.json'],
},
node: {
project: ['tsconfig.json'],
},
},
},

rules: {
/** No absolute imports */
'import/no-absolute-path': 'error',

/** Ensures all imports appear before other statements */
'import/first': ['error'],

/** Ensures there’s an empty line between imports and other statements */
'import/newline-after-import': ['warn', { count: 1 }],

/** Sorts imports automatically */
'simple-import-sort/imports': 'warn',

/** Ensures no unused imports are present, and only _ prefixed variables can be unused */
'no-unused-vars': 'off',
'unused-imports/no-unused-vars': [
'warn',
{
vars: 'all',
varsIgnorePattern: '^_',
args: 'after-used',
argsIgnorePattern: '^_',
},
],
'unused-imports/no-unused-imports': 'error',
'@typescript-eslint/no-misused-promises': 'off',

'no-restricted-syntax': [
'warn',
{
selector: 'TSEnumDeclaration',
message: 'Don’t declare enums! Use string literal unions instead, they’re safer and more ergonomic.',
},
],

'no-restricted-imports': [
'error',
{
paths: [
{
name: 'react-router-dom',
importNames: ['defer'],
message: "Please import defer from '~/domains/routing/routing.utils' instead.",
},
{
name: 'react-router-dom',
importNames: ['useLoaderData'],
message: "Please import useLoaderData from '~/domains/routing/routing.utils' instead.",
},
{
name: 'react-router-dom',
importNames: ['useActionData'],
message: "Please import useActionData from '~/domains/routing/routing.utils' instead.",
},
],
},
],

'@typescript-eslint/no-unnecessary-condition': 'warn',
'@typescript-eslint/no-unnecessary-type-arguments': 'warn',
'@typescript-eslint/prefer-for-of': 'warn',
'@typescript-eslint/prefer-function-type': 'warn',

/** Prefer types over interfaces */
'@typescript-eslint/consistent-type-definitions': ['warn', 'type'],

'@typescript-eslint/no-confusing-non-null-assertion': 'error',

/** Standardises arrays. Simple arrays use brackets, complex arrays uses generic syntax
* @example - ❌ `const foo: Array<string> = [];`
* @example - ✅ `const foo: string[] = [];`
* @example - ❌ `const foo: ReturnType<typeof bar>[] = [];`
* @example - ✅ `const foo: Array<ReturnType<typeof bar>> = [];`
*/
'@typescript-eslint/array-type': ['warn'],

/** Enforces generics on the cunstructor, not as type annotation.
* @example - ❌ `const foo: Foo<string> = new Foo();`
* @example - ✅ `const foo = new Foo<string>();`
*/
'@typescript-eslint/consistent-generic-constructors': ['warn', 'constructor'],

/** Prefer Record<X,Y> over {[key: X]: Y} syntax */
'@typescript-eslint/consistent-indexed-object-style': ['warn', 'record'],

/** Already handled by unused-imports */
'@typescript-eslint/no-unused-vars': 'off',

/** React uses that a lot */
'@typescript-eslint/unbound-method': 'off',

'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-expect-error': 'allow-with-description',
'ts-ignore': true,
'ts-nocheck': true,
'ts-check': false,
minimumDescriptionLength: 5,
},
],
},
};
3 changes: 3 additions & 0 deletions happydom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { GlobalRegistrator } from '@happy-dom/global-registrator';

GlobalRegistrator.register();
54 changes: 54 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "swr-loader",
"version": "0.0.0",
"description": "ux-centric data loading and caching",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
}
},
"files": [
"dist"
],
"scripts": {
"build": "tsup",
"release": "bun run build && changeset publish"
},
"keywords": [
"react",
"react-router",
"react-router-dom",
"remix",
"remix-router"
],
"author": "fredericoo",
"license": "ISC",
"peerDependencies": {
"react": ">= 17",
"react-router-dom": ">= 6.4.0",
"typescript": ">= 4.9"
},
"devDependencies": {
"@changesets/cli": "^2.26.2",
"@happy-dom/global-registrator": "^11.0.6",
"@testing-library/react": "^14.0.0",
"@types/node": "^20.6.1",
"bun-types": "^1.0.1",
"eslint": "^8.45.0",
"expect-type": "^0.16.0",
"happy-dom": "^11.0.6",
"prettier": "^3.0.0",
"react": "^18.2.0",
"react-router-dom": "^6.16.0",
"tsup": "^7.1.0",
"typescript": "^5.1.6"
},
"dependencies": {
"idb": "^7.1.1"
}
}
Loading

0 comments on commit 8c73ab8

Please sign in to comment.