Skip to content

Commit 71a25ae

Browse files
committed
chore: lint with eslint v9
1 parent 0272330 commit 71a25ae

File tree

14 files changed

+50
-40
lines changed

14 files changed

+50
-40
lines changed

.eslintignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.eslintrc

Lines changed: 0 additions & 20 deletions
This file was deleted.

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,13 @@ The above package doesn't work outside of Node.js and neither we need any platfo
186186
We use this proxy for auto-mocking unimplemented internals. Imagine a package does this:
187187

188188
```js
189-
const os = require("os");
189+
const os = require("node:os");
190190
if (os.platform() === "windows") {
191191
/* do some fix */
192192
}
193-
module.exports = () => "Hello world";
193+
module.exports = function main() {
194+
return "Hello world"
195+
}
194196
```
195197

196198
By aliasing `os` to `unenv/runtime/mock/proxy-cjs`, the code will be compatible with other platforms.

eslint.config.mjs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import unjs from "eslint-config-unjs";
2+
3+
// https://github.com/unjs/eslint-config
4+
export default unjs({
5+
ignores: [
6+
"runtime"
7+
],
8+
rules: {
9+
"@typescript-eslint/no-unused-vars": 0,
10+
"unicorn/no-null": 0,
11+
"@typescript-eslint/no-inferrable-types": 0,
12+
"unicorn/prefer-math-trunc": 0,
13+
"unicorn/prefer-code-point": 0,
14+
"unicorn/text-encoding-identifier-case": 0,
15+
"prefer-rest-params": 0,
16+
"prefer-spread": 0,
17+
"unicorn/number-literal-case": 0,
18+
"generator-star-spacing": 0,
19+
"indent": 0,
20+
"unicorn/no-nested-ternary": 0,
21+
"require-await": 0,
22+
"unicorn/switch-case-braces": 0,
23+
"unicorn/prefer-string-replace-all": 0,
24+
"unicorn/prefer-event-target": 0,
25+
},
26+
}, {
27+
languageOptions: {
28+
globals: {
29+
Deno: true
30+
}
31+
}
32+
});

src/runtime/node/async_hooks/_async-local-storage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class _AsyncLocalStorage<T> implements asyncHooks.AsyncLocalStorage<T> {
3131
...args: TArgs
3232
): R {
3333
this._currentStore = store;
34-
const res = callback(...args); // eslint-disable-line n/no-callback-literal
34+
const res = callback(...args);
3535
this._currentStore = undefined;
3636
return res;
3737
}
@@ -42,7 +42,7 @@ class _AsyncLocalStorage<T> implements asyncHooks.AsyncLocalStorage<T> {
4242
): R {
4343
const _previousStore = this._currentStore;
4444
this._currentStore = undefined;
45-
const res = callback(...args); // eslint-disable-line n/no-callback-literal
45+
const res = callback(...args);
4646
this._currentStore = _previousStore;
4747
return res;
4848
}

src/runtime/node/buffer/_buffer.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import * as base64 from "./_base64";
1212
import * as ieee754 from "./_ieee754";
1313

1414
const customInspectSymbol =
15-
typeof Symbol === "function" && typeof Symbol["for"] === "function" // eslint-disable-line dot-notation
16-
? Symbol["for"]("nodejs.util.inspect.custom") // eslint-disable-line dot-notation
15+
typeof Symbol === "function" && typeof Symbol["for"] === "function"
16+
? Symbol["for"]("nodejs.util.inspect.custom")
1717
: null;
1818

1919
export const INSPECT_MAX_BYTES = 50;
@@ -363,7 +363,6 @@ function checked(length) {
363363
}
364364

365365
export function SlowBuffer(length) {
366-
// eslint-disable-next-line eqeqeq
367366
if (+length != length) {
368367
length = 0;
369368
}
@@ -2161,7 +2160,7 @@ function E(sym, getMessage, Base) {
21612160
this.name = `${this.name} [${sym}]`;
21622161
// Access the stack to generate the error message including the error code
21632162
// from the name.
2164-
this.stack; // eslint-disable-line no-unused-expressions
2163+
this.stack;
21652164
// Reset the name to the actual name.
21662165
delete this.name;
21672166
}
@@ -2457,7 +2456,7 @@ function isInstance(obj, type) {
24572456
}
24582457
function numberIsNaN(obj) {
24592458
// For IE11 support
2460-
return obj !== obj; // eslint-disable-line no-self-compare
2459+
return obj !== obj;
24612460
}
24622461

24632462
// Create lookup table for `toString('hex')`

src/runtime/node/events/_events.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ function _addListener<T extends EventEmitter>(
208208
) {
209209
target._events[type].warned = true;
210210
// No error code for this since it is a Warning
211-
// eslint-disable-next-line no-restricted-syntax
211+
212212
const warning = new Error(
213213
`[unenv] Possible EventEmitter memory leak detected. ${target._events[type].length} ${type} listeners added. Use emitter.setMaxListeners() to increase limit`,
214214
) as Error & {

src/runtime/node/process/_process.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function runTimeout(fun: () => void) {
5252
} catch {
5353
try {
5454
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
55-
// eslint-disable-next-line no-useless-call
55+
5656
return cachedSetTimeout.call(null, fun, 0);
5757
} catch {
5858
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
@@ -80,7 +80,7 @@ function runClearTimeout(marker) {
8080
} catch {
8181
try {
8282
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
83-
// eslint-disable-next-line no-useless-call
83+
8484
return cachedClearTimeout.call(null, marker);
8585
} catch {
8686
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.

src/runtime/node/stream/readable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ interface ArrayOptions {
1313
signal?: AbortSignal;
1414
}
1515

16-
// eslint-disable-next-line unicorn/prefer-event-target
1716
export class _Readable extends EventEmitter implements stream.Readable {
1817
__unenv__: unknown = true;
1918

@@ -102,6 +101,7 @@ export class _Readable extends EventEmitter implements stream.Readable {
102101
return Promise.resolve();
103102
}
104103

104+
// eslint-disable-next-line require-yield
105105
async *[Symbol.asyncIterator](): AsyncIterableIterator<any> {
106106
throw createNotImplementedError("Readable.asyncIterator");
107107
}

src/runtime/node/stream/writable.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { EventEmitter } from "../events";
55

66
// Docs: https://nodejs.org/api/stream.html#stream_writable_streams
77
// Implementation: https://github.com/nodejs/node/blob/master/lib/internal/streams/writable.js
8-
// eslint-disable-next-line unicorn/prefer-event-target
98
class _Writable extends EventEmitter implements stream.Writable {
109
readonly __unenv__ = true;
1110

0 commit comments

Comments
 (0)