diff --git a/packages/react-component-library/babel.config.js b/packages/react-component-library/babel.config.js index 11e95e53de..17baa6cfcd 100755 --- a/packages/react-component-library/babel.config.js +++ b/packages/react-component-library/babel.config.js @@ -15,8 +15,8 @@ module.exports = { replace: 'replacement', }, { - search: /__RNDS_LOG_LEVEL/, - replace: process.env.RNDS_LOG_LEVEL || 'warn', + search: /__MODDS_LOG_LEVEL/, + replace: process.env.MODDS_LOG_LEVEL || 'warn', }, ], }, diff --git a/packages/react-component-library/jest.config.js b/packages/react-component-library/jest.config.js index 874cc895b1..c7725b5e2e 100644 --- a/packages/react-component-library/jest.config.js +++ b/packages/react-component-library/jest.config.js @@ -1,4 +1,4 @@ -process.env.RNDS_LOG_LEVEL = 'debug' +process.env.MODDS_LOG_LEVEL = 'debug' module.exports = { moduleNameMapper: { diff --git a/packages/react-component-library/package.json b/packages/react-component-library/package.json index a054f0de37..683f48810c 100644 --- a/packages/react-component-library/package.json +++ b/packages/react-component-library/package.json @@ -30,13 +30,13 @@ "build": "run-s build:es build:cjs types", "build:cjs": "BABEL_ENV=cjs webpack --config=webpack/prod.js", "build:es": "BABEL_ENV=es babel src --out-dir \"dist/es\" --extensions \".ts,.tsx\"", - "build:cjs:dev": "BABEL_ENV=cjs RNDS_LOG_LEVEL=debug webpack --config=webpack/dev.js", + "build:cjs:dev": "BABEL_ENV=cjs MODDS_LOG_LEVEL=debug webpack --config=webpack/dev.js", "chromatic": "chromatic --build-script-name storybook:static", "lint": "eslint src cypress --ext .js --ext .jsx --ext .ts --ext .tsx", "prepare": "yarn build", - "storybook": "BABEL_ENV=es RNDS_LOG_LEVEL=debug start-storybook -p 6006", + "storybook": "BABEL_ENV=es MODDS_LOG_LEVEL=debug start-storybook -p 6006", "storybook:static": "BABEL_ENV=es build-storybook -c .storybook -o .static_storybook", - "storybook:test": "BABEL_ENV=storybook-test RNDS_LOG_LEVEL=debug start-storybook -p 6006", + "storybook:test": "BABEL_ENV=storybook-test MODDS_LOG_LEVEL=debug start-storybook -p 6006", "test": "BABEL_ENV=test jest --testPathIgnorePatterns=./src/a11y/index.test.tsx", "test:a11y": "BABEL_ENV=test yarn storybook:static && jest ./src/a11y/index.test.tsx", "test:watch": "BABEL_ENV=test jest --watch", diff --git a/packages/react-component-library/src/components/Breadcrumbs/Breadcrumbs.test.tsx b/packages/react-component-library/src/components/Breadcrumbs/Breadcrumbs.test.tsx index be20414647..71f829d288 100644 --- a/packages/react-component-library/src/components/Breadcrumbs/Breadcrumbs.test.tsx +++ b/packages/react-component-library/src/components/Breadcrumbs/Breadcrumbs.test.tsx @@ -102,13 +102,13 @@ describe('Breadcrumbs', () => { it('should warn the consumer `isFirst` will be overwritten', () => { expect(consoleWarnSpy).toHaveBeenCalledWith( - 'WARN - RNDS - Prop `isFirst` on `BreadcrumbsItem` will be overwritten' + 'WARN - MODDS - Prop `isFirst` on `BreadcrumbsItem` will be overwritten' ) }) it('should warn the consumer `isLast` will be overwritten', () => { expect(consoleWarnSpy).toHaveBeenCalledWith( - 'WARN - RNDS - Prop `isLast` on `BreadcrumbsItem` will be overwritten' + 'WARN - MODDS - Prop `isLast` on `BreadcrumbsItem` will be overwritten' ) }) }) diff --git a/packages/react-component-library/src/components/ButtonGroup/ButtonGroup.test.tsx b/packages/react-component-library/src/components/ButtonGroup/ButtonGroup.test.tsx index 32ad686677..34ddcbcff7 100644 --- a/packages/react-component-library/src/components/ButtonGroup/ButtonGroup.test.tsx +++ b/packages/react-component-library/src/components/ButtonGroup/ButtonGroup.test.tsx @@ -149,7 +149,7 @@ describe('ButtonGroup', () => { it('should warn the consumer about specifying sizes for each item', () => { expect(consoleWarnSpy).toHaveBeenCalledTimes(2) expect(consoleWarnSpy).toHaveBeenCalledWith( - 'WARN - RNDS - Prop `size` on `ButtonGroupItem` will be replaced by `size` from `ButtonGroup`' + 'WARN - MODDS - Prop `size` on `ButtonGroupItem` will be replaced by `size` from `ButtonGroup`' ) }) }) diff --git a/packages/react-component-library/src/components/List/List.test.tsx b/packages/react-component-library/src/components/List/List.test.tsx index e335504eaa..f4ae45d0d2 100644 --- a/packages/react-component-library/src/components/List/List.test.tsx +++ b/packages/react-component-library/src/components/List/List.test.tsx @@ -228,19 +228,19 @@ describe('List', () => { it('should warn the consumer `isActive` will be overwritten', () => { expect(consoleWarnSpy).toHaveBeenCalledWith( - 'WARN - RNDS - Prop `isActive` on `ListItem` will be overwritten' + 'WARN - MODDS - Prop `isActive` on `ListItem` will be overwritten' ) }) it('should warn the consumer `onMouseEnter` will be overwritten', () => { expect(consoleWarnSpy).toHaveBeenCalledWith( - 'WARN - RNDS - Prop `onMouseEnter` on `ListItem` will be overwritten' + 'WARN - MODDS - Prop `onMouseEnter` on `ListItem` will be overwritten' ) }) it('should warn the consumer `onMouseLeave` will be overwritten', () => { expect(consoleWarnSpy).toHaveBeenCalledWith( - 'WARN - RNDS - Prop `onMouseLeave` on `ListItem` will be overwritten' + 'WARN - MODDS - Prop `onMouseLeave` on `ListItem` will be overwritten' ) }) }) diff --git a/packages/react-component-library/src/components/Timeline/__tests__/Timeline.test.tsx b/packages/react-component-library/src/components/Timeline/__tests__/Timeline.test.tsx index e6ce3ec1c4..5641b95cee 100644 --- a/packages/react-component-library/src/components/Timeline/__tests__/Timeline.test.tsx +++ b/packages/react-component-library/src/components/Timeline/__tests__/Timeline.test.tsx @@ -2130,7 +2130,7 @@ describe('Timeline', () => { it('writes an error to the console', () => { expect(consoleErrorSpy).toHaveBeenCalledWith( - 'ERROR - RNDS - `startDate` is after `endDate`' + 'ERROR - MODDS - `startDate` is after `endDate`' ) }) }) diff --git a/packages/react-component-library/src/components/TopLevelNavigation/Masthead/Masthead.test.tsx b/packages/react-component-library/src/components/TopLevelNavigation/Masthead/Masthead.test.tsx index d9fbee45d9..a66a13abc7 100644 --- a/packages/react-component-library/src/components/TopLevelNavigation/Masthead/Masthead.test.tsx +++ b/packages/react-component-library/src/components/TopLevelNavigation/Masthead/Masthead.test.tsx @@ -178,7 +178,7 @@ describe('Masthead', () => { it('should warn the consumer for using the deprecated `link` prop', () => { expect(consoleWarnSpy).toHaveBeenCalledTimes(1) expect(consoleWarnSpy).toHaveBeenCalledWith( - 'WARN - RNDS - The `link` prop is deprecated' + 'WARN - MODDS - The `link` prop is deprecated' ) }) diff --git a/packages/react-component-library/src/utils/__tests__/logger.test.ts b/packages/react-component-library/src/utils/__tests__/logger.test.ts index 598824c28f..5820ff953f 100644 --- a/packages/react-component-library/src/utils/__tests__/logger.test.ts +++ b/packages/react-component-library/src/utils/__tests__/logger.test.ts @@ -11,7 +11,9 @@ describe('logger', () => { logger.debug('Hello, World!') expect(consoleLogSpy).toHaveBeenCalledTimes(1) - expect(consoleLogSpy).toHaveBeenCalledWith('DEBUG - RNDS - Hello, World!') + expect(consoleLogSpy).toHaveBeenCalledWith( + 'DEBUG - MODDS - Hello, World!' + ) }) }) @@ -21,7 +23,9 @@ describe('logger', () => { logger.warn('Hello, World!') expect(consoleWarnSpy).toHaveBeenCalledTimes(1) - expect(consoleWarnSpy).toHaveBeenCalledWith('WARN - RNDS - Hello, World!') + expect(consoleWarnSpy).toHaveBeenCalledWith( + 'WARN - MODDS - Hello, World!' + ) }) }) @@ -31,7 +35,9 @@ describe('logger', () => { logger.error('Hello, World!') expect(consoleErrorSpy).toHaveBeenCalledTimes(1) - expect(consoleErrorSpy).toHaveBeenCalledWith('ERROR - RNDS - Hello, World!') + expect(consoleErrorSpy).toHaveBeenCalledWith( + 'ERROR - MODDS - Hello, World!' + ) }) }) }) diff --git a/packages/react-component-library/src/utils/logger.ts b/packages/react-component-library/src/utils/logger.ts index 61f445c83e..df93c5b025 100644 --- a/packages/react-component-library/src/utils/logger.ts +++ b/packages/react-component-library/src/utils/logger.ts @@ -1,8 +1,8 @@ -export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | '__RNDS_LOG_LEVEL' +export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | '__MODDS_LOG_LEVEL' export type Logger = Record -const RNDS_LOG_LEVEL: LogLevel = '__RNDS_LOG_LEVEL' +const MODDS_LOG_LEVEL: LogLevel = '__MODDS_LOG_LEVEL' const levels: LogLevel[] = ['debug', 'info', 'warn', 'error'] function isValidLogLevel(logLevel: LogLevel, index: number): boolean { @@ -15,7 +15,7 @@ function isValidLogLevel(logLevel: LogLevel, index: number): boolean { /** * Generates a `logger[debug | info | warn | error](...args)` - * Log level is set at build time via `RNDS_LOG_LEVEL` env var + * Log level is set at build time via `MODDS_LOG_LEVEL` env var * */ export default levels.reduce((logger, level: LogLevel, index: number) => { @@ -24,11 +24,15 @@ export default levels.reduce((logger, level: LogLevel, index: number) => { [level]: (...args: unknown[]) => { const func = level === 'debug' ? 'log' : level - if (RNDS_LOG_LEVEL && console && isValidLogLevel(RNDS_LOG_LEVEL, index)) { + if ( + MODDS_LOG_LEVEL && + console && + isValidLogLevel(MODDS_LOG_LEVEL, index) + ) { const [message, ...rest] = [...args] // eslint-disable-next-line no-console - console[func](`${level.toUpperCase()} - RNDS - ${message}`, ...rest) + console[func](`${level.toUpperCase()} - MODDS - ${message}`, ...rest) } }, }