From 9e259aeecfb1b9f62fb6dab43f46d1259f5ae347 Mon Sep 17 00:00:00 2001 From: scosman Date: Mon, 22 Jan 2024 01:15:35 -0500 Subject: [PATCH 1/4] Fix typescript linting --- .eslintrc.cjs | 14 ++++ package-lock.json | 205 +++++++++++++++++++++++++++++++++++++++++++++- package.json | 1 + 3 files changed, 217 insertions(+), 3 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index e52c4810..aeb77993 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -6,6 +6,20 @@ module.exports = { ecmaVersion: 2020, extraFileExtensions: ['.svelte'] }, + overrides: [ + { + files: ['*.svelte'], + parser: 'svelte-eslint-parser', + parserOptions: { + parser: { + // Specify a parser for each lang. + ts: '@typescript-eslint/parser', + js: 'espree', + typescript: '@typescript-eslint/parser' + } + } + } + ], env: { browser: true, es2017: true, diff --git a/package-lock.json b/package-lock.json index a071d10f..78269628 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "@sveltejs/adapter-auto": "^2.0.0", "@sveltejs/kit": "^1.27.6", "@tailwindcss/typography": "^0.5.9", + "@typescript-eslint/parser": "^6.19.0", "autoprefixer": "^10.4.15", "daisyui": "^3.5.1", "eslint": "^8.28.0", @@ -919,6 +920,133 @@ "@types/node": "*" } }, + "node_modules/@typescript-eslint/parser": { + "version": "6.19.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.19.0.tgz", + "integrity": "sha512-1DyBLG5SH7PYCd00QlroiW60YJ4rWMuUGa/JBV0iZuqi4l4IK3twKPq5ZkEebmGqRjXWVgsUzfd3+nZveewgow==", + "dev": true, + "dependencies": { + "@typescript-eslint/scope-manager": "6.19.0", + "@typescript-eslint/types": "6.19.0", + "@typescript-eslint/typescript-estree": "6.19.0", + "@typescript-eslint/visitor-keys": "6.19.0", + "debug": "^4.3.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "6.19.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.19.0.tgz", + "integrity": "sha512-dO1XMhV2ehBI6QN8Ufi7I10wmUovmLU0Oru3n5LVlM2JuzB4M+dVphCPLkVpKvGij2j/pHBWuJ9piuXx+BhzxQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.19.0", + "@typescript-eslint/visitor-keys": "6.19.0" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/types": { + "version": "6.19.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.19.0.tgz", + "integrity": "sha512-lFviGV/vYhOy3m8BJ/nAKoAyNhInTdXpftonhWle66XHAtT1ouBlkjL496b5H5hb8dWXHwtypTqgtb/DEa+j5A==", + "dev": true, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "6.19.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.19.0.tgz", + "integrity": "sha512-o/zefXIbbLBZ8YJ51NlkSAt2BamrK6XOmuxSR3hynMIzzyMY33KuJ9vuMdFSXW+H0tVvdF9qBPTHA91HDb4BIQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.19.0", + "@typescript-eslint/visitor-keys": "6.19.0", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "minimatch": "9.0.3", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "6.19.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.19.0.tgz", + "integrity": "sha512-hZaUCORLgubBvtGpp1JEFEazcuEdfxta9j4iUwdSAr7mEsYYAp3EAUyCZk3VEEqGj6W+AV4uWyrDGtrlawAsgQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.19.0", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, "node_modules/@ungap/structured-clone": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", @@ -1128,6 +1256,15 @@ "dequal": "^2.0.3" } }, + "node_modules/array-union": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", @@ -1624,6 +1761,18 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/dir-glob": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", + "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", + "dev": true, + "dependencies": { + "path-type": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/dlv": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/dlv/-/dlv-1.1.3.tgz", @@ -2190,6 +2339,26 @@ "resolved": "https://registry.npmjs.org/globalyzer/-/globalyzer-0.1.0.tgz", "integrity": "sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q==" }, + "node_modules/globby": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", + "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", + "dev": true, + "dependencies": { + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.2.9", + "ignore": "^5.2.0", + "merge2": "^1.4.1", + "slash": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/globrex": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz", @@ -2942,6 +3111,15 @@ "node": "14 || >=16.14" } }, + "node_modules/path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/pathe": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.2.tgz", @@ -3560,6 +3738,15 @@ "node": ">=10" } }, + "node_modules/slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/sorcery": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/sorcery/-/sorcery-0.11.0.tgz", @@ -4160,6 +4347,18 @@ "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" }, + "node_modules/ts-api-utils": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.0.3.tgz", + "integrity": "sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==", + "dev": true, + "engines": { + "node": ">=16.13.0" + }, + "peerDependencies": { + "typescript": ">=4.2.0" + } + }, "node_modules/ts-interface-checker": { "version": "0.1.13", "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", @@ -4280,9 +4479,9 @@ "dev": true }, "node_modules/vite": { - "version": "4.5.1", - "resolved": "https://registry.npmjs.org/vite/-/vite-4.5.1.tgz", - "integrity": "sha512-AXXFaAJ8yebyqzoNB9fu2pHoo/nWX+xZlaRwoeYUxEqBO+Zj4msE5G+BhGBll9lYEKv9Hfks52PAF2X7qDYXQA==", + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/vite/-/vite-4.5.2.tgz", + "integrity": "sha512-tBCZBNSBbHQkaGyhGCDUGqeo2ph8Fstyp6FMSvTtsXeZSPpSMGlviAOav2hxVTqFcx8Hj/twtWKsMJXNY0xI8w==", "dependencies": { "esbuild": "^0.18.10", "postcss": "^8.4.27", diff --git a/package.json b/package.json index c7f7a945..5720bd31 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "@sveltejs/adapter-auto": "^2.0.0", "@sveltejs/kit": "^1.27.6", "@tailwindcss/typography": "^0.5.9", + "@typescript-eslint/parser": "^6.19.0", "autoprefixer": "^10.4.15", "daisyui": "^3.5.1", "eslint": "^8.28.0", From 1d07e5b5c2400a21c07ee2f3af406e050794b10e Mon Sep 17 00:00:00 2001 From: scosman Date: Mon, 22 Jan 2024 01:35:38 -0500 Subject: [PATCH 2/4] Fix all linting errors --- .../account/(menu)/settings/settings_module.svelte | 8 ++------ src/routes/(admin)/account/create_profile/+page.svelte | 4 ++-- src/routes/(marketing)/+layout.svelte | 3 +++ src/routes/(marketing)/+page.svelte | 1 + src/routes/(marketing)/login/sign_in/+page.svelte | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/routes/(admin)/account/(menu)/settings/settings_module.svelte b/src/routes/(admin)/account/(menu)/settings/settings_module.svelte index b62d1bc9..6ef8c6d2 100644 --- a/src/routes/(admin)/account/(menu)/settings/settings_module.svelte +++ b/src/routes/(admin)/account/(menu)/settings/settings_module.svelte @@ -2,10 +2,6 @@ import { enhance, applyAction } from "$app/forms" import { page } from "$app/stores" - export let data - - let { session, supabase, profile } = data - const fieldError = (liveForm, name: String) => { let errors = liveForm?.errorFields ?? [] return errors.includes(name) @@ -20,7 +16,7 @@ export let dangerous = false export let title: string = "" export let message: string = "" - export let fields + export let fields: any export let formTarget: string = "" export let successTitle = "Success" export let successBody = "" @@ -31,7 +27,7 @@ const handleSubmit = () => { loading = true return async ({ update, result }) => { - let response = await update({ reset: false }) + await update({ reset: false }) await applyAction(result) loading = false if (result.type === "success") { diff --git a/src/routes/(admin)/account/create_profile/+page.svelte b/src/routes/(admin)/account/create_profile/+page.svelte index 6b3357e0..18f0e523 100644 --- a/src/routes/(admin)/account/create_profile/+page.svelte +++ b/src/routes/(admin)/account/create_profile/+page.svelte @@ -5,7 +5,7 @@ export let data export let form - let { session, supabase, profile } = data + let { session, profile } = data let loading = false let fullName: string = profile?.full_name ?? "" @@ -20,7 +20,7 @@ const handleSubmit = () => { loading = true return async ({ update, result }) => { - let response = await update({ reset: false }) + await update({ reset: false }) await applyAction(result) loading = false } diff --git a/src/routes/(marketing)/+layout.svelte b/src/routes/(marketing)/+layout.svelte index a7965364..73c798c1 100644 --- a/src/routes/(marketing)/+layout.svelte +++ b/src/routes/(marketing)/+layout.svelte @@ -19,6 +19,8 @@
  • Account
  • diff --git a/src/routes/(marketing)/login/sign_in/+page.svelte b/src/routes/(marketing)/login/sign_in/+page.svelte index c17d507e..ef3ef703 100644 --- a/src/routes/(marketing)/login/sign_in/+page.svelte +++ b/src/routes/(marketing)/login/sign_in/+page.svelte @@ -9,7 +9,7 @@ let { supabase } = data onMount(() => { - supabase.auth.onAuthStateChange((event, _session) => { + supabase.auth.onAuthStateChange((event) => { // Redirect to account after sucessful login if (event == "SIGNED_IN") { // Delay needed because order of callback not guaranteed. From 9a4777bd1cc34574d98fcda6cc5f3bba52b41292 Mon Sep 17 00:00:00 2001 From: scosman Date: Mon, 22 Jan 2024 01:38:19 -0500 Subject: [PATCH 3/4] Add linting to CI --- .github/workflows/linting.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/linting.yml diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml new file mode 100644 index 00000000..43aa4568 --- /dev/null +++ b/.github/workflows/linting.yml @@ -0,0 +1,24 @@ +name: Linting + +on: [push] + +env: + PUBLIC_SUPABASE_URL: 'https://fake_test_url.supabase.co' + PUBLIC_SUPABASE_ANON_KEY: 'fake_anon_key' + PRIVATE_SUPABASE_SERVICE_ROLE: 'fake_service_role' + PRIVATE_STRIPE_API_KEY: 'fake_strip_api_key' + PUBLIC_SITE_NAME: 'SaaS Starter Build Test' + +jobs: + build_and_test: + name: Build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: NPM install + run: npm install + + - name: Linting + run: npm run lint From f00f06202c64f14ea456d09724eaa08d70a02e79 Mon Sep 17 00:00:00 2001 From: Steve Cosman Date: Mon, 22 Jan 2024 01:45:43 -0500 Subject: [PATCH 4/4] Update README.md with Lint CI and git hook instructions --- README.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cf94a9db..947e2dbc 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![Build](https://github.com/CriticalMoments/CMSaasStarter/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/CriticalMoments/CMSaasStarter/actions/workflows/build.yml) [![Format Check](https://github.com/CriticalMoments/CMSaasStarter/actions/workflows/format.yml/badge.svg?branch=main)](https://github.com/CriticalMoments/CMSaasStarter/actions/workflows/format.yml) +[![Linting](https://github.com/CriticalMoments/CMSaasStarter/actions/workflows/linting.yml/badge.svg?branch=main)](https://github.com/CriticalMoments/CMSaasStarter/actions/workflows/linting.yml) [![License](https://img.shields.io/badge/License-MIT-brightgreen?labelColor=32383f)](https://github.com/CriticalMoments/CMSaasStarter/blob/main/LICENSE) ### SaaS Starter is an open source, fast, and free to host SaaS template / boilerplate @@ -115,21 +116,29 @@ The result is a perfect Google PageSpeed Insights score in all categories! ### Get Started (Local Development) -To get started, fork this project! +To get started, fork and run this project! ``` ## First fork the project on Github git pull [Your Fork] npm install -## Run the project +## Run the project locally in dev mode npm run dev -- ``` ### Developer Environment -VSCode has a [nice plugin](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). +VSCode has a [nice plugin](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). [Extensions for other editors are available here.](https://sveltesociety.dev/tools#editor-support). -[Extensions for other editors are available here.](https://sveltesociety.dev/tools#editor-support) +Optionally add the lines below to the git hook file at the location `.git/hooks/pre-commit`. This will run linting and format checking before you commit. This ensures you find issues locally before the Github Action CI checks fail. + +``` +#!/bin/sh +set -e +npm run format_check +npm run lint +npm run build +``` ### Setup Supabase