Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@

# Add .turbo to your .gitignore file. The turbo CLI uses these folders for persisting logs, outputs, and other functionality.
.turbo
node_modules

# uploads in server
apps/server/uploads/*
**/uploads/
.DS_Store

# Already set up here, so we can setup eslint ignores easier
**/node_modules/
**/.vercel/
**/build/
**/.next/
**/out/
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
**/node_modules/
**/.vercel/
**/build/
**/.next/
**/out/
43 changes: 43 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"printWidth": 126,
"useTabs": false,
"trailingComma": "es5",
"overrides": [
{
"files": "./apps/client/**/*",
"options": {
"trailingComma": "es5",
"plugins": ["@ianvs/prettier-plugin-sort-imports", "prettier-plugin-sort-json"],
"importOrder": [
"^(react/(.*)$)|^(react$)",
"^(next/(.*)$)|^(next$)",
"<THIRD_PARTY_MODULES>",
"",
"^@/(.*)$",
"^(@beatsync/shared)",
"^[.]"
],
"importOrderParserPlugins": ["typescript", "jsx", "decorators-legacy"]
}
},
{
"files": [ "./apps/server/**/*", "./packages/**/*" ],
"options": {
"plugins": ["@ianvs/prettier-plugin-sort-imports", "prettier-plugin-sort-json"],
"importOrder": [
"^(bun/?(.*)$)",
"^(node|fs)",
"<THIRD_PARTY_MODULES>",
"",
"^@/(.*)$",
"^(@beatsync/shared)",
"^[.]"
],
"importOrderParserPlugins": ["typescript", "decorators-legacy"]
}
}
]
}
28 changes: 14 additions & 14 deletions apps/client/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { dirname } from "path";
import { fileURLToPath } from "url";
import { FlatCompat } from "@eslint/eslintrc";
import tseslint from "typescript-eslint";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// "react/jsx-filename-extension": "off",
// "react/jsx-props-no-spreading": "off",
// "react/no-unused-prop-types": "off",
// "react/require-default-props": "off",
// "react/no-unescaped-entities": "off",

const compat = new FlatCompat({
baseDirectory: __dirname,
});

const eslintConfig = [
...compat.extends("next/core-web-vitals", "next/typescript"),
];

export default eslintConfig;
/**
* Target files are left open to eslint, if need to, set via "includes" in top-level tsconfig
*/
export default tseslint.config(
{
extends: [ "../../eslint.config.js", "next", "next/typescript", "next/core-web-vitals"]
},
);
13 changes: 2 additions & 11 deletions apps/client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"target": "ES2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",

"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
Expand All @@ -18,10 +14,5 @@
"name": "next"
}
],
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
5 changes: 3 additions & 2 deletions apps/server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"types": ["@types/eslint"],
"strict": true,
"jsx": "react-jsx",
"jsxImportSource": "hono/jsx"
"rootDir": "./src"
}
}
416 changes: 372 additions & 44 deletions bun.lock

Large diffs are not rendered by default.

164 changes: 164 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import stylistic from "@stylistic/eslint-plugin";
import { includeIgnoreFile } from "@eslint/compat";
import { fileURLToPath } from "node:url";
import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript";

/**
* Links to rulebooks:
* ESLint: https://eslint.org/docs/latest/rules/
* Typescript-ESLint: https://typescript-eslint.io/rules/
* Stylistic: https://eslint.style/rules
*/

const gitignorePath = fileURLToPath(new URL(".gitignore", import.meta.url));

