From a84e20ec1675652c2c198d8d8647dea10d5497f2 Mon Sep 17 00:00:00 2001 From: Liam Keegan Date: Fri, 6 Dec 2024 20:45:02 +0100 Subject: [PATCH] add pre-commit config including biome and biome.json --- .eslintrc.cjs | 30 ++++----- .pre-commit-config.yaml | 43 +++++++++++++ biome.json | 41 ++++++++++++ postcss.config.cjs | 8 +-- src/lib/components/UploadPdf.svelte | 32 +++++----- src/routes/+layout.svelte | 2 +- src/routes/+page.svelte | 96 +++++++++++++++-------------- svelte.config.js | 10 +-- tailwind.config.cjs | 38 ++++++------ vite.config.ts | 6 +- 10 files changed, 197 insertions(+), 109 deletions(-) create mode 100644 .pre-commit-config.yaml create mode 100644 biome.json diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 0b75758..25f6796 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -2,30 +2,30 @@ module.exports = { root: true, extends: [ - 'eslint:recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:svelte/recommended', - 'prettier' + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:svelte/recommended", + "prettier", ], - parser: '@typescript-eslint/parser', - plugins: ['@typescript-eslint'], + parser: "@typescript-eslint/parser", + plugins: ["@typescript-eslint"], parserOptions: { - sourceType: 'module', + sourceType: "module", ecmaVersion: 2020, - extraFileExtensions: ['.svelte'] + extraFileExtensions: [".svelte"], }, env: { browser: true, es2017: true, - node: true + node: true, }, overrides: [ { - files: ['*.svelte'], - parser: 'svelte-eslint-parser', + files: ["*.svelte"], + parser: "svelte-eslint-parser", parserOptions: { - parser: '@typescript-eslint/parser' - } - } - ] + parser: "@typescript-eslint/parser", + }, + }, + ], }; diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..55db99b --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,43 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - id: mixed-line-ending + - id: check-toml + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.7.4 + hooks: + - id: ruff + types_or: [python, pyi, jupyter] + args: [--fix] + - id: ruff-format + types_or: [python, pyi, jupyter] + + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.13.0 + hooks: + - id: mypy + additional_dependencies: ["sqlmodel"] + args: + [ + --ignore-missing-imports, + --warn-redundant-casts, + --no-namespace-packages, + ] + + - repo: https://github.com/rhysd/actionlint + rev: "v1.7.4" + hooks: + - id: actionlint + + - repo: https://github.com/biomejs/pre-commit + rev: "v0.5.0" + hooks: + - id: biome-check + additional_dependencies: ["@biomejs/biome@1.9.4"] + +exclude: "mondey_backend/openapi.json|frontend/src/lib/client" diff --git a/biome.json b/biome.json new file mode 100644 index 0000000..808e5a8 --- /dev/null +++ b/biome.json @@ -0,0 +1,41 @@ +{ + "overrides": [ + { + "include": ["*.svelte", "*.astro", "*.vue"], + "linter": { + "rules": { + "style": { + "useConst": "off", + "useImportType": "off" + } + } + } + } + ], + "linter": { + "rules": { + "suspicious": { + "all": true, + "noConsole": "off", + "noConsoleLog": "off", + "noExplicitAny": "off" + }, + "style": { + "recommended": true + }, + "complexity": { + "recommended": true, + "noForEach": "off" + }, + "correctness": { + "recommended": true + }, + "performance": { + "recommended": true + }, + "security": { + "all": true + } + } + } +} diff --git a/postcss.config.cjs b/postcss.config.cjs index fe10e55..e68d4de 100644 --- a/postcss.config.cjs +++ b/postcss.config.cjs @@ -1,13 +1,13 @@ -const tailwindcss = require('tailwindcss'); -const autoprefixer = require('autoprefixer'); +const tailwindcss = require("tailwindcss"); +const autoprefixer = require("autoprefixer"); const config = { plugins: [ //Some plugins, like tailwindcss/nesting, need to run before Tailwind, tailwindcss(), //But others, like autoprefixer, need to run after, - autoprefixer - ] + autoprefixer, + ], }; module.exports = config; diff --git a/src/lib/components/UploadPdf.svelte b/src/lib/components/UploadPdf.svelte index cd474d7..64b0f5f 100644 --- a/src/lib/components/UploadPdf.svelte +++ b/src/lib/components/UploadPdf.svelte @@ -1,26 +1,26 @@
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 17abf18..5e76407 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -1,5 +1,5 @@ diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index e1bca5d..93d5968 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,59 +1,63 @@
diff --git a/svelte.config.js b/svelte.config.js index f775263..14a0155 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,16 +1,16 @@ -import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; -import adapter from '@sveltejs/adapter-static'; +import adapter from "@sveltejs/adapter-static"; +import { vitePreprocess } from "@sveltejs/vite-plugin-svelte"; /** @type {import('@sveltejs/kit').Config} */ const config = { kit: { adapter: adapter(), paths: { - base: process.argv.includes('dev') ? '' : process.env.BASE_PATH - } + base: process.argv.includes("dev") ? "" : process.env.BASE_PATH, + }, }, - preprocess: [vitePreprocess({})] + preprocess: [vitePreprocess({})], }; export default config; diff --git a/tailwind.config.cjs b/tailwind.config.cjs index d0e83a8..74d40ec 100644 --- a/tailwind.config.cjs +++ b/tailwind.config.cjs @@ -1,30 +1,30 @@ /** @type {import('tailwindcss').Config}*/ const config = { content: [ - './src/**/*.{html,js,svelte,ts}', - './node_modules/flowbite-svelte/**/*.{html,js,svelte,ts}', - './node_modules/flowbite-svelte-icons/**/*.{html,js,svelte,ts}' + "./src/**/*.{html,js,svelte,ts}", + "./node_modules/flowbite-svelte/**/*.{html,js,svelte,ts}", + "./node_modules/flowbite-svelte-icons/**/*.{html,js,svelte,ts}", ], - plugins: [require('flowbite/plugin')], - darkMode: 'class', + plugins: [require("flowbite/plugin")], + darkMode: "class", theme: { extend: { colors: { primary: { - 50: '#f8fafc', - 100: '#f1f5f9', - 200: '#e2e8f0', - 300: '#cbd5e1', - 400: '#94a3b8', - 500: '#64748b', - 600: '#475569', - 700: '#334155', - 800: '#1e293b', - 900: '#0f172a' - } - } - } - } + 50: "#f8fafc", + 100: "#f1f5f9", + 200: "#e2e8f0", + 300: "#cbd5e1", + 400: "#94a3b8", + 500: "#64748b", + 600: "#475569", + 700: "#334155", + 800: "#1e293b", + 900: "#0f172a", + }, + }, + }, + }, }; module.exports = config; diff --git a/vite.config.ts b/vite.config.ts index 91ee8f8..6b9eb5d 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,6 +1,6 @@ -import { defineConfig } from 'vite' -import { sveltekit } from '@sveltejs/kit/vite'; +import { sveltekit } from "@sveltejs/kit/vite"; +import { defineConfig } from "vite"; export default defineConfig({ - plugins: [sveltekit()] + plugins: [sveltekit()], });