diff --git a/bench/native.js b/bench/native.js index 869514b..1994a63 100644 --- a/bench/native.js +++ b/bench/native.js @@ -1,4 +1,4 @@ -const http = require('http'); +const http = require('node:http'); http.createServer((req, res) => { if (req.url === '/favicon.ico') return; diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..5cecd56 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,14 @@ +import n from 'eslint-plugin-n' + +export default [ + { files: ['**/*.js'] }, + { + plugins: { n }, + rules: { + 'n/prefer-node-protocol': 'error' + } + }, + { + ignores: ['examples/'] + } +]; diff --git a/package.json b/package.json index cd75a5e..fadeacd 100644 --- a/package.json +++ b/package.json @@ -7,11 +7,14 @@ }, "scripts": { "build": "bun run scripts/build.ts", + "lint": "eslint", "test": "uvu -r esm -i util -i bench packages test" }, "devDependencies": { "bump": "1.0.0-next.1", "bundt": "1.1.2", + "eslint": "^9.9.1", + "eslint-plugin-n": "^17.10.2", "esm": "3.2.25", "httpie": "1.1.2", "uvu": "0.5.1" diff --git a/packages/cluster/index.js b/packages/cluster/index.js index adbefe5..dc86bd7 100644 --- a/packages/cluster/index.js +++ b/packages/cluster/index.js @@ -1,6 +1,6 @@ -import { cpus } from 'os'; -import cluster from 'cluster'; -import { createServer } from 'http'; +import { cpus } from 'node:os'; +import cluster from 'node:cluster'; +import { createServer } from 'node:http'; export default function (app, num) { if (cluster.isMaster) { diff --git a/packages/compression/index.js b/packages/compression/index.js index 9eed034..dfbaa45 100644 --- a/packages/compression/index.js +++ b/packages/compression/index.js @@ -1,6 +1,6 @@ // NOTE: supports Node 6.x -import zlib from 'zlib'; +import zlib from 'node:zlib'; const NOOP = () => {}; const MIMES = /text|javascript|\/json|xml/i; diff --git a/packages/compression/test/index.js b/packages/compression/test/index.js index e430605..74ad692 100644 --- a/packages/compression/test/index.js +++ b/packages/compression/test/index.js @@ -1,9 +1,9 @@ import { suite } from 'uvu'; import * as assert from 'uvu/assert'; -import fs from 'fs'; -import * as zlib from 'zlib'; -import { join } from 'path'; +import fs from 'node:fs'; +import * as zlib from 'node:zlib'; +import { join } from 'node:path'; import { prepare, toAscii } from './util/index'; import compression from '../index'; diff --git a/packages/compression/test/util/index.js b/packages/compression/test/util/index.js index 32e7d66..2ac2265 100644 --- a/packages/compression/test/util/index.js +++ b/packages/compression/test/util/index.js @@ -1,4 +1,4 @@ -import { IncomingMessage, ServerResponse } from 'http'; +import { IncomingMessage, ServerResponse } from 'node:http'; // IncomingMessage class Request { diff --git a/packages/parse/index.js b/packages/parse/index.js index 00bba88..0b21165 100644 --- a/packages/parse/index.js +++ b/packages/parse/index.js @@ -1,4 +1,4 @@ -import { decode } from 'querystring'; +import { decode } from 'node:querystring'; const noop = x => x; diff --git a/packages/polka/index.js b/packages/polka/index.js index 9d0f327..ec77ac0 100644 --- a/packages/polka/index.js +++ b/packages/polka/index.js @@ -1,4 +1,4 @@ -import http from 'http'; +import http from 'node:http'; import { Trouter } from 'trouter'; import { parse } from '@polka/url'; diff --git a/packages/polka/test/index.js b/packages/polka/test/index.js index db890ec..ecc775a 100644 --- a/packages/polka/test/index.js +++ b/packages/polka/test/index.js @@ -1,5 +1,5 @@ /* eslint-disable no-console */ -import http from 'http'; +import http from 'node:http'; import { test } from 'uvu'; import * as assert from 'uvu/assert'; import { get, send, post } from 'httpie'; diff --git a/packages/redirect/index.js b/packages/redirect/index.js index 6b341d6..c693e50 100644 --- a/packages/redirect/index.js +++ b/packages/redirect/index.js @@ -1,4 +1,4 @@ -import { resolve } from 'url'; +import { resolve } from 'node:url'; export default function (res, code=302, location='') { if (!location && typeof code === 'string') { diff --git a/packages/send/index.js b/packages/send/index.js index 51e51ea..e807426 100644 --- a/packages/send/index.js +++ b/packages/send/index.js @@ -1,5 +1,5 @@ -import { STATUS_CODES } from 'http'; -import { createHash } from 'crypto'; +import { STATUS_CODES } from 'node:http'; +import { createHash } from 'node:crypto'; const TYPE = 'Content-Type'; const LENGTH = 'Content-Length'; diff --git a/packages/send/test/index.js b/packages/send/test/index.js index c16ed79..c6f39d2 100644 --- a/packages/send/test/index.js +++ b/packages/send/test/index.js @@ -1,6 +1,6 @@ -import fs from 'fs'; +import fs from 'node:fs'; +import { join } from 'node:path'; import { suite } from 'uvu'; -import { join } from 'path'; import * as assert from 'uvu/assert'; import { Response, toStatusText } from './util'; import send from '../index'; diff --git a/packages/send/test/util/index.js b/packages/send/test/util/index.js index 6811a30..50164bc 100644 --- a/packages/send/test/util/index.js +++ b/packages/send/test/util/index.js @@ -1,4 +1,4 @@ -import { STATUS_CODES } from 'http'; +import { STATUS_CODES } from 'node:http'; export const toStatusText = code => STATUS_CODES[code]; diff --git a/packages/url/index.js b/packages/url/index.js index 9d5e7b9..ff90848 100644 --- a/packages/url/index.js +++ b/packages/url/index.js @@ -1,4 +1,4 @@ -import * as qs from 'querystring'; +import * as qs from 'node:querystring'; /** * @typedef ParsedURL