Quellcode durchsuchen

Merge pull request #380 from AtkinsSJ/eslint-ci

Run ESLint on CI
Eric Dubé vor 1 Jahr
Ursprung
Commit
17e08cafce

+ 10 - 5
.github/workflows/check-translations.yml → .github/workflows/lint.yml

@@ -1,6 +1,6 @@
-# This workflow runs the tools/check-translations.js script to make sure that the translation data is valid.
+# Lint PRs and pushes to the main branch
 
-name: Check Translations
+name: Lint
 
 env:
   NODE_VERSION: 21.x
@@ -13,7 +13,7 @@ on:
     branches: [ "main" ]
 
 jobs:
-  test:
+  build:
     runs-on: ubuntu-latest
 
     steps:
@@ -24,5 +24,10 @@ jobs:
         node-version: ${{ env.NODE_VERSION }}
         cache: 'npm'
         cache-dependency-path: ./package-lock.json
-    - run: npm ci
-    - run: npm run check-translations
+    - name: Install dependencies
+      run: npm ci
+    - name: Run ESLint
+      run: npx eslint
+    - name: Check translations
+      if: '!cancelled()'
+      run: npm run check-translations

+ 2 - 0
packages/backend/src/routers/kvstore/clearItems.js

@@ -38,6 +38,8 @@ module.exports = eggspress('/clearItems', {
     }
 
     const svc_mysql = req.services.get('mysql');
+    // TODO: Check if used anywhere, maybe remove
+    // eslint-disable-next-line no-undef
     const dbrw = svc_mysql.get(DB_MODE_WRITE, 'kvstore-clearItems');
     await dbrw.execute(
         `DELETE FROM kv WHERE user_id=? AND app=?`,

+ 2 - 0
packages/backend/src/routers/whoami.js

@@ -101,6 +101,8 @@ WHOAMI_POST.post('/whoami', auth, fs, express.json(), async (req, response, next
     if(req.query.return_desktop_items === 1 || req.query.return_desktop_items === '1' || req.query.return_desktop_items === 'true'){
         // by cached desktop id
         if(req.user.desktop_id){
+            // TODO: Check if used anywhere, maybe remove
+            // eslint-disable-next-line no-undef
             desktop_items = await db.read(
                 `SELECT * FROM fsentries
                 WHERE user_id = ? AND parent_uid = ?`,

+ 2 - 1
src/UI/Settings/UITabSecurity.js

@@ -8,6 +8,7 @@ export default {
     icon: 'shield.svg',
     html: () => {
         let h = `<h1>${i18n('security')}</h1>`;
+        let user = window.user;
 
         // change password button
         if(!user.is_temp){
@@ -84,7 +85,7 @@ export default {
                 ]
             })
             if ( ! alert_resp ) return;
-            const resp = await fetch(`${api_origin}/auth/configure-2fa/disable`, {
+            const resp = await fetch(`${window.api_origin}/auth/configure-2fa/disable`, {
                 method: 'POST',
                 headers: {
                     Authorization: `Bearer ${puter.authToken}`,

+ 3 - 3
src/UI/UIWindow2FASetup.js

@@ -36,7 +36,7 @@ import UIComponentWindow from "./UIComponentWindow.js";
 
 const UIWindow2FASetup = async function UIWindow2FASetup () {
     // FIRST REQUEST :: Generate the QR code and recovery codes
-    const resp = await fetch(`${api_origin}/auth/configure-2fa/setup`, {
+    const resp = await fetch(`${window.api_origin}/auth/configure-2fa/setup`, {
         method: 'POST',
         headers: {
             Authorization: `Bearer ${puter.authToken}`,
@@ -48,7 +48,7 @@ const UIWindow2FASetup = async function UIWindow2FASetup () {
 
     // SECOND REQUEST :: Verify the code [first wizard screen]
     const check_code_ = async function check_code_ (value) {
-        const resp = await fetch(`${api_origin}/auth/configure-2fa/test`, {
+        const resp = await fetch(`${window.api_origin}/auth/configure-2fa/test`, {
             method: 'POST',
             headers: {
                 Authorization: `Bearer ${puter.authToken}`,
@@ -66,7 +66,7 @@ const UIWindow2FASetup = async function UIWindow2FASetup () {
 
     // FINAL REQUEST :: Enable 2FA [second wizard screen]
     const enable_2fa_ = async function check_code_ (value) {
-        const resp = await fetch(`${api_origin}/auth/configure-2fa/enable`, {
+        const resp = await fetch(`${window.api_origin}/auth/configure-2fa/enable`, {
             method: 'POST',
             headers: {
                 Authorization: `Bearer ${puter.authToken}`,

+ 2 - 2
src/UI/UIWindowLogin.js

@@ -199,7 +199,7 @@ async function UIWindowLogin(options){
                                         let error_i18n_key = 'something_went_wrong';
                                         if ( ! value ) return;
                                         try {
-                                            const resp = await fetch(`${api_origin}/login/otp`, {
+                                            const resp = await fetch(`${window.api_origin}/login/otp`, {
                                                 method: 'POST',
                                                 headers: {
                                                     'Content-Type': 'application/json',
@@ -268,7 +268,7 @@ async function UIWindowLogin(options){
                                         let error_i18n_key = 'something_went_wrong';
                                         if ( ! value ) return;
                                         try {
-                                            const resp = await fetch(`${api_origin}/login/recovery-code`, {
+                                            const resp = await fetch(`${window.api_origin}/login/recovery-code`, {
                                                 method: 'POST',
                                                 headers: {
                                                     'Content-Type': 'application/json',

+ 1 - 1
src/i18n/translations/ru.js

@@ -177,7 +177,7 @@ const ru = {
         properties: "Свойства",
         publish: "Опубликовать",
         publish_as_website: 'Опубликовать как сайт',
-        puter_description: `Puter — это персональное облако, обеспечивающее конфиденциальность, позволяющее хранить все ваши файлы, приложения и игры в одном безопасном месте, доступном из любого места в любое время.`,
+        puter_description: `Puter — это персональное облако, обеспечивающее конфиденциальность, позволяющее хранить все ваши файлы, приложения и игры в одном безопасном месте, доступном из любого места в любое время.`,
         recent: "Недавний",
         recover_password: "Восстановить Пароль",
         refer_friends_c2a: "Получите 1 ГБ за каждого друга, который создаст и подтвердит учетную запись на Puter. Ваш друг тоже получит 1 ГБ!",