Skip to content

Commit

Permalink
lint fix and action add
Browse files Browse the repository at this point in the history
  • Loading branch information
vladbyk89 committed Jan 12, 2024
1 parent 4bc3e06 commit cff0ca8
Show file tree
Hide file tree
Showing 78 changed files with 1,191 additions and 4,678 deletions.
28 changes: 17 additions & 11 deletions .github/workflows/superlinter.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
name: Super-Linter
name: Frontend PR Tests

on: push

jobs:
super-linter:
name: Lint Code Base
build:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
fetch-depth: 0
- name: Run Super-Linter
uses: github/super-linter@v4
env:
VALIDATE_ALL_CODEBASE: true
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
node-version: 14

- name: Install dependencies
run: npm install

- name: Run ESLint
run: npm run lint

- name: Run TypeScript type checking
run: npm run typecheck
5,342 changes: 830 additions & 4,512 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"devf": "cd functions && npm run build:watch",
"deve": "firebase emulators:start",
"build": "tsc && vite build",
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"lint": "eslint --fix \"src/**/*.{js,jsx,ts,tsx}\"",
"typecheck": "tsc",
"preview": "vite preview",
"deploy:h": "npm run build && firebase deploy --only hosting",
"deploy:f": "cd functions && npm run build && firebase deploy --only functions",
Expand All @@ -22,6 +23,7 @@
"@emotion/styled": "^11.11.0",
"@reduxjs/toolkit": "^1.9.5",
"delib-npm": "^1.1.67",
"eslint-plugin-import": "^2.29.1",
"firebase": "^10.0.0",
"i18next": "^23.7.6",
"i18next-http-backend": "^2.4.1",
Expand All @@ -48,10 +50,13 @@
"@typescript-eslint/eslint-plugin": "^5.61.0",
"@typescript-eslint/parser": "^5.61.0",
"@vitejs/plugin-react-swc": "^3.3.2",
"eslint": "^8.44.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^8.7.0",
"eslint-import-resolver-alias": "1.1.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.1",
"typescript": "^5.0.2",
"prettier": "^3.1.1",
"typescript": "^5.3.3",
"vite": "^4.4.0",
"vite-plugin-pwa": "^0.16.4",
"workbox-window": "^7.0.0"
Expand Down
1 change: 1 addition & 0 deletions src/assets/icons/FrownIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FC } from "react";

interface Props {
color?: string;
}
Expand Down
1 change: 1 addition & 0 deletions src/assets/icons/InfoIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FC } from "react";

interface Props {
color: string;
}
Expand Down
2 changes: 2 additions & 0 deletions src/functions/db/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export function googleLogin() {

// The AuthCredential type that was used.
console.error(error);

// const credential = GoogleAuthProvider.credentialFromError(error);

// ...
Expand Down Expand Up @@ -80,6 +81,7 @@ export function listenToAuth(
cb(userDB);

const initialLocation = getIntialLocationSessionStorage();

//navigate to initial location
if (initialLocation) navigationCB(initialLocation);
} else {
Expand Down
3 changes: 3 additions & 0 deletions src/functions/db/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getAnalytics } from "firebase/analytics";
import { connectAuthEmulator, getAuth } from "firebase/auth";
import { getStorage, connectStorageEmulator } from "firebase/storage";
import { keys, vapidKey } from "./configKey";

// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries

Expand Down Expand Up @@ -36,11 +37,13 @@ getToken(messaging, { vapidKey })
console.info(
"No registration token available. Request permission to generate one."
);

// ...
}
})
.catch((err) => {
console.error("An error occurred while retrieving token. ", err);

// ...
});

