summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Florian Lefebvre <contact@florian-lefebvre.dev> 2024-08-15 16:52:26 +0200
committerGravatar GitHub <noreply@github.com> 2024-08-15 16:52:26 +0200
commit70945dd9181e2dd021b92f3f82d66b0cd929def9 (patch)
tree5ac4d8e0a4ed94808d5175d95fdb3cbe500382d6
parent3c2f93b66c6b8e9d2ab58e2cbe941c14ffab89b5 (diff)
downloadastro-70945dd9181e2dd021b92f3f82d66b0cd929def9.tar.gz
astro-70945dd9181e2dd021b92f3f82d66b0cd929def9.tar.zst
astro-70945dd9181e2dd021b92f3f82d66b0cd929def9.zip
refactor: enforce node prefix (#11723)
-rw-r--r--biome.json10
-rw-r--r--package.json2
-rw-r--r--packages/astro/src/assets/endpoint/node.ts2
-rw-r--r--packages/astro/src/core/dev/dev.ts2
-rw-r--r--packages/astro/src/core/logger/vite.ts2
-rw-r--r--packages/astro/src/core/preview/static-preview-server.ts2
-rw-r--r--packages/astro/src/core/routing/manifest/create.ts2
-rw-r--r--packages/astro/src/vite-plugin-astro-server/response.ts2
-rw-r--r--packages/astro/test/build-readonly-file.test.js2
-rw-r--r--packages/db/src/core/integration/index.ts8
-rw-r--r--packages/db/test/local-prod.test.js4
-rw-r--r--packages/integrations/node/src/standalone.ts2
-rw-r--r--packages/integrations/partytown/src/index.ts2
-rw-r--r--packages/integrations/sitemap/src/write-sitemap.ts10
14 files changed, 30 insertions, 22 deletions
diff --git a/biome.json b/biome.json
index 2928e8f4f..67e2a4620 100644
--- a/biome.json
+++ b/biome.json
@@ -26,7 +26,15 @@
"organizeImports": {
"enabled": true
},
- "linter": { "enabled": false },
+ "linter": {
+ "enabled": true,
+ "rules": {
+ "recommended": false,
+ "style": {
+ "useNodejsImportProtocol": "error"
+ }
+ }
+ },
"javascript": {
"formatter": {
"trailingCommas": "all",
diff --git a/package.json b/package.json
index 6958dee90..850816b5e 100644
--- a/package.json
+++ b/package.json
@@ -35,7 +35,7 @@
"test:e2e:match": "cd packages/astro && pnpm playwright install chromium firefox && pnpm run test:e2e:match",
"test:e2e:hosts": "turbo run test:hosted",
"benchmark": "astro-benchmark",
- "lint": "eslint . --report-unused-disable-directives",
+ "lint": "biome lint && eslint . --report-unused-disable-directives",
"version": "changeset version && node ./scripts/deps/update-example-versions.js && pnpm install --no-frozen-lockfile && pnpm run format",
"preinstall": "npx only-allow pnpm"
},
diff --git a/packages/astro/src/assets/endpoint/node.ts b/packages/astro/src/assets/endpoint/node.ts
index 4c50fe95f..c1acc66ef 100644
--- a/packages/astro/src/assets/endpoint/node.ts
+++ b/packages/astro/src/assets/endpoint/node.ts
@@ -5,7 +5,7 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
// @ts-expect-error
import { assetsDir, imageConfig, outDir } from 'astro:assets';
import { isRemotePath, removeQueryString } from '@astrojs/internal-helpers/path';
-import { readFile } from 'fs/promises';
+import { readFile } from 'node:fs/promises';
import * as mime from 'mrmime';
import type { APIRoute } from '../../@types/astro.js';
import { getConfiguredImageService } from '../internal.js';
diff --git a/packages/astro/src/core/dev/dev.ts b/packages/astro/src/core/dev/dev.ts
index 8d19356b6..ab1564d4e 100644
--- a/packages/astro/src/core/dev/dev.ts
+++ b/packages/astro/src/core/dev/dev.ts
@@ -2,7 +2,7 @@ import fs, { existsSync } from 'node:fs';
import type http from 'node:http';
import type { AddressInfo } from 'node:net';
import { green } from 'kleur/colors';
-import { performance } from 'perf_hooks';
+import { performance } from 'node:perf_hooks';
import { gt, major, minor, patch } from 'semver';
import type * as vite from 'vite';
import type { AstroInlineConfig } from '../../@types/astro.js';
diff --git a/packages/astro/src/core/logger/vite.ts b/packages/astro/src/core/logger/vite.ts
index ed62adc8d..f1ed49dce 100644
--- a/packages/astro/src/core/logger/vite.ts
+++ b/packages/astro/src/core/logger/vite.ts
@@ -1,4 +1,4 @@
-import { fileURLToPath } from 'url';
+import { fileURLToPath } from 'node:url';
import stripAnsi from 'strip-ansi';
import type { LogLevel, Rollup, Logger as ViteLogger } from 'vite';
import { isAstroError } from '../errors/errors.js';
diff --git a/packages/astro/src/core/preview/static-preview-server.ts b/packages/astro/src/core/preview/static-preview-server.ts
index 68ca3236b..96afeb1b3 100644
--- a/packages/astro/src/core/preview/static-preview-server.ts
+++ b/packages/astro/src/core/preview/static-preview-server.ts
@@ -1,6 +1,6 @@
import type http from 'node:http';
import { fileURLToPath } from 'node:url';
-import { performance } from 'perf_hooks';
+import { performance } from 'node:perf_hooks';
import { type PreviewServer as VitePreviewServer, preview } from 'vite';
import type { AstroSettings } from '../../@types/astro.js';
import type { Logger } from '../logger/core.js';
diff --git a/packages/astro/src/core/routing/manifest/create.ts b/packages/astro/src/core/routing/manifest/create.ts
index f9c19b9ed..d9a6c61b0 100644
--- a/packages/astro/src/core/routing/manifest/create.ts
+++ b/packages/astro/src/core/routing/manifest/create.ts
@@ -8,7 +8,7 @@ import type {
} from '../../../@types/astro.js';
import type { Logger } from '../../logger/core.js';
-import { createRequire } from 'module';
+import { createRequire } from 'node:module';
import nodeFs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
diff --git a/packages/astro/src/vite-plugin-astro-server/response.ts b/packages/astro/src/vite-plugin-astro-server/response.ts
index 2ccf1aade..707a26e40 100644
--- a/packages/astro/src/vite-plugin-astro-server/response.ts
+++ b/packages/astro/src/vite-plugin-astro-server/response.ts
@@ -2,7 +2,7 @@ import type http from 'node:http';
import type { ErrorWithMetadata } from '../core/errors/index.js';
import type { ModuleLoader } from '../core/module-loader/index.js';
-import { Readable } from 'stream';
+import { Readable } from 'node:stream';
import { getSetCookiesFromResponse } from '../core/cookies/index.js';
import { getViteErrorPayload } from '../core/errors/dev/index.js';
import notFoundTemplate from '../template/4xx.js';
diff --git a/packages/astro/test/build-readonly-file.test.js b/packages/astro/test/build-readonly-file.test.js
index bf6dd3fa4..60b3f507b 100644
--- a/packages/astro/test/build-readonly-file.test.js
+++ b/packages/astro/test/build-readonly-file.test.js
@@ -1,5 +1,5 @@
import { after, before, describe, it } from 'node:test';
-import { fileURLToPath } from 'url';
+import { fileURLToPath } from 'node:url';
import testAdapter from './test-adapter.js';
import { loadFixture } from './test-utils.js';
diff --git a/packages/db/src/core/integration/index.ts b/packages/db/src/core/integration/index.ts
index 68439cfb9..7be43c0da 100644
--- a/packages/db/src/core/integration/index.ts
+++ b/packages/db/src/core/integration/index.ts
@@ -1,11 +1,11 @@
-import { existsSync } from 'fs';
+import { existsSync } from 'node:fs';
import { parseArgs } from 'node:util';
-import { dirname } from 'path';
-import { fileURLToPath } from 'url';
+import { dirname } from 'node:path';
+import { fileURLToPath } from 'node:url';
import { type ManagedAppToken, getManagedAppTokenOrExit } from '@astrojs/studio';
import { LibsqlError } from '@libsql/client';
import type { AstroConfig, AstroIntegration } from 'astro';
-import { mkdir, writeFile } from 'fs/promises';
+import { mkdir, writeFile } from 'node:fs/promises';
import { blue, yellow } from 'kleur/colors';
import {
type HMRPayload,
diff --git a/packages/db/test/local-prod.test.js b/packages/db/test/local-prod.test.js
index 134ee6b56..be67d179a 100644
--- a/packages/db/test/local-prod.test.js
+++ b/packages/db/test/local-prod.test.js
@@ -1,7 +1,7 @@
import assert from 'node:assert/strict';
import { after, before, describe, it } from 'node:test';
-import { relative } from 'path';
-import { fileURLToPath } from 'url';
+import { relative } from 'node:path';
+import { fileURLToPath } from 'node:url';
import testAdapter from '../../astro/test/test-adapter.js';
import { loadFixture } from '../../astro/test/test-utils.js';
diff --git a/packages/integrations/node/src/standalone.ts b/packages/integrations/node/src/standalone.ts
index 817ca7020..69db5ef23 100644
--- a/packages/integrations/node/src/standalone.ts
+++ b/packages/integrations/node/src/standalone.ts
@@ -1,4 +1,4 @@
-import https from 'https';
+import https from 'node:https';
import fs from 'node:fs';
import http from 'node:http';
import type { PreviewServer } from 'astro';
diff --git a/packages/integrations/partytown/src/index.ts b/packages/integrations/partytown/src/index.ts
index bf8a6db1c..9589e32a6 100644
--- a/packages/integrations/partytown/src/index.ts
+++ b/packages/integrations/partytown/src/index.ts
@@ -1,4 +1,4 @@
-import { createRequire } from 'module';
+import { createRequire } from 'node:module';
import * as fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
diff --git a/packages/integrations/sitemap/src/write-sitemap.ts b/packages/integrations/sitemap/src/write-sitemap.ts
index 8c86ae166..b6a0c63c2 100644
--- a/packages/integrations/sitemap/src/write-sitemap.ts
+++ b/packages/integrations/sitemap/src/write-sitemap.ts
@@ -1,8 +1,8 @@
-import { type WriteStream, createWriteStream } from 'fs';
-import { normalize, resolve } from 'path';
-import { Readable, pipeline } from 'stream';
-import { promisify } from 'util';
-import { mkdir } from 'fs/promises';
+import { type WriteStream, createWriteStream } from 'node:fs';
+import { normalize, resolve } from 'node:path';
+import { Readable, pipeline } from 'node:stream';
+import { promisify } from 'node:util';
+import { mkdir } from 'node:fs/promises';
import replace from 'stream-replace-string';
import { SitemapAndIndexStream, SitemapStream } from 'sitemap';