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

Switch to "moduleResolution": "NodeNext" in tsconfig.json #186

Draft
wants to merge 31 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2a8b679
Switch to `"moduleResolution": "node16"` in `tsconfig.json`
kachkaev Oct 31, 2022
9e0e62a
Fix import
kachkaev Oct 31, 2022
4876e2b
Patch webpack config
kachkaev Oct 31, 2022
fecf8fe
Tweak tsconfig
kachkaev Oct 31, 2022
6bd6eea
Merge remote-tracking branch 'origin/main' into ak/esm-module-resolution
kachkaev Oct 31, 2022
ce7905d
Merge branch 'main' into ak/esm-module-resolution
kachkaev Nov 8, 2022
352eb42
Update yarn.lock
kachkaev Nov 8, 2022
e2a0b6c
Merge remote-tracking branch 'origin/main' into ak/esm-module-resolution
kachkaev Jan 21, 2023
2081516
Merge branch 'ak/esm-module-resolution' of github.com:kachkaev/njt in…
kachkaev Jan 21, 2023
1e516e6
`yarn fix:yarn-dedupe`
kachkaev Jan 21, 2023
dea0614
Remove unused ESLint disable directive
kachkaev Jan 21, 2023
2696db0
Remove `typeof` hack to test `typescript@4.9.4`
kachkaev Jan 21, 2023
c61c7b2
Revert "Remove `typeof` hack to test `typescript@4.9.4`"
kachkaev Jan 22, 2023
1b29c73
Align `package.json` with `main` to reduce diff
kachkaev Jan 22, 2023
7762b66
Merge remote-tracking branch 'origin/main' into ak/esm-module-resolution
kachkaev Mar 8, 2023
5a9fbff
Merge remote-tracking branch 'origin/main' into ak/esm-module-resolution
kachkaev Mar 25, 2023
d60a109
Merge remote-tracking branch 'origin/main' into ak/esm-module-resolution
kachkaev Mar 25, 2023
62bf013
yarn `fix:yarn-dedupe`
kachkaev Mar 25, 2023
dfa7763
Merge branch 'main' into ak/esm-module-resolution
kachkaev Apr 17, 2023
04e1024
Fix yarn.lock
kachkaev Apr 18, 2023
c11c67e
Merge remote-tracking branch 'origin/main' into ak/esm-module-resolution
kachkaev Apr 18, 2023
75ce596
Merge remote-tracking branch 'origin/main' into ak/esm-module-resolution
kachkaev Jun 3, 2023
e5ad9d2
Merge remote-tracking branch 'origin/main' into ak/esm-module-resolution
kachkaev Jun 3, 2023
1a9ef19
Merge remote-tracking branch 'origin/main' into ak/esm-module-resolution
kachkaev Jun 3, 2023
c34a2ed
Merge remote-tracking branch 'origin/main' into ak/esm-module-resolution
kachkaev Jul 15, 2023
9c29034
yarn.lock
kachkaev Jul 15, 2023
8039409
Reduce diff in yarn.lock
kachkaev Jul 15, 2023
70c0ad1
Merge main
kachkaev Nov 16, 2023
b3f37ab
Merge remote-tracking branch 'origin/main' into ak/esm-module-resolution
kachkaev Nov 16, 2023
2276aa8
wip
kachkaev Nov 16, 2023
b97b161
eslint-import-resolver-typescript
kachkaev Nov 16, 2023
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
11 changes: 11 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
require("@rushstack/eslint-patch/modern-module-resolution.js");

/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: [
"@kachkaev/eslint-config-react",
"@kachkaev/eslint-config-react/extra-type-checking",
"plugin:@next/next/recommended",
],
parserOptions: { tsconfigRootDir: __dirname },
settings: {
"import/resolver": {
typescript: {
alwaysTryTypes: true,
project: `${__dirname}/tsconfig.json`,
},
},
},
};
15 changes: 15 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ const nextConfig = {
destination: "/api/jump",
},
],

webpack: (config) => {
return {
...config,
resolve: {
...config.resolve,
extensionAlias: {
/* eslint-disable @typescript-eslint/naming-convention -- external API */
".js": [".js", ".ts"],
".jsx": [".jsx", ".tsx"],
/* eslint-enable @typescript-eslint/naming-convention -- external API */
},
},
};
},
};

export default nextConfig;
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@
"@kachkaev/eslint-config-react": "0.6.0",
"@kachkaev/markdownlint-config": "0.5.0",
"@next/eslint-plugin-next": "14.0.2",
"@rushstack/eslint-patch": "1.5.1",
"@tsconfig/next": "2.0.1",
"@tsconfig/strictest": "2.0.2",
"@types/hosted-git-info": "3.0.5",
"@types/node": "20.9.0",
"@types/react": "18.2.37",
"eslint": "8.53.0",
"eslint-import-resolver-typescript": "3.6.1",
"husky": "8.0.3",
"lint-staged": "15.1.0",
"markdownlint-cli": "0.37.0",
Expand Down
4 changes: 2 additions & 2 deletions pages/404.page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { NextPage } from "next";
import * as React from "react";

import { ErrorPageBody } from "./shared/error-page-body";
import { PageMetadata } from "./shared/page-metadata";
import { ErrorPageBody } from "./shared/error-page-body.jsx";
import { PageMetadata } from "./shared/page-metadata.jsx";

