feat: monorepo
This commit is contained in:
84
tooling/eslint/base.js
Normal file
84
tooling/eslint/base.js
Normal file
@@ -0,0 +1,84 @@
|
||||
/// <reference types="./types.d.ts" />
|
||||
|
||||
import * as path from "node:path";
|
||||
import { includeIgnoreFile } from "@eslint/compat";
|
||||
import eslint from "@eslint/js";
|
||||
import importPlugin from "eslint-plugin-import";
|
||||
import turboPlugin from "eslint-plugin-turbo";
|
||||
import tseslint from "typescript-eslint";
|
||||
|
||||
/**
|
||||
* All packages that leverage t3-env should use this rule
|
||||
*/
|
||||
export const restrictEnvAccess = tseslint.config(
|
||||
{ ignores: ["**/env.ts"] },
|
||||
{
|
||||
files: ["**/*.js", "**/*.ts", "**/*.tsx"],
|
||||
rules: {
|
||||
"no-restricted-properties": [
|
||||
"error",
|
||||
{
|
||||
object: "process",
|
||||
property: "env",
|
||||
message:
|
||||
"Use `import { env } from '~/env'` instead to ensure validated types.",
|
||||
},
|
||||
],
|
||||
"no-restricted-imports": [
|
||||
"error",
|
||||
{
|
||||
name: "process",
|
||||
importNames: ["env"],
|
||||
message:
|
||||
"Use `import { env } from '~/env'` instead to ensure validated types.",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
export default tseslint.config(
|
||||
// Ignore files not tracked by VCS and any config files
|
||||
includeIgnoreFile(path.join(import.meta.dirname, "../../.gitignore")),
|
||||
{ ignores: ["**/*.config.*"] },
|
||||
{
|
||||
files: ["**/*.js", "**/*.ts", "**/*.tsx"],
|
||||
plugins: {
|
||||
import: importPlugin,
|
||||
turbo: turboPlugin,
|
||||
},
|
||||
extends: [
|
||||
eslint.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
...tseslint.configs.recommendedTypeChecked,
|
||||
...tseslint.configs.stylisticTypeChecked,
|
||||
],
|
||||
rules: {
|
||||
...turboPlugin.configs.recommended.rules,
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"error",
|
||||
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
|
||||
],
|
||||
"@typescript-eslint/consistent-type-imports": [
|
||||
"warn",
|
||||
{ prefer: "type-imports", fixStyle: "separate-type-imports" },
|
||||
],
|
||||
"@typescript-eslint/no-misused-promises": [
|
||||
2,
|
||||
{ checksVoidReturn: { attributes: false } },
|
||||
],
|
||||
"@typescript-eslint/no-unnecessary-condition": [
|
||||
"error",
|
||||
{
|
||||
allowConstantLoopConditions: true,
|
||||
},
|
||||
],
|
||||
"@typescript-eslint/no-non-null-assertion": "error",
|
||||
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
|
||||
},
|
||||
},
|
||||
{
|
||||
linterOptions: { reportUnusedDisableDirectives: true },
|
||||
languageOptions: { parserOptions: { projectService: true } },
|
||||
},
|
||||
);
|
||||
17
tooling/eslint/next.js
Normal file
17
tooling/eslint/next.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import nextPlugin from "@next/eslint-plugin-next";
|
||||
|
||||
/** @type {Awaited<import('typescript-eslint').Config>} */
|
||||
export default [
|
||||
{
|
||||
files: ["**/*.ts", "**/*.tsx"],
|
||||
plugins: {
|
||||
"@next/next": nextPlugin,
|
||||
},
|
||||
rules: {
|
||||
...nextPlugin.configs.recommended.rules,
|
||||
...nextPlugin.configs["core-web-vitals"].rules,
|
||||
// TypeError: context.getAncestors is not a function
|
||||
"@next/next/no-duplicate-head": "off",
|
||||
},
|
||||
},
|
||||
];
|
||||
35
tooling/eslint/package.json
Normal file
35
tooling/eslint/package.json
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "@kan/eslint-config",
|
||||
"private": true,
|
||||
"version": "0.3.0",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"./base": "./base.js",
|
||||
"./nextjs": "./nextjs.js",
|
||||
"./react": "./react.js"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "git clean -xdf .cache .turbo node_modules",
|
||||
"format": "prettier --check . --ignore-path ../../.gitignore",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@eslint/compat": "^1.2.3",
|
||||
"@next/eslint-plugin-next": "^14.2.15",
|
||||
"eslint-plugin-import": "^2.31.0",
|
||||
"eslint-plugin-jsx-a11y": "^6.10.2",
|
||||
"eslint-plugin-react": "^7.37.2",
|
||||
"eslint-plugin-react-hooks": "^5.0.0",
|
||||
"eslint-plugin-turbo": "^2.3.1",
|
||||
"typescript-eslint": "^8.15.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kan/prettier-config": "workspace:*",
|
||||
"@kan/tsconfig": "workspace:*",
|
||||
"@types/eslint__js": "8.42.3",
|
||||
"eslint": "catalog:",
|
||||
"prettier": "catalog:",
|
||||
"typescript": "catalog:"
|
||||
},
|
||||
"prettier": "@kan/prettier-config"
|
||||
}
|
||||
22
tooling/eslint/react.js
vendored
Normal file
22
tooling/eslint/react.js
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import reactPlugin from "eslint-plugin-react";
|
||||
import hooksPlugin from "eslint-plugin-react-hooks";
|
||||
|
||||
/** @type {Awaited<import('typescript-eslint').Config>} */
|
||||
export default [
|
||||
{
|
||||
files: ["**/*.ts", "**/*.tsx"],
|
||||
plugins: {
|
||||
react: reactPlugin,
|
||||
"react-hooks": hooksPlugin,
|
||||
},
|
||||
rules: {
|
||||
...reactPlugin.configs["jsx-runtime"].rules,
|
||||
...hooksPlugin.configs.recommended.rules,
|
||||
},
|
||||
languageOptions: {
|
||||
globals: {
|
||||
React: "writable",
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
5
tooling/eslint/tsconfig.json
Normal file
5
tooling/eslint/tsconfig.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"extends": "@kan/tsconfig/base.json",
|
||||
"include": ["."],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
48
tooling/eslint/types.d.ts
vendored
Normal file
48
tooling/eslint/types.d.ts
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Since the ecosystem hasn't fully migrated to ESLint's new FlatConfig system yet,
|
||||
* we "need" to type some of the plugins manually :(
|
||||
*/
|
||||
|
||||
declare module "eslint-plugin-import" {
|
||||
import type { Linter, Rule } from "eslint";
|
||||
|
||||
export const configs: {
|
||||
recommended: { rules: Linter.RulesRecord };
|
||||
};
|
||||
export const rules: Record<string, Rule.RuleModule>;
|
||||
}
|
||||
|
||||
declare module "eslint-plugin-react" {
|
||||
import type { Linter, Rule } from "eslint";
|
||||
|
||||
export const configs: {
|
||||
recommended: { rules: Linter.RulesRecord };
|
||||
all: { rules: Linter.RulesRecord };
|
||||
"jsx-runtime": { rules: Linter.RulesRecord };
|
||||
};
|
||||
export const rules: Record<string, Rule.RuleModule>;
|
||||
}
|
||||
|
||||
declare module "eslint-plugin-react-hooks" {
|
||||
import type { Linter, Rule } from "eslint";
|
||||
|
||||
export const configs: {
|
||||
recommended: {
|
||||
rules: {
|
||||
"rules-of-hooks": Linter.RuleEntry;
|
||||
"exhaustive-deps": Linter.RuleEntry;
|
||||
};
|
||||
};
|
||||
};
|
||||
export const rules: Record<string, Rule.RuleModule>;
|
||||
}
|
||||
|
||||
declare module "@next/eslint-plugin-next" {
|
||||
import type { Linter, Rule } from "eslint";
|
||||
|
||||
export const configs: {
|
||||
recommended: { rules: Linter.RulesRecord };
|
||||
"core-web-vitals": { rules: Linter.RulesRecord };
|
||||
};
|
||||
export const rules: Record<string, Rule.RuleModule>;
|
||||
}
|
||||
48
tooling/prettier/index.js
Normal file
48
tooling/prettier/index.js
Normal file
@@ -0,0 +1,48 @@
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
/** @typedef {import("prettier").Config} PrettierConfig */
|
||||
/** @typedef {import("prettier-plugin-tailwindcss").PluginOptions} TailwindConfig */
|
||||
/** @typedef {import("@ianvs/prettier-plugin-sort-imports").PluginConfig} SortImportsConfig */
|
||||
|
||||
/** @type { PrettierConfig | SortImportsConfig | TailwindConfig } */
|
||||
const config = {
|
||||
plugins: [
|
||||
"@ianvs/prettier-plugin-sort-imports",
|
||||
"prettier-plugin-tailwindcss",
|
||||
],
|
||||
tailwindConfig: fileURLToPath(
|
||||
new URL("../../tooling/tailwind/web.ts", import.meta.url),
|
||||
),
|
||||
tailwindFunctions: ["cn", "cva"],
|
||||
importOrder: [
|
||||
"<TYPES>",
|
||||
"^(next/(.*)$)|^(next$)",
|
||||
"<THIRD_PARTY_MODULES>",
|
||||
"",
|
||||
"<TYPES>^@kan",
|
||||
"^@kan/(.*)$",
|
||||
"",
|
||||
"<TYPES>^[.|..|~]",
|
||||
"^~/",
|
||||
"^[../]",
|
||||
"^[./]",
|
||||
],
|
||||
importOrderParserPlugins: ["typescript", "jsx", "decorators-legacy"],
|
||||
importOrderTypeScriptVersion: "4.4.0",
|
||||
overrides: [
|
||||
{
|
||||
files: "*.json.hbs",
|
||||
options: {
|
||||
parser: "json",
|
||||
},
|
||||
},
|
||||
{
|
||||
files: "*.js.hbs",
|
||||
options: {
|
||||
parser: "babel",
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export default config;
|
||||
24
tooling/prettier/package.json
Normal file
24
tooling/prettier/package.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "@kan/prettier-config",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./index.js"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "git clean -xdf .cache .turbo node_modules",
|
||||
"format": "prettier --check . --ignore-path ../../.gitignore",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ianvs/prettier-plugin-sort-imports": "^4.4.0",
|
||||
"prettier": "catalog:",
|
||||
"prettier-plugin-tailwindcss": "^0.6.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kan/tsconfig": "workspace:*",
|
||||
"typescript": "catalog:"
|
||||
},
|
||||
"prettier": "@kan/prettier-config"
|
||||
}
|
||||
5
tooling/prettier/tsconfig.json
Normal file
5
tooling/prettier/tsconfig.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"extends": "@kan/tsconfig/base.json",
|
||||
"include": ["."],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
3
tooling/tailwind/eslint.config.js
Normal file
3
tooling/tailwind/eslint.config.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import baseConfig from "@kan/eslint-config/base";
|
||||
|
||||
export default [...baseConfig];
|
||||
31
tooling/tailwind/package.json
Normal file
31
tooling/tailwind/package.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "@kan/tailwind-config",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"./web": "./web.ts"
|
||||
},
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "git clean -xdf .cache .turbo node_modules",
|
||||
"format": "prettier --check . --ignore-path ../../.gitignore",
|
||||
"lint": "eslint",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tailwindcss/forms": "^0.5.6",
|
||||
"postcss": "^8.4.49",
|
||||
"tailwind-scrollbar": "^3.0.5",
|
||||
"tailwindcss": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kan/eslint-config": "workspace:*",
|
||||
"@kan/prettier-config": "workspace:*",
|
||||
"@kan/tsconfig": "workspace:*",
|
||||
"eslint": "catalog:",
|
||||
"prettier": "catalog:",
|
||||
"typescript": "catalog:"
|
||||
},
|
||||
"prettier": "@kan/prettier-config"
|
||||
}
|
||||
5
tooling/tailwind/tsconfig.json
Normal file
5
tooling/tailwind/tsconfig.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"extends": "@kan/tsconfig/base.json",
|
||||
"include": ["."],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
62
tooling/tailwind/web.ts
Normal file
62
tooling/tailwind/web.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import { type Config } from "tailwindcss";
|
||||
import forms from "@tailwindcss/forms";
|
||||
import scrollbar from "tailwind-scrollbar";
|
||||
|
||||
export default {
|
||||
content: ["./src/**/*.tsx"],
|
||||
darkMode: "class",
|
||||
theme: {
|
||||
extend: {
|
||||
fontFamily: {
|
||||
sans: ["var(--font-plus-jakarta-sans), Plus Jakarta Sans"],
|
||||
},
|
||||
fontSize: {
|
||||
sm: "0.8rem",
|
||||
},
|
||||
boxShadow: {
|
||||
"3xl-dark": "0px 16px 70px rgba(0, 0, 0, 0.5)",
|
||||
"3xl-light":
|
||||
"rgba(0, 0, 0, 0.12) 0px 4px 30px, rgba(0, 0, 0, 0.04) 0px 3px 17px, rgba(0, 0, 0, 0.04) 0px 2px 8px, rgba(0, 0, 0, 0.04) 0px 1px 1px",
|
||||
},
|
||||
animation: {
|
||||
"border-spin": "border-spin 4s linear infinite",
|
||||
},
|
||||
keyframes: {
|
||||
"border-spin": {
|
||||
from: { transform: "rotate(0deg)" },
|
||||
to: { transform: "rotate(360deg)" },
|
||||
},
|
||||
},
|
||||
colors: {
|
||||
"dark-50": "#161616",
|
||||
"dark-100": "#1c1c1c",
|
||||
"dark-200": "#232323",
|
||||
"dark-300": "#282828",
|
||||
"dark-400": "#2e2e2e",
|
||||
"dark-500": "#343434",
|
||||
"dark-600": "#3e3e3e",
|
||||
"dark-700": "#505050",
|
||||
"dark-800": "#707070",
|
||||
"dark-900": "#7e7e7e",
|
||||
"dark-950": "#bbb",
|
||||
"dark-1000": "#ededed",
|
||||
"light-50": "hsl(0deg 0% 98.8%)",
|
||||
"light-100": "hsl(0deg 0% 97.3%)",
|
||||
"light-200": "hsl(0deg 0% 95.3%)",
|
||||
"light-300": "hsl(0deg 0% 92.9%)",
|
||||
"light-400": "hsl(0deg 0% 91%)",
|
||||
"light-500": "hsl(0deg 0% 88.6%)",
|
||||
"light-600": "hsl(0deg 0% 85.9%)",
|
||||
"light-700": "hsl(0deg 0% 78%)",
|
||||
"light-800": "hsl(0deg 0% 56.1%)",
|
||||
"light-900": "hsl(0deg 0% 52.2%)",
|
||||
"light-950": "hsl(0deg 0% 43.5%)",
|
||||
"light-1000": "hsl(0deg 0% 9%)",
|
||||
},
|
||||
screens: {
|
||||
xxl: "1600px",
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [forms, scrollbar],
|
||||
} satisfies Config;
|
||||
27
tooling/typescript/base.json
Normal file
27
tooling/typescript/base.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"target": "ES2022",
|
||||
"lib": ["ES2022"],
|
||||
"allowJs": true,
|
||||
"resolveJsonModule": true,
|
||||
"moduleDetection": "force",
|
||||
"isolatedModules": true,
|
||||
|
||||
"incremental": true,
|
||||
"disableSourceOfProjectReferenceRedirect": true,
|
||||
"tsBuildInfoFile": "${configDir}/.cache/tsbuildinfo.json",
|
||||
|
||||
"strict": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"checkJs": true,
|
||||
|
||||
"module": "Preserve",
|
||||
"moduleResolution": "Bundler",
|
||||
"noEmit": true,
|
||||
"noImplicitAny": true
|
||||
},
|
||||
"exclude": ["node_modules", "build", "dist", ".next", ".expo"]
|
||||
}
|
||||
11
tooling/typescript/internal-package.json
Normal file
11
tooling/typescript/internal-package.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"extends": "./base.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"noEmit": false,
|
||||
"outDir": "${configDir}/dist"
|
||||
}
|
||||
}
|
||||
8
tooling/typescript/package.json
Normal file
8
tooling/typescript/package.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "@kan/tsconfig",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"files": [
|
||||
"*.json"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user