Skip to content

Commit

Permalink
Polish PR: Minor Refactoring & Formatting Improvements (#812)
Browse files Browse the repository at this point in the history
* Polish Commit: Minor updates to improve upon the repo

- Organize variables and scripts across packages alphabetically
- Replace broken link in `.github/ISSUE_TEMPLATE/feature_request.yml`
- Minor formatting improvements

* Minor Refactoring and Improvements

- Add `prettier` to the `eslint` package; it currently doesn't have it installed

- Remove unnecessary `React` import from `apps/expo/src/app/_layout.tsx`
- Standardize function format across `expo` app
- Import `useState` instead of the whole `React` object

- Organize recommended extensions so they appear in the Extensions Tab in alphabetical order
  • Loading branch information
peterkibuchi authored Dec 28, 2023
1 parent 4afe8fa commit 0ae51ce
Show file tree
Hide file tree
Showing 23 changed files with 57 additions and 66 deletions.
3 changes: 1 addition & 2 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This template is heavily inspired by the Next.js's template:
# See here: https://github.com/vercel/next.js/blob/canary/.github/ISSUE_TEMPLATE/3.feature_request.yml
# See here: https://github.com/vercel/next.js/tree/canary/.github/ISSUE_TEMPLATE

name: 🛠 Feature Request
description: Create a feature request for the core packages
Expand All @@ -26,4 +26,3 @@ body:
attributes:
label: Additional information
description: Add any other information related to the feature here. If your feature request is related to any issues or discussions, link them here.

4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ concurrency:
# @link https://turborepo.org/docs/core-concepts/remote-caching#remote-caching-on-vercel-builds
env:
FORCE_COLOR: 3
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}

jobs:
lint:
Expand Down Expand Up @@ -54,4 +54,4 @@ jobs:
uses: ./tooling/github/setup

- name: Typecheck
run: turbo typecheck
run: pnpm typecheck
6 changes: 3 additions & 3 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"recommendations": [
"bradlc.vscode-tailwindcss",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"expo.vscode-expo-tools",
"yoavbls.pretty-ts-errors"
"esbenp.prettier-vscode",
"yoavbls.pretty-ts-errors",
"bradlc.vscode-tailwindcss"
]
}
8 changes: 3 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit" },
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"eslint.rules.customizations": [{ "rule": "*", "severity": "warn" }],
Expand All @@ -12,9 +10,9 @@
],
"tailwindCSS.experimental.configFile": "./tooling/tailwind/index.ts",
"typescript.enablePromptUseWorkspaceTsdk": true,
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.preferences.autoImportFileExcludePatterns": [
"next/router.d.ts",
"next/dist/client/router.d.ts"
]
],
"typescript.tsdk": "node_modules/typescript/lib"
}
8 changes: 4 additions & 4 deletions apps/expo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
"dev": "expo start --ios",
"dev:android": "expo start --android",
"dev:ios": "expo start --ios",
"lint": "eslint .",
"format": "prettier --check . --ignore-path ../../.gitignore",
"typecheck": "tsc --noEmit",
"android": "expo run:android",
"ios": "expo run:ios"
"ios": "expo run:ios",
"format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "eslint .",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@expo/metro-config": "^0.10.7",
Expand Down
13 changes: 5 additions & 8 deletions apps/expo/src/app/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import { Stack } from "expo-router";
import { StatusBar } from "expo-status-bar";

Expand All @@ -8,13 +7,13 @@ import "../styles.css";

