Skip to content

Commit

Permalink
Merge pull request #429 from espoon-voltti/dependabot/npm_and_yarn/ap…
Browse files Browse the repository at this point in the history
…i-gateway/lint-29cfe9f3cb

Bump the lint group across 1 directory with 3 updates
  • Loading branch information
juhenius authored Nov 28, 2024
2 parents efa52b7 + a9003cd commit 6cd1470
Show file tree
Hide file tree
Showing 9 changed files with 458 additions and 319 deletions.
1 change: 1 addition & 0 deletions api-gateway/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
!src
!*.json
!*.lock
!*.mjs
!.yarn
!.yarnrc.yml
!config
Expand Down
79 changes: 79 additions & 0 deletions api-gateway/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// SPDX-FileCopyrightText: 2017-2024 City of Espoo
//
// SPDX-License-Identifier: LGPL-2.1-or-later

import eslint from '@eslint/js'
import tsParser from '@typescript-eslint/parser'
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
import globals from 'globals'
import typescriptEslint from 'typescript-eslint'

export default [
{ ignores: ['.yarn', 'dist', 'eslint.config.mjs'] },
eslint.configs.recommended,
...typescriptEslint.configs.recommended,
...typescriptEslint.configs.stylisticTypeChecked,
{
languageOptions: {
parser: tsParser,
ecmaVersion: 2018,
sourceType: 'module',
parserOptions: {
projectService: true,
project: './tsconfig.json',
tsconfigRootDir: import.meta.dirname,
globals: globals.node,
ecmaFeatures: {
modules: true
}
}
}
},
{
files: ['**/*.ts'],
rules: {
'@typescript-eslint/no-unused-vars': [
'warn',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^.*',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true
}
]
}
},
{
files: ['**/*.{ts,js,mjs}'],
rules: {
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/no-empty-object-type': [
'error',
{ allowInterfaces: 'always' }
],
'@typescript-eslint/no-misused-promises': [
'error',
{ checksVoidReturn: false }
],
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/prefer-optional-chain': 'off',
'@typescript-eslint/prefer-promise-reject-errors': 'off'
}
},
{
files: ['**/*.{js,mjs}'],
rules: {
'@typescript-eslint/no-var-requires': 'off'
}
},
{
files: ['**/*.js'],
rules: {
'@typescript-eslint/no-require-imports': 'off'
}
},
eslintPluginPrettierRecommended
]
40 changes: 6 additions & 34 deletions api-gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"clean": "rm -rf ./build ./dist",
"build": "yarn clean && yarn install && tsc --build .",
"lint": "eslint --ext .ts,.tsx --max-warnings 0 .",
"lint": "eslint --max-warnings 0 .",
"dev": "tsc --build . && concurrently --prefix '[{name}]' --names 'tsc,nodemon' 'tsc --build --preserveWatchOutput -w .' 'NODE_ENV=local nodemon dist/index.js'"
},
"dependencies": {
Expand Down Expand Up @@ -48,16 +48,17 @@
"@types/passport-strategy": "^0.2.38",
"@types/redis": "^4.0.11",
"@types/source-map-support": "^0.5.10",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"@typescript-eslint/eslint-plugin": "^8.15.0",
"@typescript-eslint/parser": "^8.15.0",
"concurrently": "^9.1.0",
"eslint": "^8.57.1",
"eslint": "^9.15.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"nodemon": "^3.1.7",
"prettier": "^3.3.3",
"ts-node": "^10.9.2",
"typescript": "^5.7.2"
"typescript": "^5.7.2",
"typescript-eslint": "^8.16.0"
},
"resolutions": {
"@types/mime": "3.0.4"
Expand All @@ -69,35 +70,6 @@
"singleQuote": true,
"trailingComma": "none"
},
"eslintConfig": {
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/stylistic",
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module",
"project": "./tsconfig.json",
"ecmaFeatures": {
"modules": true
}
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"@typescript-eslint/no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}
]
}
},
"engines": {
"node": ">= 20.11.0"
},
Expand Down
2 changes: 1 addition & 1 deletion api-gateway/src/auth/saml/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export function createAdSamlStrategy(
}
}

const loginVerify: VerifyWithRequest = (req, profile, done) => {
const loginVerify: VerifyWithRequest = (_req, profile, done) => {
if (!profile) return done(null, undefined)
const parseResult = Profile.safeParse(profile)
if (!parseResult.success) {
Expand Down
9 changes: 6 additions & 3 deletions api-gateway/src/clients/service-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
//
// SPDX-License-Identifier: LGPL-2.1-or-later

import express from 'express'
import axios from 'axios'
import { createAuthHeader, AppSessionUser } from '../auth/index.js'
import express from 'express'

import { AppSessionUser, createAuthHeader } from '../auth/index.js'
import { serviceUrl } from '../config.js'

export const client = axios.create({
Expand All @@ -17,7 +18,9 @@ const systemUser: AppSessionUser = {

export type ServiceRequestHeader = 'Authorization' | 'X-Request-ID'

export type ServiceRequestHeaders = { [H in ServiceRequestHeader]?: string }
export type ServiceRequestHeaders = Partial<
Record<ServiceRequestHeader, string>
>

export function createServiceRequestHeaders(
req: express.Request | undefined,
Expand Down
2 changes: 1 addition & 1 deletion api-gateway/src/logging/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const logDebug: LogFn = (msg, req?, meta?) =>
function log(
level: LogLevel,
msg: string,
req?: Request,
_req?: Request,
meta?: LogMeta,
err?: Error
): void {
Expand Down
3 changes: 1 addition & 2 deletions api-gateway/src/utils/express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ declare global {
spanId?: string
samlLogoutRequest: passportSaml.Profile
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface User extends AppSessionUser {}
}
}
Expand All @@ -80,7 +79,7 @@ declare global {
// * `req.secure`: is original request https (true)
export function trustReverseProxy(app: express.Application) {
app.set('trust proxy', 3) // private ALB, proxy nginx, public ALB
app.use((req, res, next) => {
app.use((req, _res, next) => {
if ('x-original-forwarded-proto' in req.headers) {
req.headers['x-forwarded-proto'] =
req.headers['x-original-forwarded-proto']
Expand Down
1 change: 0 additions & 1 deletion api-gateway/src/utils/promise-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export function fromCallback<T>(
f: (cb: (err: any, result?: T) => void) => void
): Promise<T> {
return new Promise<T>((resolve, reject) =>
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
f((err, result) => (err ? reject(err) : resolve(result!)))
)
}
Loading

0 comments on commit 6cd1470

Please sign in to comment.