Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump dependencies and move to es6 #17

Merged
merged 3 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
197 changes: 66 additions & 131 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"npm-run-all": "^4.1.5",
"prettier": "^3.3.2",
"sharp": "^0.31.1",
"ts-jest": "^29.1.5",
"typescript": "5.5"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/.storybook/preview.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "../src/assets.css";
import "prismjs/themes/prism-okaidia.css";
import { domSheet } from "twind/sheets";
import { setup } from "../src/twind";
import { setup } from "../src/twind.js";

export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
Expand Down
6 changes: 0 additions & 6 deletions packages/frontend/jest.config.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
/** @type {import('jest').Config} */
const config = {
modulePathIgnorePatterns: ["dist"],
preset: "ts-jest",
testEnvironment: "jsdom",
globals: {
"ts-jest": {
useESM: true,
},
},
transform: {
"^.+\\.(t|j)sx?$": "@swc/jest",
},
Expand Down
5 changes: 4 additions & 1 deletion packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"private": true,
"main": "dist/index.js",
"type": "module",
"types": "dist/index.d.ts",
"scripts": {
"clean": "rimraf dist node_modules",
Expand All @@ -26,7 +27,6 @@
"@types/prismjs": "^1.26.0",
"date-fns": "^2.28.0",
"moment": "^2.29.1",
"node-fetch": "^2.6.7",
"prismjs": "^1.29.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
Expand All @@ -47,5 +47,8 @@
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"babel-loader": "^8.2.3"
},
"alias": {
"react/jsx-runtime": "react/jsx-runtime.js"
}
}
9 changes: 5 additions & 4 deletions packages/frontend/src/AsyncContext.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import fetchMock from "jest-fetch-mock";
import { render, waitFor } from "@testing-library/react";
import { useFetch } from "./AsyncContext";
import { useFetch } from "./AsyncContext.js";

