Skip to content

Commit a91ac71

Browse files
authored
feat: Update ESLint config to fix imports/exports (#109)
1 parent 88c0335 commit a91ac71

29 files changed

+174
-48
lines changed

packages/cloudflare/eslint.config.mjs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import pluginJs from "@eslint/js";
2+
import importPlugin from "eslint-plugin-import";
3+
import simpleImportSort from "eslint-plugin-simple-import-sort";
14
import eslintPluginUnicorn from "eslint-plugin-unicorn";
25
import globals from "globals";
3-
import pluginJs from "@eslint/js";
46
import tseslint from "typescript-eslint";
57

68
export default [
@@ -18,13 +20,20 @@ export default [
1820
pluginJs.configs.recommended,
1921
...tseslint.configs.recommended,
2022
{
23+
name: "open-next",
2124
plugins: {
2225
unicorn: eslintPluginUnicorn,
26+
"simple-import-sort": simpleImportSort,
27+
import: importPlugin,
2328
},
2429
rules: {
2530
"@typescript-eslint/ban-ts-comment": "off",
2631
"unicorn/prefer-node-protocol": "error",
27-
"sort-imports": "error",
32+
"simple-import-sort/imports": "error",
33+
"simple-import-sort/exports": "error",
34+
"import/first": "error",
35+
"import/newline-after-import": "error",
36+
"import/no-duplicates": "error",
2837
},
2938
},
3039
];

packages/cloudflare/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
"@types/node": "catalog:",
4747
"esbuild": "catalog:",
4848
"eslint": "catalog:",
49+
"eslint-plugin-import": "^2.31.0",
50+
"eslint-plugin-simple-import-sort": "^12.1.1",
4951
"eslint-plugin-unicorn": "catalog:",
5052
"glob": "catalog:",
5153
"globals": "catalog:",

packages/cloudflare/src/cli/args.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { type Stats, mkdirSync, statSync } from "node:fs";
2-
import { parseArgs } from "node:util";
1+
import { mkdirSync, type Stats, statSync } from "node:fs";
32
import { resolve } from "node:path";
3+
import { parseArgs } from "node:util";
44

55
export function getArgs(): {
66
skipNextBuild: boolean;

packages/cloudflare/src/cli/build/build-next-app.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { type AgentName as PackageManager, detect } from "package-manager-detector";
21
import { execSync } from "node:child_process";
32

3+
import { type AgentName as PackageManager, detect } from "package-manager-detector";
4+
45
/**
56
* Builds the Next.js app in the standard Next.js cli way (this outputs a `.next` directory)
67
*

packages/cloudflare/src/cli/build/build-worker.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
import { Plugin, build } from "esbuild";
1+
import { existsSync, readFileSync } from "node:fs";
22
import { cp, readFile, writeFile } from "node:fs/promises";
33
import { dirname, join } from "node:path";
4-
import { existsSync, readFileSync } from "node:fs";
4+
import { fileURLToPath } from "node:url";
5+
6+
import { build, Plugin } from "esbuild";
7+
58
import { Config } from "../config";
69
import { copyPackageCliFiles } from "./patches/investigated/copy-package-cli-files";
7-
import { copyPrerenderedRoutes } from "./utils";
8-
import { fileURLToPath } from "node:url";
10+
import { patchCache } from "./patches/investigated/patch-cache";
11+
import { patchRequire } from "./patches/investigated/patch-require";
12+
import { updateWebpackChunksFile } from "./patches/investigated/update-webpack-chunks-file";
913
import { inlineEvalManifest } from "./patches/to-investigate/inline-eval-manifest";
1014
import { inlineMiddlewareManifestRequire } from "./patches/to-investigate/inline-middleware-manifest-require";
1115
import { inlineNextRequire } from "./patches/to-investigate/inline-next-require";
12-
import { patchCache } from "./patches/investigated/patch-cache";
1316
import { patchExceptionBubbling } from "./patches/to-investigate/patch-exception-bubbling";
1417
import { patchFindDir } from "./patches/to-investigate/patch-find-dir";
1518
import { patchReadFile } from "./patches/to-investigate/patch-read-file";
16-
import { patchRequire } from "./patches/investigated/patch-require";
1719
import { patchWranglerDeps } from "./patches/to-investigate/wrangler-deps";
18-
import { updateWebpackChunksFile } from "./patches/investigated/update-webpack-chunks-file";
20+
import { copyPrerenderedRoutes } from "./utils";
1921

2022
/** The dist directory of the Cloudflare adapter package */
2123
const packageDistDir = join(dirname(fileURLToPath(import.meta.url)), "..");

packages/cloudflare/src/cli/build/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { containsDotNextDir, getConfig } from "../config";
1+
import { cpSync } from "node:fs";
2+
import { rm } from "node:fs/promises";
3+
import { join } from "node:path";
4+
25
import type { ProjectOptions } from "../config";
6+
import { containsDotNextDir, getConfig } from "../config";
37
import { buildNextjsApp } from "./build-next-app";
48
import { buildWorker } from "./build-worker";
5-
import { cpSync } from "node:fs";
6-
import { join } from "node:path";
7-
import { rm } from "node:fs/promises";
89

910
/**
1011
* Builds the application in a format that can be passed to workerd

packages/cloudflare/src/cli/build/patches/investigated/copy-package-cli-files.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { Config } from "../../../config";
21
import { cpSync } from "node:fs";
32
import { join } from "node:path";
43

4+
import { Config } from "../../../config";
5+
56
/**
67
* Copies the template files present in the cloudflare adapter package into the standalone node_modules folder
78
*/

packages/cloudflare/src/cli/build/patches/investigated/patch-cache.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { Config } from "../../../config";
2-
import { build } from "esbuild";
31
import { join } from "node:path";
42

3+
import { build } from "esbuild";
4+
5+
import { Config } from "../../../config";
6+
57
/**
68
* Sets up the OpenNext cache handler in a Next.js build.
79
*

packages/cloudflare/src/cli/build/patches/investigated/update-webpack-chunks-file/get-chunk-installation-identifiers.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { describe, expect, test } from "vitest";
2-
import { getChunkInstallationIdentifiers } from "./get-chunk-installation-identifiers";
31
import { readFile } from "node:fs/promises";
2+
3+
import { describe, expect, test } from "vitest";
4+
45
import { tsParseFile } from "../../../utils";
6+
import { getChunkInstallationIdentifiers } from "./get-chunk-installation-identifiers";
57

68
describe("getChunkInstallationIdentifiers", () => {
79
test("gets chunk identifiers from unminified code", async () => {

packages/cloudflare/src/cli/build/patches/investigated/update-webpack-chunks-file/get-file-content-with-updated-webpack-f-require-code.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { describe, expect, test } from "vitest";
2-
import { getFileContentWithUpdatedWebpackFRequireCode } from "./get-file-content-with-updated-webpack-f-require-code";
31
import { readFile } from "node:fs/promises";
2+
3+
import { describe, expect, test } from "vitest";
4+
45
import { tsParseFile } from "../../../utils";
6+
import { getFileContentWithUpdatedWebpackFRequireCode } from "./get-file-content-with-updated-webpack-f-require-code";
57

68
describe("getFileContentWithUpdatedWebpackFRequireCode", () => {
79
test("returns the updated content of the f.require function from unminified webpack runtime code", async () => {

0 commit comments

Comments
 (0)