Merged in feat/sw-3596-console (pull request #3100)
feat(SW-3596): added lint rule for no console.log. Use logger instead. * feat(SW-3596): added lint rule for no console.log. Use logger instead. Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -46,6 +46,7 @@ export default defineConfig([
|
||||
},
|
||||
|
||||
rules: {
|
||||
"no-console": "warn",
|
||||
"no-unused-vars": "off",
|
||||
"react/function-component-definition": "error",
|
||||
"import/no-relative-packages": "error",
|
||||
|
||||
@@ -14,6 +14,7 @@ export function DebugButton() {
|
||||
const handleClick = () => {
|
||||
const allRoomAvailability = getAllRoomAvailability(context)
|
||||
const allRoomPackages = getAllRoomPackages(context)
|
||||
// eslint-disable-next-line no-console
|
||||
console.log("%c SelectRateContext: ", "background: #AD0015; color: #FFF", {
|
||||
...context,
|
||||
...allRoomAvailability,
|
||||
|
||||
@@ -214,7 +214,7 @@ export function SelectRateProvider({
|
||||
})
|
||||
|
||||
if (selectedRatesPerRoom && selectedRatesPerRoom.length > 1) {
|
||||
console.error(`Multiple selected rates found for room index ${ix}:`)
|
||||
logger.error(`Multiple selected rates found for room index ${ix}:`)
|
||||
}
|
||||
|
||||
const selectedRate = selectedRatesPerRoom?.at(0)
|
||||
@@ -234,7 +234,7 @@ export function SelectRateProvider({
|
||||
const getPriceForRoom = useCallback(
|
||||
(roomIndex: number): Price | null => {
|
||||
if (roomIndex < 0 || roomIndex >= selectedRates.length) {
|
||||
console.warn("Room index out of bounds:", roomIndex)
|
||||
logger.warn("Room index out of bounds:", roomIndex)
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -422,7 +422,7 @@ export function SelectRateProvider({
|
||||
selectPackages: ({ roomIndex, packages }) => {
|
||||
const updatedRoom = selectRateBooking?.rooms?.[roomIndex]
|
||||
if (!updatedRoom) {
|
||||
console.error("No room found at index", roomIndex)
|
||||
logger.error("No room found at index", roomIndex)
|
||||
// TODO: What to do here?
|
||||
return
|
||||
}
|
||||
@@ -443,7 +443,7 @@ export function SelectRateProvider({
|
||||
}) => {
|
||||
const updatedRoom = selectRateBooking?.rooms?.[roomIndex]
|
||||
if (!updatedRoom) {
|
||||
console.error("No room found at index", roomIndex)
|
||||
logger.error("No room found at index", roomIndex)
|
||||
// TODO: What to do here?
|
||||
return
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ export default defineConfig([
|
||||
},
|
||||
|
||||
rules: {
|
||||
"no-console": "warn",
|
||||
"no-unused-vars": "off",
|
||||
"import/no-relative-packages": "error",
|
||||
"simple-import-sort/imports": [
|
||||
|
||||
@@ -47,6 +47,7 @@ export function createLogger(loggerPrefix: string | (() => Promise<string>)) {
|
||||
`${await getLoggerPrefix()} ${message}`.trim(),
|
||||
logValue
|
||||
)
|
||||
// eslint-disable-next-line no-console
|
||||
console[level](`${await getLoggerPrefix()} ${message}`.trim(), ...args)
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ export const minimumLogLevel = (() => {
|
||||
).toLowerCase() as (typeof logLevels)[number]
|
||||
|
||||
if (!logLevels.includes(configuredMinimumLogLevel)) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(
|
||||
`Invalid log level configured: ${configuredMinimumLogLevel}, defaulting to 'info'`
|
||||
)
|
||||
|
||||
@@ -30,6 +30,7 @@ export default defineConfig([
|
||||
},
|
||||
|
||||
rules: {
|
||||
"no-console": "warn",
|
||||
"no-unused-vars": "off",
|
||||
"import/no-relative-packages": "error",
|
||||
"simple-import-sort/imports": [
|
||||
|
||||
@@ -30,6 +30,7 @@ export default defineConfig([
|
||||
},
|
||||
|
||||
rules: {
|
||||
"no-console": "warn",
|
||||
"no-unused-vars": "off",
|
||||
"import/no-relative-packages": "error",
|
||||
"simple-import-sort/imports": [
|
||||
|
||||
@@ -177,7 +177,7 @@ export const enterDetails = safeProtectedServiceProcedure
|
||||
}
|
||||
|
||||
if (selectedRooms.some((sr) => !sr)) {
|
||||
console.log("DEBUG: REDIRECTING TO SELECT RATE", selectedRooms)
|
||||
logger.debug("DEBUG: REDIRECTING TO SELECT RATE", selectedRooms)
|
||||
return selectRateRedirectURL(input, selectedRooms.map(Boolean))
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { logger } from "@scandic-hotels/common/logger"
|
||||
|
||||
import type { FacilityEnum } from "@scandic-hotels/common/constants/facilities"
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
@@ -140,7 +142,7 @@ function getLocalizedCountryByCountryCode(
|
||||
const country = new Intl.DisplayNames([lang], { type: "region" })
|
||||
const localizedCountry = country.of(countryCode)
|
||||
if (!localizedCountry) {
|
||||
console.error(`Could not map ${countryCode} to localized country.`)
|
||||
logger.error(`Could not map ${countryCode} to localized country.`)
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user