Skip to content

Commit b2312c8

Browse files
committed
Add svelte-check and prittier and format
1 parent 2e6b49f commit b2312c8

18 files changed

+433
-205
lines changed

.prettierignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.DS_Store
2+
node_modules
3+
/build
4+
/.svelte-kit
5+
/package
6+
.env
7+
.env.*
8+
!.env.example
9+
10+
# Ignore files for PNPM, NPM and YARN
11+
pnpm-lock.yaml
12+
package-lock.json
13+
yarn.lock

.prettierrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"useTabs": false,
3+
"singleQuote": true,
4+
"trailingComma": "none",
5+
"printWidth": 100,
6+
"plugins": ["prettier-plugin-svelte"],
7+
"pluginSearchDirs": ["."],
8+
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
9+
}

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@
44
"scripts": {
55
"dev": "vite dev",
66
"build": "vite build",
7-
"preview": "vite preview"
7+
"preview": "vite preview",
8+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
9+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
10+
"lint": "prettier --plugin-search-dir . --check . && eslint .",
11+
"format": "prettier --plugin-search-dir . --write ."
812
},
913
"devDependencies": {
1014
"@sveltejs/adapter-auto": "^1.0.0-next.84",
1115
"@sveltejs/kit": "1.0.0-next.524",
16+
"prettier": "^2.7.1",
17+
"prettier-plugin-svelte": "^2.8.0",
1218
"svelte": "^3.52.0",
19+
"svelte-check": "^2.9.2",
1320
"svelte-preprocess": "^4.10.7",
1421
"tslib": "^2.4.0",
1522
"typescript": "^4.8.4",

src/components/NavBar.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
NavbarBrand,
77
Nav,
88
NavItem,
9-
NavLink,
9+
NavLink
1010
} from 'sveltestrap/src';
1111
import authStore from '../stores/authStore';
1212
import firebase from 'firebase/compat/app';

src/db.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import firebase from "firebase/app";
2-
import { firestore } from "./firestore";
1+
import firebase from 'firebase/app';
2+
import { firestore } from './firestore';
33

44
export type Ingredient = {
55
name: string;
@@ -30,19 +30,19 @@ export const createRecipe = async (recipeForm: RecipeForm, userId: string) => {
3030
ingredients: recipeForm.ingredients,
3131
userId,
3232
createdAt: firebase.firestore.FieldValue.serverTimestamp(),
33-
updatedAt: firebase.firestore.FieldValue.serverTimestamp(),
33+
updatedAt: firebase.firestore.FieldValue.serverTimestamp()
3434
};
3535
const db = await firestore();
36-
const recipeRef = await db.collection("recipes").add(recipe);
36+
const recipeRef = await db.collection('recipes').add(recipe);
3737
const path = await uploadFile(recipeRef.id, userId, recipeForm.mainPicture);
3838
const url = await getUrl(path);
39-
recipeRef.update("picture", url);
39+
recipeRef.update('picture', url);
4040

4141
return recipeRef;
4242
};
4343

4444
const uploadFile = async (recipeId: string, userId: string, pic: File) => {
45-
const mainPicturePath = `/${userId}/${recipeId}.${pic.name.split(".").pop()}`;
45+
const mainPicturePath = `/${userId}/${recipeId}.${pic.name.split('.').pop()}`;
4646
const storage = firebase.storage();
4747
const ref = storage.ref(mainPicturePath);
4848
await ref.put(pic);

src/env.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
export default {
2-
apiKey: "AIzaSyD5p9J1bkYxy3MmIvfZs2t8Gteuv3N8ZgY",
3-
authDomain: "noahvideos.firebaseapp.com",
4-
databaseURL: "https://noahvideos.firebaseio.com",
5-
projectId: "noahvideos",
6-
storageBucket: "noahvideos.appspot.com",
7-
messagingSenderId: "826072574665",
8-
appId: "1:826072574665:web:3f7ca610c553a87eddfb18",
9-
measurementId: "G-GEQPVWNR55",
2+
apiKey: 'AIzaSyD5p9J1bkYxy3MmIvfZs2t8Gteuv3N8ZgY',
3+
authDomain: 'noahvideos.firebaseapp.com',
4+
databaseURL: 'https://noahvideos.firebaseio.com',
5+
projectId: 'noahvideos',
6+
storageBucket: 'noahvideos.appspot.com',
7+
messagingSenderId: '826072574665',
8+
appId: '1:826072574665:web:3f7ca610c553a87eddfb18',
9+
measurementId: 'G-GEQPVWNR55'
1010
};

src/firestore.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type firebase from "firebase/compat/app";
1+
import type firebase from 'firebase/compat/app';
22

33
let db: firebase.firestore.Firestore = null;
44

@@ -8,13 +8,13 @@ export async function firestore(): Promise<firebase.firestore.Firestore> {
88
}
99

1010
// Checks for the client
11-
if (typeof window !== "undefined") {
12-
const fb: any = (await import("firebase/compat/app")).default;
11+
if (typeof window !== 'undefined') {
12+
const fb: any = (await import('firebase/compat/app')).default;
1313

1414
db = fb.firestore();
1515
return db;
1616
}
1717

18-
const fb: any = await import("firebase/compat");
18+
const fb: any = await import('firebase/compat');
1919
return fb.apps[0].firestore() as firebase.firestore.Firestore;
2020
}

src/initFirebase.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import firebaseConfig from "./env";
2-
import { initializeApp, getApp } from "firebase/app";
1+
import firebaseConfig from './env';
2+
import { initializeApp, getApp } from 'firebase/app';
33

4-
import type { FirebaseApp } from "firebase/app";
5-
import firebase from "firebase/compat/app"
4+
import type { FirebaseApp } from 'firebase/app';
5+
import firebase from 'firebase/compat/app';
66

77
export function initFirebase() {
8-
let fb: FirebaseApp
8+
let fb: FirebaseApp;
99
try {
1010
fb = getApp();
1111
} catch {
12-
fb = firebase.initializeApp(firebaseConfig)
12+
fb = firebase.initializeApp(firebaseConfig);
1313
}
14-
return fb
14+
return fb;
1515
}

src/routes/+layout.svelte

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<script context="module" lang="ts">
2-
32
</script>
43

54
<script lang="ts">
@@ -14,9 +13,8 @@
1413
firebase.auth().onAuthStateChanged((user) => {
1514
authStore.set({
1615
isLoggedIn: user !== null,
17-
// @ts-ignore:
1816
user,
19-
firebaseControlled: true,
17+
firebaseControlled: true
2018
});
2119
});
2220
});

src/routes/+layout.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { initFirebase } from '../initFirebase';
22
import type { LayoutLoad } from './$types';
33

4-
export const load: LayoutLoad = async () => {
4+
export const load: LayoutLoad = async () => {
55
initFirebase();
66
return {};
7-
}
7+
};

0 commit comments

Comments
 (0)