Skip to content

Commit 6176053

Browse files
committed
update to next 16.2
1 parent 40ea071 commit 6176053

Some content is hidden

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

43 files changed

+5584
-4766
lines changed

.eslintignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

.eslintrc

Lines changed: 0 additions & 37 deletions
This file was deleted.

eslint-local-rules/rules/metadata.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,19 @@ function parseExpectedErrorsEntries(rawEntries) {
8484

8585
if (parsed && typeof parsed === 'object') {
8686
for (const [key, value] of Object.entries(parsed)) {
87-
entries[key] = normalizeEntryValues(Array.isArray(value) ? value.flat() : value);
87+
entries[key] = normalizeEntryValues(
88+
Array.isArray(value) ? value.flat() : value
89+
);
8890
}
8991
}
9092

9193
return entries;
9294
}
9395

9496
function parseExpectedErrorsToken(tokenText) {
95-
const match = tokenText.match(/^\{\s*expectedErrors\s*:\s*(\{[\s\S]*\})\s*\}$/);
97+
const match = tokenText.match(
98+
/^\{\s*expectedErrors\s*:\s*(\{[\s\S]*\})\s*\}$/
99+
);
96100
if (!match) {
97101
return null;
98102
}
@@ -103,7 +107,7 @@ function parseExpectedErrorsToken(tokenText) {
103107

104108
try {
105109
entries = parseExpectedErrorsEntries(entriesSource);
106-
} catch (error) {
110+
} catch (_error) {
107111
parseError = true;
108112
entries = {};
109113
}
@@ -203,7 +207,9 @@ function cloneMetadata(metadata) {
203207
}
204208

205209
function findExpectedErrorsToken(metadata) {
206-
return metadata.tokens.find((token) => token.type === 'expectedErrors') || null;
210+
return (
211+
metadata.tokens.find((token) => token.type === 'expectedErrors') || null
212+
);
207213
}
208214

209215
function getCompilerExpectedLines(metadata) {

eslint-local-rules/rules/react-compiler.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function runReactCompiler(code, filename) {
8282
configFile: false,
8383
babelrc: false,
8484
});
85-
} catch (error) {
85+
} catch (_error) {
8686
return {...result, diagnostics: []};
8787
}
8888

@@ -98,17 +98,19 @@ function runReactCompiler(code, filename) {
9898
continue;
9999
}
100100

101-
const loc = typeof detail.primaryLocation === 'function'
102-
? detail.primaryLocation()
103-
: null;
101+
const loc =
102+
typeof detail.primaryLocation === 'function'
103+
? detail.primaryLocation()
104+
: null;
104105

105106
if (loc == null || typeof loc === 'symbol') {
106107
continue;
107108
}
108109

109-
const message = typeof detail.printErrorMessage === 'function'
110-
? detail.printErrorMessage(result.sourceCode, {eslint: true})
111-
: detail.description || 'Unknown React Compiler error';
110+
const message =
111+
typeof detail.printErrorMessage === 'function'
112+
? detail.printErrorMessage(result.sourceCode, {eslint: true})
113+
: detail.description || 'Unknown React Compiler error';
112114

113115
diagnostics.push({detail, loc, message});
114116
}

