From 5da3e457cb39b341ab66fba18d57d25989b57b85 Mon Sep 17 00:00:00 2001 From: Anton Gunnarsson Date: Tue, 2 Dec 2025 10:08:56 +0000 Subject: [PATCH] Merged in chore/migrate-from-next-lint (pull request #3263) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit chore: Migrate from next lint to eslint * Migrate scandic-web * Migrate partner-sas * Enable any rule in partner-sas Approved-by: Joakim Jäderberg Approved-by: Linus Flood --- apps/partner-sas/eslint.config.mjs | 18 ++++++++++++++++++ apps/partner-sas/lint-staged.config.js | 8 +++----- apps/partner-sas/package.json | 6 +++--- apps/partner-sas/types/window.d.ts | 1 + apps/scandic-web/eslint.config.mjs | 19 +++++++++++++++++++ apps/scandic-web/lint-staged.config.js | 8 +++----- .../middlewares/familyAndFriends.ts | 4 ++-- .../netlify/functions/sitemap-manual.mts | 1 + .../scandic-web/netlify/functions/sitemap.mts | 1 + .../functions/warmup-scheduled-background.mts | 1 + apps/scandic-web/package.json | 6 +++--- .../components/headers/dynamicContent.ts | 3 +-- .../sidepeek/meetingsAndConferences.ts | 1 + .../types/components/mapLocation.ts | 3 +-- .../types/trpc/routers/contentstack/footer.ts | 3 +-- apps/scandic-web/utils/aes.ts | 4 ---- apps/scandic-web/utils/cache.ts | 1 + yarn.lock | 4 ++-- 18 files changed, 62 insertions(+), 30 deletions(-) diff --git a/apps/partner-sas/eslint.config.mjs b/apps/partner-sas/eslint.config.mjs index 00e75a007..07cfbbf65 100644 --- a/apps/partner-sas/eslint.config.mjs +++ b/apps/partner-sas/eslint.config.mjs @@ -12,6 +12,22 @@ const compat = new FlatCompat({ }) export default defineConfig([ + { + ignores: [ + ".next/**", + "node_modules/**", + "dist/**", + "build/**", + "public/**", + "playwright-report/**", + "test-results/**", + "coverage/**", + "*.config.js", + "*.config.ts", + "*.config.mjs", + "next-env.d.ts", + ], + }, { extends: compat.extends( "next/core-web-vitals", @@ -80,6 +96,8 @@ export default defineConfig([ ], "@typescript-eslint/consistent-type-imports": "error", + "@typescript-eslint/no-empty-object-type": "off", + "@typescript-eslint/no-require-imports": "off", "@typescript-eslint/no-unused-vars": [ "error", diff --git a/apps/partner-sas/lint-staged.config.js b/apps/partner-sas/lint-staged.config.js index 47f5f04b6..9a79cdf55 100644 --- a/apps/partner-sas/lint-staged.config.js +++ b/apps/partner-sas/lint-staged.config.js @@ -2,13 +2,11 @@ import path from "node:path" const WEB_ROOT = path.join(process.cwd(), "apps/partner-sas/") -// https://nextjs.org/docs/app/building-your-application/configuring/eslint#lint-staged const buildEslintCommand = (filenames) => { - const cmd = `next lint --fix --max-warnings 0 --file ${filenames + const files = filenames .map((f) => `'${path.relative(WEB_ROOT, f)}'`) - .join(" --file ")}` - - return cmd + .join(" ") + return `eslint --fix --no-warn-ignored --max-warnings 0 ${files}` } const config = { diff --git a/apps/partner-sas/package.json b/apps/partner-sas/package.json index 2a5fe2cfc..7a27d3475 100644 --- a/apps/partner-sas/package.json +++ b/apps/partner-sas/package.json @@ -7,8 +7,8 @@ "dev": "NODE_OPTIONS=--openssl-legacy-provider PORT=3001 NEXT_PUBLIC_PORT=3001 next dev --turbo", "build": "next build", "start": "node .next/standalone/server.js", - "lint": "next lint --max-warnings 0 && tsgo --noEmit", - "lint:fix": "next lint --fix && tsgo --noEmit", + "lint": "eslint --max-warnings 0 . && tsgo --noEmit", + "lint:fix": "eslint --fix . && tsgo --noEmit", "check-types": "tsgo --noEmit", "typegen": "next typegen", "clean": "rm -rf .next", @@ -42,7 +42,6 @@ "usehooks-ts": "3.1.1" }, "devDependencies": { - "@eslint/eslintrc": "^3.3.1", "@eslint/js": "^9.26.0", "@playwright/test": "^1.53.1", "@scandic-hotels/common": "workspace:*", @@ -53,6 +52,7 @@ "@types/react-dom": "^19.2.3", "@typescript-eslint/eslint-plugin": "^8.32.0", "@typescript-eslint/parser": "^8.32.0", + "@typescript/native-preview": "^7.0.0-dev.20251104.1", "babel-plugin-formatjs": "^10.5.39", "eslint": "^9", "eslint-config-next": "15.3.2", diff --git a/apps/partner-sas/types/window.d.ts b/apps/partner-sas/types/window.d.ts index b6b03f0aa..7ff5dbe97 100644 --- a/apps/partner-sas/types/window.d.ts +++ b/apps/partner-sas/types/window.d.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ interface Window { dataLayer: { [key: string]: any diff --git a/apps/scandic-web/eslint.config.mjs b/apps/scandic-web/eslint.config.mjs index 9cd0a2f91..2abb9d0c2 100644 --- a/apps/scandic-web/eslint.config.mjs +++ b/apps/scandic-web/eslint.config.mjs @@ -12,6 +12,23 @@ const compat = new FlatCompat({ }) export default defineConfig([ + { + ignores: [ + ".next/**", + "node_modules/**", + "dist/**", + "build/**", + ".netlify/**", + "public/**", + "playwright-report/**", + "test-results/**", + "coverage/**", + "*.config.js", + "*.config.ts", + "*.config.mjs", + "next-env.d.ts", + ], + }, { extends: compat.extends( "next/core-web-vitals", @@ -79,6 +96,8 @@ export default defineConfig([ ], "@typescript-eslint/consistent-type-imports": "warn", + "@typescript-eslint/no-empty-object-type": "off", + "@typescript-eslint/no-require-imports": "off", "@typescript-eslint/no-unused-vars": [ "warn", diff --git a/apps/scandic-web/lint-staged.config.js b/apps/scandic-web/lint-staged.config.js index 0fd068a75..e66d6a9f1 100644 --- a/apps/scandic-web/lint-staged.config.js +++ b/apps/scandic-web/lint-staged.config.js @@ -2,13 +2,11 @@ import path from "node:path" const WEB_ROOT = path.join(process.cwd(), "apps/scandic-web/") -// https://nextjs.org/docs/app/building-your-application/configuring/eslint#lint-staged const buildEslintCommand = (filenames) => { - const cmd = `next lint --fix --max-warnings 0 --file ${filenames + const files = filenames .map((f) => `'${path.relative(WEB_ROOT, f)}'`) - .join(" --file ")}` - - return cmd + .join(" ") + return `eslint --fix --no-warn-ignored --max-warnings 0 ${files}` } const config = { diff --git a/apps/scandic-web/middlewares/familyAndFriends.ts b/apps/scandic-web/middlewares/familyAndFriends.ts index 45d2fa953..74eea983a 100644 --- a/apps/scandic-web/middlewares/familyAndFriends.ts +++ b/apps/scandic-web/middlewares/familyAndFriends.ts @@ -1,9 +1,9 @@ import { type NextMiddleware, NextResponse } from "next/server" -import { getPublicNextURL } from "@/server/utils" - import { findLang } from "@scandic-hotels/common/utils/languages" +import { getPublicNextURL } from "@/server/utils" + import { getDefaultRequestHeaders } from "./utils" import type { MiddlewareMatcher } from "@/types/middleware" diff --git a/apps/scandic-web/netlify/functions/sitemap-manual.mts b/apps/scandic-web/netlify/functions/sitemap-manual.mts index e8fec1e7c..c858928d2 100644 --- a/apps/scandic-web/netlify/functions/sitemap-manual.mts +++ b/apps/scandic-web/netlify/functions/sitemap-manual.mts @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ /* eslint-disable import/no-anonymous-default-export */ import type { Context } from "@netlify/functions" diff --git a/apps/scandic-web/netlify/functions/sitemap.mts b/apps/scandic-web/netlify/functions/sitemap.mts index c5a74cacc..435f8f674 100644 --- a/apps/scandic-web/netlify/functions/sitemap.mts +++ b/apps/scandic-web/netlify/functions/sitemap.mts @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ /* eslint-disable import/no-anonymous-default-export */ import type { Config, Context } from "@netlify/functions" diff --git a/apps/scandic-web/netlify/functions/warmup-scheduled-background.mts b/apps/scandic-web/netlify/functions/warmup-scheduled-background.mts index b4e6c7f76..58cda0e46 100644 --- a/apps/scandic-web/netlify/functions/warmup-scheduled-background.mts +++ b/apps/scandic-web/netlify/functions/warmup-scheduled-background.mts @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ import { performWarmup } from "./warmup-background.mjs" import type { Config, Context } from "@netlify/functions" diff --git a/apps/scandic-web/package.json b/apps/scandic-web/package.json index 0f07d9f39..aa85676e1 100644 --- a/apps/scandic-web/package.json +++ b/apps/scandic-web/package.json @@ -6,8 +6,8 @@ "scripts": { "build": "next build", "dev": "NODE_OPTIONS=--openssl-legacy-provider PORT=3000 NEXT_PUBLIC_PORT=3000 next dev --turbo", - "lint": "next typegen && next lint --max-warnings 0 && tsc", - "lint:fix": "next typegen && next lint --fix --max-warnings 0 && tsc", + "lint": "next typegen && eslint --max-warnings 0 . && tsgo --noEmit", + "lint:fix": "next typegen && eslint --fix --max-warnings 0 . && tsgo --noEmit", "start": "node .next/standalone/server.js", "test:setup": "yarn build && yarn start", "preinstall": "/bin/sh -c \"export $(cat .env.local | grep -v '^#' | xargs)\"", @@ -48,6 +48,7 @@ "@tsparticles/confetti": "^3.8.1", "@types/geojson": "^7946.0.16", "@types/supercluster": "^7.1.3", + "@typescript/native-preview": "^7.0.0-dev.20251104.1", "@vis.gl/react-google-maps": "^1.5.2", "class-variance-authority": "^0.7.1", "client-only": "^0.0.1", @@ -87,7 +88,6 @@ }, "devDependencies": { "@eslint/compat": "^1.2.9", - "@eslint/eslintrc": "^3.3.1", "@eslint/js": "^9.26.0", "@formatjs/cli": "^6.7.1", "@lokalise/node-api": "^14.0.0", diff --git a/apps/scandic-web/types/components/headers/dynamicContent.ts b/apps/scandic-web/types/components/headers/dynamicContent.ts index aebfb736f..ffcd9cbff 100644 --- a/apps/scandic-web/types/components/headers/dynamicContent.ts +++ b/apps/scandic-web/types/components/headers/dynamicContent.ts @@ -1,5 +1,4 @@ +import type { dynamicContentSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/headers/dynamicContent" import type { z } from "zod" -import type { dynamicContentSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/headers/dynamicContent" - export type HeaderDynamicContentProps = z.infer diff --git a/apps/scandic-web/types/components/hotelPage/sidepeek/meetingsAndConferences.ts b/apps/scandic-web/types/components/hotelPage/sidepeek/meetingsAndConferences.ts index f3d15da29..c9a6d9ea6 100644 --- a/apps/scandic-web/types/components/hotelPage/sidepeek/meetingsAndConferences.ts +++ b/apps/scandic-web/types/components/hotelPage/sidepeek/meetingsAndConferences.ts @@ -1,4 +1,5 @@ import type { AdditionalData, Hotel } from "@scandic-hotels/trpc/types/hotel" + import type { MeetingRooms } from "../meetingRooms" export type MeetingsAndConferencesSidePeekProps = { diff --git a/apps/scandic-web/types/components/mapLocation.ts b/apps/scandic-web/types/components/mapLocation.ts index 95cc01db5..a6cf211ac 100644 --- a/apps/scandic-web/types/components/mapLocation.ts +++ b/apps/scandic-web/types/components/mapLocation.ts @@ -1,5 +1,4 @@ +import type { mapLocationSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/mapLocation" import type { z } from "zod" -import type { mapLocationSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/mapLocation" - export type MapLocation = z.output diff --git a/apps/scandic-web/types/trpc/routers/contentstack/footer.ts b/apps/scandic-web/types/trpc/routers/contentstack/footer.ts index 0e208f846..13346070b 100644 --- a/apps/scandic-web/types/trpc/routers/contentstack/footer.ts +++ b/apps/scandic-web/types/trpc/routers/contentstack/footer.ts @@ -1,10 +1,9 @@ -import type { z } from "zod" - import type { validateLinkItem, validateLinksWithType, validateSecondaryLinks, } from "@scandic-hotels/trpc/routers/contentstack/base/output" +import type { z } from "zod" export type FooterLink = z.output export type FooterSecondaryNavGroup = z.output diff --git a/apps/scandic-web/utils/aes.ts b/apps/scandic-web/utils/aes.ts index 620d82017..419b417bc 100644 --- a/apps/scandic-web/utils/aes.ts +++ b/apps/scandic-web/utils/aes.ts @@ -7,10 +7,6 @@ function base64ToUint8Array(base64String: string) { return byteArray } -function utf8ToUint8Array(utf8String: string) { - return new TextEncoder().encode(utf8String) -} - function uint8ArrayToUtf8(uint8Array: Uint8Array) { return new TextDecoder().decode(uint8Array) } diff --git a/apps/scandic-web/utils/cache.ts b/apps/scandic-web/utils/cache.ts index 2b44dee49..da03873dd 100644 --- a/apps/scandic-web/utils/cache.ts +++ b/apps/scandic-web/utils/cache.ts @@ -10,6 +10,7 @@ import { cache as reactCache } from "react" * * @param fn - The function to memoize */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any export function cache any>(fn: T) { const cachedFunction = reactCache((stringifiedParams: string) => { return fn(...JSON.parse(stringifiedParams)) diff --git a/yarn.lock b/yarn.lock index 23c28d02a..f322112b0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5337,7 +5337,6 @@ __metadata: version: 0.0.0-use.local resolution: "@scandic-hotels/partner-sas@workspace:apps/partner-sas" dependencies: - "@eslint/eslintrc": "npm:^3.3.1" "@eslint/js": "npm:^9.26.0" "@formatjs/intl": "npm:^3.1.6" "@netlify/plugin-nextjs": "npm:^5.14.4" @@ -5357,6 +5356,7 @@ __metadata: "@types/react-dom": "npm:^19.2.3" "@typescript-eslint/eslint-plugin": "npm:^8.32.0" "@typescript-eslint/parser": "npm:^8.32.0" + "@typescript/native-preview": "npm:^7.0.0-dev.20251104.1" babel-plugin-formatjs: "npm:^10.5.39" eslint: "npm:^9" eslint-config-next: "npm:15.3.2" @@ -5420,7 +5420,6 @@ __metadata: dependencies: "@contentstack/live-preview-utils": "npm:^3.2.1" "@eslint/compat": "npm:^1.2.9" - "@eslint/eslintrc": "npm:^3.3.1" "@eslint/js": "npm:^9.26.0" "@formatjs/cli": "npm:^6.7.1" "@formatjs/intl": "npm:^3.1.6" @@ -5462,6 +5461,7 @@ __metadata: "@types/supercluster": "npm:^7.1.3" "@typescript-eslint/eslint-plugin": "npm:^8.32.0" "@typescript-eslint/parser": "npm:^8.32.0" + "@typescript/native-preview": "npm:^7.0.0-dev.20251104.1" "@vis.gl/react-google-maps": "npm:^1.5.2" "@vitejs/plugin-react": "npm:^5.0.0" adm-zip: "npm:^0.5.16"