Skip to content

Commit

Permalink
Merge branch 'main' into next-fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusmarminge committed Jun 28, 2023
2 parents 7077e1c + 2bc867f commit e2ad25d
Show file tree
Hide file tree
Showing 146 changed files with 846 additions and 635 deletions.
21 changes: 14 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const config = {
parser: '@typescript-eslint/parser',
plugins: ['no-only-tests', 'unicorn', 'turbo'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:@typescript-eslint/recommended-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'prettier',
Expand All @@ -22,15 +22,22 @@ const config = {
'./www/tsconfig.json',
], // Allows for the use of rules which require parserServices to be generated
},
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
rules: {
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
// These rules aren't enabled in typescript-eslint's basic recommended config, but we like them
'@typescript-eslint/no-non-null-assertion': 'error',

// These rules enabled in typescript-eslint's configs don't apply here
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/no-empty-interface': 'off',

// Todo: do we want these?
'@typescript-eslint/no-explicit-any': 'off',

'react/react-in-jsx-scope': 'off',
'react/prop-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'no-only-tests/no-only-tests': 'error',
'@typescript-eslint/no-empty-interface': 'off',
'unicorn/filename-case': [
'error',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export function RawExample() {
<input
type="text"
value={text}
onChange={(e) => setText(e.target.value)}
onChange={(e) => {
setText(e.target.value);
}}
/>
</label>
<br />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ import { z } from 'zod';

export function createForm<TDef extends ActionHandlerDef>(opts: {
action: TRPCActionHandler<TDef>;
schema: { _input: TDef['input'] } & z.ZodSchema<any>;
schema: z.ZodSchema<any> & { _input: TDef['input'] };
hookProps?: Omit<UseFormProps<TDef['input']>, 'resolver'>;
}) {
type FormValues = TDef['input'];
function Form(
props: Omit<
JSX.IntrinsicElements['form'],
'ref' | 'action' | 'onSubmit' | 'encType' | 'method'
'action' | 'encType' | 'method' | 'onSubmit' | 'ref'
> & {
render: (renderProps: {
form: UseFormReturn<FormValues>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,21 @@ export function UseActionExample() {
<input
type={'text'}
value={text}
onChange={(e) => setText(e.target.value)}
onChange={(e) => {
setText(e.target.value);
}}
className="bg-slate-300 text-slate-900"
/>
</label>
</p>

<p>
<button
onClick={() =>
onClick={() => {
mutation.mutate({
text,
})
}
});
}}
>
Run server action
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ type UnwrapZodEffect<TType extends z.ZodType> = TType extends z.ZodEffects<
type GetInput<TType extends z.ZodType> = UnwrapZodEffect<TType>['_input'];

function useZodFormData<TSchema extends z.ZodType>(
props: {
props: Omit<UseFormProps<GetInput<TSchema>>, 'resolver'> & {
schema: TSchema;
} & Omit<UseFormProps<GetInput<TSchema>>, 'resolver'>,
},
) {
const formRef = useRef<HTMLFormElement>(null);
const _resolver = zodResolver(props.schema, undefined, {
Expand Down Expand Up @@ -108,7 +108,9 @@ export default function Page() {
<input
type="checkbox"
checked={noJs}
onChange={(e) => setNoJs(e.target.checked)}
onChange={(e) => {
setNoJs(e.target.checked);
}}
/>
</div>
<div>
Expand Down
20 changes: 15 additions & 5 deletions examples/.interop/next-prisma-starter/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"parser": "@typescript-eslint/parser", // Specifies the ESLint parser
"extends": [
"plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:@typescript-eslint/stylistic-type-checked",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:prettier/recommended"
Expand All @@ -13,17 +14,26 @@
},
"rules": {
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/consistent-type-definitions": "off",
"react/react-in-jsx-scope": "off",
"react/prop-types": "off",
"@typescript-eslint/no-explicit-any": "off"

// Consider removing these rule disables for more type safety in your app ✨
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/require-await": "off"
},
// "overrides": [
// {
// "files": [],
// "rules": {
// "@typescript-eslint/no-unused-vars": "off"
// "@typescript-eslint/no-unused-vars": "off"
// }
// }
// ],
Expand Down
4 changes: 2 additions & 2 deletions examples/.interop/next-prisma-starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
"@tanstack/react-query-devtools": "^4.18.0",
"@types/node": "^18.16.16",
"@types/react": "^18.2.8",
"@typescript-eslint/eslint-plugin": "^5.59.2",
"@typescript-eslint/parser": "^5.59.2",
"@typescript-eslint/eslint-plugin": "6.0.0-alpha.158",
"@typescript-eslint/parser": "6.0.0-alpha.158",
"eslint": "^8.40.0",
"eslint-config-next": "^13.4.3",
"eslint-config-prettier": "^8.8.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/.interop/next-prisma-starter/src/server/prisma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const prismaGlobal = global as typeof global & {
};

export const prisma: PrismaClient =
prismaGlobal.prisma ||
prismaGlobal.prisma ??
new PrismaClient({
log:
env.NODE_ENV === 'development' ? ['query', 'error', 'warn'] : ['error'],
Expand Down
4 changes: 2 additions & 2 deletions examples/fastify-server/src/server/router/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { inferAsyncReturnType } from '@trpc/server';
import { CreateFastifyContextOptions } from '@trpc/server/adapters/fastify';

export interface User {
name: string | string[];
name: string[] | string;
}

export function createContext({ req, res }: CreateFastifyContextOptions) {
const user: User = { name: req.headers['username'] ?? 'anonymous' };
const user: User = { name: req.headers.username ?? 'anonymous' };

return { req, res, user };
}
Expand Down
2 changes: 1 addition & 1 deletion examples/lambda-api-gateway/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function createContext({
}: CreateAWSLambdaContextOptions<APIGatewayProxyEvent>) {
return {
event: event,
apiVersion: (event as { version?: string }).version || '1.0',
apiVersion: (event as { version?: string }).version ?? '1.0',
user: event.headers['x-user'],
};
}
Expand Down
3 changes: 2 additions & 1 deletion examples/minimal-react/client/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import React from 'react';
import ReactDOM from 'react-dom/client';
import { App } from './App';

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
</React.StrictMode>,
Expand Down
20 changes: 15 additions & 5 deletions examples/next-prisma-starter/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"parser": "@typescript-eslint/parser", // Specifies the ESLint parser
"extends": [
"plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:@typescript-eslint/stylistic-type-checked",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:prettier/recommended"
Expand All @@ -13,17 +14,26 @@
},
"rules": {
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/consistent-type-definitions": "off",
"react/react-in-jsx-scope": "off",
"react/prop-types": "off",
"@typescript-eslint/no-explicit-any": "off"

// Consider removing these rule disables for more type safety in your app ✨
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/require-await": "off"
},
// "overrides": [
// {
// "files": [],
// "rules": {
// "@typescript-eslint/no-unused-vars": "off"
// "@typescript-eslint/no-unused-vars": "off"
// }
// }
// ],
Expand Down
4 changes: 2 additions & 2 deletions examples/next-prisma-starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
"@playwright/test": "^1.26.1",
"@types/node": "^18.16.16",
"@types/react": "^18.2.8",
"@typescript-eslint/eslint-plugin": "^5.59.2",
"@typescript-eslint/parser": "^5.59.2",
"@typescript-eslint/eslint-plugin": "6.0.0-alpha.158",
"@typescript-eslint/parser": "6.0.0-alpha.158",
"autoprefixer": "^10.4.7",
"eslint": "^8.40.0",
"eslint-config-next": "^13.4.3",
Expand Down
2 changes: 1 addition & 1 deletion examples/next-prisma-starter/src/server/prisma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const prismaGlobal = global as typeof global & {
};

export const prisma: PrismaClient =
prismaGlobal.prisma ||
prismaGlobal.prisma ??
new PrismaClient({
log:
env.NODE_ENV === 'development' ? ['query', 'error', 'warn'] : ['error'],
Expand Down
22 changes: 18 additions & 4 deletions examples/next-prisma-websockets-starter/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"parser": "@typescript-eslint/parser", // Specifies the ESLint parser
"extends": [
"plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:@typescript-eslint/stylistic-type-checked",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:prettier/recommended"
Expand All @@ -13,11 +14,24 @@
},
"rules": {
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/consistent-type-definitions": "off",
"react/react-in-jsx-scope": "off",
"react/prop-types": "off",
"@typescript-eslint/no-explicit-any": "off"

// Consider removing these rule disables for more type safety in your app ✨
"@typescript-eslint/no-confusing-void-expression": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-declaration-merging": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/prefer-nullish-coalescing": "off",
"@typescript-eslint/require-await": "off",
"@typescript-eslint/restrict-plus-operands": "off"
},
// "overrides": [
// {
Expand Down
4 changes: 2 additions & 2 deletions examples/next-prisma-websockets-starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
"@types/node": "^18.16.16",
"@types/react": "^18.2.8",
"@types/ws": "^8.2.0",
"@typescript-eslint/eslint-plugin": "^5.59.2",
"@typescript-eslint/parser": "^5.59.2",
"@typescript-eslint/eslint-plugin": "6.0.0-alpha.158",
"@typescript-eslint/parser": "6.0.0-alpha.158",
"autoprefixer": "^10.4.7",
"cross-env": "^7.0.3",
"eslint": "^8.40.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/next-prisma-websockets-starter/src/server/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import ws from 'ws';
*/
export const createContext = async (
opts:
| trpcNext.CreateNextContextOptions
| NodeHTTPCreateContextFnOptions<IncomingMessage, ws>,
| NodeHTTPCreateContextFnOptions<IncomingMessage, ws>
| trpcNext.CreateNextContextOptions,
) => {
const session = await getSession(opts);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ void app.prepare().then(() => {
});
server.listen(port);

// tslint:disable-next-line:no-console
console.log(
`> Server listening at http://localhost:${port} as ${
dev ? 'development' : process.env.NODE_ENV
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ const interval = setInterval(() => {
ee.emit('isTypingUpdate');
}
}, 3e3);
process.on('SIGTERM', () => clearInterval(interval));
process.on('SIGTERM', () => {
clearInterval(interval);
});

export const postRouter = router({
add: authedProcedure
Expand Down Expand Up @@ -105,7 +107,7 @@ export const postRouter = router({
skip: 0,
});
const items = page.reverse();
let prevCursor: null | typeof cursor = null;
let prevCursor: typeof cursor | null = null;
if (items.length > take) {
const prev = items.shift();
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
Expand All @@ -119,7 +121,9 @@ export const postRouter = router({

onAdd: publicProcedure.subscription(() => {
return observable<Post>((emit) => {
const onAdd = (data: Post) => emit.next(data);
const onAdd = (data: Post) => {
emit.next(data);
};
ee.on('add', onAdd);
return () => {
ee.off('add', onAdd);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
"@testing-library/user-event": "^14.4.3",
"@types/node": "^18.16.16",
"@types/prettier": "^2.7.2",
"@typescript-eslint/eslint-plugin": "^5.59.2",
"@typescript-eslint/parser": "^5.59.2",
"@typescript-eslint/eslint-plugin": "6.0.0-alpha.158",
"@typescript-eslint/parser": "6.0.0-alpha.158",
"eslint": "^8.40.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-no-only-tests": "^3.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/TRPCClientError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '@trpc/server';
import { TRPCErrorResponse, TRPCErrorShape } from '@trpc/server/rpc';

type ErrorInferrable = AnyRouter | AnyProcedure | TRPCErrorShape<number>;
type ErrorInferrable = AnyProcedure | AnyRouter | TRPCErrorShape<number>;

type inferErrorShape<TInferrable extends ErrorInferrable> =
TInferrable extends AnyRouter
Expand Down
Loading

0 comments on commit e2ad25d

Please sign in to comment.