diff --git a/.eslintrc.js b/.eslintrc.cjs similarity index 100% rename from .eslintrc.js rename to .eslintrc.cjs diff --git a/README.md b/README.md index 3155cbec..6b260bda 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ Parse an incoming file upload, with the [Node.js's built-in `http` module](https://nodejs.org/api/http.html). ```js -import http from 'http'; +import http from 'node:http'; import formidable from 'formidable'; const server = http.createServer((req, res) => { diff --git a/examples/json.js b/examples/json.js index d12715e1..b3d6fcd3 100644 --- a/examples/json.js +++ b/examples/json.js @@ -1,4 +1,4 @@ -import http from 'http'; +import http from 'node:http'; import util from 'util'; import formidable from '../src/index.js'; diff --git a/examples/log-file-content-to-console.js b/examples/log-file-content-to-console.js index 6a9f75f8..e847c971 100644 --- a/examples/log-file-content-to-console.js +++ b/examples/log-file-content-to-console.js @@ -1,5 +1,5 @@ -import http from 'http'; -import { Writable } from 'stream'; +import http from 'node:http'; +import { Writable } from 'node:stream'; import formidable from '../src/index.js'; diff --git a/examples/multiples.js b/examples/multiples.js index 1c51cfcf..1cb378cf 100644 --- a/examples/multiples.js +++ b/examples/multiples.js @@ -1,5 +1,5 @@ -import http from 'http'; -import os from 'os'; +import http from 'node:http'; +import os from 'node:os'; import formidable from '../src/index.js'; diff --git a/examples/store-files-on-s3.js b/examples/store-files-on-s3.js index 133d7fec..018468da 100644 --- a/examples/store-files-on-s3.js +++ b/examples/store-files-on-s3.js @@ -1,7 +1,7 @@ // To test this example you have to install aws-sdk nodejs package and create a bucket named "demo-bucket" -import http from 'http'; -import { PassThrough } from 'stream'; +import http from 'node:http'; +import { PassThrough } from 'node:stream'; import AWS from 'aws-sdk'; import formidable from '../src/index.js'; diff --git a/examples/upload-multiple-files.js b/examples/upload-multiple-files.js index f78869ad..42eb5aa8 100644 --- a/examples/upload-multiple-files.js +++ b/examples/upload-multiple-files.js @@ -1,6 +1,6 @@ -import http from 'http'; -import util from 'util'; -import os from 'os'; +import http from 'node:http'; +import util from 'node:util'; +import os from 'node:os'; import formidable from '../src/index.js'; diff --git a/examples/urlencoded-no-enctype.js b/examples/urlencoded-no-enctype.js index c88ebcf5..db884b1d 100644 --- a/examples/urlencoded-no-enctype.js +++ b/examples/urlencoded-no-enctype.js @@ -1,5 +1,5 @@ -import http from 'http'; -import util from 'util'; +import http from 'node:http'; +import util from 'node:util'; import formidable from '../src/index.js'; diff --git a/examples/with-http.js b/examples/with-http.js index 75becf71..f8e9683a 100644 --- a/examples/with-http.js +++ b/examples/with-http.js @@ -1,4 +1,4 @@ -import http from 'http'; +import http from 'node:http'; import formidable from '../src/index.js'; diff --git a/src/Formidable.js b/src/Formidable.js index 664c9058..a823c281 100644 --- a/src/Formidable.js +++ b/src/Formidable.js @@ -1,13 +1,13 @@ /* eslint-disable class-methods-use-this */ /* eslint-disable no-underscore-dangle */ -import os from 'os'; -import path from 'path'; +import os from 'node:os'; +import path from 'node:path'; +import { EventEmitter } from 'node:events'; +import { StringDecoder } from 'node:string_decoder'; import hexoid from 'hexoid'; import once from 'once'; import dezalgo from 'dezalgo'; -import { EventEmitter } from 'events'; -import { StringDecoder } from 'string_decoder'; import { octetstream, querystring, multipart, json } from './plugins/index.js'; import PersistentFile from './PersistentFile.js'; import VolatileFile from './VolatileFile.js'; diff --git a/src/PersistentFile.js b/src/PersistentFile.js index e6d58531..7dc727ce 100644 --- a/src/PersistentFile.js +++ b/src/PersistentFile.js @@ -1,8 +1,8 @@ /* eslint-disable no-underscore-dangle */ -import { WriteStream, unlink } from 'fs'; -import { createHash } from 'crypto'; -import { EventEmitter } from 'events'; +import { WriteStream, unlink } from 'node:fs'; +import { createHash } from 'node:crypto'; +import { EventEmitter } from 'node:events'; class PersistentFile extends EventEmitter { constructor({ filepath, newFilename, originalFilename, mimetype, hashAlgorithm }) { diff --git a/src/VolatileFile.js b/src/VolatileFile.js index eb59500f..6f594b0c 100644 --- a/src/VolatileFile.js +++ b/src/VolatileFile.js @@ -1,7 +1,7 @@ /* eslint-disable no-underscore-dangle */ -import { createHash } from 'crypto'; -import { EventEmitter } from 'events'; +import { createHash } from 'node:crypto'; +import { EventEmitter } from 'node:events'; class VolatileFile extends EventEmitter { constructor({ filepath, newFilename, originalFilename, mimetype, hashAlgorithm, createFileWriteStream }) { diff --git a/src/parsers/Dummy.js b/src/parsers/Dummy.js index 49409b61..be074a55 100644 --- a/src/parsers/Dummy.js +++ b/src/parsers/Dummy.js @@ -1,6 +1,6 @@ /* eslint-disable no-underscore-dangle */ -import { Transform } from 'stream'; +import { Transform } from 'node:stream'; class DummyParser extends Transform { constructor(incomingForm, options = {}) { diff --git a/src/parsers/JSON.js b/src/parsers/JSON.js index 9f8dede2..28af758d 100644 --- a/src/parsers/JSON.js +++ b/src/parsers/JSON.js @@ -1,6 +1,6 @@ /* eslint-disable no-underscore-dangle */ -import { Transform } from 'stream'; +import { Transform } from 'node:stream'; class JSONParser extends Transform { constructor(options = {}) { diff --git a/src/parsers/Multipart.js b/src/parsers/Multipart.js index 25badce4..361a9cc4 100644 --- a/src/parsers/Multipart.js +++ b/src/parsers/Multipart.js @@ -3,7 +3,7 @@ /* eslint-disable no-plusplus */ /* eslint-disable no-underscore-dangle */ -import { Transform } from 'stream'; +import { Transform } from 'node:stream'; import * as errors from '../FormidableError.js'; import FormidableError from '../FormidableError.js'; diff --git a/src/parsers/OctetStream.js b/src/parsers/OctetStream.js index 6f70972c..541862e0 100644 --- a/src/parsers/OctetStream.js +++ b/src/parsers/OctetStream.js @@ -1,4 +1,4 @@ -import { PassThrough } from 'stream'; +import { PassThrough } from 'node:stream'; class OctetStreamParser extends PassThrough { constructor(options = {}) { diff --git a/src/parsers/Querystring.js b/src/parsers/Querystring.js index 0daeadb8..88267114 100644 --- a/src/parsers/Querystring.js +++ b/src/parsers/Querystring.js @@ -1,6 +1,6 @@ /* eslint-disable no-underscore-dangle */ -import { Transform } from 'stream'; +import { Transform } from 'node:stream'; // This is a buffering parser, have a look at StreamingQuerystring.js for a streaming parser class QuerystringParser extends Transform { diff --git a/src/parsers/StreamingQuerystring.js b/src/parsers/StreamingQuerystring.js index 92c6c419..072eb366 100644 --- a/src/parsers/StreamingQuerystring.js +++ b/src/parsers/StreamingQuerystring.js @@ -1,7 +1,7 @@ // not used /* eslint-disable no-underscore-dangle */ -import { Transform } from 'stream'; +import { Transform } from 'node:stream'; import FormidableError, { maxFieldsSizeExceeded } from '../FormidableError.js'; const AMPERSAND = 38; diff --git a/src/plugins/multipart.js b/src/plugins/multipart.js index 52c836cb..1df84c33 100644 --- a/src/plugins/multipart.js +++ b/src/plugins/multipart.js @@ -1,6 +1,6 @@ /* eslint-disable no-underscore-dangle */ -import { Stream } from 'stream'; +import { Stream } from 'node:stream'; import MultipartParser from '../parsers/Multipart.js'; import * as errors from '../FormidableError.js'; import FormidableError from '../FormidableError.js'; diff --git a/test/integration/file-write-stream-handler-option.test.js b/test/integration/file-write-stream-handler-option.test.js index 22bf2389..aac78e0d 100644 --- a/test/integration/file-write-stream-handler-option.test.js +++ b/test/integration/file-write-stream-handler-option.test.js @@ -1,9 +1,9 @@ -import { existsSync, mkdirSync, createWriteStream, readdirSync, statSync, unlinkSync, createReadStream } from 'fs'; -import { tmpdir } from 'os'; -import { createServer, request as _request } from 'http'; -import path, { join, dirname } from 'path'; -import url from 'url'; -import assert, { strictEqual, ok } from 'assert'; +import { existsSync, mkdirSync, createWriteStream, readdirSync, statSync, unlinkSync, createReadStream } from 'node:fs'; +import { tmpdir } from 'node:os'; +import { createServer, request as _request } from 'node:http'; +import path, { join, dirname } from 'node:path'; +import url from 'node:url'; +import assert, { strictEqual, ok } from 'node:assert'; import formidable from '../../src/index.js'; diff --git a/test/integration/fixtures.test.js b/test/integration/fixtures.test.js index 27546474..0b6c81b3 100644 --- a/test/integration/fixtures.test.js +++ b/test/integration/fixtures.test.js @@ -1,11 +1,11 @@ /* eslint-disable global-require */ /* eslint-disable import/no-dynamic-require */ -import { createReadStream } from 'fs'; -import { createConnection } from 'net'; -import { join } from 'path'; -import { createServer } from 'http'; -import { strictEqual } from 'assert'; +import { createReadStream } from 'node:fs'; +import { createConnection } from 'node:net'; +import { join } from 'node:path'; +import { createServer } from 'node:http'; +import { strictEqual } from 'node:assert'; import formidable from '../../src/index.js'; diff --git a/test/integration/json.test.js b/test/integration/json.test.js index 8efc5e7b..167d1eed 100644 --- a/test/integration/json.test.js +++ b/test/integration/json.test.js @@ -1,5 +1,5 @@ -import { createServer, request as _request } from 'http'; -import assert, { deepStrictEqual } from 'assert'; +import { createServer, request as _request } from 'node:http'; +import assert, { deepStrictEqual } from 'node:assert'; import formidable from '../../src/index.js'; const testData = { diff --git a/test/integration/octet-stream.test.js b/test/integration/octet-stream.test.js index 6fafb385..7f03da9d 100644 --- a/test/integration/octet-stream.test.js +++ b/test/integration/octet-stream.test.js @@ -1,8 +1,8 @@ -import { readFileSync, createReadStream } from 'fs'; -import { createServer, request as _request } from 'http'; -import path, { join, dirname } from 'path'; -import url from 'url'; -import assert, { strictEqual, deepStrictEqual } from 'assert'; +import { readFileSync, createReadStream } from 'node:fs'; +import { createServer, request as _request } from 'node:http'; +import path, { join, dirname } from 'node:path'; +import url from 'node:url'; +import assert, { strictEqual, deepStrictEqual } from 'node:assert'; import formidable from '../../src/index.js'; diff --git a/test/integration/store-files-option.test.js b/test/integration/store-files-option.test.js index 30217ee5..86f4a11d 100644 --- a/test/integration/store-files-option.test.js +++ b/test/integration/store-files-option.test.js @@ -1,10 +1,10 @@ -import { existsSync, mkdirSync, WriteStream, statSync, unlinkSync, createReadStream } from 'fs'; -import { tmpdir } from 'os'; +import { existsSync, mkdirSync, WriteStream, statSync, unlinkSync, createReadStream } from 'node:fs'; +import { tmpdir } from 'node:os'; import { createServer, request as _request } from 'http'; -import assert, { strictEqual, ok } from 'assert'; +import assert, { strictEqual, ok } from 'node:assert'; -import path, { join, dirname } from 'path'; -import url from 'url'; +import path, { join, dirname } from 'node:path'; +import url from 'node:url'; import formidable from '../../src/index.js'; diff --git a/test/standalone/connection-aborted.test.js b/test/standalone/connection-aborted.test.js index 783982ab..b7181424 100644 --- a/test/standalone/connection-aborted.test.js +++ b/test/standalone/connection-aborted.test.js @@ -1,6 +1,6 @@ -import assert from 'assert'; -import { createServer } from 'http'; -import { connect } from 'net'; +import assert from 'node:assert'; +import { createServer } from 'node:http'; +import { connect } from 'node:net'; import formidable from '../../src/index.js'; const PORT = 13539; diff --git a/test/standalone/content-transfer-encoding.test.js b/test/standalone/content-transfer-encoding.test.js index 8427a9f5..4db89ea9 100644 --- a/test/standalone/content-transfer-encoding.test.js +++ b/test/standalone/content-transfer-encoding.test.js @@ -1,6 +1,6 @@ -import { join } from 'path'; -import { createServer, request } from 'http'; -import { strictEqual } from 'assert'; +import { join } from 'node:path'; +import { createServer, request } from 'node:http'; +import { strictEqual } from 'node:assert'; import formidable from '../../src/index.js'; diff --git a/test/standalone/issue-46.test.js b/test/standalone/issue-46.test.js index be9c1132..f0b2eb7f 100644 --- a/test/standalone/issue-46.test.js +++ b/test/standalone/issue-46.test.js @@ -1,5 +1,5 @@ -import { createServer } from 'http'; -import { ok, strictEqual } from 'assert'; +import { createServer } from 'node:http'; +import { ok, strictEqual } from 'node:assert'; import request from 'request'; import formidable from '../../src/index.js'; diff --git a/test/standalone/keep-alive-error.test.js b/test/standalone/keep-alive-error.test.js index 06ac32a3..67c4f696 100644 --- a/test/standalone/keep-alive-error.test.js +++ b/test/standalone/keep-alive-error.test.js @@ -1,8 +1,8 @@ /* eslint-disable max-nested-callbacks */ -import { createConnection } from 'net'; -import { createServer } from 'http'; -import { strictEqual } from 'assert'; +import { createConnection } from 'node:net'; +import { createServer } from 'node:http'; +import { strictEqual } from 'node:assert'; import formidable from '../../src/index.js'; let ok = 0; diff --git a/test/unit/custom-plugins.test.js b/test/unit/custom-plugins.test.js index 3725f03e..18f8621e 100644 --- a/test/unit/custom-plugins.test.js +++ b/test/unit/custom-plugins.test.js @@ -1,6 +1,6 @@ /* eslint-disable no-underscore-dangle */ -import { join } from 'path'; +import { join } from 'node:path'; import Koa from 'koa'; import request from 'supertest'; diff --git a/test/unit/formidable.test.js b/test/unit/formidable.test.js index 9af6f1cf..4fd4357e 100644 --- a/test/unit/formidable.test.js +++ b/test/unit/formidable.test.js @@ -2,9 +2,9 @@ /* eslint-disable no-underscore-dangle */ import {jest} from '@jest/globals'; -import Stream from 'stream'; -import http from 'http'; -import path from 'path'; +import Stream from 'node:stream'; +import http from 'node:http'; +import path from 'node:path'; import formidable from '../../src/index.js'; import * as mod from '../../src/index.js';