diff --git a/devenv.yaml b/devenv.yaml index 116a2ad..fefdd49 100644 --- a/devenv.yaml +++ b/devenv.yaml @@ -2,7 +2,6 @@ inputs: nixpkgs: url: github:cachix/devenv-nixpkgs/rolling - # If you're using non-OSS software, you can set allowUnfree to true. # allowUnfree: true diff --git a/eslint.config.js b/eslint.config.js index 092408a..79a552e 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,28 +1,28 @@ -import js from '@eslint/js' -import globals from 'globals' -import reactHooks from 'eslint-plugin-react-hooks' -import reactRefresh from 'eslint-plugin-react-refresh' -import tseslint from 'typescript-eslint' +import js from "@eslint/js"; +import globals from "globals"; +import reactHooks from "eslint-plugin-react-hooks"; +import reactRefresh from "eslint-plugin-react-refresh"; +import tseslint from "typescript-eslint"; export default tseslint.config( - { ignores: ['dist'] }, + { ignores: ["dist"] }, { extends: [js.configs.recommended, ...tseslint.configs.recommended], - files: ['**/*.{ts,tsx}'], + files: ["**/*.{ts,tsx}"], languageOptions: { ecmaVersion: 2020, globals: globals.browser, }, plugins: { - 'react-hooks': reactHooks, - 'react-refresh': reactRefresh, + "react-hooks": reactHooks, + "react-refresh": reactRefresh, }, rules: { ...reactHooks.configs.recommended.rules, - 'react-refresh/only-export-components': [ - 'warn', + "react-refresh/only-export-components": [ + "warn", { allowConstantExport: true }, ], }, }, -) +); diff --git a/package.json b/package.json index ac6007b..cf0b426 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,11 @@ "lint": "eslint .", "preview": "vite preview" }, + "prettier": { + "plugins": [ + "prettier-plugin-tailwindcss" + ] + }, "dependencies": { "@tailwindcss/vite": "^4.0.6", "pixelarticons": "^1.8.1", @@ -28,6 +33,8 @@ "eslint-plugin-react-hooks": "^5.0.0", "eslint-plugin-react-refresh": "^0.4.18", "globals": "^15.14.0", + "prettier": "^3.5.3", + "prettier-plugin-tailwindcss": "^0.6.11", "typescript": "~5.7.2", "typescript-eslint": "^8.22.0", "vite": "^6.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6b71be0..940d866 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -57,6 +57,12 @@ importers: globals: specifier: ^15.14.0 version: 15.15.0 + prettier: + specifier: ^3.5.3 + version: 3.5.3 + prettier-plugin-tailwindcss: + specifier: ^0.6.11 + version: 0.6.11(prettier@3.5.3) typescript: specifier: ~5.7.2 version: 5.7.3 @@ -1273,6 +1279,66 @@ packages: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} + prettier-plugin-tailwindcss@0.6.11: + resolution: {integrity: sha512-YxaYSIvZPAqhrrEpRtonnrXdghZg1irNg4qrjboCXrpybLWVs55cW2N3juhspVJiO0JBvYJT8SYsJpc8OQSnsA==} + engines: {node: '>=14.21.3'} + peerDependencies: + '@ianvs/prettier-plugin-sort-imports': '*' + '@prettier/plugin-pug': '*' + '@shopify/prettier-plugin-liquid': '*' + '@trivago/prettier-plugin-sort-imports': '*' + '@zackad/prettier-plugin-twig': '*' + prettier: ^3.0 + prettier-plugin-astro: '*' + prettier-plugin-css-order: '*' + prettier-plugin-import-sort: '*' + prettier-plugin-jsdoc: '*' + prettier-plugin-marko: '*' + prettier-plugin-multiline-arrays: '*' + prettier-plugin-organize-attributes: '*' + prettier-plugin-organize-imports: '*' + prettier-plugin-sort-imports: '*' + prettier-plugin-style-order: '*' + prettier-plugin-svelte: '*' + peerDependenciesMeta: + '@ianvs/prettier-plugin-sort-imports': + optional: true + '@prettier/plugin-pug': + optional: true + '@shopify/prettier-plugin-liquid': + optional: true + '@trivago/prettier-plugin-sort-imports': + optional: true + '@zackad/prettier-plugin-twig': + optional: true + prettier-plugin-astro: + optional: true + prettier-plugin-css-order: + optional: true + prettier-plugin-import-sort: + optional: true + prettier-plugin-jsdoc: + optional: true + prettier-plugin-marko: + optional: true + prettier-plugin-multiline-arrays: + optional: true + prettier-plugin-organize-attributes: + optional: true + prettier-plugin-organize-imports: + optional: true + prettier-plugin-sort-imports: + optional: true + prettier-plugin-style-order: + optional: true + prettier-plugin-svelte: + optional: true + + prettier@3.5.3: + resolution: {integrity: sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==} + engines: {node: '>=14'} + hasBin: true + punycode@2.3.1: resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} engines: {node: '>=6'} @@ -2556,6 +2622,12 @@ snapshots: prelude-ls@1.2.1: {} + prettier-plugin-tailwindcss@0.6.11(prettier@3.5.3): + dependencies: + prettier: 3.5.3 + + prettier@3.5.3: {} + punycode@2.3.1: {} queue-microtask@1.2.3: {} diff --git a/src/App.tsx b/src/App.tsx index 8ffa41d..381949c 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,5 +1,5 @@ import QuoteList from "./QuoteList"; export default function App() { - return + return ; } diff --git a/src/QuoteAdd.tsx b/src/QuoteAdd.tsx index 592e86e..f5b1f7e 100644 --- a/src/QuoteAdd.tsx +++ b/src/QuoteAdd.tsx @@ -1,63 +1,92 @@ import { useEffect, useState } from "react"; -import { Collections, IsoDateString, TypedPocketBase } from "./pocketbase-types"; -import PocketBase from 'pocketbase' +import { + Collections, + IsoDateString, + TypedPocketBase, +} from "./pocketbase-types"; +import PocketBase from "pocketbase"; import { useNavigate } from "react-router"; -import { useForm, SubmitHandler } from "react-hook-form" +import { useForm, SubmitHandler } from "react-hook-form"; interface QuoteAddProps { quote: string; context?: string; - collection: Collections + collection: Collections; author: string; date: IsoDateString; - } export default function QuoteAdd() { - - const pb = new PocketBase("https://api.m3.fyi") as TypedPocketBase - const [date, setDate] = useState("") + const pb = new PocketBase("https://api.m3.fyi") as TypedPocketBase; + const [date, setDate] = useState(""); useEffect(() => { const d = new Date(); - d.setTime(d.getTime() + 60 * 60 * 1000) - const formattedDate = d.toISOString().slice(0, 16) - setDate(formattedDate) + d.setTime(d.getTime() + 60 * 60 * 1000); + const formattedDate = d.toISOString().slice(0, 16); + setDate(formattedDate); }, []); - const { register, handleSubmit, watch, formState: { errors }, } = useForm() + const { + register, + handleSubmit, + watch, + formState: { errors }, + } = useForm(); const onSubmit: SubmitHandler = async (data) => { - console.log(data) - console.log(date) - let formDate = new Date(date) - formDate.setTime(formDate.getTime() + 60 * 60 * 1000) + console.log(data); + console.log(date); + let formDate = new Date(date); + formDate.setTime(formDate.getTime() + 60 * 60 * 1000); - console.log(date, formDate) + console.log(date, formDate); let quote = { - "quote": data.quote, - "context": data.context || "", - "author": data.author, - "date": formDate.toISOString().substring(0, 19) + "Z" - } - console.log(quote) - await pb.collection(data.collection).create(quote) + quote: data.quote, + context: data.context || "", + author: data.author, + date: formDate.toISOString().substring(0, 19) + "Z", + }; + console.log(quote); + await pb.collection(data.collection).create(quote); let navigate = useNavigate(); - navigate("/") - } - + navigate("/"); + }; return ( -
-