mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-10 07:25:48 +01:00
🚨 Fix nestjs warnings, remove old eslint plugins
This commit is contained in:
10
.eslintrc.js
10
.eslintrc.js
@@ -2,12 +2,12 @@ module.exports = {
|
|||||||
extends: [
|
extends: [
|
||||||
'mantine',
|
'mantine',
|
||||||
'plugin:@next/next/recommended',
|
'plugin:@next/next/recommended',
|
||||||
'plugin:jest/recommended',
|
|
||||||
'eslint:recommended',
|
'eslint:recommended',
|
||||||
'plugin:@typescript-eslint/eslint-recommended',
|
'plugin:@typescript-eslint/eslint-recommended',
|
||||||
'plugin:@typescript-eslint/recommended',
|
'plugin:@typescript-eslint/recommended',
|
||||||
|
'plugin:vitest/recommended',
|
||||||
],
|
],
|
||||||
plugins: ['testing-library', 'jest', 'react-hooks', 'react', 'unused-imports'],
|
plugins: ['testing-library', 'react-hooks', 'react', 'unused-imports', 'vitest'],
|
||||||
overrides: [
|
overrides: [
|
||||||
{
|
{
|
||||||
files: ['**/?(*.)+(spec|test).[jt]s?(x)'],
|
files: ['**/?(*.)+(spec|test).[jt]s?(x)'],
|
||||||
@@ -31,5 +31,11 @@ module.exports = {
|
|||||||
'@typescript-eslint/no-non-null-assertion': 'off',
|
'@typescript-eslint/no-non-null-assertion': 'off',
|
||||||
'no-continue': 'off',
|
'no-continue': 'off',
|
||||||
'linebreak-style': 0,
|
'linebreak-style': 0,
|
||||||
|
'vitest/max-nested-describe': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
max: 3,
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
// https://www.i18next.com/overview/configuration-options#logging
|
|
||||||
i18n: {
|
i18n: {
|
||||||
defaultLocale: 'en',
|
defaultLocale: 'en',
|
||||||
locales: [
|
locales: [
|
||||||
@@ -28,12 +27,12 @@ module.exports = {
|
|||||||
'sk',
|
'sk',
|
||||||
'no',
|
'no',
|
||||||
],
|
],
|
||||||
localePath: path.resolve('./public/locales'),
|
|
||||||
fallbackLng: 'en',
|
|
||||||
localeDetection: true,
|
localeDetection: true,
|
||||||
returnEmptyString: false,
|
|
||||||
debug: false,
|
|
||||||
appendNamespaceToCIMode: true,
|
|
||||||
reloadOnPrerender: process.env.NODE_ENV === 'development',
|
|
||||||
},
|
},
|
||||||
|
returnEmptyString: false,
|
||||||
|
appendNamespaceToCIMode: true,
|
||||||
|
reloadOnPrerender: process.env.NODE_ENV === 'development',
|
||||||
|
fallbackLng: 'en',
|
||||||
|
localePath: path.resolve('./public/locales'),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,5 +10,5 @@ module.exports = withBundleAnalyzer({
|
|||||||
},
|
},
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
output: 'standalone',
|
output: 'standalone',
|
||||||
i18n,
|
i18n: i18n,
|
||||||
});
|
});
|
||||||
|
|||||||
14
package.json
14
package.json
@@ -9,20 +9,17 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
"build": "next build",
|
"build": "vitest run && next build",
|
||||||
"analyze": "ANALYZE=true next build",
|
"analyze": "vitest run && ANALYZE=true next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"typecheck": "tsc --noEmit",
|
"typecheck": "tsc --noEmit",
|
||||||
"export": "next build && next export",
|
"export": "vitest run && next build && next export",
|
||||||
"lint": "next lint",
|
"lint": "next lint",
|
||||||
"jest": "jest",
|
|
||||||
"jest:watch": "jest --watch",
|
|
||||||
"prettier:check": "prettier --check \"**/*.{ts,tsx}\"",
|
"prettier:check": "prettier --check \"**/*.{ts,tsx}\"",
|
||||||
"prettier:write": "prettier --write \"**/*.{ts,tsx}\"",
|
"prettier:write": "prettier --write \"**/*.{ts,tsx}\"",
|
||||||
"test": "vitest",
|
"test": "vitest",
|
||||||
"test:ui": "vitest --ui",
|
"test:ui": "vitest --ui",
|
||||||
"test:run": "vitest run",
|
"test:run": "vitest run"
|
||||||
"ci": "yarn test && yarn lint --fix && yarn typecheck && yarn prettier:write"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ctrl/deluge": "^4.1.0",
|
"@ctrl/deluge": "^4.1.0",
|
||||||
@@ -88,13 +85,12 @@
|
|||||||
"eslint-config-airbnb-typescript": "^17.0.0",
|
"eslint-config-airbnb-typescript": "^17.0.0",
|
||||||
"eslint-config-mantine": "^2.0.0",
|
"eslint-config-mantine": "^2.0.0",
|
||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
"eslint-plugin-jest": "^26.6.0",
|
|
||||||
"eslint-plugin-jsx-a11y": "^6.6.1",
|
"eslint-plugin-jsx-a11y": "^6.6.1",
|
||||||
"eslint-plugin-react": "^7.30.1",
|
"eslint-plugin-react": "^7.30.1",
|
||||||
"eslint-plugin-react-hooks": "^4.6.0",
|
"eslint-plugin-react-hooks": "^4.6.0",
|
||||||
"eslint-plugin-testing-library": "^5.5.1",
|
"eslint-plugin-testing-library": "^5.5.1",
|
||||||
"eslint-plugin-unused-imports": "^2.0.0",
|
"eslint-plugin-unused-imports": "^2.0.0",
|
||||||
"jest": "^28.1.3",
|
"eslint-plugin-vitest": "^0.0.54",
|
||||||
"jsdom": "^21.1.1",
|
"jsdom": "^21.1.1",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^2.7.1",
|
||||||
"sass": "^1.56.1",
|
"sass": "^1.56.1",
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ import { useState } from 'react';
|
|||||||
import { TFunction } from 'react-i18next';
|
import { TFunction } from 'react-i18next';
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
import { useConfigContext } from '../../config/provider';
|
import { useConfigContext } from '../../config/provider';
|
||||||
import { tryMatchService } from '../../tools/addToHomarr';
|
|
||||||
import { openContextModalGeneric } from '../../tools/mantineModalManagerExtensions';
|
import { openContextModalGeneric } from '../../tools/mantineModalManagerExtensions';
|
||||||
|
import { MatchingImages, ServiceType, tryMatchPort } from '../../tools/types';
|
||||||
import { AppType } from '../../types/app';
|
import { AppType } from '../../types/app';
|
||||||
|
|
||||||
let t: TFunction<'modules/docker', undefined>;
|
let t: TFunction<'modules/docker', undefined>;
|
||||||
@@ -206,3 +206,28 @@ export default function ContainerActionBar({ selected, reload }: ContainerAction
|
|||||||
</Group>
|
</Group>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function tryMatchType(imageName: string): ServiceType {
|
||||||
|
const match = MatchingImages.find(({ image }) => imageName.includes(image));
|
||||||
|
if (match) {
|
||||||
|
return match.type;
|
||||||
|
}
|
||||||
|
// TODO: Remove this legacy code
|
||||||
|
return 'Other';
|
||||||
|
}
|
||||||
|
|
||||||
|
const tryMatchService = (container: Dockerode.ContainerInfo | undefined) => {
|
||||||
|
if (container === undefined) return {};
|
||||||
|
const name = container.Names[0].substring(1);
|
||||||
|
const type = tryMatchType(container.Image);
|
||||||
|
const port = tryMatchPort(type.toLowerCase())?.value ?? container.Ports[0]?.PublicPort;
|
||||||
|
return {
|
||||||
|
name,
|
||||||
|
id: container.Id,
|
||||||
|
type: tryMatchType(container.Image),
|
||||||
|
url: `localhost${port ? `:${port}` : ''}`,
|
||||||
|
icon: `https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons/png/${name
|
||||||
|
.replace(/\s+/g, '-')
|
||||||
|
.toLowerCase()}.png`,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|||||||
@@ -9,8 +9,9 @@ import {
|
|||||||
} from '@mantine/core';
|
} from '@mantine/core';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
|
import { GetServerSidePropsContext } from 'next';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
|
import { getServerSideTranslations } from '../tools/server/getServerSideTranslations';
|
||||||
|
|
||||||
const useStyles = createStyles((theme) => ({
|
const useStyles = createStyles((theme) => ({
|
||||||
root: {
|
root: {
|
||||||
@@ -94,12 +95,11 @@ export default function Custom404() {
|
|||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
export async function getStaticProps({ req, res, locale }: GetServerSidePropsContext) {
|
||||||
export async function getStaticProps({ locale }: { locale: string }) {
|
const translations = await getServerSideTranslations(['common'], locale, undefined, undefined);
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
...(await serverSideTranslations(locale, ['common'])),
|
...translations,
|
||||||
// Will be passed to the page component as props
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export async function getServerSideProps({
|
|||||||
const configPath = path.join(process.cwd(), 'data/configs', `${configName}.json`);
|
const configPath = path.join(process.cwd(), 'data/configs', `${configName}.json`);
|
||||||
const configExists = fs.existsSync(configPath);
|
const configExists = fs.existsSync(configPath);
|
||||||
|
|
||||||
const translations = await getServerSideTranslations(req, res, dashboardNamespaces, locale);
|
const translations = await getServerSideTranslations(dashboardNamespaces, locale, req, res);
|
||||||
|
|
||||||
if (!configExists) {
|
if (!configExists) {
|
||||||
// Redirect to 404
|
// Redirect to 404
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export async function getServerSideProps({
|
|||||||
configName = 'default';
|
configName = 'default';
|
||||||
}
|
}
|
||||||
|
|
||||||
const translations = await getServerSideTranslations(req, res, dashboardNamespaces, locale);
|
const translations = await getServerSideTranslations(dashboardNamespaces, locale, req, res);
|
||||||
const config = getFrontendConfig(configName as string);
|
const config = getFrontendConfig(configName as string);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -3,17 +3,22 @@ import { IncomingMessage, ServerResponse } from 'http';
|
|||||||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
|
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
|
||||||
|
|
||||||
export const getServerSideTranslations = async (
|
export const getServerSideTranslations = async (
|
||||||
req: IncomingMessage,
|
|
||||||
res: ServerResponse,
|
|
||||||
namespaces: string[],
|
namespaces: string[],
|
||||||
requestLocale?: string
|
requestLocale?: string,
|
||||||
|
req?: IncomingMessage,
|
||||||
|
res?: ServerResponse,
|
||||||
) => {
|
) => {
|
||||||
|
if (!req || !res) {
|
||||||
|
return await serverSideTranslations(
|
||||||
|
requestLocale ?? 'en',
|
||||||
|
namespaces
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const configLocale = getCookie('config-locale', { req, res });
|
const configLocale = getCookie('config-locale', { req, res });
|
||||||
|
|
||||||
const translations = await serverSideTranslations(
|
return await serverSideTranslations(
|
||||||
(configLocale ?? requestLocale ?? 'en') as string,
|
(configLocale ?? requestLocale ?? 'en') as string,
|
||||||
namespaces
|
namespaces
|
||||||
);
|
);
|
||||||
|
|
||||||
return translations;
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user