Skip to content

Commit

Permalink
setup turbo; make lint and build work
Browse files Browse the repository at this point in the history
  • Loading branch information
sitek94 committed Nov 26, 2023
1 parent c8b2fd1 commit 2a226b3
Show file tree
Hide file tree
Showing 39 changed files with 3,514 additions and 7,706 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ node_modules
dist
build
public/build
.next

## Monorepo
.turbo

# Environment variables
.env
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
auto-install-peers = true
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ pnpm develop:remix
- https://github.com/storybookjs/storybook
- https://storybook.js.org/tutorials/design-systems-for-developers/react/en/architecture/
- https://turbo.build/repo/docs/getting-started/existing-monorepo
- https://github.com/vercel/style-guide/tree/canary
16 changes: 1 addition & 15 deletions apps/docs/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: [
'@repo/eslint-config/base',
'@repo/eslint-config/react',
'plugin:storybook/recommended',
],
overrides: [
{
files: ['*.stories.tsx'],
rules: {
// For some reason it shows errors for imports from @repo/ui, even though they are resolved correctly.
// Both develop and build work fine, so I'm disabling it for now.
'import/no-unresolved': 'off',
},
},
],
extends: ['@repo/eslint-config/storybook'],
}
2 changes: 1 addition & 1 deletion apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"build": "storybook build -o build",
"start": "serve build",
"clean": "rm -rf .turbo && rm -rf node_modules",
"lint": "eslint ./stories/*.stories.tsx --max-warnings 0"
"lint": "eslint ."
},
"dependencies": {
"@repo/ui": "workspace:*",
Expand Down
15 changes: 1 addition & 14 deletions apps/docs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"allowJs": true,
"declaration": false,
"declarationMap": false,
"incremental": true,
"jsx": "preserve",
"lib": ["dom", "dom.iterable", "esnext"],
"module": "esnext",
"noEmit": true,
"resolveJsonModule": true,
"target": "es5",
"skipLibCheck": true
},
"extends": "@repo/tsconfig/react-app.json",
"include": ["."],
"exclude": ["dist", "build", "node_modules"]
}
8 changes: 8 additions & 0 deletions apps/docs/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": ["//"],
"pipeline": {
"build": {
"outputs": ["build/**"]
}
}
}
20 changes: 1 addition & 19 deletions apps/nestjs/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: ['@repo/eslint-config/base'],
env: {
node: true,
},
settings: {
'import/resolver': {
typescript: {
project: 'apps/nestjs/tsconfig.json',
},
},
},
overrides: [
{
files: ['jest.config.js', 'jest-e2e.config.js'],
rules: {
'@typescript-eslint/no-var-requires': 'off',
},
},
],
extends: ['@repo/eslint-config/nest'],
}
8 changes: 8 additions & 0 deletions apps/nestjs/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": ["//"],
"pipeline": {
"build": {
"outputs": ["build/**"]
}
}
}
9 changes: 1 addition & 8 deletions apps/remix/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: ['@repo/eslint-config/base', '@repo/eslint-config/react'],
settings: {
'import/resolver': {
typescript: {
project: 'apps/remix/tsconfig.json',
},
},
},
extends: ['@repo/eslint-config/remix'],
}
18 changes: 12 additions & 6 deletions apps/remix/app/api/cats.api.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import type { Cat } from '@repo/types'
import axios from 'axios'

const client = axios.create({
baseURL: process.env.API_URL || 'http://localhost:2222',
})
const BASE_URL = process.env.API_URL || 'http://localhost:2222'