eslint.config.mjs

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import nextCoreWebVitals from "eslint-config-next/core-web-vitals";
2+
import reactCompiler from "eslint-plugin-react-compiler";
3+
import localRules from "eslint-plugin-local-rules";
4+
import globals from "globals";
5+
import tsParser from "@typescript-eslint/parser";
6+
import parser from "./eslint-local-rules/parser.js";
7+
8+
// Extract plugin instances from next's config to avoid
9+
// "Cannot redefine plugin" errors in flat config.
10+
function getNextPlugin(name) {
11+
return nextCoreWebVitals.find((c) => c.plugins?.[name])?.plugins[name];
12+
}
13+
const tsPlugin = getNextPlugin("@typescript-eslint");
14+
const reactHooksPlugin = getNextPlugin("react-hooks");
15+
16+
export default [
17+
{
18+
ignores: [
19+
"**/scripts",
20+
"**/plugins",
21+
"**/next.config.js",
22+
"**/.claude/",
23+
"**/worker-bundle.dist.js",
24+
],
25+
},
26+
...nextCoreWebVitals,
27+
{
28+
plugins: {
29+
"@typescript-eslint": tsPlugin,
30+
"react-hooks": reactHooksPlugin,
31+
"react-compiler": reactCompiler,
32+
"local-rules": localRules,
33+
},
34+
35+
languageOptions: {
36+
globals: Object.fromEntries(
37+
Object.entries({
38+
...globals.node,
39+
...globals.commonjs,
40+
...globals.browser,
41+
}).map(([key, value]) => [key.trim(), value])
42+
),
43+
44+
parser: tsParser,
45+
},
46+
47+
rules: {
48+
"no-unused-vars": "off",
49+
50+
"@typescript-eslint/no-unused-vars": ["error", {
51+
varsIgnorePattern: "^_",
52+
caughtErrorsIgnorePattern: "^_",
53+
}],
54+
55+
"react-hooks/exhaustive-deps": "error",
56+
57+
"react/no-unknown-property": ["error", {
58+
ignore: ["meta"],
59+
}],
60+
61+
// New rules in react-hooks plugin — pre-existing patterns need refactoring
62+
"react-hooks/set-state-in-effect": "warn",
63+
"react-hooks/refs": "warn",
64+
65+
"react-compiler/react-compiler": "error",
66+
"local-rules/lint-markdown-code-blocks": "error",
67+
},
68+
},
69+
{
70+
files: ["src/content/**/*.md"],
71+
72+
languageOptions: {
73+
parser: parser,
74+
ecmaVersion: 5,
75+
sourceType: "module",
76+
},
77+
78+
rules: {
79+
"no-unused-vars": "off",
80+
"@typescript-eslint/no-unused-vars": "off",
81+
"react-hooks/exhaustive-deps": "off",
82+
"react/no-unknown-property": "off",
83+
"react-compiler/react-compiler": "off",
84+
"local-rules/lint-markdown-code-blocks": "error",
85+
},
86+
},
87+
];

next-env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3+
import './.next/types/routes.d.ts';
34

45
// NOTE: This file should not be edited
56
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.

next.config.js

