Skip to content

Commit

Permalink
feat: add lint
Browse files Browse the repository at this point in the history
  • Loading branch information
dewanakl committed Jun 16, 2024
1 parent c05929a commit 43035fe
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 11 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/code-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Code Analysis

on: [push, pull_request]

jobs:
analyze-code:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install dependencies
run: npm install

- name: Run ESLint (JavaScript)
run: npx eslint js

- name: Run stylelint (CSS)
run: npx stylelint css

- name: Run HTMLHint (HTML)
run: npx htmlhint "**/*.html"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.github
CNAME
CODE_OF_CONDUCT.md
SECURITY.md
LICENSE
node_modules
package-lock.json
3 changes: 3 additions & 0 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "stylelint-config-recommended"
}
2 changes: 1 addition & 1 deletion css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ body {
}

.font-esthetic {
font-family: 'Sacramento', cursive !important;
font-family: Sacramento, cursive !important;
}

.font-arabic {
Expand Down
2 changes: 1 addition & 1 deletion css/dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ body {
overflow-x: hidden;
}

@media screen and (max-width: 767px) {
@media screen and (width <= 767px) {
html {
scrollbar-width: none !important;
width: 100%;
Expand Down
8 changes: 8 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import globals from "globals";
import pluginJs from "@eslint/js";


export default [
{languageOptions: { globals: globals.browser }},
pluginJs.configs.recommended,
];
1 change: 1 addition & 0 deletions js/aos.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const AOS = window.AOS;
1 change: 1 addition & 0 deletions js/bootstrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const bootstrap = window.bootstrap;
8 changes: 4 additions & 4 deletions js/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ export const card = (() => {
if (lists.size === 0) {
const text = theme.isDarkMode('light', 'dark');
const data = [
['\*', `<strong class="text-${text}">$1</strong>`],
['\_', `<em class="text-${text}">$1</em>`],
['\~', `<del class="text-${text}">$1</del>`],
['\`\`\`', `<code class="font-monospace text-${text}">$1</code>`]
['*', `<strong class="text-${text}">$1</strong>`],
['_', `<em class="text-${text}">$1</em>`],
['~', `<del class="text-${text}">$1</del>`],
['```', `<code class="font-monospace text-${text}">$1</code>`]
];

data.forEach((v) => {
Expand Down
1 change: 1 addition & 0 deletions js/confetti.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const confetti = window.confetti;
2 changes: 2 additions & 0 deletions js/navbar.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { bootstrap } from './bootstrap.js';

export const navbar = (() => {

const buttonNavHome = (btn) => {
Expand Down
1 change: 1 addition & 0 deletions js/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { user } from './user.js';
import { theme } from './theme.js';
import { storage } from './storage.js';
import { comment } from './comment.js';
import { bootstrap } from './bootstrap.js';
import { request, HTTP_POST } from './request.js';

export const session = (() => {
Expand Down
2 changes: 1 addition & 1 deletion js/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export const user = (() => {
const copyAccessKey = async (button) => {
try {
await navigator.clipboard.writeText(user.get('access_key'));
} catch (err) {
} catch {
alert('Failed to copy access key');
return;
}
Expand Down
7 changes: 4 additions & 3 deletions js/util.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { AOS } from './aos.js';
import { audio } from './audio.js';
import { theme } from './theme.js';
import { comment } from './comment.js';
import { storage } from './storage.js';
import { confetti } from './confetti.js';
import { bootstrap } from './bootstrap.js';
import { request, HTTP_GET } from './request.js';

export const util = (() => {
Expand Down Expand Up @@ -49,10 +52,8 @@ export const util = (() => {
};

const animate = (svg, timeout, classes) => {
let handler = null;
handler = setTimeout(() => {
setTimeout(() => {
svg.classList.add(classes);
handler = null;
}, timeout);
};

Expand Down
13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"devDependencies": {
"eslint": "^9.5.0",
"htmlhint": "^1.1.4",
"stylelint": "^16.6.1",
"stylelint-config-recommended": "^14.0.0"
},
"scripts": {
"lint:js": "eslint js",
"lint:css": "stylelint css",
"lint:html": "htmlhint **/*.html"
}
}

0 comments on commit 43035fe

Please sign in to comment.