const Page: NextPage = () => {
const message = "page not found";
Expand Down
5 changes: 2 additions & 3 deletions pages/_app.page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// eslint-disable-next-line import/no-unresolved -- https://github.com/import-js/eslint-plugin-import/issues/1810
import { Analytics } from "@vercel/analytics/react";
import type { AppProps } from "next/app";
import type { AppProps } from "next/app.js";
import * as React from "react";

import { PageLayout } from "./_app.page/page-layout";
import { PageLayout } from "./_app.page/page-layout.jsx";

const App: React.FunctionComponent<AppProps> = ({ Component, pageProps }) => {
React.useEffect(() => {
Expand Down
8 changes: 5 additions & 3 deletions pages/_app.page/page-layout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import * as React from "react";
import styled, { createGlobalStyle, css } from "styled-components";
import normalize from "styled-normalize";
import _styled, { createGlobalStyle, css } from "styled-components";
import { normalize } from "styled-normalize";

import { ExternalLink } from "../shared/external-link";
import { ExternalLink } from "../shared/external-link.jsx";

const styled = _styled as unknown as typeof _styled.default;

const base = css`
body {
Expand Down
6 changes: 4 additions & 2 deletions pages/_document.page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { DocumentContext } from "next/document";
import Document, { Head, Html, Main, NextScript } from "next/document";
import type { DocumentContext } from "next/document.js";
import _Document, { Head, Html, Main, NextScript } from "next/document.js";
import * as React from "react";
import { ServerStyleSheet } from "styled-components";

const Document = _Document as unknown as typeof _Document.default;

export default class MyDocument extends Document {
static override async getInitialProps(ctx: DocumentContext) {
const sheet = new ServerStyleSheet();
Expand Down
4 changes: 2 additions & 2 deletions pages/_error.page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { NextPage } from "next";
import * as React from "react";

import { ErrorPageBody } from "./shared/error-page-body";
import { PageMetadata } from "./shared/page-metadata";
import { ErrorPageBody } from "./shared/error-page-body.jsx";
import { PageMetadata } from "./shared/page-metadata.jsx";

const Page: NextPage<{ statusCode: number }> = ({ statusCode }) => {
const message = "unknown error";
Expand Down
2 changes: 1 addition & 1 deletion pages/api/jump.handler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { NextApiHandler } from "next";

import { resolveDestination } from "../shared/destinations";
import { resolveDestination } from "../shared/destinations.js";

const handler: NextApiHandler = async (req, res) => {
let destinationUrl = "/";
Expand Down
14 changes: 8 additions & 6 deletions pages/index.page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import * as React from "react";
import styled from "styled-components";
import _styled from "styled-components";

import { AvailableDestinations } from "./index.page/available-destinations";
import { Example } from "./index.page/example";
import { InputForm } from "./index.page/input-form";
import { ExternalLink } from "./shared/external-link";
import { PageMetadata } from "./shared/page-metadata";
import { AvailableDestinations } from "./index.page/available-destinations.jsx";
import { Example } from "./index.page/example.jsx";
import { InputForm } from "./index.page/input-form.jsx";
import { ExternalLink } from "./shared/external-link.jsx";
import { PageMetadata } from "./shared/page-metadata.jsx";

const styled = _styled as unknown as typeof _styled.default;

const H2 = styled.h2`
margin-top: 3em;
Expand Down
8 changes: 5 additions & 3 deletions pages/index.page/available-destinations.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import * as React from "react";
import styled from "styled-components";
import _styled from "styled-components";

import { ExternalLink } from "../shared/external-link";
import { ClickableCode } from "./clickable-code";
import { ExternalLink } from "../shared/external-link.jsx";
import { ClickableCode } from "./clickable-code.jsx";

const styled = _styled as unknown as typeof _styled.default;

const Ul = styled.ul`
padding-left: 0;
Expand Down
4 changes: 3 additions & 1 deletion pages/index.page/clickable-code.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import styled from "styled-components";
import _styled from "styled-components";

const styled = _styled as unknown as typeof _styled.default;

export const ClickableCode = styled.code`
border-bottom: 1px dotted transparent;
Expand Down
8 changes: 5 additions & 3 deletions pages/index.page/example.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import * as React from "react";
import styled from "styled-components";
import _styled from "styled-components";

import { ExternalLink } from "../shared/external-link";
import { ClickableCode } from "./clickable-code";
import { ExternalLink } from "../shared/external-link.jsx";
import { ClickableCode } from "./clickable-code.jsx";

const styled = _styled as unknown as typeof _styled.default;

const Remark = styled.span`
white-space: nowrap;
Expand Down
4 changes: 3 additions & 1 deletion pages/index.page/input-form.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as React from "react";
import styled from "styled-components";
import _styled from "styled-components";

const styled = _styled as unknown as typeof _styled.default;

const verticalFormPadding = 20;

Expand Down
2 changes: 1 addition & 1 deletion pages/shared/destinations.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import hostedGitInfo from "hosted-git-info";
import { LRUCache } from "lru-cache";

import type { JsonObject } from "./json-types";
import type { JsonObject } from "./json-types.js";

export interface SuccessfullyResolvedDestination {
outcome: "success";
Expand Down
7 changes: 5 additions & 2 deletions pages/shared/error-page-body.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import Link from "next/link";
import _Link from "next/link.js";
import * as React from "react";
import styled from "styled-components";
import _styled from "styled-components";

const Link = _Link as unknown as typeof _Link.default;
const styled = _styled as unknown as typeof _styled.default;

const Container = styled.div`
text-align: center;
Expand Down
4 changes: 3 additions & 1 deletion pages/shared/page-metadata.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Head from "next/head";
import _Head from "next/head.js";
import * as React from "react";

const Head = _Head as unknown as typeof _Head.default;

const getBaseUrl = () => {
const hostname = process.env["NEXT_PUBLIC_VERCEL_URL"] ?? "njt.vercel.app";
const protocol = hostname.split(":")[0] === "localhost" ? "http" : "https";
Expand Down
73 changes: 65 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading