Skip to content

Commit 33d81b4

Browse files
authored
Next 13.4 and React 18 (#40039)
1 parent 508c463 commit 33d81b4

17 files changed

+2410
-6657
lines changed

.babelrc

-4
This file was deleted.

.eslintrc.cjs

+33-24
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,53 @@ module.exports = {
55
es2020: true,
66
node: true,
77
},
8-
parser: '@babel/eslint-parser',
9-
extends: ['eslint:recommended', 'standard', 'plugin:import/errors', 'prettier'],
8+
extends: [
9+
"eslint:recommended",
10+
"standard",
11+
"plugin:import/errors",
12+
"prettier",
13+
],
1014
parserOptions: {
11-
ecmaVersion: 11,
12-
requireConfigFile: 'false',
13-
babelOptions: { configFile: './.babelrc' },
14-
sourceType: 'module',
15+
ecmaVersion: 2022,
16+
requireConfigFile: "false",
17+
sourceType: "module",
1518
},
16-
ignorePatterns: ['tmp/*', '!/.*', '/.next/', 'script/bookmarklets/*', 'rest-api-description/'],
19+
ignorePatterns: [
20+
"tmp/*",
21+
"!/.*",
22+
"/.next/",
23+
"script/bookmarklets/*",
24+
"rest-api-description/",
25+
],
1726
rules: {
18-
'import/no-extraneous-dependencies': ['error', { packageDir: '.' }],
27+
"import/no-extraneous-dependencies": ["error", { packageDir: "." }],
1928
},
2029
overrides: [
2130
{
22-
files: ['**/tests/**/*.js'],
31+
files: ["**/tests/**/*.js"],
2332
env: {
2433
jest: true,
2534
},
2635
},
2736
{
28-
files: ['**/*.tsx', '**/*.ts'],
29-
plugins: ['@typescript-eslint', 'jsx-a11y'],
30-
extends: ['plugin:jsx-a11y/recommended'],
31-
parser: '@typescript-eslint/parser',
37+
files: ["**/*.tsx", "**/*.ts"],
38+
plugins: ["@typescript-eslint", "jsx-a11y"],
39+
extends: ["plugin:jsx-a11y/recommended"],
40+
parser: "@typescript-eslint/parser",
3241
rules: {
33-
camelcase: 'off',
34-
'no-unused-vars': 'off',
35-
'no-undef': 'off',
36-
'no-use-before-define': 'off',
37-
'@typescript-eslint/no-unused-vars': ['error'],
38-
'jsx-a11y/no-onchange': 'off',
42+
camelcase: "off",
43+
"no-unused-vars": "off",
44+
"no-undef": "off",
45+
"no-use-before-define": "off",
46+
"@typescript-eslint/no-unused-vars": ["error"],
47+
"jsx-a11y/no-onchange": "off",
3948
},
4049
},
4150
],
4251
settings: {
43-
'import/resolver': {
52+
"import/resolver": {
4453
typescript: true,
45-
node: true
46-
}
47-
}
48-
}
54+
node: true,
55+
},
56+
},
57+
};
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Based on https://nextjs.org/docs/pages/building-your-application/deploying/ci-build-caching#github-actions
2+
3+
name: Cache Nextjs build cache
4+
5+
description: Cache the .next/cache according to best practices
6+
7+
runs:
8+
using: 'composite'
9+
steps:
10+
- name: Cache .next/cache
11+
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # pin @3.3.1
12+
with:
13+
path: ${{ github.workspace }}/.next/cache
14+
# Generate a new cache whenever packages or source files change.
15+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.ts', '**/*.tsx') }}
16+
# If source files changed but packages didn't, rebuild from a prior cache.
17+
restore-keys: |
18+
${{ runner.os }}-nextjs-v13-${{ hashFiles('**/package-lock.json') }}-

.github/workflows/headless-tests.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,7 @@ jobs:
3535

3636
- uses: ./.github/actions/node-npm-setup
3737

38-
- name: Cache nextjs build
39-
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
40-
with:
41-
path: .next/cache
42-
key: ${{ runner.os }}-nextjs-${{ hashFiles('package*.json') }}
38+
- uses: ./.github/actions/cache-nextjs
4339

4440
- name: Run build script
4541
run: npm run build

.github/workflows/keep-caches-warm.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@ jobs:
2525