/**
* Target files are left open to eslint, if need to, set via "includes" in top-level tsconfig
*/
export default tseslint.config(
includeIgnoreFile(gitignorePath),
{
settings: {
"import/resolver": [
createTypeScriptImportResolver({
alwaysTryTypes: true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`

bun: true, // resolve Bun modules https://github.com/import-js/eslint-import-resolver-typescript#bun

// We have the option to include multiple tsconfigs, but our main one holds the relevant "paths" value for all modules
project: "./tsconfig.json",
}),
],
},
},
stylistic.configs.customize({
commaDangle: "only-multiline",
indent: 2,
jsx: false,
quoteProps: "consistent-as-needed",
semi: true,
}),
eslint.configs.recommended,
tseslint.configs.stylisticTypeChecked,
tseslint.configs.recommendedTypeChecked,
{
// For the above ^
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: ["./tsconfig.json"],
tsconfigRootDir: import.meta.dirname,
},
},
// ESLint
rules: {
"import/no-anonymous-default-export": "off",
"no-constant-condition": [
"warn",
{
checkLoops: "allExceptWhileTrue",
},
],
// I would prefer to also disable this for ^_ vars
"prefer-const": ["warn", {
destructuring: "all",
ignoreReadBeforeAssign: true,
}]
},
},
{
// Typescript-ESLint
rules: {
"@typescript-eslint/no-unused-vars": [
"warn",
{
args: "all",
argsIgnorePattern: "^_",
caughtErrors: "none",
varsIgnorePattern: "(^_.+)|(^[A-Z\\-_])",
ignoreRestSiblings: true,
},
],
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unnecessary-condition": [
"warn",
{
allowConstantLoopConditions: true,
checkTypePredicates: true
},
],
"@typescript-eslint/prefer-nullish-coalescing": [
"error",
{
ignorePrimitives: {
boolean: true,
},
},
],
"@typescript-eslint/restrict-plus-operands": [
"error",
{
allowNumberAndString: true,
},
],
"@typescript-eslint/restrict-template-expressions": [
"error",
{
allowNumber: true,
},
],
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/prefer-optional-chain": "warn"
},
},
{
// Stylistic
rules: {
"@stylistic/array-bracket-spacing": "off",
"@stylistic/no-multiple-empty-lines": [
"error",
{
max: 4,
},
],
"@stylistic/brace-style": [
"warn",
"1tbs",
{
allowSingleLine: true,
},
],
"@stylistic/arrow-parens": "off",
"@stylistic/eol-last": "error",
"@stylistic/member-delimiter-style": [
"error",
{
multiline: {
delimiter: "semi",
},
},
],
"@stylistic/no-extra-semi": "error",
"@stylistic/no-multi-spaces": [
"error",
{
ignoreEOLComments: true,
},
],
"@stylistic/quotes": [
"error",
"double",
{
avoidEscape: true,
allowTemplateLiterals: "avoidEscape",
}
],
"@stylistic/no-trailing-spaces": ["warn", {
ignoreComments: true
}],
},
}
);
27 changes: 24 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,45 @@
{
"name": "beatsync",
"packageManager": "bun@1.2.2",
"type": "module",
"scripts": {
"build": "turbo run build",
"dev": "turbo run dev",
"start": "turbo run start",
"server": "turbo start --filter=server",
"client": "turbo start --filter=client"
"client": "turbo start --filter=client",
"lint": "eslint \"./\"",
"lint:fix": "eslint \"./\" --fix",
"format": "prettier . --write",
"format:check": "prettier . --check"
},
"workspaces": [
"apps/*",
"packages/*"
],
"devDependencies": {
"@types/bun": "latest"
"@eslint/compat": "^1.2.9",
"@eslint/js": "^9.26.0",
"@ianvs/prettier-plugin-sort-imports": "4.4.0",
"@stylistic/eslint-plugin": "^4.2.0",
"@types/bun": "latest",
"@types/eslint": "^9.6.1",
"@types/eslint__js": "^9.14.0",
"@typescript-eslint/eslint-plugin": "^8.19.1",
"@typescript-eslint/parser": "8.19.1",
"eslint": "^9.26.0",
"eslint-config-next": "^15.1.4",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^4.3.4",
"eslint-plugin-prettier": "^5.2.1",
"prettier": "^3.4.2",
"prettier-plugin-sort-json": "^4.1.1",
"typescript-eslint": "^8.32.0"
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"dependencies": {
"turbo": "^2.4.4"
}
}
}
26 changes: 1 addition & 25 deletions packages/shared/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,3 @@
{
"compilerOptions": {
// Enable latest features
"lib": ["ESNext", "DOM"],
"target": "ESNext",
"module": "ESNext",
"moduleDetection": "force",
"jsx": "react-jsx",
"allowJs": true,

// Bundler mode
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,

// Best practices
"strict": true,
"skipLibCheck": true,
"noFallthroughCasesInSwitch": true,

// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noPropertyAccessFromIndexSignature": false
}
"extends": "../../tsconfig.json"
}
Loading