Merged in chore/migrate-from-next-lint (pull request #3263)

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
This commit is contained in:
Anton Gunnarsson
2025-12-02 10:08:56 +00:00
parent be28982e73
commit 5da3e457cb
18 changed files with 62 additions and 30 deletions

View File

@@ -12,6 +12,22 @@ const compat = new FlatCompat({
}) })
export default defineConfig([ 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( extends: compat.extends(
"next/core-web-vitals", "next/core-web-vitals",
@@ -80,6 +96,8 @@ export default defineConfig([
], ],
"@typescript-eslint/consistent-type-imports": "error", "@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-empty-object-type": "off",
"@typescript-eslint/no-require-imports": "off",
"@typescript-eslint/no-unused-vars": [ "@typescript-eslint/no-unused-vars": [
"error", "error",

View File

@@ -2,13 +2,11 @@ import path from "node:path"
const WEB_ROOT = path.join(process.cwd(), "apps/partner-sas/") 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 buildEslintCommand = (filenames) => {
const cmd = `next lint --fix --max-warnings 0 --file ${filenames const files = filenames
.map((f) => `'${path.relative(WEB_ROOT, f)}'`) .map((f) => `'${path.relative(WEB_ROOT, f)}'`)
.join(" --file ")}` .join(" ")
return `eslint --fix --no-warn-ignored --max-warnings 0 ${files}`
return cmd
} }
const config = { const config = {

View File

@@ -7,8 +7,8 @@
"dev": "NODE_OPTIONS=--openssl-legacy-provider PORT=3001 NEXT_PUBLIC_PORT=3001 next dev --turbo", "dev": "NODE_OPTIONS=--openssl-legacy-provider PORT=3001 NEXT_PUBLIC_PORT=3001 next dev --turbo",
"build": "next build", "build": "next build",
"start": "node .next/standalone/server.js", "start": "node .next/standalone/server.js",
"lint": "next lint --max-warnings 0 && tsgo --noEmit", "lint": "eslint --max-warnings 0 . && tsgo --noEmit",
"lint:fix": "next lint --fix && tsgo --noEmit", "lint:fix": "eslint --fix . && tsgo --noEmit",
"check-types": "tsgo --noEmit", "check-types": "tsgo --noEmit",
"typegen": "next typegen", "typegen": "next typegen",
"clean": "rm -rf .next", "clean": "rm -rf .next",
@@ -42,7 +42,6 @@
"usehooks-ts": "3.1.1" "usehooks-ts": "3.1.1"
}, },
"devDependencies": { "devDependencies": {
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.26.0", "@eslint/js": "^9.26.0",
"@playwright/test": "^1.53.1", "@playwright/test": "^1.53.1",
"@scandic-hotels/common": "workspace:*", "@scandic-hotels/common": "workspace:*",
@@ -53,6 +52,7 @@
"@types/react-dom": "^19.2.3", "@types/react-dom": "^19.2.3",
"@typescript-eslint/eslint-plugin": "^8.32.0", "@typescript-eslint/eslint-plugin": "^8.32.0",
"@typescript-eslint/parser": "^8.32.0", "@typescript-eslint/parser": "^8.32.0",
"@typescript/native-preview": "^7.0.0-dev.20251104.1",
"babel-plugin-formatjs": "^10.5.39", "babel-plugin-formatjs": "^10.5.39",
"eslint": "^9", "eslint": "^9",
"eslint-config-next": "15.3.2", "eslint-config-next": "15.3.2",

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
interface Window { interface Window {
dataLayer: { dataLayer: {
[key: string]: any [key: string]: any

View File

@@ -12,6 +12,23 @@ const compat = new FlatCompat({
}) })
export default defineConfig([ 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( extends: compat.extends(
"next/core-web-vitals", "next/core-web-vitals",
@@ -79,6 +96,8 @@ export default defineConfig([
], ],
"@typescript-eslint/consistent-type-imports": "warn", "@typescript-eslint/consistent-type-imports": "warn",
"@typescript-eslint/no-empty-object-type": "off",
"@typescript-eslint/no-require-imports": "off",
"@typescript-eslint/no-unused-vars": [ "@typescript-eslint/no-unused-vars": [
"warn", "warn",

View File

@@ -2,13 +2,11 @@ import path from "node:path"
const WEB_ROOT = path.join(process.cwd(), "apps/scandic-web/") 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 buildEslintCommand = (filenames) => {
const cmd = `next lint --fix --max-warnings 0 --file ${filenames const files = filenames
.map((f) => `'${path.relative(WEB_ROOT, f)}'`) .map((f) => `'${path.relative(WEB_ROOT, f)}'`)
.join(" --file ")}` .join(" ")
return `eslint --fix --no-warn-ignored --max-warnings 0 ${files}`
return cmd
} }
const config = { const config = {

View File

@@ -1,9 +1,9 @@
import { type NextMiddleware, NextResponse } from "next/server" import { type NextMiddleware, NextResponse } from "next/server"
import { getPublicNextURL } from "@/server/utils"
import { findLang } from "@scandic-hotels/common/utils/languages" import { findLang } from "@scandic-hotels/common/utils/languages"
import { getPublicNextURL } from "@/server/utils"
import { getDefaultRequestHeaders } from "./utils" import { getDefaultRequestHeaders } from "./utils"
import type { MiddlewareMatcher } from "@/types/middleware" import type { MiddlewareMatcher } from "@/types/middleware"

View File

@@ -1,3 +1,4 @@
/* eslint-disable no-console */
/* eslint-disable import/no-anonymous-default-export */ /* eslint-disable import/no-anonymous-default-export */
import type { Context } from "@netlify/functions" import type { Context } from "@netlify/functions"

View File

@@ -1,3 +1,4 @@
/* eslint-disable no-console */
/* eslint-disable import/no-anonymous-default-export */ /* eslint-disable import/no-anonymous-default-export */
import type { Config, Context } from "@netlify/functions" import type { Config, Context } from "@netlify/functions"

View File

@@ -1,3 +1,4 @@
/* eslint-disable no-console */
import { performWarmup } from "./warmup-background.mjs" import { performWarmup } from "./warmup-background.mjs"
import type { Config, Context } from "@netlify/functions" import type { Config, Context } from "@netlify/functions"

View File

@@ -6,8 +6,8 @@
"scripts": { "scripts": {
"build": "next build", "build": "next build",
"dev": "NODE_OPTIONS=--openssl-legacy-provider PORT=3000 NEXT_PUBLIC_PORT=3000 next dev --turbo", "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": "next typegen && eslint --max-warnings 0 . && tsgo --noEmit",
"lint:fix": "next typegen && next lint --fix --max-warnings 0 && tsc", "lint:fix": "next typegen && eslint --fix --max-warnings 0 . && tsgo --noEmit",
"start": "node .next/standalone/server.js", "start": "node .next/standalone/server.js",
"test:setup": "yarn build && yarn start", "test:setup": "yarn build && yarn start",
"preinstall": "/bin/sh -c \"export $(cat .env.local | grep -v '^#' | xargs)\"", "preinstall": "/bin/sh -c \"export $(cat .env.local | grep -v '^#' | xargs)\"",
@@ -48,6 +48,7 @@
"@tsparticles/confetti": "^3.8.1", "@tsparticles/confetti": "^3.8.1",
"@types/geojson": "^7946.0.16", "@types/geojson": "^7946.0.16",
"@types/supercluster": "^7.1.3", "@types/supercluster": "^7.1.3",
"@typescript/native-preview": "^7.0.0-dev.20251104.1",
"@vis.gl/react-google-maps": "^1.5.2", "@vis.gl/react-google-maps": "^1.5.2",
"class-variance-authority": "^0.7.1", "class-variance-authority": "^0.7.1",
"client-only": "^0.0.1", "client-only": "^0.0.1",
@@ -87,7 +88,6 @@
}, },
"devDependencies": { "devDependencies": {
"@eslint/compat": "^1.2.9", "@eslint/compat": "^1.2.9",
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.26.0", "@eslint/js": "^9.26.0",
"@formatjs/cli": "^6.7.1", "@formatjs/cli": "^6.7.1",
"@lokalise/node-api": "^14.0.0", "@lokalise/node-api": "^14.0.0",

View File

@@ -1,5 +1,4 @@
import type { dynamicContentSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/headers/dynamicContent"
import type { z } from "zod" import type { z } from "zod"
import type { dynamicContentSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/headers/dynamicContent"
export type HeaderDynamicContentProps = z.infer<typeof dynamicContentSchema> export type HeaderDynamicContentProps = z.infer<typeof dynamicContentSchema>

View File

@@ -1,4 +1,5 @@
import type { AdditionalData, Hotel } from "@scandic-hotels/trpc/types/hotel" import type { AdditionalData, Hotel } from "@scandic-hotels/trpc/types/hotel"
import type { MeetingRooms } from "../meetingRooms" import type { MeetingRooms } from "../meetingRooms"
export type MeetingsAndConferencesSidePeekProps = { export type MeetingsAndConferencesSidePeekProps = {

View File

@@ -1,5 +1,4 @@
import type { mapLocationSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/mapLocation"
import type { z } from "zod" import type { z } from "zod"
import type { mapLocationSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/mapLocation"
export type MapLocation = z.output<typeof mapLocationSchema> export type MapLocation = z.output<typeof mapLocationSchema>

View File

@@ -1,10 +1,9 @@
import type { z } from "zod"
import type { import type {
validateLinkItem, validateLinkItem,
validateLinksWithType, validateLinksWithType,
validateSecondaryLinks, validateSecondaryLinks,
} from "@scandic-hotels/trpc/routers/contentstack/base/output" } from "@scandic-hotels/trpc/routers/contentstack/base/output"
import type { z } from "zod"
export type FooterLink = z.output<typeof validateLinkItem> export type FooterLink = z.output<typeof validateLinkItem>
export type FooterSecondaryNavGroup = z.output<typeof validateSecondaryLinks> export type FooterSecondaryNavGroup = z.output<typeof validateSecondaryLinks>

View File

@@ -7,10 +7,6 @@ function base64ToUint8Array(base64String: string) {
return byteArray return byteArray
} }
function utf8ToUint8Array(utf8String: string) {
return new TextEncoder().encode(utf8String)
}
function uint8ArrayToUtf8(uint8Array: Uint8Array) { function uint8ArrayToUtf8(uint8Array: Uint8Array) {
return new TextDecoder().decode(uint8Array) return new TextDecoder().decode(uint8Array)
} }

View File

@@ -10,6 +10,7 @@ import { cache as reactCache } from "react"
* *
* @param fn - The function to memoize * @param fn - The function to memoize
*/ */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function cache<T extends (...args: any[]) => any>(fn: T) { export function cache<T extends (...args: any[]) => any>(fn: T) {
const cachedFunction = reactCache((stringifiedParams: string) => { const cachedFunction = reactCache((stringifiedParams: string) => {
return fn(...JSON.parse(stringifiedParams)) return fn(...JSON.parse(stringifiedParams))

View File

@@ -5337,7 +5337,6 @@ __metadata:
version: 0.0.0-use.local version: 0.0.0-use.local
resolution: "@scandic-hotels/partner-sas@workspace:apps/partner-sas" resolution: "@scandic-hotels/partner-sas@workspace:apps/partner-sas"
dependencies: dependencies:
"@eslint/eslintrc": "npm:^3.3.1"
"@eslint/js": "npm:^9.26.0" "@eslint/js": "npm:^9.26.0"
"@formatjs/intl": "npm:^3.1.6" "@formatjs/intl": "npm:^3.1.6"
"@netlify/plugin-nextjs": "npm:^5.14.4" "@netlify/plugin-nextjs": "npm:^5.14.4"
@@ -5357,6 +5356,7 @@ __metadata:
"@types/react-dom": "npm:^19.2.3" "@types/react-dom": "npm:^19.2.3"
"@typescript-eslint/eslint-plugin": "npm:^8.32.0" "@typescript-eslint/eslint-plugin": "npm:^8.32.0"
"@typescript-eslint/parser": "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" babel-plugin-formatjs: "npm:^10.5.39"
eslint: "npm:^9" eslint: "npm:^9"
eslint-config-next: "npm:15.3.2" eslint-config-next: "npm:15.3.2"
@@ -5420,7 +5420,6 @@ __metadata:
dependencies: dependencies:
"@contentstack/live-preview-utils": "npm:^3.2.1" "@contentstack/live-preview-utils": "npm:^3.2.1"
"@eslint/compat": "npm:^1.2.9" "@eslint/compat": "npm:^1.2.9"
"@eslint/eslintrc": "npm:^3.3.1"
"@eslint/js": "npm:^9.26.0" "@eslint/js": "npm:^9.26.0"
"@formatjs/cli": "npm:^6.7.1" "@formatjs/cli": "npm:^6.7.1"
"@formatjs/intl": "npm:^3.1.6" "@formatjs/intl": "npm:^3.1.6"
@@ -5462,6 +5461,7 @@ __metadata:
"@types/supercluster": "npm:^7.1.3" "@types/supercluster": "npm:^7.1.3"
"@typescript-eslint/eslint-plugin": "npm:^8.32.0" "@typescript-eslint/eslint-plugin": "npm:^8.32.0"
"@typescript-eslint/parser": "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" "@vis.gl/react-google-maps": "npm:^1.5.2"
"@vitejs/plugin-react": "npm:^5.0.0" "@vitejs/plugin-react": "npm:^5.0.0"
adm-zip: "npm:^0.5.16" adm-zip: "npm:^0.5.16"