Skip to content
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
4 changes: 2 additions & 2 deletions apps/site/app/[locale]/[...path]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ const getPage: FC<PageParams> = async props => {
// If we have a filename and layout then we have a page
if (context.filename && context.frontmatter.layout) {
return basePage.renderPage({
content: content,
content,
layout: context.frontmatter.layout,
context: context,
context,
});
}

Expand Down
4 changes: 2 additions & 2 deletions apps/site/app/[locale]/blog/[...path]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ const getPage: FC<PageParams> = async props => {
// Gets the Markdown content and context for Blog pages
// otherwise this is likely a blog-category or a blog post
const [content, context] = await basePage.getMarkdownContext({
locale: locale,
locale,
pathname: `blog/${pathname}`,
});

// If this isn't a valid dynamic route for blog post or there's no markdown file
// for this, then we fail as not found as there's nothing we can do.
if (isDynamicRoute || context.filename) {
return basePage.renderPage({
content: content,
content,
layout: context.frontmatter.layout ?? 'blog-category',
context: { ...context, pathname: `/blog/${pathname}` },
});
Expand Down
6 changes: 3 additions & 3 deletions apps/site/app/[locale]/download/archive/[version]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const generateStaticParams = async () => {

return ARCHIVE_DYNAMIC_ROUTES.map(version => ({
locale: defaultLocale.code,
version: version,
version,
}));
};

Expand All @@ -58,15 +58,15 @@ const getPage: FC<PageParams> = async props => {

// Gets the Markdown content and context for Download Archive pages
const [content, context] = await basePage.getMarkdownContext({
locale: locale,
locale,
pathname: 'download/archive',
});

// If this isn't a valid dynamic route for archive version or there's no markdown
// file for this, then we fail as not found as there's nothing we can do.
if (isDynamicRoute && context.filename) {
return basePage.renderPage({
content: content,
content,
layout: context.frontmatter.layout!,
context: { ...context, pathname: `/download/archive/${pathname}` },
});
Expand Down
4 changes: 2 additions & 2 deletions apps/site/app/[locale]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ const getPage: FC<PageParams> = async props => {
// If we have a filename and layout then we have a page
if (context.filename && context.frontmatter.layout) {
return basePage.renderPage({
content: content,
content,
layout: context.frontmatter.layout,
context: context,
context,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ const PrebuiltDownloadButtons: FC = () => {
const installerUrl = platform
? getNodeDownloadUrl({
versionWithPrefix: release.versionWithPrefix,
os: os,
platform: platform,
os,
platform,
kind: 'installer',
})
: '';

const binaryUrl = platform
? getNodeDownloadUrl({
versionWithPrefix: release.versionWithPrefix,
os: os,
platform: platform,
os,
platform,
kind: 'binary',
})
: '';
Expand Down
4 changes: 2 additions & 2 deletions apps/site/components/Downloads/Release/VersionDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ const VersionDropdown: FC = () => {
);

if (release?.isLts && pathname.includes('current')) {
redirect({ href: '/download', locale: locale });
redirect({ href: '/download', locale });
return;
}

if (release?.status === 'Current' && !pathname.includes('current')) {
redirect({ href: '/download/current', locale: locale });
redirect({ href: '/download/current', locale });
return;
}

Expand Down
4 changes: 1 addition & 3 deletions apps/site/components/withBreadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ const WithBreadcrumbs: FC<WithBreadcrumbsProps> = ({ navKeys = [] }) => {
// Goes deeper on the tree of items if there are any.
currentNode = items;

return label
? [...breadcrumbs, { label: label, href: link }]
: breadcrumbs;
return label ? [...breadcrumbs, { label, href: link }] : breadcrumbs;
}

return breadcrumbs;
Expand Down
2 changes: 1 addition & 1 deletion apps/site/components/withFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const WithFooter: FC = () => {
const { socialLinks, footerLinks } = siteNavigation;

const navigation = {
socialLinks: socialLinks,
socialLinks,
footerLinks: footerLinks.map(link => ({ ...link, text: t(link.text) })),
};

Expand Down
4 changes: 2 additions & 2 deletions apps/site/components/withNavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ const WithNavBar: FC = () => {

<NavBar
navItems={navigationItems.map(([, { label, link, target }]) => ({
link: link,
link,
text: label,
target: target,
target,
}))}
pathname={pathname}
as={Link}
Expand Down
97 changes: 38 additions & 59 deletions apps/site/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,60 +1,36 @@
import { FlatCompat } from '@eslint/eslintrc';
import { flatConfigs } from 'eslint-plugin-import-x';
import next from '@next/eslint-plugin-next';
import * as mdx from 'eslint-plugin-mdx';
import react from 'eslint-plugin-react';
import tseslint from 'typescript-eslint';
import * as hooks from 'eslint-plugin-react-hooks';

import baseConfig from '../../eslint.config.js';

const compat = new FlatCompat();

const compatConfig = compat.config({
extends: [
// https://github.com/vercel/next.js/discussions/49337
'plugin:@next/eslint-plugin-next/core-web-vitals',
export default baseConfig.concat([
{
ignores: ['pages/en/blog/**/*.{md,mdx}/**', 'public', 'next-env.d.ts'],
},

// https://github.com/facebook/react/issues/28313
'plugin:react-hooks/recommended',
],
});
react.configs.flat['jsx-runtime'],
hooks.configs['recommended-latest'],
next.flatConfig.coreWebVitals,
mdx.flatCodeBlocks,

export default tseslint.config(
...baseConfig,
{ ignores: ['pages/en/blog/**/*.{md,mdx}/**', 'public', 'next-env.d.ts'] },
// Type-checking
{
extends: [
react.configs.flat['jsx-runtime'],
...tseslint.configs.recommended,
flatConfigs.typescript,
...compatConfig,
],
files: ['**/*.{js,md,mdx,mjs,ts,tsx}'],
ignores: ['**/*.{md,mdx}', '**/*.{md,mdx}/**'],
languageOptions: {
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
'@typescript-eslint/array-type': ['error', { default: 'generic' }],
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-require-imports': 'off',
'@next/next/no-duplicate-head': 'off',
'import-x/no-duplicates': 'off',
},
settings: { react: { version: 'detect' } },
},
{
files: ['**/*.{md,mdx}'],
extends: [mdx.flat],
processor: mdx.createRemarkProcessor({ lintCodeBlocks: true }),
rules: {
'no-irregular-whitespace': 'off',
'@next/next/no-img-element': 'off',
'@next/next/no-html-link-for-pages': ['error', 'apps/site/pages/'],

// https://github.com/typescript-eslint/typescript-eslint/issues/9860
'@typescript-eslint/consistent-type-imports': 'off',
},
},
{
files: ['**/*.{mdx,tsx}'],
rules: {
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
'react/no-unescaped-entities': 'off',
'react/function-component-definition': [
'error',
Expand All @@ -63,22 +39,25 @@ export default tseslint.config(
unnamedComponents: 'arrow-function',
},
],
'no-restricted-syntax': [
'error',
{
selector:
"ImportDeclaration[source.value='react'][specifiers.0.type='ImportDefaultSpecifier']",
message:
'Default React import not allowed since we use the TypeScript jsx-transform. If you need a global type that collides with a React named export (such as `MouseEvent`), try using `globalThis.MouseHandler`',
},
{
selector:
"ImportDeclaration[source.value='react'] :matches(ImportNamespaceSpecifier)",
message:
'Named * React import is not allowed. Please import what you need from React with Named Imports',
},
],
},
settings: { react: { version: 'detect' } },
},

{
files: ['**/*.{md,mdx}/**'],
rules: {
'@typescript-eslint/no-require-imports': 'off',
},
},

{
...mdx.flat,
processor: mdx.createRemarkProcessor({ lintCodeBlocks: true }),
rules: {
...mdx.flat.rules,
'no-irregular-whitespace': 'off',
'@next/next/no-img-element': 'off',
'@next/next/no-html-link-for-pages': ['error', 'apps/site/pages/'],
},
},
mdx.flatCodeBlocks
);
]);
6 changes: 3 additions & 3 deletions apps/site/hooks/react-generic/useSiteNavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import type {
type Context = Record<string, RichTranslationValues>;
type Navigation = Record<string, NavigationEntry>;

interface MappedNavigationEntry {
type MappedNavigationEntry = {
items: Array<[string, MappedNavigationEntry]>;
label: FormattedMessage;
link: string;
target?: HTMLAttributeAnchorTarget | undefined;
}
};

// Provides Context replacement for variables within the Link. This is also something that is not going
// to happen in the future with `nodejs/nodejs.dev` codebase
Expand Down Expand Up @@ -49,7 +49,7 @@ const useSiteNavigation = () => {
] => [
key,
{
target: target,
target,
label: label ? getFormattedMessage(label, key) : '',
link: link ? replaceLinkWithContext(link, context[key]) : '',
items: items ? mapNavigationEntries(items, context) : [],
Expand Down
2 changes: 1 addition & 1 deletion apps/site/i18n.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default getRequestConfig(async ({ requestLocale }) => {
}

return {
locale: locale,
locale,
// This is the dictionary of messages to be loaded
messages: await loadLocaleDictionary(locale),
// We always define the App timezone as UTC
Expand Down
6 changes: 3 additions & 3 deletions apps/site/layouts/Blog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ const getBlogCategory = (pathname: string) => {
const { posts, pagination } = getBlogData(category, Number(page));

return {
category: category,
posts: posts,
pagination: pagination,
category,
posts,
pagination,
page: Number(page),
};
};
Expand Down
4 changes: 2 additions & 2 deletions apps/site/layouts/Post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import styles from './layouts.module.css';
const PostLayout: FC<PropsWithChildren> = ({ children }) => {
const { frontmatter } = useClientContext();

const authors = mapAuthorToCardAuthors(frontmatter.author);
const authors = mapAuthorToCardAuthors(frontmatter.author!);

const type = mapBlogCategoryToPreviewType(frontmatter.category);
const type = mapBlogCategoryToPreviewType(frontmatter.category!);

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('generateWebsiteFeeds', () => {
id: blogData.posts[0].slug,
title: blogData.posts[0].title,
guid: `${blogData.posts[0].slug}?${date.getTime()}`,
date: date,
date,
link: `${base}${blogData.posts[0].slug}`,
},
]);
Expand Down
12 changes: 6 additions & 6 deletions apps/site/next-data/generators/blogData.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ const getFrontMatter = (filename, source) => {
const slug = `/blog/${category}/${basename(filename, extname(filename))}`;

return {
title: title,
author: author,
username: username,
title,
author,
username,
date: new Date(date),
categories: categories,
slug: slug,
categories,
slug,
};
};

Expand Down Expand Up @@ -110,7 +110,7 @@ const generateBlogData = async () => {
)
);

return { categories: [...blogCategories], posts: posts };
return { categories: [...blogCategories], posts };
};

export default generateBlogData;
4 changes: 2 additions & 2 deletions apps/site/next-data/generators/releaseData.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const generateReleaseData = async () => {

return {
...support,
status: status,
status,
major: latestVersion.semver.major,
version: latestVersion.semver.raw,
versionWithPrefix: `v${latestVersion.semver.raw}`,
Expand All @@ -68,7 +68,7 @@ const generateReleaseData = async () => {
v8: latestVersion.dependencies.v8,
releaseDate: latestVersion.releaseDate,
modules: latestVersion.modules.version || '',
minorVersions: minorVersions,
minorVersions,
};
});
};
Expand Down
4 changes: 2 additions & 2 deletions apps/site/next-data/generators/websiteFeeds.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const generateWebsiteFeeds = ({ posts }) => {
({ category, title, description, file }) => {
const feed = new Feed({
id: file,
title: title,
title,
language: 'en',
link: canonicalUrl,
description: description || '',
Expand All @@ -46,7 +46,7 @@ const generateWebsiteFeeds = ({ posts }) => {
id: post.slug,
title: post.title,
author: post.author,
date: date,
date,
link: `${canonicalUrl}${post.slug}`,
guid:
time > guidTimestampStartDate
Expand Down
Loading
Loading