Skip to content

Commit

Permalink
add pre-commit config including biome and biome.json
Browse files Browse the repository at this point in the history
  • Loading branch information
lkeegan committed Dec 6, 2024
1 parent 54a50da commit a84e20e
Show file tree
Hide file tree
Showing 10 changed files with 197 additions and 109 deletions.
30 changes: 15 additions & 15 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
],
};
43 changes: 43 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]"]

exclude: "mondey_backend/openapi.json|frontend/src/lib/client"
41 changes: 41 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -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
}
}
}
}
8 changes: 4 additions & 4 deletions postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -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;
32 changes: 16 additions & 16 deletions src/lib/components/UploadPdf.svelte
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<svelte:options runes={true} />

<script lang="ts">
import { Fileupload, Label } from 'flowbite-svelte';
import { Fileupload, Label } from "flowbite-svelte";
let {
file = $bindable(null as File | null),
label
}: {
file: File | null;
label: string;
} = $props();
let {
file = $bindable(null as File | null),
label,
}: {
file: File | null;
label: string;
} = $props();
let files: FileList | undefined = $state(undefined);
let files: FileList | undefined = $state(undefined);
function updateFile(event: Event) {
const target = event.target as HTMLInputElement;
if (target.files) {
file = target.files[0];
} else {
file = null;
}
function updateFile(event: Event) {
const target = event.target as HTMLInputElement;
if (target.files) {
file = target.files[0];
} else {
file = null;
}
}
</script>

<div class="flex flex-col">
Expand Down
2 changes: 1 addition & 1 deletion src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
import '../app.pcss';
import "../app.pcss";
</script>

<slot />
96 changes: 50 additions & 46 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,59 +1,63 @@
<svelte:options runes={true} />

<script lang="ts">
import Button from 'flowbite-svelte/Button.svelte';
import Card from 'flowbite-svelte/Card.svelte';
import Input from 'flowbite-svelte/Input.svelte';
import Label from 'flowbite-svelte/Label.svelte';
import Heading from 'flowbite-svelte/Heading.svelte';
import P from 'flowbite-svelte/P.svelte';
import Checkbox from 'flowbite-svelte/Checkbox.svelte';
import DownloadOutline from 'flowbite-svelte-icons/DownloadOutline.svelte';
import { PDFDocument } from 'pdf-lib';
import type { PDFPage } from 'pdf-lib';
import PDFMerger from 'pdf-merger-js/browser';
import UploadPdf from '$lib/components/UploadPdf.svelte';
import UploadPdf from "$lib/components/UploadPdf.svelte";
import DownloadOutline from "flowbite-svelte-icons/DownloadOutline.svelte";
import Button from "flowbite-svelte/Button.svelte";
import Card from "flowbite-svelte/Card.svelte";
import Checkbox from "flowbite-svelte/Checkbox.svelte";
import Heading from "flowbite-svelte/Heading.svelte";
import Input from "flowbite-svelte/Input.svelte";
import Label from "flowbite-svelte/Label.svelte";
import P from "flowbite-svelte/P.svelte";
import { PDFDocument } from "pdf-lib";
import type { PDFPage } from "pdf-lib";
import PDFMerger from "pdf-merger-js/browser";
let position = $state('RSE');
let name = $state('');
let pdfCoverLetter = $state(null as File | null);
let pdfCV = $state(null as File | null);
let pdfMastersCertificate = $state(null as File | null);
let applicationComplete = true; //$derived(pdfCoverLetter && pdfCV && pdfMastersCertificate);
let position = $state("RSE");
let name = $state("");
let pdfCoverLetter = $state(null as File | null);
let pdfCV = $state(null as File | null);
let pdfMastersCertificate = $state(null as File | null);
let applicationComplete = true; //$derived(pdfCoverLetter && pdfCV && pdfMastersCertificate);
let checkboxes = $state([
{ id: 'Internal candidate', text: 'Internal candidate', value: false },
{ id: 'Check2', text: 'check box 2', value: false }
]);
let checkboxes = $state([
{ id: "Internal candidate", text: "Internal candidate", value: false },
{ id: "Check2", text: "check box 2", value: false },
]);
function writeLine(page: PDFPage, text: string, ypos: number): number {
page.drawText(text, { x: 50, y: page.getSize().height - ypos });
return ypos + 50;
}
function writeLine(page: PDFPage, text: string, ypos: number): number {
page.drawText(text, { x: 50, y: page.getSize().height - ypos });
return ypos + 50;
}
async function createPdfFrontPage() {
const pdfDoc = await PDFDocument.create();
const page = pdfDoc.addPage();
let ypos = 100;
ypos = writeLine(page, `Application for SSC Position: ${position}`, ypos);
ypos = writeLine(page, `Name: ${name}`, ypos);
for (const checkbox of checkboxes) {
ypos = writeLine(page, `${checkbox.id}: ${checkbox.value ? 'YES' : 'NO'}`, ypos);
}
return pdfDoc.save();
async function createPdfFrontPage() {
const pdfDoc = await PDFDocument.create();
const page = pdfDoc.addPage();
let ypos = 100;
ypos = writeLine(page, `Application for SSC Position: ${position}`, ypos);
ypos = writeLine(page, `Name: ${name}`, ypos);
for (const checkbox of checkboxes) {
ypos = writeLine(
page,
`${checkbox.id}: ${checkbox.value ? "YES" : "NO"}`,
ypos,
);
}
return pdfDoc.save();
}
async function downloadMergedPdf() {
if (!applicationComplete) {
return;
}
const merger = new PDFMerger();
await merger.add(await createPdfFrontPage());
// await merger.add(pdfCoverLetter)
// await merger.add(pdfCV)
// await merger.add(pdfMastersCertificate)
await merger.save('application');
async function downloadMergedPdf() {
if (!applicationComplete) {
return;
}
const merger = new PDFMerger();
await merger.add(await createPdfFrontPage());
// await merger.add(pdfCoverLetter)
// await merger.add(pdfCV)
// await merger.add(pdfMastersCertificate)
await merger.save("application");
}
</script>

<div class="flex flex-col md:container md:mx-auto">
Expand Down
10 changes: 5 additions & 5 deletions svelte.config.js
Original file line number Diff line number Diff line change
@@ -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;
38 changes: 19 additions & 19 deletions tailwind.config.cjs
Original file line number Diff line number Diff line change
@@ -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;
6 changes: 3 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -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()],
});

0 comments on commit a84e20e

Please sign in to comment.