Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

CI: Add eslint and fix a few things #233

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/pages/settings.svelte
45 changes: 45 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: ["eslint:recommended", "plugin:svelte/recommended"],
overrides: [
{
env: {
node: true,
},
files: [".eslintrc.{js,cjs}"],
parserOptions: {
sourceType: "script",
},
},
{
files: ["*.svelte"],
parser: "svelte-eslint-parser",
},
],
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
rules: {
"svelte/no-at-html-tags": "off",
// blocks while (true) { ... } loops
"no-constant-condition": "off",
// regex stuff i dont understand, and catches <a />
"no-useless-escape": "off",
"no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
// empty catch blocks are fine
"no-empty": "off",
// spaces for minor indentation, tabs for major indentation
"no-mixed-spaces-and-tabs": "off",
},
};
41 changes: 41 additions & 0 deletions .github/workflows/eslint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# ESLint is a tool for identifying and reporting on patterns
# found in ECMAScript/JavaScript code.
# More details at https://github.com/eslint/eslint
# and https://eslint.org

name: ESLint

on:
push:
branches: [ "develop", "main" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "develop" ]
schedule:
- cron: '43 10 * * 2'

jobs:
eslint:
name: Run eslint scanning
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install ESLint
run: |
npm install --group=dev
npm install eslint@8.10.0

- name: Run ESLint
run: npx eslint .
--config .eslintrc.cjs
continue-on-error: false
1,866 changes: 1,291 additions & 575 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -15,6 +15,8 @@
"@roxi/routify": "^2.18.12",
"@sveltejs/vite-plugin-svelte": "^3.1.1",
"@twemoji/api": "^15.1.0",
"eslint": "^8.56.0",
"eslint-plugin-svelte": "^2.35.1",
"markdown-it": "^14.1.0",
"prettier": "^3.3.3",
"prettier-plugin-svelte": "^3.2.5",
6 changes: 6 additions & 0 deletions src/lib/PostList.svelte
Original file line number Diff line number Diff line change
@@ -191,8 +191,13 @@
if ($user.hide_blocked_users) {
// @ts-ignore
result = result.filter(
/*
* @type {import('./types.js').ListPost | import('./types.js').User} post
*/
post =>
// @ts-ignore
$relationships[post._id] !== 2 &&
// @ts-ignore
$relationships[post.u] !== 2
);
}
@@ -223,6 +228,7 @@
};
list.addItem(pendingPost);
// eslint-disable-next-line no-async-promise-executor
const postProm = new Promise(async (resolve, reject) => {
try {
const resp = await fetch(
1 change: 0 additions & 1 deletion src/lib/Sidebar.svelte
Original file line number Diff line number Diff line change
@@ -22,7 +22,6 @@
import profile from "../assets/profile.svg";
import settings from "../assets/settings.svg";
import logout from "../assets/logout.svg";
import changelog from "../assets/changelog.svg";
import info from "../assets/info.svg";
import {fade} from "svelte/transition";
2 changes: 0 additions & 2 deletions src/lib/cloudlink.js
Original file line number Diff line number Diff line change
@@ -25,8 +25,6 @@
* SOFTWARE.
*/

import sleep from "./sleep.js";

/**
* A callback type used for packet events.
*
6 changes: 3 additions & 3 deletions src/lib/modals/moderation/KickAllUsers.svelte
Original file line number Diff line number Diff line change
@@ -7,15 +7,15 @@
import sleep from "../../sleep";
let loading, error;
let _loading, error;
</script>

<Modal on:close={modals.closeLastModal}>
<h2 slot="header">Kick All Users</h2>
<div slot="default">
<form
on:submit|preventDefault={async () => {
loading = true;
_loading = true;
try {
const resp = await fetch(`${apiUrl}admin/server/kick-all`, {
method: "POST",
@@ -29,7 +29,7 @@
modals.closeLastModal();
} catch (e) {
error = e;
loading = false;
_loading = false;
}
}}
>
11 changes: 4 additions & 7 deletions src/lib/modals/moderation/ModerateUser.svelte
Original file line number Diff line number Diff line change
@@ -129,13 +129,10 @@
async function kick() {
kickStatus = "Kicking...";
try {
const resp = await fetch(
`${apiUrl}admin/users/${user._id}/kick`,
{
method: "POST",
headers: $authHeader,
}
);
const resp = await fetch(`${apiUrl}admin/users/${user._id}/kick`, {
method: "POST",
headers: $authHeader,
});
if (!resp.ok) {
throw new Error(
"Response code is not OK; code is " + resp.status
2 changes: 0 additions & 2 deletions src/pages/settings.svelte
Original file line number Diff line number Diff line change
@@ -11,8 +11,6 @@
User,
Paintbrush,
Lock,
Smartphone,
Contact,
ShieldBan,
Flag,
Info,