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,26 +1,26 @@
{ {
"dependencies": { "dependencies": {
"react": "^18.2.0", "@tailwindcss/forms": "^0.5.7",
"react-dom": "^18.2.0" "@tailwindcss/typography": "^0.5.10",
}, "react": "^18.2.0",
"devDependencies": { "react-dom": "^18.2.0",
"@tsconfig/vite-react": "^3.0.0", "tailwindcss-animate": "^1.0.7"
"@types/react": "^18.2.56", },
"@types/react-dom": "^18.2.19", "devDependencies": {
"@vitejs/plugin-react": "^4.2.1", "@tsconfig/vite-react": "^3.0.0",
"eslint-plugin-react": "^7.33.2", "@types/react": "^18.2.56",
"eslint-plugin-react-hooks": "^4.6.0", "@types/react-dom": "^18.2.19",
"eslint-plugin-react-refresh": "^0.4.5", "@vitejs/plugin-react": "^4.2.1",
"vite": "^5.1.4" "vite": "^5.1.4"
}, },
"name": "@appname/client", "name": "@appname/client",
"private": true, "private": true,
"scripts": { "scripts": {
"build": "tsc && vite build", "build": "tsc && vite build",
"dev": "vite", "dev": "vite",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview" "preview": "vite preview"
}, },
"type": "module", "type": "module",
"version": "0.0.0" "version": "0.0.0"
} }

View File

@ -1,4 +1,23 @@
export default { import forms from "@tailwindcss/forms";
content: ["./src/**/*.{js,ts,jsx,tsx}"], import typography from "@tailwindcss/typography";
plugins: [require("daisyui")], 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,39 +1,57 @@
{ {
"compilerOptions": { "compilerOptions": {
// Specifying ECMAScript targets for the compiler // Specifying ECMAScript targets for the compiler
"target": "ESNext", // "composite": true, // Enable project references
"module": "ESNext", "target": "ESNext",
"lib": ["DOM", "DOM.Iterable", "ESNext"], "module": "ESNext",
// Enabling options for better interoperability and module handling "lib": [
"moduleResolution": "Bundler", "DOM",
"esModuleInterop": true, "DOM.Iterable",
"allowSyntheticDefaultImports": true, "ESNext"
"allowImportingTsExtensions": true, ],
"resolveJsonModule": true, // Enabling options for better interoperability and module handling
// Configuring behavior for JSX, specific to React "moduleResolution": "Bundler",
"jsx": "react-jsx", // Transform JSX for React 17+ JSX Transform "esModuleInterop": true,
// Strengthening type-checking and ensuring consistency "allowSyntheticDefaultImports": true,
"strict": true, // Enable all strict type-checking options "allowImportingTsExtensions": true,
"strictNullChecks": true, // Enable strict null checks "resolveJsonModule": true,
"noUnusedLocals": true, // Disallow unused local variables // Configuring behavior for JSX, specific to React
"noUnusedParameters": true, // Disallow unused function parameters "jsx": "react-jsx", // Transform JSX for React 17+ JSX Transform
"noFallthroughCasesInSwitch": true, // Prevent fallthrough cases in switch statements // Strengthening type-checking and ensuring consistency
"forceConsistentCasingInFileNames": true, // Ensure consistent file naming "strict": true, // Enable all strict type-checking options
// Improving project robustness "strictNullChecks": true, // Enable strict null checks
"isolatedModules": true, // Ensure correct transpiling of files "noUnusedLocals": true, // Disallow unused local variables
"noErrorTruncation": true, // Show full type error messages "noUnusedParameters": true, // Disallow unused function parameters
"useDefineForClassFields": true, // Align class field behavior with the standard "noFallthroughCasesInSwitch": true, // Prevent fallthrough cases in switch statements
// Configuring project build process "forceConsistentCasingInFileNames": true, // Ensure consistent file naming
"allowJs": true, // Allow JavaScript files to be imported // Improving project robustness
"skipLibCheck": true, // Skip type checking of declaration files "isolatedModules": true, // Ensure correct transpiling of files
"noEmit": true, // Vite handles the emitting of files "noErrorTruncation": true, // Show full type error messages
"paths": { "useDefineForClassFields": true, // Align class field behavior with the standard
"@root/*": ["./*"], // Configuring project build process
"@/*": ["./src/*"] "allowJs": true, // Allow JavaScript files to be imported
} // Allow absolute imports from src. Create a path alias for the root directory - @root "skipLibCheck": true, // Skip type checking of declaration files
"noEmit": true, // Vite handles the emitting of files
"paths": {
"@root/*": [
"./*"
],
"@/*": [
"./src/*"
]
} // Allow absolute imports from src. Create a path alias for the root directory - @root
}, },
// Specifying folders and files to include in compilation // Specifying folders and files to include in compilation
"include": ["src/**/*", "server/index.ts", "server/services"], "include": [
"src/**/*"
],
// Excluding certain directories from the compilation // Excluding certain directories from the compilation
"exclude": ["node_modules"] "exclude": [
} "node_modules"
],
"references": [
{
"path": "./tsconfig.node.json"
}
]
}

View File

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

View File

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

View File

@ -1,6 +1,10 @@
import eslintPluginJs from "@eslint/js"; import eslintPluginJs from "@eslint/js";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended"; 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 tseslint from "typescript-eslint";
import globals from "globals";
/** @type {import('eslint').Linter.FlatConfig[]} */ /** @type {import('eslint').Linter.FlatConfig[]} */
export default [ export default [
eslintPluginJs.configs.recommended, eslintPluginJs.configs.recommended,
@ -8,6 +12,7 @@ export default [
...tseslint.configs.stylistic, ...tseslint.configs.stylistic,
eslintPluginPrettierRecommended, 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"], ignores: ["node_modules/", "dist/", "build/", "coverage/", "public/", "**/eslint.config.js"],
languageOptions: { languageOptions: {
parserOptions: { 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": "^8.57.0",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3", "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", "postcss": "^8.4.35",
"prettier": "^3.2.5", "prettier": "^3.2.5",
"tailwindcss": "^3.4.1", "tailwindcss": "^3.4.1",

View File

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