Skip to content

Commit da102b5

Browse files
authored
Fix globals dependency for lint config (#15208)
1 parent 9b74dab commit da102b5

7 files changed

Lines changed: 35 additions & 77 deletions

File tree

eslint.config.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { createRequire } from "node:module";
22
import { fixupPluginRules } from "@eslint/compat";
33
import { defineConfig } from "eslint/config";
4+
import globals from "globals";
45

56
const require = createRequire(import.meta.url);
6-
const eslintRequire = createRequire(require.resolve("eslint/package.json"));
77

8-
const globals = eslintRequire("globals");
98
const reactAppConfig = require("eslint-config-react-app");
109

1110
const flowtypePlugin = fixupPluginRules(require("eslint-plugin-flowtype"));
@@ -27,6 +26,9 @@ const reactAppTsOverride = reactAppConfig.overrides.find(
2726
if (!reactAppTsOverride) {
2827
throw new Error("Could not find the react-app TypeScript override.");
2928
}
29+
if (!jestPlugin.configs) {
30+
throw new Error("Could not find the jest plugin configs.");
31+
}
3032

3133
const jestRecommended = jestPlugin.configs["flat/recommended"];
3234

@@ -119,6 +121,12 @@ export default defineConfig([
119121
"react/jsx-uses-vars": "warn",
120122
},
121123
},
124+
{
125+
files: ["**/*.config.js", "**/jest.config*.js"],
126+
rules: {
127+
"import/no-anonymous-default-export": "off",
128+
},
129+
},
122130
{
123131
files: ["**/*.{ts,tsx}"],
124132
languageOptions: {

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,13 @@
8181
"eslint-plugin-react": "^7.37.5",
8282
"eslint-plugin-react-hooks": "^7.1.1",
8383
"fast-glob": "3.3.3",
84+
"globals": "^17.6.0",
8485
"isbot": "^5.1.40",
8586
"jest": "^30.4.2",
8687
"jest-environment-jsdom": "^30.4.1",
8788
"jsdom": "^29.1.1",
89+
"react": "catalog:",
90+
"react-dom": "catalog:",
8891
"picocolors": "^1.1.1",
8992
"prettier": "^3.8.3",
9093
"prompts": "^2.4.2",

packages/react-router-dev/cli/run.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { readFileSync } from "node:fs";
2-
import path from "node:path";
31
import arg from "arg";
42
import semver from "semver";
53
import colors from "picocolors";

packages/react-router-dev/vite/has-dependency.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ export function hasDependency({
1111
}) {
1212
try {
1313
return Boolean(nodeRequire.resolve(name, { paths: [rootDirectory] }));
14-
} catch (err) {
14+
} catch (
15+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
16+
e
17+
) {
1518
return false;
1619
}
1720
}

packages/react-router-dev/vite/plugin.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// context but want to use Vite's ESM build since Vite 7+ is ESM only
33
import type * as Vite from "vite";
44
import { type BinaryLike, createHash } from "node:crypto";
5-
import { existsSync, readFileSync, readdirSync, rmSync } from "node:fs";
5+
import { existsSync, readFileSync, readdirSync } from "node:fs";
66
import {
77
cp,
88
mkdir,
@@ -221,28 +221,6 @@ const isRouteVirtualModule = (id: string): boolean => {
221221
return isRouteEntryModuleId(id) || isRouteChunkModuleId(id);
222222
};
223223

224-
const isServerBuildVirtualModuleId = (id: string): boolean => {
225-
return id.split("?")[0] === virtual.serverBuild.id;
226-
};
227-
228-
const getServerBuildFile = (viteManifest: Vite.Manifest): string => {
229-
let serverBuildIds = Object.keys(viteManifest).filter(
230-
isServerBuildVirtualModuleId,
231-
);
232-
233-
invariant(
234-
serverBuildIds.length <= 1,
235-
"Multiple server build files found in manifest",
236-
);
237-
238-
invariant(
239-
serverBuildIds.length === 1,
240-
"Server build file not found in manifest",
241-
);
242-
243-
return viteManifest[serverBuildIds[0]].file;
244-
};
245-
246224
type ReactRouterPluginContext = {
247225
buildManifest: BuildManifest | null;
248226
rootDirectory: string;

packages/react-router/lib/rsc/server.rsc.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import {
2424
type Params,
2525
type ShouldRevalidateFunction,
2626
type RouteMatch,
27-
type RouteObject,
2827
type RouterContextProvider,
2928
type TrackedPromise,
3029
isAbsoluteUrl,

pnpm-lock.yaml

Lines changed: 17 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)