Skip to content

Commit

Permalink
chore: update eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed May 24, 2023
1 parent 02bb8b3 commit 4de6a50
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 78 deletions.
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"generator-star-spacing": 0,
"indent": 0,
"unicorn/no-nested-ternary": 0,
"require-await": 0
"require-await": 0,
"unicorn/switch-case-braces": 0,
"unicorn/prefer-string-replace-all": 0
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
"pathe": "^1.1.0"
},
"devDependencies": {
"@types/node": "^18.16.14",
"@types/node": "^20.2.3",
"changelogen": "^0.5.3",
"eslint": "^8.41.0",
"eslint-config-unjs": "^0.1.0",
"eslint-config-unjs": "^0.2.0",
"jiti": "^1.18.2",
"prettier": "^2.8.8",
"typescript": "^5.0.4",
Expand Down
142 changes: 81 additions & 61 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/runtime/node/buffer/_base64.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const lookup = [];
const revLookup = [];
const Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
const Arr = typeof Uint8Array === "undefined" ? Array : Uint8Array;

const code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
for (let i = 0, len = code.length; i < len; ++i) {
Expand Down
12 changes: 6 additions & 6 deletions src/runtime/node/buffer/_buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,10 @@ Buffer.concat = function concat(list, length) {
} else {
Uint8Array.prototype.set.call(buffer, buf, pos);
}
} else if (!Buffer.isBuffer(buf)) {
throw new TypeError('"list" argument must be an Array of Buffers');
} else {
} else if (Buffer.isBuffer(buf)) {
buf.copy(buffer, pos);
} else {
throw new TypeError('"list" argument must be an Array of Buffers');
}
pos += buf.length;
}
Expand Down Expand Up @@ -922,13 +922,13 @@ Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
function hexWrite(buf, string, offset, length) {
offset = Number(offset) || 0;
const remaining = buf.length - offset;
if (!length) {
length = remaining;
} else {
if (length) {
length = Number(length);
if (length > remaining) {
length = remaining;
}
} else {
length = remaining;
}

const strLen = string.length;
Expand Down
1 change: 1 addition & 0 deletions src/runtime/node/stream/readable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { BufferEncoding, Callback } from "../../_internal/types";
// Docs: https://nodejs.org/api/stream.html#stream_readable_streams
// Implementation: https://github.com/nodejs/node/blob/master/lib/internal/streams/readable.js

// eslint-disable-next-line unicorn/prefer-event-target
export class Readable extends EventEmitter implements stream.Readable {
readonly readableEncoding: BufferEncoding | null = null;
readonly readableEnded: boolean = true;
Expand Down
6 changes: 3 additions & 3 deletions src/runtime/node/stream/writable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { BufferEncoding, Callback } from "../../_internal/types";

// Docs: https://nodejs.org/api/stream.html#stream_writable_streams
// Implementation: https://github.com/nodejs/node/blob/master/lib/internal/streams/writable.js

// eslint-disable-next-line unicorn/prefer-event-target
export class Writable extends EventEmitter implements stream.Writable {
readonly writable: boolean = true;
writableEnded: boolean = false;
Expand Down Expand Up @@ -100,9 +100,9 @@ export class Writable extends EventEmitter implements stream.Writable {
}
return this;
}
const data = arg1 !== callback ? arg1 : undefined;
const data = arg1 === callback ? undefined : arg1;
if (data) {
const encoding = arg2 !== callback ? arg2 : undefined;
const encoding = arg2 === callback ? undefined : arg2;
this.write(data, encoding, callback);
}
this.writableEnded = true;
Expand Down
6 changes: 3 additions & 3 deletions src/runtime/node/url/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ export const format = <typeof url.format>(
let url: URL;
if (typeof urlInput === "string") {
url = new URL(urlInput);
} else if (!(urlInput instanceof URL)) {
} else if (urlInput instanceof URL) {
url = urlInput;
} else {
// TODO
throw new TypeError("format urlObject is not supported");
} else {
url = urlInput;
}
if (options) {
if (options.auth === false) {
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/node/util/_legacy-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const isSymbol: typeof util.isSymbol = (val): val is symbol =>
typeof val === "symbol";

export const isUndefined: typeof util.isUndefined = (val): val is undefined =>
typeof val === "undefined";
val === undefined;

// eslint-disable-next-line @typescript-eslint/ban-types
export const isFunction: typeof util.isFunction = (val): val is Function =>
Expand Down

0 comments on commit 4de6a50

Please sign in to comment.