Skip to content

Commit

Permalink
refactor: use explicit node: imports (#786)
Browse files Browse the repository at this point in the history
* refactor: use explicit node: imports

* fix: rename eslint for now
  • Loading branch information
GrosSacASac committed Nov 26, 2021
1 parent 9c1ebdc commit 1b27107
Show file tree
Hide file tree
Showing 30 changed files with 68 additions and 68 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/json.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import http from 'http';
import http from 'node:http';
import util from 'util';
import formidable from '../src/index.js';

Expand Down
4 changes: 2 additions & 2 deletions examples/log-file-content-to-console.js
Original file line number Diff line number Diff line change
@@ -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';


Expand Down
4 changes: 2 additions & 2 deletions examples/multiples.js
Original file line number Diff line number Diff line change
@@ -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';


Expand Down
4 changes: 2 additions & 2 deletions examples/store-files-on-s3.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
6 changes: 3 additions & 3 deletions examples/upload-multiple-files.js
Original file line number Diff line number Diff line change
@@ -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';


Expand Down
4 changes: 2 additions & 2 deletions examples/urlencoded-no-enctype.js
Original file line number Diff line number Diff line change
@@ -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';


Expand Down
2 changes: 1 addition & 1 deletion examples/with-http.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import http from 'http';
import http from 'node:http';
import formidable from '../src/index.js';


Expand Down
8 changes: 4 additions & 4 deletions src/Formidable.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
6 changes: 3 additions & 3 deletions src/PersistentFile.js
Original file line number Diff line number Diff line change
@@ -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 }) {
Expand Down
4 changes: 2 additions & 2 deletions src/VolatileFile.js
Original file line number Diff line number Diff line change
@@ -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 }) {
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/Dummy.js
Original file line number Diff line number Diff line change
@@ -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 = {}) {
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/JSON.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-underscore-dangle */

import { Transform } from 'stream';
import { Transform } from 'node:stream';

class JSONParser extends Transform {
constructor(options = {}) {
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/Multipart.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/parsers/OctetStream.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PassThrough } from 'stream';
import { PassThrough } from 'node:stream';

class OctetStreamParser extends PassThrough {
constructor(options = {}) {
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/Querystring.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/StreamingQuerystring.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/multipart.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
12 changes: 6 additions & 6 deletions test/integration/file-write-stream-handler-option.test.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
10 changes: 5 additions & 5 deletions test/integration/fixtures.test.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
4 changes: 2 additions & 2 deletions test/integration/json.test.js
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
10 changes: 5 additions & 5 deletions test/integration/octet-stream.test.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
10 changes: 5 additions & 5 deletions test/integration/store-files-option.test.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
6 changes: 3 additions & 3 deletions test/standalone/connection-aborted.test.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 3 additions & 3 deletions test/standalone/content-transfer-encoding.test.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
4 changes: 2 additions & 2 deletions test/standalone/issue-46.test.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
6 changes: 3 additions & 3 deletions test/standalone/keep-alive-error.test.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/unit/custom-plugins.test.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
6 changes: 3 additions & 3 deletions test/unit/formidable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 1b27107

Please sign in to comment.