// This is the main layout of the app
// It wraps your pages with the providers they need
const RootLayout = () => {
export default function RootLayout() {
return (
<TRPCProvider>
{/*
The Stack component displays the current page.
It also allows you to configure your screens
*/}
The Stack component displays the current page.
It also allows you to configure your screens
*/}
<Stack
screenOptions={{
headerStyle: {
Expand All @@ -25,6 +24,4 @@ const RootLayout = () => {
<StatusBar />
</TRPCProvider>
);
};

export default RootLayout;
}
12 changes: 5 additions & 7 deletions apps/expo/src/app/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import { useState } from "react";
import { Button, Pressable, Text, TextInput, View } from "react-native";
import { SafeAreaView } from "react-native-safe-area-context";
import { Link, Stack } from "expo-router";
Expand Down Expand Up @@ -39,8 +39,8 @@ function PostCard(props: {
function CreatePost() {
const utils = api.useUtils();

const [title, setTitle] = React.useState("");
const [content, setContent] = React.useState("");
const [title, setTitle] = useState("");
const [content, setContent] = useState("");

const { mutate, error } = api.post.create.useMutation({
async onSuccess() {
Expand Down Expand Up @@ -96,7 +96,7 @@ function CreatePost() {
);
}

const Index = () => {
export default function Index() {
const utils = api.useUtils();

const postQuery = api.post.all.useQuery();
Expand Down Expand Up @@ -142,6 +142,4 @@ const Index = () => {
</View>
</SafeAreaView>
);
};

export default Index;
}
8 changes: 3 additions & 5 deletions apps/expo/src/utils/api.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import { useState } from "react";
import Constants from "expo-constants";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { httpBatchLink, loggerLink } from "@trpc/client";
Expand Down Expand Up @@ -26,7 +26,6 @@ const getBaseUrl = () => {
* **NOTE**: This is only for development. In production, you'll want to set the
* baseUrl to your production API URL.
*/

const debuggerHost = Constants.expoConfig?.hostUri;
const localhost = debuggerHost?.split(":")[0];

Expand All @@ -43,10 +42,9 @@ const getBaseUrl = () => {
* A wrapper for your app that provides the TRPC context.
* Use only in _app.tsx
*/

export function TRPCProvider(props: { children: React.ReactNode }) {
const [queryClient] = React.useState(() => new QueryClient());
const [trpcClient] = React.useState(() =>
const [queryClient] = useState(() => new QueryClient());
const [trpcClient] = useState(() =>
api.createClient({
transformer: superjson,
links: [
Expand Down
2 changes: 2 additions & 0 deletions apps/nextjs/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import "@acme/auth/env";
/** @type {import("next").NextConfig} */
const config = {
reactStrictMode: true,

/** Enables hot reloading for local packages without a build step */
transpilePackages: ["@acme/api", "@acme/auth", "@acme/db"],

/** We already do linting and typechecking as separate tasks in CI */
eslint: { ignoreDuringBuilds: true },
typescript: { ignoreBuildErrors: true },
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"build": "pnpm with-env next build",
"clean": "git clean -xdf .next .turbo node_modules",
"dev": "pnpm with-env next dev",
"lint": "dotenv -v SKIP_ENV_VALIDATION=1 next lint",
"format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "dotenv -v SKIP_ENV_VALIDATION=1 next lint",
"start": "pnpm with-env next start",
"typecheck": "tsc --noEmit",
"with-env": "dotenv -e ../../.env --"
Expand Down
17 changes: 9 additions & 8 deletions apps/nextjs/src/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ export const env = createEnv({
PORT: z.coerce.number().default(3000),
},
/**
* Specify your server-side environment variables schema here. This way you can ensure the app isn't
* built with invalid env vars.
* Specify your server-side environment variables schema here.
* This way you can ensure the app isn't built with invalid env vars.
*/
server: {
DB_USERNAME: z.string(),
DB_PASSWORD: z.string(),
DB_HOST: z.string(),
DB_NAME: z.string(),
DB_PASSWORD: z.string(),
DB_USERNAME: z.string(),
},
/**
* Specify your client-side environment variables schema here.
Expand All @@ -34,12 +34,13 @@ export const env = createEnv({
* Destructure all variables from `process.env` to make sure they aren't tree-shaken away.
*/
runtimeEnv: {
VERCEL_URL: process.env.VERCEL_URL,
PORT: process.env.PORT,
DB_USERNAME: process.env.DB_USERNAME,
DB_PASSWORD: process.env.DB_PASSWORD,
DB_HOST: process.env.DB_HOST,
DB_NAME: process.env.DB_NAME,
DB_PASSWORD: process.env.DB_PASSWORD,
DB_USERNAME: process.env.DB_USERNAME,
PORT: process.env.PORT,
VERCEL_URL: process.env.VERCEL_URL,

// NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR,
},
skipValidation:
Expand Down
6 changes: 1 addition & 5 deletions apps/nextjs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
"paths": {
"~/*": ["./src/*"]
},
"plugins": [
{
"name": "next"
}
],
"plugins": [{ "name": "next" }],
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json"
},
"include": [".", ".next/types/**/*.ts"],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"build": "turbo build",
"clean": "git clean -xdf node_modules",
"clean:workspaces": "turbo clean",
"postinstall": "pnpm lint:ws",
"db:push": "pnpm -F db push",
"db:studio": "pnpm -F db studio",
"dev": "turbo dev --parallel",
Expand All @@ -18,6 +17,7 @@
"lint": "turbo lint --continue -- --cache --cache-location node_modules/.cache/.eslintcache",
"lint:fix": "turbo lint --continue -- --fix --cache --cache-location node_modules/.cache/.eslintcache",
"lint:ws": "pnpm dlx sherif@latest",
"postinstall": "pnpm lint:ws",
"typecheck": "turbo typecheck"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"license": "MIT",
"scripts": {
"clean": "rm -rf .turbo node_modules",
"lint": "eslint .",
"format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "eslint .",
"typecheck": "tsc --noEmit"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"license": "MIT",
"scripts": {
"clean": "rm -rf .turbo node_modules",
"lint": "eslint .",
"format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "eslint .",
"typecheck": "tsc --noEmit"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"license": "MIT",
"scripts": {
"clean": "rm -rf .turbo node_modules",
"lint": "eslint .",
"format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "eslint .",
"push": "drizzle-kit push:mysql",
"studio": "drizzle-kit studio",
"typecheck": "tsc --noEmit"
Expand Down
4 changes: 2 additions & 2 deletions packages/db/src/schema/_table.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { mysqlTableCreator } from "drizzle-orm/mysql-core";

/**
* This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same
* database instance for multiple projects.
* This is an example of how to use the multi-project schema feature of Drizzle ORM.
* Use the same database instance for multiple projects.
*
* @see https://orm.drizzle.team/docs/goodies#multi-project-schema
*/
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions tooling/eslint/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ const config = {
node: true,
},
parser: "@typescript-eslint/parser",
parserOptions: {
project: true,
},
parserOptions: { project: true },
plugins: ["@typescript-eslint", "import"],
rules: {
"turbo/no-undeclared-env-vars": "off",
Expand All @@ -33,9 +31,9 @@ const config = {
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
},
ignorePatterns: [
"**/.eslintrc.cjs",
"**/*.config.js",
"**/*.config.cjs",
"**/.eslintrc.cjs",
".next",
"dist",
"pnpm-lock.yaml",
Expand Down
5 changes: 3 additions & 2 deletions tooling/eslint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
],
"scripts": {
"clean": "rm -rf .turbo node_modules",
"lint": "eslint .",
"format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "eslint .",
"typecheck": "tsc --noEmit"
},
"dependencies": {
Expand All @@ -26,10 +26,11 @@
"eslint-plugin-react-hooks": "^4.6.0"
},
"devDependencies": {
"@types/eslint": "^8.44.7",
"@acme/prettier-config": "workspace:^0.1.0",
"@acme/tsconfig": "workspace:^0.1.0",
"@types/eslint": "^8.44.7",
"eslint": "^8.56.0",
"prettier": "^3.1.1",
"typescript": "^5.3.3"
},
"eslintConfig": {
Expand Down
4 changes: 2 additions & 2 deletions tooling/prettier/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { fileURLToPath } from "url";

/** @typedef {import("prettier").Config} PrettierConfig */
/** @typedef {import("prettier").Config} PrettierConfig */
/** @typedef {import("prettier-plugin-tailwindcss").PluginOptions} TailwindConfig */
/** @typedef {import("@ianvs/prettier-plugin-sort-imports").PluginConfig} SortImportsConfig */
/** @typedef {import("@ianvs/prettier-plugin-sort-imports").PluginConfig} SortImportsConfig */

/** @type { PrettierConfig | SortImportsConfig | TailwindConfig } */
const config = {
Expand Down
2 changes: 1 addition & 1 deletion tooling/tailwind/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"license": "MIT",
"scripts": {
"clean": "rm -rf .turbo node_modules",
"lint": "eslint .",
"format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "eslint .",
"typecheck": "tsc --noEmit"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion turbo/generators/templates/package.json.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"license": "MIT",
"scripts": {
"clean": "rm -rf .turbo node_modules",
"lint": "eslint .",
"format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "eslint .",
"typecheck": "tsc --noEmit"
},
"devDependencies": {
Expand Down

0 comments on commit 0ae51ce

Please sign in to comment.