mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
work on lint, stylelint
This commit is contained in:
parent
81d88bb189
commit
97d41fc0b0
@ -80,17 +80,5 @@
|
||||
/* Advanced Options */
|
||||
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
||||
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
"path": "../database/tsconfig.json"
|
||||
// add 'prepend' if you want to include the referenced project in your output file
|
||||
// "prepend": true
|
||||
},
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"test",
|
||||
"**/*.test.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,22 +1,22 @@
|
||||
import Joi from 'joi'
|
||||
|
||||
export const browserUrls = Joi.array()
|
||||
.items(Joi.string().uri())
|
||||
.items(Joi.string().uri())
|
||||
.sparse(true)
|
||||
.custom((value: string[], helpers: Joi.CustomHelpers<string[]>) => {
|
||||
let protocol: string | undefined
|
||||
for (const url of value) {
|
||||
if (url === undefined) {
|
||||
continue
|
||||
if (url === undefined) {
|
||||
continue
|
||||
}
|
||||
const urlObject = new URL(url)
|
||||
if(!protocol) {
|
||||
if (!protocol) {
|
||||
protocol = urlObject.protocol
|
||||
} else if(urlObject.protocol !== protocol) {
|
||||
} else if (urlObject.protocol !== protocol) {
|
||||
return helpers.error('any.invalid')
|
||||
}
|
||||
}
|
||||
return value;
|
||||
return value
|
||||
})
|
||||
.required()
|
||||
.description('All URLs need to have same protocol to prevent mixed block errors')
|
||||
@ -29,8 +29,12 @@ export const DECAY_START_TIME = Joi.date()
|
||||
|
||||
export const DB_VERSION = Joi.string()
|
||||
.pattern(/^\d{4}-[a-z0-9-_]+$/)
|
||||
.message('DB_VERSION must be in the format: YYYY-description, e.g. "0087-add_index_on_user_roles".')
|
||||
.description('db version string, last migration file name without ending or last folder in entity')
|
||||
.message(
|
||||
'DB_VERSION must be in the format: YYYY-description, e.g. "0087-add_index_on_user_roles".',
|
||||
)
|
||||
.description(
|
||||
'db version string, last migration file name without ending or last folder in entity',
|
||||
)
|
||||
.required()
|
||||
|
||||
export const COMMUNITY_URL = Joi.string()
|
||||
@ -39,9 +43,11 @@ export const COMMUNITY_URL = Joi.string()
|
||||
if (value.endsWith('/')) {
|
||||
return helpers.error('any.invalid', { message: 'URL should not end with a slash (/)' })
|
||||
}
|
||||
return value;
|
||||
return value
|
||||
})
|
||||
.description('The base URL of the community, should have the same protocol as frontend, admin and backend api to prevent mixed contend issues.')
|
||||
.description(
|
||||
'The base URL of the community, should have the same protocol as frontend, admin and backend api to prevent mixed contend issues.',
|
||||
)
|
||||
.default('http://0.0.0.0')
|
||||
.required()
|
||||
|
||||
@ -62,7 +68,7 @@ export const COMMUNITY_NAME = Joi.string()
|
||||
.max(40)
|
||||
.description('The name of the community')
|
||||
.default('Gradido Entwicklung')
|
||||
.required()
|
||||
.required()
|
||||
|
||||
export const COMMUNITY_DESCRIPTION = Joi.string()
|
||||
.min(10)
|
||||
@ -82,19 +88,19 @@ export const COMMUNITY_LOCATION = Joi.string()
|
||||
.when('GMS_ACTIVE', {
|
||||
is: true,
|
||||
then: Joi.string().required(),
|
||||
otherwise: Joi.string().optional()
|
||||
otherwise: Joi.string().optional(),
|
||||
})
|
||||
.description('Geographical location of the community in "latitude, longitude" format')
|
||||
.default('49.280377, 9.690151')
|
||||
|
||||
.default('49.280377, 9.690151')
|
||||
|
||||
export const GRAPHIQL = Joi.boolean()
|
||||
.description('Flag for enabling GraphQL playground for debugging.')
|
||||
.default(false)
|
||||
.when('NODE_ENV', {
|
||||
is: 'development',
|
||||
then: Joi.boolean().valid(true, false).required(), // only allow true in development mode
|
||||
otherwise: Joi.boolean().valid(false).required() // false in any other mode
|
||||
})
|
||||
.description('Flag for enabling GraphQL playground for debugging.')
|
||||
.default(false)
|
||||
.when('NODE_ENV', {
|
||||
is: 'development',
|
||||
then: Joi.boolean().valid(true, false).required(), // only allow true in development mode
|
||||
otherwise: Joi.boolean().valid(false).required(), // false in any other mode
|
||||
})
|
||||
|
||||
export const GMS_ACTIVE = Joi.boolean()
|
||||
.description('Flag to indicate if the GMS (Geographic Member Search) service is used.')
|
||||
@ -123,20 +129,20 @@ export const HUMHUB_API_URL = Joi.string()
|
||||
.description('The API URL for HumHub integration')
|
||||
|
||||
export const LOG_LEVEL = Joi.string()
|
||||
.valid('all', 'mark', 'trace', 'debug', 'info', 'warn', 'error', 'fatal', 'off')
|
||||
.valid('all', 'mark', 'trace', 'debug', 'info', 'warn', 'error', 'fatal', 'off')
|
||||
.description('set log level')
|
||||
.default('info')
|
||||
.required()
|
||||
|
||||
export const LOG4JS_CONFIG = Joi.string()
|
||||
.pattern(/^[a-zA-Z0-9-_]+\.json$/)
|
||||
.pattern(/^[a-zA-Z0-9-_]+\.json$/)
|
||||
.message('LOG4JS_CONFIG must be a valid filename ending with .json')
|
||||
.description('config file name for log4js config file')
|
||||
.default('log4js-config.json')
|
||||
.required()
|
||||
|
||||
export const LOGIN_APP_SECRET = Joi.string()
|
||||
.pattern(/^[a-fA-F0-9]+$/)
|
||||
.pattern(/^[a-fA-F0-9]+$/)
|
||||
.message('need to be valid hex')
|
||||
.default('21ffbbc616fe')
|
||||
.description('App secret for salt component for libsodium crypto_pwhash')
|
||||
@ -147,7 +153,9 @@ export const LOGIN_SERVER_KEY = Joi.string()
|
||||
.length(32)
|
||||
.message('need to be valid hex and 32 character')
|
||||
.default('a51ef8ac7ef1abf162fb7a65261acd7a')
|
||||
.description('Server key for password hashing as additional salt for libsodium crypto_shorthash_keygen')
|
||||
.description(
|
||||
'Server key for password hashing as additional salt for libsodium crypto_shorthash_keygen',
|
||||
)
|
||||
.required()
|
||||
|
||||
export const OPENAI_ACTIVE = Joi.boolean()
|
||||
@ -156,7 +164,7 @@ export const OPENAI_ACTIVE = Joi.boolean()
|
||||
.required()
|
||||
|
||||
export const TYPEORM_LOGGING_RELATIVE_PATH = Joi.string()
|
||||
.pattern(new RegExp('^[a-zA-Z0-9-_\./]+\.log$'))
|
||||
.pattern(/^[a-zA-Z0-9-_\.\/]+\.log$/)
|
||||
.message('TYPEORM_LOGGING_RELATIVE_PATH must be a valid filename ending with .log')
|
||||
.description('log file name for logging typeorm activities')
|
||||
.default('typeorm.log')
|
||||
@ -168,7 +176,7 @@ export const DB_HOST = Joi.string()
|
||||
.description("database host like 'localhost' or 'mariadb' in docker setup")
|
||||
.default('localhost')
|
||||
.required()
|
||||
|
||||
|
||||
export const DB_PORT = Joi.number()
|
||||
.integer()
|
||||
.min(1024)
|
||||
@ -179,10 +187,10 @@ export const DB_PORT = Joi.number()
|
||||
|
||||
export const DB_USER = Joi.string()
|
||||
.pattern(/^[A-Za-z0-9]([A-Za-z0-9-_\.]*[A-Za-z0-9])?$/) // Validates MariaDB username rules
|
||||
.min(1) // Minimum length 1
|
||||
.min(1) // Minimum length 1
|
||||
.max(16) // Maximum length 16
|
||||
.message(
|
||||
'Valid database username (letters, numbers, hyphens, underscores, dots allowed; no spaces, must not start or end with hyphen, dot, or underscore)'
|
||||
'Valid database username (letters, numbers, hyphens, underscores, dots allowed; no spaces, must not start or end with hyphen, dot, or underscore)',
|
||||
)
|
||||
.description('database username for mariadb')
|
||||
.default('root')
|
||||
@ -191,24 +199,26 @@ export const DB_USER = Joi.string()
|
||||
export const DB_PASSWORD = Joi.string()
|
||||
.when(Joi.ref('NODE_ENV'), {
|
||||
is: 'development',
|
||||
then: Joi.string().allow(''),
|
||||
then: Joi.string().allow(''),
|
||||
otherwise: Joi.string()
|
||||
.min(8)
|
||||
.min(8)
|
||||
.max(32)
|
||||
.pattern(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*(),.?":{}|<>]).+$/)
|
||||
.message(
|
||||
'Password must be between 8 and 32 characters long, and contain at least one uppercase letter, one lowercase letter, one number, and one special character (e.g., !@#$%^&*).'
|
||||
)
|
||||
'Password must be between 8 and 32 characters long, and contain at least one uppercase letter, one lowercase letter, one number, and one special character (e.g., !@#$%^&*).',
|
||||
),
|
||||
})
|
||||
.description(
|
||||
'Password for the database user. In development mode, an empty password is allowed. In other environments, a complex password is required.'
|
||||
'Password for the database user. In development mode, an empty password is allowed. In other environments, a complex password is required.',
|
||||
)
|
||||
.default('')
|
||||
.default('')
|
||||
.required()
|
||||
|
||||
export const DB_DATABASE = Joi.string()
|
||||
.pattern(/^[a-zA-Z][a-zA-Z0-9_-]{1,63}$/)
|
||||
.description('Database name like gradido_community (must start with a letter, and can only contain letters, numbers, underscores, or dashes)')
|
||||
.description(
|
||||
'Database name like gradido_community (must start with a letter, and can only contain letters, numbers, underscores, or dashes)',
|
||||
)
|
||||
.default('gradido_community')
|
||||
.required()
|
||||
|
||||
@ -221,13 +231,13 @@ export const APP_VERSION = Joi.string()
|
||||
export const BUILD_COMMIT = Joi.string()
|
||||
.pattern(/^[0-9a-f]{40}$/)
|
||||
.message('The commit hash must be a 40-character hexadecimal string.')
|
||||
.description('The full git commit hash.')
|
||||
.description('The full git commit hash.')
|
||||
.optional()
|
||||
|
||||
export const BUILD_COMMIT_SHORT = Joi.string()
|
||||
.pattern(/^[0-9a-f]{7}$/)
|
||||
.message('The first 7 hexadecimal character from git commit hash.')
|
||||
.description('A short version from the git commit hash.')
|
||||
.description('A short version from the git commit hash.')
|
||||
.required()
|
||||
|
||||
export const NODE_ENV = Joi.string()
|
||||
@ -236,11 +246,15 @@ export const NODE_ENV = Joi.string()
|
||||
.description('Specifies the environment in which the application is running.')
|
||||
|
||||
export const DEBUG = Joi.boolean()
|
||||
.description('Indicates whether the application is in debugging mode. Set to true when NODE_ENV is not "production".')
|
||||
.description(
|
||||
'Indicates whether the application is in debugging mode. Set to true when NODE_ENV is not "production".',
|
||||
)
|
||||
.default(false)
|
||||
.required()
|
||||
|
||||
|
||||
export const PRODUCTION = Joi.boolean()
|
||||
.default(false)
|
||||
.description('Indicates whether the application is running in production mode. Set to true when NODE_ENV is "production".')
|
||||
.description(
|
||||
'Indicates whether the application is running in production mode. Set to true when NODE_ENV is "production".',
|
||||
)
|
||||
.required()
|
||||
|
||||
@ -22,7 +22,9 @@ export function validate(schema: ObjectSchema, data: any) {
|
||||
? schema.describe().keys[key].flags.description
|
||||
: 'No description available'
|
||||
if (data[key] === undefined) {
|
||||
throw new Error(`Environment Variable '${key}' is missing. ${description}, details: ${details}`)
|
||||
throw new Error(
|
||||
`Environment Variable '${key}' is missing. ${description}, details: ${details}`,
|
||||
)
|
||||
} else {
|
||||
throw new Error(
|
||||
`Error on Environment Variable ${key} with value = ${value}: ${err.message}. ${description}`,
|
||||
@ -30,4 +32,4 @@ export function validate(schema: ObjectSchema, data: any) {
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ module.exports = {
|
||||
'import/no-nodejs-modules': 'off',
|
||||
'import/unambiguous': 'error',
|
||||
'import/default': 'error',
|
||||
'import/named': 'error',
|
||||
'import/named': 'off',
|
||||
'import/namespace': 'error',
|
||||
'import/no-absolute-path': 'error',
|
||||
'import/no-cycle': 'error',
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
"devDependencies": {
|
||||
"@eslint-community/eslint-plugin-eslint-comments": "^3.2.1",
|
||||
"@types/dotenv": "^8.2.0",
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/jest": "^27.0.2",
|
||||
"@types/joi": "^17.2.3",
|
||||
"@types/node": "^17.0.21",
|
||||
"@types/uuid": "^8.3.4",
|
||||
@ -42,12 +42,12 @@
|
||||
"eslint-config-standard": "^17.0.0",
|
||||
"eslint-import-resolver-typescript": "^3.5.4",
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
"eslint-plugin-jest": "^27.2.1",
|
||||
"eslint-plugin-jest": "^27.2.4",
|
||||
"eslint-plugin-n": "^15.7.0",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"eslint-plugin-promise": "^6.1.1",
|
||||
"eslint-plugin-security": "^1.7.1",
|
||||
"jest": "^29.5.14",
|
||||
"jest": "^27.2.4",
|
||||
"prettier": "^2.8.7",
|
||||
"ts-jest": "^27.0.5",
|
||||
"ts-node": "^10.9.2",
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
|
||||
import { Community as DbCommunity } from '@entity/Community'
|
||||
import { FederatedCommunity as DbFederatedCommunity } from '@entity/FederatedCommunity'
|
||||
import DHT from '@hyperswarm/dht'
|
||||
import { Community as DbCommunity, FederatedCommunity as DbFederatedCommunity } from 'database'
|
||||
import { validate as validateUUID, version as versionUUID } from 'uuid'
|
||||
|
||||
import { testEnvironment, cleanDB } from '@test/helpers'
|
||||
@ -249,7 +248,7 @@ describe('federation', () => {
|
||||
it('logs an error of unexpected data format and structure', () => {
|
||||
expect(logger.error).toBeCalledWith(
|
||||
'Error on receiving data from socket:',
|
||||
new SyntaxError('Unexpected token \'o\', "no-json string" is not valid JSON'),
|
||||
new SyntaxError('Unexpected token o in JSON at position 1'),
|
||||
)
|
||||
})
|
||||
})
|
||||
@ -291,7 +290,7 @@ describe('federation', () => {
|
||||
it('logs an error of unexpected data format and structure', () => {
|
||||
expect(logger.error).toBeCalledWith(
|
||||
'Error on receiving data from socket:',
|
||||
new SyntaxError('Unexpected token \'i\', "invalid ty"... is not valid JSON'),
|
||||
new SyntaxError('Unexpected token i in JSON at position 0'),
|
||||
)
|
||||
})
|
||||
})
|
||||
@ -315,7 +314,7 @@ describe('federation', () => {
|
||||
it('logs an error of unexpected data format and structure', () => {
|
||||
expect(logger.error).toBeCalledWith(
|
||||
'Error on receiving data from socket:',
|
||||
new SyntaxError('Unexpected token \'a\', "api,url,in"... is not valid JSON'),
|
||||
new SyntaxError('Unexpected token a in JSON at position 0'),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@ -1,7 +1,11 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
import { Community as DbCommunity, CommunityLoggingView, FederatedCommunity as DbFederatedCommunity } from 'database'
|
||||
import DHT from '@hyperswarm/dht'
|
||||
import {
|
||||
Community as DbCommunity,
|
||||
CommunityLoggingView,
|
||||
FederatedCommunity as DbFederatedCommunity,
|
||||
} from 'database'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
|
||||
import { CONFIG } from '@/config'
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// TODO This is super weird - since the entities are defined in another project they have their own globals.
|
||||
// We cannot use our connection here, but must use the external typeorm installation
|
||||
import { Connection, createConnection, FileLogger } from 'typeorm'
|
||||
import { entities } from 'database'
|
||||
import { Connection, createConnection, FileLogger } from 'typeorm'
|
||||
|
||||
import { CONFIG } from '@/config'
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
import { entities } from '@entity/index'
|
||||
import { entities } from 'database'
|
||||
|
||||
import { CONFIG } from '@/config'
|
||||
import { connection } from '@/typeorm/connection'
|
||||
|
||||
@ -71,10 +71,5 @@
|
||||
/* Advanced Options */
|
||||
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
||||
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"test",
|
||||
"**/*.test.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"extends": ["//"],
|
||||
"tasks": {
|
||||
"test": {
|
||||
"dependsOn": ["database#build", "config-schema#build", "database#up:dht_test"]
|
||||
"dependsOn": ["database#build", "config-schema#build", "database#up"]
|
||||
},
|
||||
"dev": {
|
||||
"dependsOn": ["database#up"]
|
||||
|
||||
@ -80,10 +80,5 @@
|
||||
/* Advanced Options */
|
||||
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
||||
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"test",
|
||||
"**/*.test.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
14
yarn.lock
14
yarn.lock
@ -2336,6 +2336,14 @@
|
||||
dependencies:
|
||||
"@types/istanbul-lib-report" "*"
|
||||
|
||||
"@types/jest@^27.0.2":
|
||||
version "27.5.2"
|
||||
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-27.5.2.tgz#ec49d29d926500ffb9fd22b84262e862049c026c"
|
||||
integrity sha512-mpT8LJJ4CMeeahobofYWIjFo0xonRS/HfxnVEPMPFSQdGUt1uHCnoPT7Zhb+sjDU2wz0oKV0OLUR0WzrHNgfeA==
|
||||
dependencies:
|
||||
jest-matcher-utils "^27.0.0"
|
||||
pretty-format "^27.0.0"
|
||||
|
||||
"@types/jest@^29.5.14":
|
||||
version "29.5.14"
|
||||
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-29.5.14.tgz#2b910912fa1d6856cadcd0c1f95af7df1d6049e5"
|
||||
@ -5735,7 +5743,7 @@ eslint-plugin-import@^2.25.2, eslint-plugin-import@^2.27.5:
|
||||
string.prototype.trimend "^1.0.8"
|
||||
tsconfig-paths "^3.15.0"
|
||||
|
||||
eslint-plugin-jest@^27.2.1:
|
||||
eslint-plugin-jest@^27.2.1, eslint-plugin-jest@^27.2.4:
|
||||
version "27.9.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-27.9.0.tgz#7c98a33605e1d8b8442ace092b60e9919730000b"
|
||||
integrity sha512-QIT7FH7fNmd9n4se7FFKHbsLKGQiw885Ds6Y/sxKgCZ6natwCsXdgPOADnYVxN2QrRweF0FZWbJ6S7Rsn7llug==
|
||||
@ -7947,7 +7955,7 @@ jest-leak-detector@^29.7.0:
|
||||
jest-get-type "^29.6.3"
|
||||
pretty-format "^29.7.0"
|
||||
|
||||
jest-matcher-utils@^27.5.1:
|
||||
jest-matcher-utils@^27.0.0, jest-matcher-utils@^27.5.1:
|
||||
version "27.5.1"
|
||||
resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-27.5.1.tgz#9c0cdbda8245bc22d2331729d1091308b40cf8ab"
|
||||
integrity sha512-z2uTx/T6LBaCoNWNFWwChLBKYxTMcGBRjAt+2SbP929/Fflb9aa5LGma654Rz8z9HLxsrUaYzxE9T/EFIL/PAw==
|
||||
@ -9915,7 +9923,7 @@ prettier@^3.5.3:
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.5.3.tgz#4fc2ce0d657e7a02e602549f053b239cb7dfe1b5"
|
||||
integrity sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==
|
||||
|
||||
pretty-format@^27.5.1:
|
||||
pretty-format@^27.0.0, pretty-format@^27.5.1:
|
||||
version "27.5.1"
|
||||
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-27.5.1.tgz#2181879fdea51a7a5851fb39d920faa63f01d88e"
|
||||
integrity sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user