mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
Align lint and type-check configuration
This commit is contained in:
+17
-2
@@ -1,14 +1,29 @@
|
||||
import { sleep } from './common'
|
||||
import { logger } from './logger'
|
||||
import { PrismaClient as NowClient } from '../../prisma/generated/now_test_client'
|
||||
import { PrismaClient as LogClient } from '../../prisma/generated/now_log_test_client'
|
||||
import { PrismaClient as LogClient } from '../../prisma/generated/now_log_test_client/default'
|
||||
import mariadb from 'mariadb'
|
||||
import { MARIADB_HOST, MARIADB_PASSWORD, DB_CONNECTION_LIMIT, MARIADB_USER, RUNNING_ENV } from './config'
|
||||
|
||||
import { readFile } from 'fs/promises'
|
||||
import { PathLike } from 'fs'
|
||||
|
||||
export const logDb = new LogClient()
|
||||
type LogRecord = Record<string, unknown> & {
|
||||
luid?: number
|
||||
suid?: number
|
||||
buid?: number
|
||||
tuid?: number
|
||||
}
|
||||
|
||||
type LogModel = {
|
||||
findMany: (...args: unknown[]) => Promise<LogRecord[]>
|
||||
findFirst: (...args: unknown[]) => Promise<LogRecord | null>
|
||||
fields: Record<string, unknown>
|
||||
}
|
||||
|
||||
type LogPrismaClient = LogClient & { log: LogModel }
|
||||
|
||||
export const logDb = new LogClient() as unknown as LogPrismaClient
|
||||
export const nowDb = new NowClient()
|
||||
|
||||
export const getCrossSearchFields = () => {
|
||||
|
||||
@@ -4,13 +4,20 @@
|
||||
"outDir": "./build/",
|
||||
"module": "CommonJS",
|
||||
"moduleResolution": "node",
|
||||
"baseUrl": ".",
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"esModuleInterop": true,
|
||||
"noImplicitAny": true
|
||||
"noImplicitAny": true,
|
||||
"resolveJsonModule": true,
|
||||
"skipLibCheck": true,
|
||||
"types": ["node"],
|
||||
"paths": {
|
||||
"../../prisma/generated/now_log_test_client": ["./prisma/generated/now_log_test_client/default.ts"]
|
||||
}
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
|
||||
+26
-7
@@ -1,28 +1,47 @@
|
||||
import globals from 'globals'
|
||||
import jsPlugin from '@eslint/js'
|
||||
import cypressPlugin from 'eslint-plugin-cypress/flat'
|
||||
import prettierPlugin from 'eslint-plugin-prettier/recommended'
|
||||
import mochaPlugin from 'eslint-plugin-mocha'
|
||||
|
||||
// NOTE: This config is only used for running ESLint on the Cypress tests. Frontend and backend use their own configs.
|
||||
|
||||
const mochaRecommended = mochaPlugin.configs.flat.recommended
|
||||
const cypressRecommended = cypressPlugin.configs.recommended
|
||||
const mochaLanguageOptions = mochaRecommended.languageOptions ?? {}
|
||||
const cypressLanguageOptions = cypressRecommended.languageOptions ?? {}
|
||||
const mochaRules = mochaRecommended.rules ?? {}
|
||||
const cypressRules = cypressRecommended.rules ?? {}
|
||||
|
||||
/** @type {import('eslint').Linter.Config[]} */
|
||||
export default [
|
||||
mochaPlugin.configs.flat.recommended,
|
||||
cypressPlugin.configs.recommended,
|
||||
|
||||
{
|
||||
files: ['cypress/**/*.{cy,spec}.{js,ts,tsx}'],
|
||||
...mochaRecommended,
|
||||
...cypressRecommended,
|
||||
rules: {
|
||||
...jsPlugin.configs.recommended.rules,
|
||||
...mochaRules,
|
||||
...cypressRules,
|
||||
'mocha/no-mocha-arrows': 'off',
|
||||
'mocha/no-skipped-tests': 'off',
|
||||
'mocha/max-top-level-suites': 'off',
|
||||
'mocha/no-top-level-hooks': 'off',
|
||||
'mocha/no-sibling-hooks': 'off',
|
||||
},
|
||||
|
||||
languageOptions: {
|
||||
globals: globals.browser,
|
||||
...mochaLanguageOptions,
|
||||
...cypressLanguageOptions,
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.node,
|
||||
},
|
||||
parserOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
mocha: mochaPlugin,
|
||||
cypress: cypressPlugin,
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitAny": true,
|
||||
"baseUrl": ".",
|
||||
"types": ["node", "jest"],
|
||||
"types": ["vite/client", "jest", "node"],
|
||||
"paths": {
|
||||
"@/*": ["./src/*"],
|
||||
"@components/*": ["./src/components/*"],
|
||||
@@ -30,8 +30,8 @@
|
||||
"@shared/*": ["../shared/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src", "tests"],
|
||||
"exclude": ["../backend/**/*", "./src/country_data/**"],
|
||||
"include": ["src", "tests", "vite.config.ts", "jest.config.ts"],
|
||||
"exclude": ["../backend/**/*", "./src/country_data/**", "node_modules", "dist"],
|
||||
|
||||
"references": [{ "path": "./tsconfig.node.json" }]
|
||||
}
|
||||
|
||||
+10
-4
@@ -12,11 +12,17 @@
|
||||
"dev": "docker compose -f docker-compose.dev.yml up",
|
||||
"dev:down": "docker compose -f docker-compose.dev.yml down -v",
|
||||
"anon:down": "docker compose -f docker-compose.anon.yml down -v",
|
||||
"check": "echo \"Running checks for both services and cypress tests...\" && npm run check:frontend && npm run check:backend && npm run check:cypress && echo \"All good! :)\"",
|
||||
"check:backend": "echo \"Running backend tsc ...\" && cd backend && npx tsc --noEmit && echo \"Running backend eslint ...\"&& npm run lint",
|
||||
"check:frontend": "echo \"Running frontend tsc ...\" && cd frontend && npx tsc --noEmit && echo \"Running frontend eslint ...\" && npm run lint",
|
||||
"check:cypress": "echo \"Running cypress eslint ...\" && npm run lint:cypress",
|
||||
"check": "echo \"Running checks for both services and cypress tests...\" && npm run tsc && npm run lint && echo \"All good! :)\"",
|
||||
"check:backend": "npm run tsc:backend && npm run lint:backend",
|
||||
"check:frontend": "npm run tsc:frontend && npm run lint:frontend",
|
||||
"check:cypress": "npm run lint:cypress",
|
||||
"lint": "npm run lint:backend && npm run lint:frontend && npm run lint:cypress",
|
||||
"lint:backend": "cd backend && npm run lint",
|
||||
"lint:frontend": "cd frontend && npm run lint",
|
||||
"lint:cypress": "eslint --report-unused-disable-directives --max-warnings 0 cypress/e2e/**.cy.js",
|
||||
"tsc": "npm run tsc:backend && npm run tsc:frontend",
|
||||
"tsc:backend": "cd backend && npx tsc --noEmit",
|
||||
"tsc:frontend": "cd frontend && npx tsc --noEmit",
|
||||
"test:backend": "npm run test:unit:backend && npm run test:api",
|
||||
"test:api": "npm run test:api:build && npm run test:api:run",
|
||||
"test:api:build": "docker build -t nowdb-api-tests . -f backend/dev.Dockerfile --target api-tests",
|
||||
|
||||
Reference in New Issue
Block a user