Skip to content

Commit a035a8c

Browse files
committed
feat(linting): improve eslint
1 parent 03e8834 commit a035a8c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+393
-678
lines changed

apps/site/app/[locale]/[...path]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ const getPage: FC<PageParams> = async props => {
7474
// If we have a filename and layout then we have a page
7575
if (context.filename && context.frontmatter.layout) {
7676
return basePage.renderPage({
77-
content: content,
77+
content,
7878
layout: context.frontmatter.layout,
79-
context: context,
79+
context,
8080
});
8181
}
8282

apps/site/app/[locale]/blog/[...path]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ const getPage: FC<PageParams> = async props => {
5050
// Gets the Markdown content and context for Blog pages
5151
// otherwise this is likely a blog-category or a blog post
5252
const [content, context] = await basePage.getMarkdownContext({
53-
locale: locale,
53+
locale,
5454
pathname: `blog/${pathname}`,
5555
});
5656

5757
// If this isn't a valid dynamic route for blog post or there's no markdown file
5858
// for this, then we fail as not found as there's nothing we can do.
5959
if (isDynamicRoute || context.filename) {
6060
return basePage.renderPage({
61-
content: content,
61+
content,
6262
layout: context.frontmatter.layout ?? 'blog-category',
6363
context: { ...context, pathname: `/blog/${pathname}` },
6464
});

apps/site/app/[locale]/download/archive/[version]/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const generateStaticParams = async () => {
3131

3232
return ARCHIVE_DYNAMIC_ROUTES.map(version => ({
3333
locale: defaultLocale.code,
34-
version: version,
34+
version,
3535
}));
3636
};
3737

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

5959
// Gets the Markdown content and context for Download Archive pages
6060
const [content, context] = await basePage.getMarkdownContext({
61-
locale: locale,
61+
locale,
6262
pathname: 'download/archive',
6363
});
6464

6565
// If this isn't a valid dynamic route for archive version or there's no markdown
6666
// file for this, then we fail as not found as there's nothing we can do.
6767
if (isDynamicRoute && context.filename) {
6868
return basePage.renderPage({
69-
content: content,
69+
content,
7070
layout: context.frontmatter.layout!,
7171
context: { ...context, pathname: `/download/archive/${pathname}` },
7272
});

apps/site/app/[locale]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ const getPage: FC<PageParams> = async props => {
6464
// If we have a filename and layout then we have a page
6565
if (context.filename && context.frontmatter.layout) {
6666
return basePage.renderPage({
67-
content: content,
67+
content,
6868
layout: context.frontmatter.layout,
69-
context: context,
69+
context,
7070
});
7171
}
7272

apps/site/components/Downloads/Release/PrebuiltDownloadButtons.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ const PrebuiltDownloadButtons: FC = () => {
2424
const installerUrl = platform
2525
? getNodeDownloadUrl({
2626
versionWithPrefix: release.versionWithPrefix,
27-
os: os,
28-
platform: platform,
27+
os,
28+
platform,
2929
kind: 'installer',
3030
})
3131
: '';
3232

3333
const binaryUrl = platform
3434
? getNodeDownloadUrl({
3535
versionWithPrefix: release.versionWithPrefix,
36-
os: os,
37-
platform: platform,
36+
os,
37+
platform,
3838
kind: 'binary',
3939
})
4040
: '';

apps/site/components/Downloads/Release/VersionDropdown.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ const VersionDropdown: FC = () => {
3838
);
3939

4040
if (release?.isLts && pathname.includes('current')) {
41-
redirect({ href: '/download', locale: locale });
41+
redirect({ href: '/download', locale });
4242
return;
4343
}
4444

4545
if (release?.status === 'Current' && !pathname.includes('current')) {
46-
redirect({ href: '/download/current', locale: locale });
46+
redirect({ href: '/download/current', locale });
4747
return;
4848
}
4949

apps/site/components/withBreadcrumbs.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ const WithBreadcrumbs: FC<WithBreadcrumbsProps> = ({ navKeys = [] }) => {
5757
// Goes deeper on the tree of items if there are any.
5858
currentNode = items;
5959

60-
return label
61-
? [...breadcrumbs, { label: label, href: link }]
62-
: breadcrumbs;
60+
return label ? [...breadcrumbs, { label, href: link }] : breadcrumbs;
6361
}
6462

6563
return breadcrumbs;

apps/site/components/withFooter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const WithFooter: FC = () => {
1616
const { socialLinks, footerLinks } = siteNavigation;
1717

1818
const navigation = {
19-
socialLinks: socialLinks,
19+
socialLinks,
2020
footerLinks: footerLinks.map(link => ({ ...link, text: t(link.text) })),
2121
};
2222

apps/site/components/withNavBar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ const WithNavBar: FC = () => {
6262

6363
<NavBar
6464
navItems={navigationItems.map(([, { label, link, target }]) => ({
65-
link: link,
65+
link,
6666
text: label,
67-
target: target,
67+
target,
6868
}))}
6969
pathname={pathname}
7070
as={Link}

apps/site/eslint.config.js

Lines changed: 38 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,36 @@
1-
import { FlatCompat } from '@eslint/eslintrc';
2-
import { flatConfigs } from 'eslint-plugin-import-x';
1+
import next from '@next/eslint-plugin-next';
32
import * as mdx from 'eslint-plugin-mdx';
43
import react from 'eslint-plugin-react';
5-
import tseslint from 'typescript-eslint';
4+
import * as hooks from 'eslint-plugin-react-hooks';
65

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

9-
const compat = new FlatCompat();
10-
11-
const compatConfig = compat.config({
12-
extends: [
13-
// https://github.com/vercel/next.js/discussions/49337
14-
'plugin:@next/eslint-plugin-next/core-web-vitals',
8+
export default baseConfig.concat([
9+
{
10+
ignores: ['pages/en/blog/**/*.{md,mdx}/**', 'public', 'next-env.d.ts'],
11+
},
1512

16-
// https://github.com/facebook/react/issues/28313
17-
'plugin:react-hooks/recommended',
18-
],
19-
});
13+
react.configs.flat['jsx-runtime'],
14+
hooks.configs['recommended-latest'],
15+
next.flatConfig.coreWebVitals,
16+
mdx.flatCodeBlocks,
2017

21-
export default tseslint.config(
22-
...baseConfig,
23-
{ ignores: ['pages/en/blog/**/*.{md,mdx}/**', 'public', 'next-env.d.ts'] },
18+
// Type-checking
2419
{
25-
extends: [
26-
react.configs.flat['jsx-runtime'],
27-
...tseslint.configs.recommended,
28-
flatConfigs.typescript,
29-
...compatConfig,
30-
],
31-
files: ['**/*.{js,md,mdx,mjs,ts,tsx}'],
20+
ignores: ['**/*.{md,mdx}', '**/*.{md,mdx}/**'],
21+
languageOptions: {
22+
parserOptions: {
23+
project: './tsconfig.json',
24+
tsconfigRootDir: import.meta.dirname,
25+
},
26+
},
3227
rules: {
33-
'@typescript-eslint/array-type': ['error', { default: 'generic' }],
3428
'@typescript-eslint/consistent-type-imports': 'error',
35-
'@typescript-eslint/no-require-imports': 'off',
36-
'@next/next/no-duplicate-head': 'off',
37-
'import-x/no-duplicates': 'off',
3829
},
39-
settings: { react: { version: 'detect' } },
4030
},
41-
{
42-
files: ['**/*.{md,mdx}'],
43-
extends: [mdx.flat],
44-
processor: mdx.createRemarkProcessor({ lintCodeBlocks: true }),
45-
rules: {
46-
'no-irregular-whitespace': 'off',
47-
'@next/next/no-img-element': 'off',
48-
'@next/next/no-html-link-for-pages': ['error', 'apps/site/pages/'],
4931

50-
// https://github.com/typescript-eslint/typescript-eslint/issues/9860
51-
'@typescript-eslint/consistent-type-imports': 'off',
52-
},
53-
},
5432
{
55-
files: ['**/*.{mdx,tsx}'],
5633
rules: {
57-
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
5834
'react/no-unescaped-entities': 'off',
5935
'react/function-component-definition': [
6036
'error',
@@ -63,22 +39,25 @@ export default tseslint.config(
6339
unnamedComponents: 'arrow-function',
6440
},
6541
],
66-
'no-restricted-syntax': [
67-
'error',
68-
{
69-
selector:
70-
"ImportDeclaration[source.value='react'][specifiers.0.type='ImportDefaultSpecifier']",
71-
message:
72-
'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`',
73-
},
74-
{
75-
selector:
76-
"ImportDeclaration[source.value='react'] :matches(ImportNamespaceSpecifier)",
77-
message:
78-
'Named * React import is not allowed. Please import what you need from React with Named Imports',
79-
},
80-
],
42+
},
43+
settings: { react: { version: 'detect' } },
44+
},
45+
46+
{
47+
files: ['**/*.{md,mdx}/**'],
48+
rules: {
49+
'@typescript-eslint/no-require-imports': 'off',
50+
},
51+
},
52+
53+
{
54+
...mdx.flat,
55+
processor: mdx.createRemarkProcessor({ lintCodeBlocks: true }),
56+
rules: {
57+
...mdx.flat.rules,
58+
'no-irregular-whitespace': 'off',
59+
'@next/next/no-img-element': 'off',
60+
'@next/next/no-html-link-for-pages': ['error', 'apps/site/pages/'],
8161
},
8262
},
83-
mdx.flatCodeBlocks
84-
);
63+
]);

0 commit comments

Comments
 (0)