Skip to content

Commit

Permalink
chore: setup turborepo (#3)
Browse files Browse the repository at this point in the history
Co-authored-by: Turbobot <turbobot@vercel.com>
  • Loading branch information
AsPulse and turbobot-temp authored Dec 11, 2023
1 parent 09e15ea commit 47ab0f7
Show file tree
Hide file tree
Showing 18 changed files with 3,561 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// This configuration only applies to the package manager root.
/** @type {import("eslint").Linter.Config} */
module.exports = {
ignorePatterns: ["apps/**", "packages/**"],
extends: ["@repo/eslint-config/library.js"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: true,
},
};
25 changes: 25 additions & 0 deletions .github/actions/setup-turbo/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Setup turbo
description: "Setup pnpm, Node.js, turborepo and its own remote-caching server."
inputs:
node-version:
description: "version of Node.js using setup."
default: "20"
required: false

runs:
using: composite
steps:
- name: Launch Turbo Remote Cache Server
uses: dtinth/setup-github-actions-caching-for-turbo@v1.1.0
- name: Setup pnpm
uses: pnpm/action-setup@v2
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node-version }}
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
- name: Install packages
shell: sh
run: pnpm install --frozen-lockfile

26 changes: 26 additions & 0 deletions .github/workflows/format-and-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: format-and-lint

on:
push:
branches: [main]
pull_request_target:

permissions: read-all

jobs:
prettier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-turbo
- name: Run Prettier
run: pnpm run format:check

eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-turbo
- name: Run ESLint
run: pnpm run lint

38 changes: 38 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# Dependencies
node_modules
.pnp
.pnp.js

# Local env files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# Testing
coverage

# Turbo
.turbo

# Vercel
.vercel

# Build Outputs
.next/
out/
build
dist


# Debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Misc
.DS_Store
*.pem
Empty file added .npmrc
Empty file.
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"eslint.workingDirectories": [
{
"mode": "auto"
}
]
}
3 changes: 3 additions & 0 deletions configs/eslint-config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `@turbo/eslint-config`

Collection of internal eslint configurations.
34 changes: 34 additions & 0 deletions configs/eslint-config/library.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const { resolve } = require("node:path");

const project = resolve(process.cwd(), "tsconfig.json");

/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: ["eslint:recommended", "prettier", "eslint-config-turbo"],
plugins: ["only-warn"],
globals: {
React: true,
JSX: true,
},
env: {
node: true,
},
settings: {
"import/resolver": {
typescript: {
project,
},
},
},
ignorePatterns: [
// Ignore dotfiles
".*.js",
"node_modules/",
"dist/",
],
overrides: [
{
files: ["*.js?(x)", "*.ts?(x)"],
},
],
};
19 changes: 19 additions & 0 deletions configs/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@repo/eslint-config",
"version": "0.0.0",
"private": true,
"files": [
"library.js",
"next.js",
"react-internal.js"
],
"devDependencies": {
"@vercel/style-guide": "^5.1.0",
"eslint-config-turbo": "^1.10.12",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-only-warn": "^1.1.0",
"@typescript-eslint/parser": "^6.11.0",
"@typescript-eslint/eslint-plugin": "^6.11.0",
"typescript": "^5.2.2"
}
}
43 changes: 43 additions & 0 deletions configs/eslint-config/react-internal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const { resolve } = require("node:path");

const project = resolve(process.cwd(), "tsconfig.json");

/*
* This is a custom ESLint configuration for use with
* internal (bundled by their consumer) libraries
* that utilize React.
*
* This config extends the Vercel Engineering Style Guide.
* For more information, see https://github.com/vercel/style-guide
*
*/

/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: ["eslint:recommended", "prettier", "eslint-config-turbo"],
plugins: ["only-warn"],
globals: {
React: true,
JSX: true,
},
env: {
browser: true,
},
settings: {
"import/resolver": {
typescript: {
project,
},
},
},
ignorePatterns: [
// Ignore dotfiles
".*.js",
"node_modules/",
"dist/",
],
overrides: [
// Force ESLint to detect .tsx files
{ files: ["*.js?(x)", "*.ts?(x)"] },
],
};
20 changes: 20 additions & 0 deletions configs/typescript-config/base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Default",
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"incremental": false,
"isolatedModules": true,
"lib": ["es2022", "DOM", "DOM.Iterable"],
"module": "NodeNext",
"moduleDetection": "force",
"moduleResolution": "NodeNext",
"noUncheckedIndexedAccess": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"target": "ES2022"
}
}
9 changes: 9 additions & 0 deletions configs/typescript-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "@repo/typescript-config",
"version": "0.0.0",
"private": true,
"license": "MIT",
"publishConfig": {
"access": "public"
}
}
8 changes: 8 additions & 0 deletions configs/typescript-config/react-library.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "React Library",
"extends": "./base.json",
"compilerOptions": {
"jsx": "react-jsx"
}
}
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "sugarform",
"private": true,
"scripts": {
"build": "turbo build",
"lint": "turbo lint -- --max-warnings=0",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"format:check": "prettier --check \"**/*.{ts,tsx,md}\""
},
"devDependencies": {
"@repo/eslint-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"prettier": "^3.1.0",
"turbo": "latest"
},
"packageManager": "pnpm@8.9.0",
"engines": {
"node": ">=18"
}
}
Loading

0 comments on commit 47ab0f7

Please sign in to comment.