diff --git a/.changeset/pretty-fireants-taste.md b/.changeset/pretty-fireants-taste.md new file mode 100644 index 0000000000..db18c73b2f --- /dev/null +++ b/.changeset/pretty-fireants-taste.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog': patch +--- + +Removed unused functions and the moment library. #4278 diff --git a/plugins/catalog/package.json b/plugins/catalog/package.json index c806c58e67..2ca0b59539 100644 --- a/plugins/catalog/package.json +++ b/plugins/catalog/package.json @@ -42,7 +42,6 @@ "@types/react": "^16.9", "classnames": "^2.2.6", "git-url-parse": "^11.4.4", - "moment": "^2.26.0", "react": "^16.13.1", "react-dom": "^16.13.1", "react-helmet": "6.1.0", diff --git a/plugins/catalog/src/components/CatalogPage/utils/timeUtil.js b/plugins/catalog/src/components/CatalogPage/utils/timeUtil.js index 327f4177a8..e464b1d8fb 100644 --- a/plugins/catalog/src/components/CatalogPage/utils/timeUtil.js +++ b/plugins/catalog/src/components/CatalogPage/utils/timeUtil.js @@ -14,36 +14,10 @@ * limitations under the License. */ -import moment from 'moment'; import goodMorning from './locales/goodMorning.locales.json'; import goodAfternoon from './locales/goodAfternoon.locales.json'; import goodEvening from './locales/goodEvening.locales.json'; -/** - * Validates that a date is a valid ISO string. - * - * @param date A date string - * @returns {bool} Whether the date is valid or not. - */ -export function isValidDate(date) { - return moment(date).isValid(); -} - -/** - * Validates that a date is a valid ISO string and a specific format. - * - * @param date A date string - * @param format A format string or an array of format strings to validate against. - * @returns {bool} Whether the date is valid or not according to the format. - */ -export function isValidDateAndFormat(date, format) { - return moment(date, format, true).isValid(); -} - -export function relativeTime(timestamp) { - return moment(timestamp).fromNow(); -} - // Select a large random integer at startup, to prevent the greetings to change every time the user // navigates. const greetingRandomSeed = Math.floor(Math.random() * 1000000); diff --git a/plugins/catalog/src/components/CatalogPage/utils/timeUtil.test.js b/plugins/catalog/src/components/CatalogPage/utils/timeUtil.test.js index d18b4a5b20..a95273325e 100644 --- a/plugins/catalog/src/components/CatalogPage/utils/timeUtil.test.js +++ b/plugins/catalog/src/components/CatalogPage/utils/timeUtil.test.js @@ -14,20 +14,7 @@ * limitations under the License. */ -import { isValidDateAndFormat, getTimeBasedGreeting } from './timeUtil'; - -it('validates time format', () => { - const valid = isValidDateAndFormat( - '1970-01-01T00:00:00', - 'YYYY-MM-DD[T]HH:mm:ss', - ); - const invalid = isValidDateAndFormat( - '1970/01/01T00:00:00', - 'YYYY-MM-DD[T]HH:mm:ss', - ); - expect(valid).toBe(true); - expect(invalid).toBe(false); -}); +import { getTimeBasedGreeting } from './timeUtil'; it('has greeting and language', () => { const greeting = getTimeBasedGreeting();