2626
- uses: ./.github/actions/node-npm-setup
2727

28-
- name: Cache nextjs build
29-
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
30-
with:
31-
path: .next/cache
32-
key: ${{ runner.os }}-nextjs-${{ hashFiles('package*.json') }}
28+
- uses: ./.github/actions/cache-nextjs
3329

3430
- name: Build
3531
run: npm run build

.github/workflows/local-dev.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ jobs:
2121
- name: Check out repo
2222
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
2323

24-
- uses: ./.github/actions/node-npm-setup
24+
# - uses: ./.github/actions/node-npm-setup
25+
- name: Install dependencies
26+
run: npm install
2527

2628
# Note that we don't check out docs-early-access, Elasticsearch,
2729
# or any remote translations. Nothing fancy here!

.github/workflows/sync-search-elasticsearch.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,7 @@ jobs:
126126

127127
- uses: ./.github/actions/node-npm-setup
128128

129-
- name: Cache nextjs build
130-
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
131-
with:
132-
path: .next/cache
133-
key: ${{ runner.os }}-nextjs-${{ hashFiles('package*.json') }}
129+
- uses: ./.github/actions/cache-nextjs
134130

135131
- name: Run build scripts
136132
run: npm run build

.github/workflows/sync-search-pr.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,7 @@ jobs:
5151

5252
- uses: ./.github/actions/node-npm-setup
5353

54-
- name: Cache nextjs build
55-
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
56-
with:
57-
path: .next/cache
58-
key: ${{ runner.os }}-nextjs-${{ hashFiles('package*.json') }}
54+
- uses: ./.github/actions/cache-nextjs
5955

6056
- name: Build
6157
run: npm run build

.github/workflows/test.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,7 @@ jobs:
152152
echo __ format, write to get_diff_files.txt __
153153
echo $DIFF | tr '\n' ' ' > get_diff_files.txt
154154
155-
- name: Cache nextjs build
156-
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
157-
with:
158-
path: .next/cache
159-
key: ${{ runner.os }}-nextjs-${{ hashFiles('package*.json') }}
155+
- uses: ./.github/actions/cache-nextjs
160156

161157
- name: Run build script
162158
run: npm run build

.npmrc

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# skip installing optional dependencies to avoid issues with troublesome `fsevents` module
2-
omit=optional
3-
41
# For 15-25% faster npm install
52
# https://www.peterbe.com/plog/benchmarking-npm-install-with-or-without-audit
63
# Also we have Dependabot alerts configured in the GitHub repo.

components/GenericError.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ export const SimpleHeader = () => {
4545
aria-label="Main"
4646
>
4747
<div className="d-flex flex-items-center" style={{ zIndex: 3 }} id="github-logo-mobile">
48-
<Link href={`/${router.locale}`}>
48+
<Link href={`/${router.locale}`} passHref legacyBehavior>
4949
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
5050
<a aria-hidden="true" tabIndex={-1}>
5151
<MarkGithubIcon size={32} className="color-fg-default" />
5252
</a>
5353
</Link>
5454

55-
<Link href={`/${router.locale}`}>
55+
<Link href={`/${router.locale}`} passHref legacyBehavior>
5656
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
5757
<a className="h4 color-fg-default no-underline no-wrap pl-2">GitHub Docs</a>
5858
</Link>

components/Link.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ export function Link(props: Props) {
2525
}
2626

2727
return (
28-
<NextLink href={locale ? `/${locale}${href}` : href || ''} locale={locale || false}>
28+
<NextLink
29+
href={locale ? `/${locale}${href}` : href || ''}
30+
locale={locale || false}
31+
passHref
32+
legacyBehavior
33+
>
2934
{/* eslint-disable-next-line jsx-a11y/anchor-has-content */}
3035
<a rel={isExternal ? 'noopener' : ''} {...restProps} />
3136
</NextLink>

jest.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ if (isActions) {
99
}
1010

1111
export default {
12+
preset: 'ts-jest',
1213
coverageThreshold: {
1314
global: {
1415
branches: 95,

next.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,8 @@ export default {
6161
// This makes it so that going Back will scroll to the previous position
6262
scrollRestoration: true,
6363
},
64+
65+
compiler: {
66+
styledComponents: true,
67+
},
6468
}

0 commit comments

Comments
 (0)