function UseFetchTester({ url }: { url: string }) {
const { content, loading } = useFetch(url);
Expand All @@ -10,7 +11,7 @@ function UseFetchTester({ url }: { url: string }) {

describe("AsyncContext", () => {
beforeEach(() => {
fetchMock.resetMocks();
fetchMock.default.resetMocks();
});

describe("useFetch", () => {
Expand All @@ -26,7 +27,7 @@ describe("AsyncContext", () => {
it("it returns { loading: true } while response is not done", async () => {
const url = "/url/to/be/fetched/2";
//eslint-disable-next-line
fetchMock.mockReturnValue(new Promise((_) => {}));
fetchMock.default.mockReturnValue(new Promise((_) => {}));

const { container } = render(<UseFetchTester url={url} />);

Expand All @@ -38,7 +39,7 @@ describe("AsyncContext", () => {
it("it returns { loading: false, content } when response is done", async () => {
const url = "/url/to/be/fetched/3";
const content = "this is the content";
fetchMock.mockOnce(content);
fetchMock.default.mockOnce(content);

const { container } = render(<UseFetchTester url={url} />);

Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/AsyncContext.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import React, {
DependencyList,
EffectCallback,
PropsWithChildren,
Expand Down
6 changes: 3 additions & 3 deletions packages/frontend/src/DateSpan.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { parseISO } from "date-fns/fp";
import { format as fnsFormat } from "date-fns";
import { tw } from "./twind";
import React from "react";
import { format as fnsFormat, parseISO } from "date-fns";
import { tw } from "./twind.js";

export type DateSpanProps = {
iso?: string;
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/src/FetchTracker.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import { PropsWithChildren, useContext, useCallback, useState } from "react";
import { AsyncContext } from "./AsyncContext";
import { AsyncContext } from "./AsyncContext.js";

export function FetchTracker({ children }: PropsWithChildren<unknown>) {
const {
Expand Down
7 changes: 4 additions & 3 deletions packages/frontend/src/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Link } from "./links";
import { tw } from "./twind";
import { name } from "./title";
import React from "react";
import { Link } from "./links.js";
import { tw } from "./twind.js";
import { name } from "./title.js";

export interface FooterProps {
pkgVersion?: string;
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/src/Header.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import { render } from "@testing-library/react";
import { Header } from "./Header";
import { Header } from "./Header.js";

describe("Header", () => {
it("should render html with h1 with the given title", () => {
Expand Down
11 changes: 6 additions & 5 deletions packages/frontend/src/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { DateSpan } from "./DateSpan";
import { tw } from "./twind";
import { Icon, IconProps } from "./Icon";
import { createTitle } from "./title";
import { Anchor, Link } from "./links";
import React from "react";
import { DateSpan } from "./DateSpan.js";
import { tw } from "./twind.js";
import { Icon, IconProps } from "./Icon.js";
import { createTitle } from "./title.js";
import { Anchor, Link } from "./links.js";

export interface HeaderProps {
title?: string | null;
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/src/Icon.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import { render } from "@testing-library/react";
import { Icon } from "./Icon";
import { Icon } from "./Icon.js";

describe("Icon", () => {
it("should render an svg", () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/src/Icon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { tw } from "./twind";
import React from "react";
import { tw } from "./twind.js";

function LinkedInIcon() {
return (
Expand Down
5 changes: 3 additions & 2 deletions packages/frontend/src/LoadingBar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import { useMemo } from "react";
import { useFetchCounter } from "./FetchTracker";
import { tw, animation, keyframes } from "./twind";
import { useFetchCounter } from "./FetchTracker.js";
import { tw, animation, keyframes } from "./twind.js";

function creatingAnimation() {
return animation(
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/src/Page.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import { ComponentMeta, ComponentStory } from "@storybook/react";
import { Page } from "./Page";
import { Page } from "./Page.js";

export default {
title: "Page",
Expand Down
11 changes: 6 additions & 5 deletions packages/frontend/src/Page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from "react";
import { PropsWithChildren, StrictMode } from "react";
import { tw } from "./twind";
import { Footer, FooterProps } from "./Footer";
import { Header, HeaderProps } from "./Header";
import { LoadingBar } from "./LoadingBar";
import { FetchTracker } from "./FetchTracker";
import { tw } from "./twind.js";
import { Footer, FooterProps } from "./Footer.js";
import { Header, HeaderProps } from "./Header.js";
import { LoadingBar } from "./LoadingBar.js";
import { FetchTracker } from "./FetchTracker.js";

export type PageProps = FooterProps & HeaderProps;

Expand Down
5 changes: 3 additions & 2 deletions packages/frontend/src/PageRenderer.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import { act, render } from "@testing-library/react";
import { PageRenderer } from "./PageRenderer";
import { history } from "./History";
import { PageRenderer } from "./PageRenderer.js";
import { history } from "./History.js";

jest.mock("./History", () => {
const history = jest.fn();
Expand Down
10 changes: 5 additions & 5 deletions packages/frontend/src/PageRenderer.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useCallback, useEffect, useState } from "react";
import { PageWithItems, PageWithListProps } from "./PageWithItems";
import { PageWithMarkdown, PageWithMarkdownProps } from "./PageWithMarkdown";
import { createTitle } from "./title";
import { history } from "./History";
import React, { useCallback, useEffect, useState } from "react";
import { PageWithItems, PageWithListProps } from "./PageWithItems.js";
import { PageWithMarkdown, PageWithMarkdownProps } from "./PageWithMarkdown.js";
import { createTitle } from "./title.js";
import { history } from "./History.js";

function getPageProps(input: PageRendererProps) {
if ("payload" in input) {
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/src/PageWithItems.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import { ComponentMeta, ComponentStory } from "@storybook/react";
import { PageWithItems } from "./PageWithItems";
import { PageWithItems } from "./PageWithItems.js";

export default {
title: "PageWithItems",
Expand Down
11 changes: 6 additions & 5 deletions packages/frontend/src/PageWithItems.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { DateSpan } from "./DateSpan";
import { Page, PageProps } from "./Page";
import { tw } from "./twind";
import { Anchor, Link } from "./links";
import { MarkedContent } from "./marked/MarkedContent";
import React from "react";
import { DateSpan } from "./DateSpan.js";
import { Page, PageProps } from "./Page.js";
import { tw } from "./twind.js";
import { Anchor, Link } from "./links.js";
import { MarkedContent } from "./marked/MarkedContent.js";

export type PageItem = {
date?: string;
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/src/PageWithMarkdown.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import { render, screen } from "@testing-library/react";
import { PageWithMarkdown } from "./PageWithMarkdown";
import { PageWithMarkdown } from "./PageWithMarkdown.js";

describe("PageWithMarkdown", () => {
it("should render html", async () => {
Expand Down
5 changes: 3 additions & 2 deletions packages/frontend/src/PageWithMarkdown.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from "react";
import { ComponentMeta, ComponentStory } from "@storybook/react";
import trueArticle from "../../web/src/articles/testing-rxjs.md";
import articleContainingTweet from "../../web/src/articles/devoxx-2014.md";
import { PageWithMarkdown } from "./PageWithMarkdown";
import { AsyncContext, AsyncContextState } from "./AsyncContext";
import { PageWithMarkdown } from "./PageWithMarkdown.js";
import { AsyncContext, AsyncContextState } from "./AsyncContext.js";

export default {
title: "PageWithMarkdown",
Expand Down
5 changes: 3 additions & 2 deletions packages/frontend/src/PageWithMarkdown.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Page, PageProps } from "./Page";
import { MarkedContent } from "./marked/MarkedContent";
import React from "react";
import { Page, PageProps } from "./Page.js";
import { MarkedContent } from "./marked/MarkedContent.js";

export type PageWithMarkdownProps = PageProps & {
bodyMarkdown?: string;
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/src/PrismCodeBlock.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import { render } from "@testing-library/react";
import { PrismCodeBlock } from "./PrismCodeBlock";
import { PrismCodeBlock } from "./PrismCodeBlock.js";

describe("PrismCode", () => {
it("should render formated the given code", () => {
Expand Down
5 changes: 3 additions & 2 deletions packages/frontend/src/PrismCodeBlock.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import { ComponentMeta, ComponentStory } from "@storybook/react";
import { PrismCodeBlock } from "./PrismCodeBlock";
import { Link } from "./links";
import { PrismCodeBlock } from "./PrismCodeBlock.js";
import { Link } from "./links.js";

export default {
title: PrismCodeBlock.name,
Expand Down
5 changes: 3 additions & 2 deletions packages/frontend/src/PrismCodeBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import { PropsWithChildren } from "react";
import { getGrammar, highlight } from "./prism";
import { tw } from "./twind";
import { getGrammar, highlight } from "./prism.js";
import { tw } from "./twind.js";

export type PrismCodeProps = {
language?: string;
Expand Down
14 changes: 7 additions & 7 deletions packages/frontend/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { setup } from "./twind";
export * from "./PageWithMarkdown";
export * from "./PageWithItems";
export * from "./PageRenderer";
export * from "./md";
export * from "./title";
export * from "./History";
import { setup } from "./twind.js";
export * from "./PageWithMarkdown.js";
export * from "./PageWithItems.js";
export * from "./PageRenderer.js";
export * from "./md.js";
export * from "./title.js";
export * from "./History.js";

setup();
11 changes: 6 additions & 5 deletions packages/frontend/src/links.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import React from "react";
import fetchMock from "jest-fetch-mock";
import { render, fireEvent, waitFor } from "@testing-library/react";
import { Anchor } from "./links";
import * as history from "./History";
import { Anchor } from "./links.js";
import * as history from "./History.js";

jest.mock("./History", () => ({
history: jest.fn(),
}));

describe("links", () => {
beforeEach(() => {
fetchMock.resetMocks();
fetchMock.default.resetMocks();

jest.mocked(history.history).mockReturnValue({
pushState: jest.fn(),
Expand Down Expand Up @@ -59,7 +60,7 @@ describe("links", () => {

it("pushes the fetched state to history", async () => {
const payload = "payload";
fetchMock.mockOnce(payload);
fetchMock.default.mockOnce(payload);
const pushState = jest.fn();
jest.mocked(history.history).mockReturnValue({
pushState,
Expand All @@ -84,7 +85,7 @@ describe("links", () => {

it("pushes an href with an ending / to the history", async () => {
const payload = "payload";
fetchMock.mockOnce(payload);
fetchMock.default.mockOnce(payload);
const pushState = jest.fn();
jest.mocked(history.history).mockReturnValue({
pushState,
Expand Down
7 changes: 4 additions & 3 deletions packages/frontend/src/links.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from "react";
import { ComponentMeta, ComponentStory } from "@storybook/react";
import { PageWithMarkdown } from "./PageWithMarkdown";
import { Link } from "./links";
import { CodeSpan } from "./marked/CodeSpan";
import { PageWithMarkdown } from "./PageWithMarkdown.js";
import { Link } from "./links.js";
import { CodeSpan } from "./marked/CodeSpan.js";

export default {
title: "links",
Expand Down
7 changes: 4 additions & 3 deletions packages/frontend/src/links.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from "react";
import { MouseEvent, useCallback, PropsWithChildren } from "react";
import { tw } from "./twind";
import { Icon, IconProps } from "./Icon";
import { history } from "./History";
import { tw } from "./twind.js";
import { Icon, IconProps } from "./Icon.js";
import { history } from "./History.js";

function computeHref(href: string) {
if (!href.endsWith("/")) {
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/marked/CodeBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { CodeBlockRendererProps } from "react-marked-renderer";
import { PrismCodeBlock } from "../PrismCodeBlock";
import { PrismCodeBlock } from "../PrismCodeBlock.js";

export function CodeBlock({ lang, children }: CodeBlockRendererProps) {
const code = typeof children === "string" ? children : undefined;
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/marked/CodeSpan.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { CodeSpanRendererProps } from "react-marked-renderer";
import { tw } from "../twind";
import { tw } from "../twind.js";

export function CodeSpan({ children }: CodeSpanRendererProps) {
return <code className={tw`bg-gray-200 rounded px-1`}>{children}</code>;
Expand Down
Loading
Loading