Reorganization in projects, fixed tsconfigs and eslint configurations

This commit is contained in:
Igor Barcik 2024-03-04 21:10:58 +01:00
parent 8b9c7bc6a3
commit 001eec66af
10 changed files with 144 additions and 96 deletions

BIN
bun.lockb

Binary file not shown.

View File

@ -1,30 +0,0 @@
import pluginReact from "eslint-plugin-react";
import pluginReactHooks from "eslint-plugin-react-hooks";
import pluginReactRefresh from "eslint-plugin-react-refresh";
import pluginReactRecommended from "eslint-plugin-react/configs/recommended";
import globals from "globals";
import baseConfig from "../eslint.config";
/** @type {import('eslint').Linter.FlatConfig[]} */
export default [
...baseConfig,
pluginReactRecommended,
pluginReactHooks,
{
files: ["**/*.{js,jsx,mjs,cjs,ts,tsx}"],
plugins: {
react: pluginReact,
"react-refresh": pluginReactRefresh,
},
languageOptions: {
parserOptions: {
ecmaFeatures: "latest",
sourceType: "module",
project: ["./tsconfig.json"],
tsconfigRootDir: "./",
},
globals: {
...globals.browser,
},
},
},
];

View File

@ -1,16 +1,16 @@
{
"dependencies": {
"@tailwindcss/forms": "^0.5.7",
"@tailwindcss/typography": "^0.5.10",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"tailwindcss-animate": "^1.0.7"
},
"devDependencies": {
"@tsconfig/vite-react": "^3.0.0",
"@types/react": "^18.2.56",
"@types/react-dom": "^18.2.19",
"@vitejs/plugin-react": "^4.2.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"vite": "^5.1.4"
},
"name": "@appname/client",

View File

@ -1,4 +1,23 @@
export default {
content: ["./src/**/*.{js,ts,jsx,tsx}"],
plugins: [require("daisyui")],
import forms from "@tailwindcss/forms";
import typography from "@tailwindcss/typography";
import daisyUI from "daisyui";
import type { Config } from "tailwindcss";
import twanimate from "tailwindcss-animate";
const config: Config = {
darkMode: "class",
content: [
"./pages/**/*.{ts,tsx}",
"./components/**/*.{ts,tsx}",
"./app/**/*.{ts,tsx}",
"./src/**/*.{ts,tsx}",
"./index.html",
],
prefix: "",
plugins: [twanimate, forms, typography, daisyUI],
daisyui: {
themes: ["light", "dark"],
},
};
export default config;

View File

@ -1,9 +1,14 @@
{
"compilerOptions": {
// Specifying ECMAScript targets for the compiler
// "composite": true, // Enable project references
"target": "ESNext",
"module": "ESNext",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"lib": [
"DOM",
"DOM.Iterable",
"ESNext"
],
// Enabling options for better interoperability and module handling
"moduleResolution": "Bundler",
"esModuleInterop": true,
@ -28,12 +33,25 @@
"skipLibCheck": true, // Skip type checking of declaration files
"noEmit": true, // Vite handles the emitting of files
"paths": {
"@root/*": ["./*"],
"@/*": ["./src/*"]
"@root/*": [
"./*"
],
"@/*": [
"./src/*"
]
} // Allow absolute imports from src. Create a path alias for the root directory - @root
},
// Specifying folders and files to include in compilation
"include": ["src/**/*", "server/index.ts", "server/services"],
"include": [
"src/**/*"
],
// Excluding certain directories from the compilation
"exclude": ["node_modules"]
"exclude": [
"node_modules"
],
"references": [
{
"path": "./tsconfig.node.json"
}
]
}

View File

@ -9,6 +9,7 @@
},
"include": [
"vite.config.ts",
"tailwind.config.ts",
],
"ts-node": {
"esm": true

View File

@ -1,10 +1,10 @@
import react from "@vitejs/plugin-react";
import { defineConfig, loadEnv } from "vite";
import path from "path";
import { defineConfig, loadEnv } from "vite";
// https://vitejs.dev/config/
export default ({ mode }) => {
export default defineConfig(({ mode }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
return defineConfig({
resolve: {
@ -16,4 +16,4 @@ export default ({ mode }) => {
plugins: [react()],
server: { proxy: { "/api": "http://localhost:3000" } },
});
};
});

View File

@ -1,6 +1,10 @@
import eslintPluginJs from "@eslint/js";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
import pluginReactRefresh from "eslint-plugin-react-refresh";
import pluginReact from "eslint-plugin-react";
import tseslint from "typescript-eslint";
import globals from "globals";
/** @type {import('eslint').Linter.FlatConfig[]} */
export default [
eslintPluginJs.configs.recommended,
@ -8,6 +12,7 @@ export default [
...tseslint.configs.stylistic,
eslintPluginPrettierRecommended,
{
files: ["./server/**/*.{js,jsx,mjs,cjs,ts,tsx}", "./shared/**/*.{js,jsx,mjs,cjs,ts,tsx}"],
ignores: ["node_modules/", "dist/", "build/", "coverage/", "public/", "**/eslint.config.js"],
languageOptions: {
parserOptions: {
@ -16,4 +21,35 @@ export default [
},
},
},
{
files: ["./client/**/*.{js,jsx,mjs,cjs,ts,tsx}"],
plugins: {
react: pluginReact,
"react-refresh": pluginReactRefresh,
},
ignores: [
"client/**/node_modules/",
"client/**/dist/**",
"client/**/build/**",
"client/**/coverage/**",
"client/**/public/**",
"client/*.{js,ts}",
],
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
project: ["./client/tsconfig.json"],
tsconfigRootDir: "./client",
},
globals: {
...globals.browser,
},
},
rules: {
"reactPlugin/jsx-uses-react": "error",
"reactPlugin/jsx-uses-vars": "error",
},
},
];

View File

@ -11,6 +11,9 @@
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.34.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"postcss": "^8.4.35",
"prettier": "^3.2.5",
"tailwindcss": "^3.4.1",

View File

@ -38,11 +38,12 @@
"@client/*": [
"./client/*"
]
}
},
"rootDir": "."
},
"include": [
"shared/**/*",
"server/**/*",
"server/**/*"
],
"exclude": [
"node_modules",