Skip to content

Commit

Permalink
fixing all lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
TeaByte committed Feb 7, 2024
1 parent 3136142 commit b68b52c
Show file tree
Hide file tree
Showing 17 changed files with 44 additions and 34 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# NakhlahJS (نخلة جي أس)

![Deploy Workflow](https://github.com/TeaByte/NakhlahJS/actions/workflows/build-deno.yml/badge.svg)

🚧 Still in a preliminary version and under continuous development
[![Deploy Workflow](https://github.com/TeaByte/NakhlahJS/actions/workflows/build-deno.yml/badge.svg)](https://github.com/TeaByte/NakhlahJS/actions/workflows/build-deno.yml)
[![Lint Workflow](https://github.com/TeaByte/NakhlahJS/actions/workflows/lint.yml/badge.svg)](https://github.com/TeaByte/NakhlahJS/actions/workflows/lint.yml)
[![Deploy Workflow](https://github.com/TeaByte/NakhlahJS/actions/workflows/codeql.yml/badge.svg)](https://github.com/TeaByte/NakhlahJS/actions/workflows/codeql.yml/)

NakhlahJS is a dynamic Arabic JavaScript learning platform, drawing inspiration
from the style of [freeCodeCamp](https://www.freecodecamp.org/learn/). Our
Expand Down
2 changes: 1 addition & 1 deletion components/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function Drawer(
<div class="drawer-content">
<label
for="my-drawer-4"
class="drawer-button btn btn-active ghost-color"
class="drawer-button btn ghost-color"
>
<IconLayoutSidebarLeftCollapse aria-hidden="true" />
</label>
Expand Down
8 changes: 7 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
"preview": "deno run --unstable -A main.ts",
"update": "deno run -A -r https://fresh.deno.dev/update ."
},
"lint": { "rules": { "tags": ["fresh", "recommended"] } },
"lint": {
"exclude": ["testcases/**/*", "precodes/**/*"],
"rules": {
"tags": ["fresh", "recommended"],
"exclude": ["no-unused-vars"]
}
},
"exclude": ["**/_fresh/*"],
"imports": {
"@/": "./",
Expand Down
7 changes: 3 additions & 4 deletions islands/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ export default function Editor(props: EditorProps) {
setIsError(false);
eval(props.testingCode);
if (isPass) {
let courseSlug: string;
courseSlug = props.slug;
const courseSlug = props.slug;
const passedCourses = localStorage.getItem("passedCourses");
// check if there are a value in the local storage
if (passedCourses) {
Expand Down Expand Up @@ -159,15 +158,15 @@ export default function Editor(props: EditorProps) {
تشغيل
</button>
<button
class="btn btn-active ghost-color grow"
class="btn ghost-color grow"
onClick={handleCodeClear}
>
مسح
</button>
<button
class={`btn grow border-0 ${
isTestPassed === undefined
? "btn-active ghost-color"
? "ghost-color"
: isTestPassed
? "btn-info bg-success hover:bg-[#9bc27a]"
: "btn-info bg-error hover:bg-[#ff6868]"
Expand Down
4 changes: 3 additions & 1 deletion islands/ThemeToggle.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { useEffect } from "preact/hooks";

// deno-lint-ignore no-var
declare var window: Window & typeof globalThis;

interface Window {
// deno-lint-ignore no-explicit-any
monaco: any;
}

Expand Down Expand Up @@ -39,7 +41,7 @@ export default function ThemeToggle() {
};

return (
<label class="swap swap-rotate btn btn-active ghost-color">
<label class="swap swap-rotate btn ghost-color">
<input
type="checkbox"
onChange={handleThemeChange}
Expand Down
4 changes: 2 additions & 2 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "$std/dotenv/load.ts";

import { start } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts";
import config from "./fresh.config.ts";
// import config from "./fresh.config.ts";

import { freshSEOPlugin } from "https://deno.land/x/fresh_seo/mod.ts";
import { walk } from "https://deno.land/std/fs/mod.ts";
Expand Down Expand Up @@ -40,4 +40,4 @@ await start(manifest, {
include: [...coursesPath],
}),
],
});
});
8 changes: 4 additions & 4 deletions plugins/sw-page-json-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export default function SW_cache(
const SW_cacheMiddleware: PluginMiddleware = {
path: "/",
middleware: {
handler: async (_, ctx) => {
handler: (_, ctx) => {
if (ctx.url.pathname == "/sw-cache.json") {
const resp = new Response(JSON.stringify(await getFlatSlugs()), {
const resp = new Response(JSON.stringify(getFlatSlugs()), {
headers: {
"content-type": "application/json",
}
Expand All @@ -25,7 +25,7 @@ export default function SW_cache(

return {
name: "sw-cache",
async configResolved(config) {
configResolved(config) {
if (config.dev) {
staticDir = config.staticDir;
middlewares.push(SW_cacheMiddleware);
Expand All @@ -36,7 +36,7 @@ export default function SW_cache(
staticDir = config.staticDir;
console.log("SW_cache buildStart");
const outFilePath = path.join(staticDir, "sw-cache.json");
const slugs = await getFlatSlugs();
const slugs = getFlatSlugs();
const data = JSON.stringify(slugs);
await Deno.writeTextFile(outFilePath, data);
},
Expand Down
2 changes: 1 addition & 1 deletion precodes/intro.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
console.log("مرحبا بكم في منصة نخلة")
console.log("مرحبا")
3 changes: 2 additions & 1 deletion precodes/strings/bracket-examples.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
const x = "Augusta"
const x = "Augusta"
console.log(x)
1 change: 1 addition & 0 deletions precodes/strings/understand-immutability.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
let animal = "قيل";
console.log(animal)
3 changes: 2 additions & 1 deletion precodes/strings/use-brackets.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
const country = "Syria";
const country = "Syria";
console.log(country)
4 changes: 2 additions & 2 deletions routes/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export const handler: Handlers<Props> = {
let lable: string | undefined;
const course = await getCourse(ctx.params.slug);
if (course === null) return ctx.renderNotFound();
const nextCourse = await findNextCourse(ctx.params.slug);
const prevCourse = await findPrevCourse(ctx.params.slug);
const nextCourse = findNextCourse(ctx.params.slug);
const prevCourse = findPrevCourse(ctx.params.slug);
if (ctx.params.slug.includes("/")) {
const [lableSlug, lable] = await getJson(ctx.params.slug.split("/")[0]);
return ctx.render({ course, lable, lableSlug, nextCourse, prevCourse });
Expand Down
1 change: 1 addition & 0 deletions routes/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import NavBar from "../components/Nav.tsx";
import { populateCache } from "../utils/course-cache.ts";
populateCache();

// deno-lint-ignore require-await
export default async function Layout(req: Request, ctx: FreshContext) {
return (
// Don't delete data-theme="dim", used for defult theme and styles
Expand Down
4 changes: 2 additions & 2 deletions routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ interface Props {
total: number;
}
export const handler: Handlers<Props> = {
async GET(_req, ctx) {
GET(_req, ctx) {
const courses = cache.courses;
const total = await getNumberOfCourses();
const total = getNumberOfCourses();
return ctx.render({
total,
courses: courses,
Expand Down
4 changes: 2 additions & 2 deletions static/sw.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const CACHE_NAME = 'cache-v1';

self.addEventListener('install', async function (event) {
self.addEventListener('install', async function (_event) {
const cacheNames = await caches.keys();
await Promise.all(
cacheNames.map(function (cacheName) {
Expand Down Expand Up @@ -86,7 +86,7 @@ self.addEventListener('sync', function (event) {
}
});

async function syncData() {
function syncData() {
// Implement your data synchronization logic here
// This function will be called when the connection is restored
console.log('Syncing data...');
Expand Down
3 changes: 1 addition & 2 deletions testcases/variables/uninitialized-variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ if (!regex.test(code)) {
msg = "لم تقم بتعريف متغير غير المهيأة"
} else {
// get the variables name
let variables;
regex = /(let|var)\s+(\w+)\s*/g;
variables = code.match(regex).map(match => match.split(' ')[1]);
const variables = code.match(regex).map(match => match.split(' ')[1]);
if (variables.length != 1) {
isPass = false;
msg = "ما حد طلب منك تعريف أكثر من متغير غير مهيأة "
Expand Down
14 changes: 7 additions & 7 deletions utils/course.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export async function getCourses(
return cache;
}

export async function getFlatSlugs() {
export function getFlatSlugs() {
if (FlatSlugsCache.length > 0) {
// console.log("Using cache");
return FlatSlugsCache;
Expand All @@ -126,22 +126,22 @@ export async function getFlatSlugs() {
FlatSlugsCache = FlatSlugs;
return FlatSlugs;
}
export async function getNumberOfCourses() {
const FlatSlugs = await getFlatSlugs();
export function getNumberOfCourses() {
const FlatSlugs = getFlatSlugs();
return FlatSlugs.length;
}

export async function findNextCourse(slug: string) {
const FlatSlugs = await getFlatSlugs();
export function findNextCourse(slug: string) {
const FlatSlugs = getFlatSlugs();
const index = FlatSlugs.indexOf(slug);
if (index === -1) {
return slug;
}
return FlatSlugs[index + 1];
}

export async function findPrevCourse(slug: string) {
const FlatSlugs = await getFlatSlugs();
export function findPrevCourse(slug: string) {
const FlatSlugs = getFlatSlugs();
const index = FlatSlugs.indexOf(slug);
if (index === 1) {
return slug;
Expand Down

0 comments on commit b68b52c

Please sign in to comment.