chore: improve tsconfigs

This commit is contained in:
Yordis Prieto
2024-05-16 03:02:22 -04:00
parent b1473fe296
commit 0bf41b3716
34 changed files with 2665 additions and 3359 deletions

View File

@@ -4,10 +4,11 @@
"main": "index.js",
"license": "MIT",
"dependencies": {
"eslint-config-next": "latest",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-react": "7.28.0",
"eslint-config-turbo": "latest"
"eslint-config-next": "^14.2.3",
"@typescript-eslint/parser": "^7.9.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-react": "^7.34.1",
"eslint-config-turbo": "^1.13.3"
},
"publishConfig": {
"access": "public"

View File

@@ -1,8 +0,0 @@
import type { JestConfigWithTsJest } from 'ts-jest'
const jestConfig: JestConfigWithTsJest = {
preset: 'ts-jest',
testEnvironment: 'node'
}
export default jestConfig

View File

@@ -14,24 +14,17 @@
"build": "tsup --dts",
"test": "pnpm test:unit",
"test:watch": "pnpm test:unit:watch",
"test:unit": "jest",
"test:unit:watch": "jest --watch",
"test:unit": "vitest",
"test:unit:watch": "vitest --watch",
"dev": "tsup --watch --dts",
"lint": "eslint \"src/**/*.ts*\"",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf src/proto"
},
"devDependencies": {
"@bufbuild/buf": "^1.14.0",
"@types/jest": "^29.5.1",
"@zitadel/tsconfig": "workspace:*",
"eslint": "^7.32.0",
"eslint-config-zitadel": "workspace:*",
"jest": "^29.5.0",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"ts-proto": "^1.139.0",
"tsup": "^5.10.1",
"typescript": "^4.9.3"
"ts-proto": "^1.139.0"
},
"publishConfig": {
"access": "public"

View File

@@ -1,3 +1,5 @@
import { describe, expect, test, vitest } from "vitest";
import { CallOptions, ClientMiddlewareCall, Metadata, MethodDescriptor } from "nice-grpc-web";
import { authMiddleware } from "./middleware";
@@ -24,9 +26,9 @@ describe('authMiddleware', () => {
];
scenarios.forEach(({ name, initialMetadata, expectedMetadata, token }) => {
it(name, async () => {
test(name, async () => {
const mockNext = jest.fn().mockImplementation(async function*() { });
const mockNext = vitest.fn().mockImplementation(async function*() { });
const mockRequest = {};
const mockMethodDescriptor: MethodDescriptor = {

View File

@@ -1,8 +1,5 @@
{
"extends": "@zitadel/tsconfig/node14.json",
"include": ["."],
"compilerOptions": {
"baseUrl": "."
},
"extends": "@zitadel/tsconfig/tsup.json",
"include": ["./src/**/*"],
"exclude": ["dist", "build", "node_modules"]
}

View File

@@ -1,8 +0,0 @@
import type { JestConfigWithTsJest } from 'ts-jest'
const jestConfig: JestConfigWithTsJest = {
preset: 'ts-jest',
testEnvironment: 'node'
}
export default jestConfig

View File

@@ -13,23 +13,16 @@
"build": "tsup",
"test": "pnpm test:unit",
"test:watch": "pnpm test:unit:watch",
"test:unit": "jest --passWithNoTests",
"test:unit:watch": "jest --watch",
"test:unit": "vitest",
"test:unit:watch": "vitest --watch",
"dev": "tsup --watch",
"lint": "eslint \"src/**/*.ts*\"",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
},
"devDependencies": {
"@types/jest": "^29.5.1",
"@types/react": "^17.0.13",
"@zitadel/tsconfig": "workspace:*",
"eslint": "^7.32.0",
"eslint-config-zitadel": "workspace:*",
"jest": "^29.5.0",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"tsup": "^5.10.1",
"typescript": "^4.9.3",
"tailwindcss": "3.2.4",
"postcss": "8.4.21",
"zitadel-tailwind-config": "workspace:*",
@@ -38,13 +31,13 @@
"peerDependencies": {
"@zitadel/react": "workspace:*",
"@zitadel/server": "workspace:*",
"next": "^13",
"next": "^14.2.3",
"react": "18.2.0"
},
"publishConfig": {
"access": "public"
},
"dependencies": {
"next": "^13.4.10"
"next": "^14.2.3"
}
}

View File

@@ -1,9 +0,0 @@
import type { JestConfigWithTsJest } from 'ts-jest'
const jestConfig: JestConfigWithTsJest = {
preset: 'ts-jest',
testEnvironment: 'jsdom',
setupFilesAfterEnv: [ '@testing-library/jest-dom/extend-expect' ]
}
export default jestConfig

View File

@@ -7,41 +7,36 @@
],
"license": "MIT",
"exports": {
".": "./dist",
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
},
"./styles.css": "./dist/index.css",
"./assets/*": "./dist/assets/*"
},
"scripts": {
"build": "tsup src/index.tsx --format esm,cjs --dts --external react",
"build": "tsup",
"test": "pnpm test:unit",
"test:watch": "pnpm test:unit:watch",
"test:unit": "jest",
"test:unit:watch": "jest --watch",
"test:unit": "vitest",
"test:unit:watch": "vitest --watch",
"dev": "tsup --watch",
"lint": "eslint \"src/**/*.ts*\"",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
"copy-files": "cp -R ./src/public/ ./dist/"
},
"devDependencies": {
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^14.0.0",
"@types/jest": "^29.5.1",
"@types/react": "^18.2.17",
"@types/react-dom": "^18.2.7",
"@types/testing-library__jest-dom": "^5.14.6",
"@zitadel/tsconfig": "workspace:*",
"autoprefixer": "10.4.13",
"eslint": "^7.32.0",
"eslint-config-zitadel": "workspace:*",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"jsdom": "^24.0.0",
"postcss": "8.4.21",
"sass": "^1.62.0",
"sass": "^1.77.1",
"tailwindcss": "3.2.4",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"tsup": "^7.1.0",
"typescript": "^5.1.6",
"zitadel-tailwind-config": "workspace:*"
},
"publishConfig": {

View File

@@ -1,19 +1,23 @@
import { render, screen } from "@testing-library/react";
import { afterEach, describe, expect, test } from "vitest";
import { cleanup, render, screen } from "@testing-library/react";
import { SignInWithGitlab } from "./SignInWithGitlab";
afterEach(cleanup);
describe("<SignInWithGitlab />", () => {
it("renders without crashing", () => {
test("renders without crashing", () => {
const { container } = render(<SignInWithGitlab />);
expect(container.firstChild).toBeDefined();
});
it("displays the default text", () => {
test("displays the default text", () => {
render(<SignInWithGitlab />);
const signInText = screen.getByText(/Sign in with Gitlab/i);
expect(signInText).toBeInTheDocument();
});
it("displays the given text", () => {
test("displays the given text", () => {
render(<SignInWithGitlab name={"Gitlab"} />);
const signInText = screen.getByText(/Gitlab/i);
expect(signInText).toBeInTheDocument();

View File

@@ -1,19 +1,23 @@
import { render, screen } from "@testing-library/react";
import { afterEach, describe, expect, test } from "vitest";
import { cleanup, render, screen } from "@testing-library/react";
import { SignInWithGoogle } from "./SignInWithGoogle";
afterEach(cleanup);
describe("<SignInWithGoogle />", () => {
it("renders without crashing", () => {
test("renders without crashing", () => {
const { container } = render(<SignInWithGoogle />);
expect(container.firstChild).toBeDefined();
});
it("displays the default text", () => {
test("displays the default text", () => {
render(<SignInWithGoogle />);
const signInText = screen.getByText(/Sign in with Google/i);
expect(signInText).toBeInTheDocument();
});
it("displays the given text", () => {
test("displays the given text", () => {
render(<SignInWithGoogle name={"Google"} />);
const signInText = screen.getByText(/Google/i);
expect(signInText).toBeInTheDocument();

View File

@@ -0,0 +1,9 @@
import { defineConfig, Options } from "tsup";
export default defineConfig((options: Options) => ({
entry: ["src/index.tsx"],
format: ["esm", "cjs"],
dts: true,
external: ["react"],
...options,
}));

View File

@@ -0,0 +1,11 @@
import { defineConfig } from "vitest/config";
import react from "@vitejs/plugin-react";
export default defineConfig({
plugins: [react()],
test: {
include: ['src/**/*.test.ts', 'src/**/*.test.tsx'],
environment: "jsdom",
setupFiles: ["@testing-library/jest-dom/vitest"],
},
});

View File

@@ -1,8 +0,0 @@
import type { JestConfigWithTsJest } from 'ts-jest'
const jestConfig: JestConfigWithTsJest = {
preset: 'ts-jest',
testEnvironment: 'node'
}
export default jestConfig

View File

@@ -15,24 +15,17 @@
"build": "tsup --dts",
"test": "pnpm test:unit",
"test:watch": "pnpm test:unit:watch",
"test:unit": "jest",
"test:unit:watch": "jest --watch",
"test:unit": "vitest",
"test:unit:watch": "vitest --watch",
"dev": "tsup --dts --watch",
"lint": "eslint \"src/**/*.ts*\"",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf src/proto"
},
"devDependencies": {
"@bufbuild/buf": "^1.14.0",
"@types/jest": "^29.5.1",
"@zitadel/tsconfig": "workspace:*",
"eslint": "^7.32.0",
"eslint-config-zitadel": "workspace:*",
"jest": "^29.5.0",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"ts-proto": "^1.139.0",
"tsup": "^5.10.1",
"typescript": "^4.9.3"
"ts-proto": "^1.139.0"
},
"publishConfig": {
"access": "public"
@@ -44,4 +37,4 @@
"nice-grpc-common": "^2.0.2",
"protobufjs": "^7.2.3"
}
}
}

View File

@@ -1,3 +1,5 @@
import { describe, expect, test, vitest } from "vitest";
import { CallOptions, ClientMiddlewareCall, Metadata, MethodDescriptor } from "nice-grpc";
import { authMiddleware } from "./middleware";
@@ -24,9 +26,9 @@ describe('authMiddleware', () => {
];
scenarios.forEach(({ name, initialMetadata, expectedMetadata, token }) => {
it(name, async () => {
test(name, async () => {
const mockNext = jest.fn().mockImplementation(async function*() { });
const mockNext = vitest.fn().mockImplementation(async function*() { });
const mockRequest = {};
const mockMethodDescriptor: MethodDescriptor = {

View File

@@ -1,9 +1,5 @@
{
"extends": "@zitadel/tsconfig/node14.json",
"include": ["src/**/*.ts"],
"compilerOptions": {
"baseUrl": ".",
"rootDir": "src"
},
"extends": "@zitadel/tsconfig/tsup.json",
"include": ["./src/**/*"],
"exclude": ["dist", "build", "node_modules"]
}

View File

@@ -9,7 +9,7 @@
"forceConsistentCasingInFileNames": true,
"inlineSources": false,
"isolatedModules": true,
"moduleResolution": "node",
"moduleResolution": "node16",
"noUnusedLocals": false,
"noUnusedParameters": false,
"preserveWatchOutput": true,

View File

@@ -12,11 +12,14 @@
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"preserveSymlinks": true,
"declaration": false,
"declarationMap": false,
"baseUrl": ".",
"plugins": [
{

View File

@@ -1,10 +1,10 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Node 14",
"display": "Node 20",
"extends": "./base.json",
"compilerOptions": {
"lib": ["ES2020"],
"module": "commonjs",
"target": "ES2020"
"lib": ["es2023"],
"module": "node16",
"target": "es2022"
}
}

View File

@@ -5,7 +5,7 @@
"compilerOptions": {
"jsx": "react-jsx",
"lib": ["dom", "ES2015"],
"module": "ESNext",
"target": "es6"
"module": "preserve",
"moduleResolution": "Bundler"
}
}

View File

@@ -0,0 +1,9 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "tsup",
"extends": "./node20.json",
"compilerOptions": {
"module": "preserve",
"moduleResolution": "Bundler"
}
}