export const catsApi = {
getAll: () => client.get<Cat[]>('/cats'),
interface CatsApi {
getAll: () => Promise<Cat[]>
}

export const catsApi: CatsApi = {
getAll: async () => {
const response = await fetch(`${BASE_URL}/cats`)
const data: unknown = await response.json()

return data as Cat[]
},
}
4 changes: 2 additions & 2 deletions apps/remix/app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ function handleBotRequest(
let shellRendered = false
const { pipe, abort } = renderToPipeableStream(
<RemixServer
abortDelay={ABORT_DELAY}
context={remixContext}
url={request.url}
abortDelay={ABORT_DELAY}
/>,
{
onAllReady() {
Expand Down Expand Up @@ -95,9 +95,9 @@ function handleBrowserRequest(
let shellRendered = false
const { pipe, abort } = renderToPipeableStream(
<RemixServer
abortDelay={ABORT_DELAY}
context={remixContext}
url={request.url}
abortDelay={ABORT_DELAY}
/>,
{
onShellReady() {
Expand Down
4 changes: 2 additions & 2 deletions apps/remix/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ export const links: LinksFunction = () => [

export default function App() {
return (
<html lang="en" className="dark">
<html className="dark" lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta content="width=device-width, initial-scale=1" name="viewport" />
<Meta />
<Links />
</head>
Expand Down
9 changes: 4 additions & 5 deletions apps/remix/app/routes/_index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { json, type MetaFunction } from '@remix-run/node'
import { useLoaderData } from '@remix-run/react'
import { Button } from '@repo/ui'
import { Card } from '@repo/ui/components/card'
import { Button, Card } from '@repo/ui'

import { catsApi } from '~/api/cats.api'

Expand All @@ -14,9 +13,9 @@ export const meta: MetaFunction = () => {

export const loader = async () => {
try {
const { data: cats } = await catsApi.getAll()
const cats = await catsApi.getAll()
return json({ cats })
} catch (error) {
} catch (error: any) {
console.log(`Error fetching cats: ${error}`)
return json({ cats: [] })
}
Expand All @@ -32,7 +31,7 @@ export default function Index() {
<h2>Cats fetched from NestJS</h2>
<pre>{JSON.stringify(cats, null, 2)}</pre>

<Card title="Card component" href="#components">
<Card href="#components" title="Card component">
Imported from internal @repo/ui package
</Card>

Expand Down
15 changes: 9 additions & 6 deletions apps/remix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,28 @@
"scripts": {
"build": "remix build",
"develop": "remix dev --manual",
"start": "remix-serve ./build/index.js"
"start": "remix-serve ./build/index.js",
"lint": "eslint . ",
"lint:fix": "pnpm lint --fix",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@remix-run/css-bundle": "^2.3.1",
"@remix-run/node": "^2.3.1",
"@remix-run/react": "^2.3.1",
"@remix-run/serve": "^2.3.1",
"@repo/ui": "workspace:^",
"axios": "^1.6.2",
"@repo/ui": "workspace:*",
"isbot": "^3.6.8",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@repo/eslint-config": "workspace:*",
"@repo/types": "workspace:*",
"@remix-run/dev": "^2.3.1",
"@remix-run/eslint-config": "^2.3.1",
"@repo/tailwind-config": "workspace:^",
"@repo/eslint-config": "workspace:*",
"@repo/tailwind-config": "workspace:*",
"@repo/tsconfig": "workspace:^",
"@repo/types": "workspace:*",
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/container-queries": "^0.1.1",
"@tailwindcss/forms": "^0.5.7",
Expand Down
2 changes: 1 addition & 1 deletion apps/remix/remix.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export default {
// Bundle UI lib, so that it's not necessary to include build step within the lib itself.
// serverDependenciesToBundle: ['@repo/ui'],
// Restart server when UI lib changes
watchPaths: ['../../libs/ui/**/*'],
// watchPaths: ['../../libs/ui/**/*'],
}
19 changes: 5 additions & 14 deletions apps/remix/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
{
"extends": "../../tsconfig.json",
"extends": "@repo/tsconfig/remix.json",
"exclude": ["node_modules", "build"],
"include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"],
"compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"],
"isolatedModules": true,
"jsx": "react-jsx",
"moduleResolution": "Bundler",
"resolveJsonModule": true,
"skipLibCheck": true,
"baseUrl": "./",
"baseUrl": ".",
"paths": {
"~/*": ["./app/*"]
},

// Remix takes care of building everything in `remix build`.
"noEmit": true
},
"exclude": ["node_modules", "build", "dist"]
}
}
}
8 changes: 8 additions & 0 deletions apps/remix/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": ["//"],
"pipeline": {
"build": {
"outputs": ["build/**", "public/build/**"]
}
}
}
34 changes: 34 additions & 0 deletions libs/eslint-config/_base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
ignorePatterns: [
'node_modules/',
'dist/',
'build/',
'public/build/',
'.eslintrc.js',
'**/*.css',
],
rules: {
'import/order': [
'error',
{
alphabetize: { caseInsensitive: true, order: 'asc' },
groups: ['builtin', 'external', 'internal', 'parent', 'sibling'],
'newlines-between': 'always',
},
],
'import/no-default-export': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',

// ⚠️
// Following rules are disabled during setup, but should probably be enabled later:

// Errors as unknown, etc.
'@typescript-eslint/no-explicit-any': 'off',

// Some weird type issues when calling `catsApi` in Remix index route
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
},
}
47 changes: 0 additions & 47 deletions libs/eslint-config/base.js

This file was deleted.

Loading

0 comments on commit 2a226b3

Please sign in to comment.