Lines changed: 18 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,29 @@
1313
* @type {import('next').NextConfig}
1414
**/
1515
const nextConfig = {
16+
turbopack: {
17+
resolveAlias: {
18+
// Don't bundle the shim unnecessarily.
19+
'use-sync-external-store/shim': 'react',
20+
// ESLint depends on the CommonJS version of esquery,
21+
// but Webpack loads the ESM version by default. This
22+
// alias ensures the correct version is used.
23+
//
24+
// More info:
25+
// https://github.com/reactjs/react.dev/pull/8115
26+
esquery: 'esquery/dist/esquery.min.js',
27+
// Replace transitive dependencies with lightweight shims.
28+
raf: './src/utils/rafShim.js',
29+
process: './src/utils/processShim.js',
30+
},
31+
},
1632
pageExtensions: ['jsx', 'js', 'ts', 'tsx', 'mdx', 'md'],
1733
reactStrictMode: true,
1834
experimental: {
1935
scrollRestoration: true,
20-
reactCompiler: true,
36+
turbopackImportTypeText: true,
2137
},
38+
reactCompiler: true,
2239
async rewrites() {
2340
return {
2441
beforeFiles: [
@@ -44,58 +61,6 @@ const nextConfig = {
4461
};
4562
},
4663
env: {},
47-
webpack: (config, {dev, isServer, ...options}) => {
48-
if (process.env.ANALYZE) {
49-
const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer');
50-
config.plugins.push(
51-
new BundleAnalyzerPlugin({
52-
analyzerMode: 'static',
53-
reportFilename: options.isServer
54-
? '../analyze/server.html'
55-
: './analyze/client.html',
56-
})
57-
);
58-
}
59-
60-
// Don't bundle the shim unnecessarily.
61-
config.resolve.alias['use-sync-external-store/shim'] = 'react';
62-
63-
// ESLint depends on the CommonJS version of esquery,
64-
// but Webpack loads the ESM version by default. This
65-
// alias ensures the correct version is used.
66-
//
67-
// More info:
68-
// https://github.com/reactjs/react.dev/pull/8115
69-
config.resolve.alias['esquery'] = 'esquery/dist/esquery.min.js';
70-
71-
const {IgnorePlugin, NormalModuleReplacementPlugin} = require('webpack');
72-
config.plugins.push(
73-
new NormalModuleReplacementPlugin(
74-
/^raf$/,
75-
require.resolve('./src/utils/rafShim.js')
76-
),
77-
new NormalModuleReplacementPlugin(
78-
/^process$/,
79-
require.resolve('./src/utils/processShim.js')
80-
),
81-
new IgnorePlugin({
82-
checkResource(resource, context) {
83-
if (
84-
/\/eslint\/lib\/rules$/.test(context) &&
85-
/\.\/[\w-]+(\.js)?$/.test(resource)
86-
) {
87-
// Skips imports of built-in rules that ESLint
88-
// tries to carry into the bundle by default.
89-
// We only want the engine and the React rules.
90-
return true;
91-
}
92-
return false;
93-
},
94-
})
95-
);
96-
97-
return config;
98-
},
9964
};
10065

10166
module.exports = nextConfig;

package.json

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
"private": true,
55
"license": "CC",
66
"scripts": {
7-
"analyze": "ANALYZE=true next build",
7+
"analyze": "next experimental-analyze",
88
"dev": "next-remote-watch ./src/content",
9-
"prebuild:rsc": "node scripts/buildRscWorker.mjs",
109
"build": "node scripts/buildRscWorker.mjs && next build && node --experimental-modules ./scripts/downloadFonts.mjs",
11-
"lint": "next lint && eslint \"src/content/**/*.md\"",
12-
"lint:fix": "next lint --fix && eslint \"src/content/**/*.md\" --fix",
10+
"lint": "eslint . && eslint \"src/content/**/*.md\"",
11+
"lint:fix": "eslint --fix . && eslint \"src/content/**/*.md\" --fix",
1312
"format:source": "prettier --config .prettierrc --write \"{plugins,src}/**/*.{js,ts,jsx,tsx,css}\"",
1413
"nit:source": "prettier --config .prettierrc --list-different \"{plugins,src}/**/*.{js,ts,jsx,tsx,css}\"",
1514
"prettier": "yarn format:source",
@@ -36,13 +35,12 @@
3635
"classnames": "^2.2.6",
3736
"debounce": "^1.2.1",
3837
"github-slugger": "^1.3.0",
39-
"next": "15.1.12",
38+
"next": "16.2.0",
4039
"next-remote-watch": "^1.0.0",
4140
"parse-numeric-range": "^1.2.0",
42-
"raw-loader": "^4.0.2",
43-
"react": "^19.0.0",
41+
"react": "19.2.4",
4442
"react-collapsed": "4.0.4",
45-
"react-dom": "^19.0.0",
43+
"react-dom": "19.2.4",
4644
"remark-frontmatter": "^4.0.1",
4745
"remark-gfm": "^3.0.1"
4846
},
@@ -58,8 +56,9 @@
5856
"@types/mdx-js__react": "^1.5.2",
5957
"@types/node": "^14.6.4",
6058
"@types/parse-numeric-range": "^0.0.1",
61-
"@types/react": "^19.0.0",
62-
"@types/react-dom": "^19.0.0",
59+
"@types/prop-types": "^15.7.15",
60+
"@types/react": "19.2.14",
61+
"@types/react-dom": "19.2.3",
6362
"@typescript-eslint/eslint-plugin": "^5.36.2",
6463
"@typescript-eslint/parser": "^5.36.2",
6564
"asyncro": "^3.0.0",
@@ -68,8 +67,8 @@
6867
"babel-plugin-react-compiler": "^1.0.0",
6968
"chalk": "4.1.2",
7069
"esbuild": "^0.24.0",
71-
"eslint": "7.x",
72-
"eslint-config-next": "12.0.3",
70+
"eslint": "^9",
71+
"eslint-config-next": "16.2.0",
7372
"eslint-config-react-app": "^5.2.1",
7473
"eslint-plugin-flowtype": "4.x",
7574
"eslint-plugin-import": "2.x",
@@ -90,7 +89,7 @@
9089
"postcss": "^8.4.5",
9190
"postcss-flexbugs-fixes": "4.2.1",
9291
"postcss-preset-env": "^6.7.0",
93-
"prettier": "^2.5.1",
92+
"prettier": "^3.8.1",
9493
"react-server-dom-webpack": "^19.2.4",
9594
"reading-time": "^1.2.0",
9695
"remark": "^12.0.1",
@@ -104,20 +103,18 @@
104103
"rss": "^1.2.2",
105104
"tailwindcss": "^3.4.1",
106105
"typescript": "^5.7.2",
107-
"unist-util-visit": "^2.0.3",
108-
"webpack-bundle-analyzer": "^4.5.0"
106+
"unist-util-visit": "^2.0.3"
109107
},
110108
"engines": {
111109
"node": ">=16.8.0"
112110
},
113-
"nextBundleAnalysis": {
114-
"budget": null,
115-
"budgetPercentIncreaseRed": 10,
116-
"showDetails": true
117-
},
118111
"lint-staged": {
119112
"*.{js,ts,jsx,tsx,css}": "yarn prettier",
120113
"src/**/*.md": "yarn fix-headings"
121114
},
122-
"packageManager": "yarn@1.22.22"
115+
"packageManager": "yarn@1.22.22",
116+
"resolutions": {
117+
"@types/react": "19.2.14",
118+
"@types/react-dom": "19.2.3"
119+
}
123120
}

0 commit comments

Comments
 (0)