Expand Down
18 changes: 12 additions & 6 deletions src/functions/db/evaluation/getEvaluation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export function listenToEvaluations(
where("parentId", "==", parentId),
where("evaluatorId", "==", evaluatorId)
);
return onSnapshot(q, (evaluationsDB) => {

return onSnapshot(q, (evaluationsDB) => {
try {
evaluationsDB.forEach((evaluationDB) => {
try {
Expand All @@ -43,7 +44,8 @@ export function listenToEvaluations(
});
} catch (error) {
console.error(error);
return () => {};

return () => {};
}
}

Expand All @@ -59,7 +61,8 @@ export async function getEvaluations(parentId: string): Promise<Evaluation[]> {
if (!evauatorsIds.has(evaluation.evaluatorId)) {
//prevent duplicate evaluators
evauatorsIds.add(evaluation.evaluatorId);
return evaluation;

return evaluation;
}
}).filter((evaluation) => evaluation) as Evaluation[];

Expand All @@ -72,7 +75,8 @@ export async function getEvaluations(parentId: string): Promise<Evaluation[]> {
evaluation.evaluatorId
);
const promise = getDoc(evaluatorRef);
return promise;

return promise;
}
}).filter((promise) => promise) as Promise<any>[];

Expand All @@ -87,9 +91,11 @@ export async function getEvaluations(parentId: string): Promise<Evaluation[]> {
);
if (evaluator) evaluation.evaluator = evaluator;
});
return evaluations;

return evaluations;
} catch (error) {
console.error(error);
return [] as Evaluation[];

return [] as Evaluation[];
}
}
15 changes: 10 additions & 5 deletions src/functions/db/results/getResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export async function getResultsDB( statement:Statement): Promise<Statement[]> {

} catch (error) {
console.error(error);
return [];

return [];
}
}

Expand All @@ -44,10 +45,12 @@ export async function getResultsByTopVoteDB(statement: Statement): Promise<State
const statementRef = doc(DB, Collections.statements, topStatementId);
const statementSnap = await getDoc(statementRef);
const statementData = statementSnap.data() as Statement;
return [statementData];

return [statementData];
} catch (error) {
console.error(error);
return [];

return [];
}
}

Expand All @@ -61,9 +64,11 @@ async function getTopOtionsDB(statement: Statement): Promise<Statement[]> {
const topOptionsSnap = await getDocs(q);

const topOptions = topOptionsSnap.docs.map(doc => doc.data() as Statement);
return topOptions;

return topOptions;
} catch (error) {
console.error(error);
return [];

return [];
}
}
2 changes: 1 addition & 1 deletion src/functions/db/results/setResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { z } from 'zod';
import { DB } from '../config';
import { Collections, ResultsBy } from 'delib-npm';

export async function updateResultsSettings(statementId: string, resultsBy: ResultsBy = ResultsBy.topOptions, numberOfResults: number = 3) {
export async function updateResultsSettings(statementId: string, resultsBy: ResultsBy = ResultsBy.topOptions, numberOfResults = 3) {
try {
z.string().parse(statementId);
z.number().parse(numberOfResults);
Expand Down
9 changes: 6 additions & 3 deletions src/functions/db/rooms/getRooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export function listenToAllRoomsRquest(statement: Statement, cb: Function) {
})
} catch (error) {
console.error(error)
return () => {}

return () => {}
}
}

Expand All @@ -54,7 +55,8 @@ export function listenToRoomSolutions(statementId: string, cb: Function) {
)
)
)
return onSnapshot(q, (roomSolutionsDB) => {

return onSnapshot(q, (roomSolutionsDB) => {
try {
roomSolutionsDB.forEach((roomSolutionDB) => {
try {
Expand All @@ -73,6 +75,7 @@ export function listenToRoomSolutions(statementId: string, cb: Function) {
})
} catch (error) {
console.error(error)
return () => {}

return () => {}
}
}
12 changes: 8 additions & 4 deletions src/functions/db/rooms/setRooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,33 @@ export async function askToJoinRoomDB(statement: Statement): Promise<boolean> {


await saveToDB(requestId, requestRef, statement);
return true;

return true;


} else if (request.statement.statementId !== statement.statementId) {

await saveToDB(requestId, requestRef, statement);
return true;

return true;

} else {
const { parentId, participant, requestId } = request;
const _request = { parentId, participant, requestId, lastUpdate: new Date().getTime() };

//set to undefined to show that the user is not in the room
await setDoc(requestRef, _request);
return false;

return false;
}


}

} catch (error) {
console.error(error)
return false

return false
}

async function saveToDB(requestId: string, requestRef: any, statement: Statement) {
Expand Down
Loading

0 comments on commit cff0ca8

Please sign in to comment.