Skip to content

tools: lint typescript files #58256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: lint ts
  • Loading branch information
Jorgee97 committed Jul 7, 2025
commit 57231e5a545a033c0cdd38fad1ebc786b83b166f
2 changes: 1 addition & 1 deletion doc/api/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ This will result in [`ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX`][] error:
```ts
// This namespace is exporting a value
namespace A {
export let x = 1
export const x = 1;
}
```

Expand Down
17 changes: 16 additions & 1 deletion test/eslint.config_partial.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,29 @@ export default [
},
{
files: [
'test/{common,fixtures,wpt}/**/*.{js,mjs,cjs,ts,mts,cts}',
'test/{common,fixtures,wpt}/**/*.{js,mjs,cjs}',
'test/eslint.config_partial.mjs',
],
rules: {
'node-core/required-modules': 'off',
'node-core/require-common-first': 'off',
},
},
{
files: [
'test/{common,fixtures,wpt}/**/*.{ts,mts,cts}',
],
rules: {
'node-core/required-modules': 'off',
'node-core/require-common-first': 'off',

// Fixtures rules off
'node-core/async-iife-no-unused-result': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@stylistic/js/max-len': 'off',
},
},
{
files: [
'test/es-module/test-esm-example-loader.js',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
import '../../../common/index.mjs';

interface Foo {
/** line
*
* blocks */
// line
//
// blocks
}

async function Throw() {
await 0;
throw new Error('message')
throw new Error('message');
}

(async function main() {
await Promise.all([0, 1, 2, Throw()]);
})()
})();

// To recreate:
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import '../../../common/index.mjs';

interface Block {
/** line
*
* blocks */
// line
//
// blocks
}

class Foo {
Expand Down
2 changes: 1 addition & 1 deletion typings/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { SymbolsBinding } from './internalBinding/symbols';
import { TimersBinding } from './internalBinding/timers';
import { TypesBinding } from './internalBinding/types';
import { URLBinding } from './internalBinding/url';
import { URLPatternBinding } from "./internalBinding/url_pattern";
import { URLPatternBinding } from './internalBinding/url_pattern';
import { UtilBinding } from './internalBinding/util';
import { WASIBinding } from './internalBinding/wasi';
import { WorkerBinding } from './internalBinding/worker';
Expand Down
1 change: 1 addition & 0 deletions typings/internalBinding/constants.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ export interface ConstantsBinding {
RSA_PSS_SALTLEN_DIGEST: -1;
RSA_PSS_SALTLEN_MAX_SIGN: -2;
RSA_PSS_SALTLEN_AUTO: -2;
/* eslint-disable @stylistic/js/max-len */
defaultCoreCipherList: 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA';
TLS1_VERSION: 769;
TLS1_1_VERSION: 770;
Expand Down
173 changes: 139 additions & 34 deletions typings/internalBinding/fs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ declare namespace InternalFSBinding {

function copyFile(src: StringOrBuffer, dest: StringOrBuffer, mode: number, req: FSReqCallback): void;
function copyFile(src: StringOrBuffer, dest: StringOrBuffer, mode: number, req: undefined, ctx: FSSyncContext): void;
function copyFile(src: StringOrBuffer, dest: StringOrBuffer, mode: number, usePromises: typeof kUsePromises): Promise<void>;
function copyFile(src: StringOrBuffer,
dest: StringOrBuffer,
mode: number,
usePromises: typeof kUsePromises): Promise<void>;

function cpSyncCheckPaths(src: StringOrBuffer, dest: StringOrBuffer, dereference: boolean, recursive: boolean): void;
function cpSyncOverrideFile(src: StringOrBuffer, dest: StringOrBuffer, mode: number, preserveTimestamps: boolean): void;
Expand All @@ -96,10 +99,15 @@ declare namespace InternalFSBinding {
function fstat(fd: number, useBigint: boolean, req: FSReqCallback<Float64Array | BigUint64Array>): void;
function fstat(fd: number, useBigint: true, req: FSReqCallback<BigUint64Array>): void;
function fstat(fd: number, useBigint: false, req: FSReqCallback<Float64Array>): void;
function fstat(fd: number, useBigint: boolean, req: undefined, shouldNotThrow: boolean): Float64Array | BigUint64Array;
function fstat(fd: number,
useBigint: boolean,
req: undefined,
shouldNotThrow: boolean): Float64Array | BigUint64Array;
function fstat(fd: number, useBigint: true, req: undefined, shouldNotThrow: boolean): BigUint64Array;
function fstat(fd: number, useBigint: false, req: undefined, shouldNotThrow: boolean): Float64Array;
function fstat(fd: number, useBigint: boolean, usePromises: typeof kUsePromises): Promise<Float64Array | BigUint64Array>;
function fstat(fd: number,
useBigint: boolean,
usePromises: typeof kUsePromises): Promise<Float64Array | BigUint64Array>;
function fstat(fd: number, useBigint: true, usePromises: typeof kUsePromises): Promise<BigUint64Array>;
function fstat(fd: number, useBigint: false, usePromises: typeof kUsePromises): Promise<Float64Array>;

Expand Down Expand Up @@ -130,10 +138,15 @@ declare namespace InternalFSBinding {
function lstat(path: StringOrBuffer, useBigint: boolean, req: FSReqCallback<Float64Array | BigUint64Array>): void;
function lstat(path: StringOrBuffer, useBigint: true, req: FSReqCallback<BigUint64Array>): void;
function lstat(path: StringOrBuffer, useBigint: false, req: FSReqCallback<Float64Array>): void;
function lstat(path: StringOrBuffer, useBigint: boolean, req: undefined, throwIfNoEntry: boolean): Float64Array | BigUint64Array;
function lstat(path: StringOrBuffer,
useBigint: boolean,
req: undefined,
throwIfNoEntry: boolean): Float64Array | BigUint64Array;
function lstat(path: StringOrBuffer, useBigint: true, req: undefined, throwIfNoEntry: boolean): BigUint64Array;
function lstat(path: StringOrBuffer, useBigint: false, req: undefined, throwIfNoEntry: boolean): Float64Array;
function lstat(path: StringOrBuffer, useBigint: boolean, usePromises: typeof kUsePromises): Promise<Float64Array | BigUint64Array>;
function lstat(path: StringOrBuffer,
useBigint: boolean,
usePromises: typeof kUsePromises): Promise<Float64Array | BigUint64Array>;
function lstat(path: StringOrBuffer, useBigint: true, usePromises: typeof kUsePromises): Promise<BigUint64Array>;
function lstat(path: StringOrBuffer, useBigint: false, usePromises: typeof kUsePromises): Promise<Float64Array>;

Expand All @@ -152,43 +165,89 @@ declare namespace InternalFSBinding {
function mkdir(path: string, mode: number, recursive: boolean): void | string;
function mkdir(path: string, mode: number, recursive: true): string;
function mkdir(path: string, mode: number, recursive: false): void;
function mkdir(path: string, mode: number, recursive: boolean, usePromises: typeof kUsePromises): Promise<void | string>;
function mkdir(path: string,
mode: number,
recursive: boolean,
usePromises: typeof kUsePromises): Promise<void | string>;
function mkdir(path: string, mode: number, recursive: true, usePromises: typeof kUsePromises): Promise<string>;
function mkdir(path: string, mode: number, recursive: false, usePromises: typeof kUsePromises): Promise<void>;

function open(path: StringOrBuffer, flags: number, mode: number, req: FSReqCallback<number>): void;
function open(path: StringOrBuffer, flags: number, mode: number): number;

function openFileHandle(path: StringOrBuffer, flags: number, mode: number, usePromises: typeof kUsePromises): Promise<FileHandle>;

function read(fd: number, buffer: ArrayBufferView, offset: number, length: number, position: number, req: FSReqCallback<number>): void;
function read(fd: number, buffer: ArrayBufferView, offset: number, length: number, position: number, usePromises: typeof kUsePromises): Promise<number>;
function openFileHandle(path: StringOrBuffer,
flags: number,
mode: number,
usePromises: typeof kUsePromises): Promise<FileHandle>;

function read(fd: number,
buffer: ArrayBufferView,
offset: number,
length: number,
position: number,
req: FSReqCallback<number>): void;
function read(fd: number,
buffer: ArrayBufferView,
offset: number,
length: number,
position: number,
usePromises: typeof kUsePromises): Promise<number>;
function read(fd: number, buffer: ArrayBufferView, offset: number, length: number, position: number): number;

function readBuffers(fd: number, buffers: ArrayBufferView[], position: number, req: FSReqCallback<number>): void;
function readBuffers(fd: number, buffers: ArrayBufferView[], position: number, req: undefined, ctx: FSSyncContext): number;
function readBuffers(fd: number, buffers: ArrayBufferView[], position: number, usePromises: typeof kUsePromises): Promise<number>;

function readdir(path: StringOrBuffer, encoding: unknown, withFileTypes: boolean, req: FSReqCallback<string[] | [string[], number[]]>): void;
function readdir(path: StringOrBuffer, encoding: unknown, withFileTypes: true, req: FSReqCallback<[string[], number[]]>): void;
function readBuffers(fd: number,
buffers: ArrayBufferView[],
position: number,
req: undefined,
ctx: FSSyncContext): number;
function readBuffers(fd: number,
buffers: ArrayBufferView[],
position: number,
usePromises: typeof kUsePromises): Promise<number>;

function readdir(path: StringOrBuffer,
encoding: unknown,
withFileTypes: boolean,
req: FSReqCallback<string[] | [string[], number[]]>): void;
function readdir(path: StringOrBuffer,
encoding: unknown,
withFileTypes: true,
req: FSReqCallback<[string[], number[]]>): void;
function readdir(path: StringOrBuffer, encoding: unknown, withFileTypes: false, req: FSReqCallback<string[]>): void;
function readdir(path: StringOrBuffer, encoding: unknown, withFileTypes: boolean, req: undefined, ctx: FSSyncContext): string[] | [string[], number[]];
function readdir(path: StringOrBuffer,
encoding: unknown,
withFileTypes: boolean,
req: undefined,
ctx: FSSyncContext): string[] | [string[], number[]];
function readdir(path: StringOrBuffer, encoding: unknown, withFileTypes: true): [string[], number[]];
function readdir(path: StringOrBuffer, encoding: unknown, withFileTypes: false): string[];
function readdir(path: StringOrBuffer, encoding: unknown, withFileTypes: boolean, usePromises: typeof kUsePromises): Promise<string[] | [string[], number[]]>;
function readdir(path: StringOrBuffer, encoding: unknown, withFileTypes: true, usePromises: typeof kUsePromises): Promise<[string[], number[]]>;
function readdir(path: StringOrBuffer, encoding: unknown, withFileTypes: false, usePromises: typeof kUsePromises): Promise<string[]>;
function readdir(path: StringOrBuffer,
encoding: unknown,
withFileTypes: boolean,
usePromises: typeof kUsePromises): Promise<string[] | [string[], number[]]>;
function readdir(path: StringOrBuffer,
encoding: unknown,
withFileTypes: true,
usePromises: typeof kUsePromises): Promise<[string[], number[]]>;
function readdir(path: StringOrBuffer,
encoding: unknown,
withFileTypes: false,
usePromises: typeof kUsePromises): Promise<string[]>;

function readFileUtf8(path: StringOrBuffer, flags: number): string;

function readlink(path: StringOrBuffer, encoding: unknown, req: FSReqCallback<string | Buffer>): void;
function readlink(path: StringOrBuffer, encoding: unknown, req: undefined, ctx: FSSyncContext): string | Buffer;
function readlink(path: StringOrBuffer, encoding: unknown, usePromises: typeof kUsePromises): Promise<string | Buffer>;
function readlink(path: StringOrBuffer,
encoding: unknown,
usePromises: typeof kUsePromises): Promise<string | Buffer>;
function readlink(path: StringOrBuffer, encoding: unknown): StringOrBuffer;

function realpath(path: StringOrBuffer, encoding: unknown, req: FSReqCallback<string | Buffer>): void;
function realpath(path: StringOrBuffer, encoding: unknown, req: undefined, ctx: FSSyncContext): string | Buffer;
function realpath(path: StringOrBuffer, encoding: unknown, usePromises: typeof kUsePromises): Promise<string | Buffer>;
function realpath(path: StringOrBuffer,
encoding: unknown,
usePromises: typeof kUsePromises): Promise<string | Buffer>;
function realpath(path: StringOrBuffer, encoding: unknown): StringOrBuffer;

function rename(oldPath: string, newPath: string, req: FSReqCallback): void;
Expand All @@ -205,16 +264,28 @@ declare namespace InternalFSBinding {
function stat(path: StringOrBuffer, useBigint: boolean, req: FSReqCallback<Float64Array | BigUint64Array>): void;
function stat(path: StringOrBuffer, useBigint: true, req: FSReqCallback<BigUint64Array>): void;
function stat(path: StringOrBuffer, useBigint: false, req: FSReqCallback<Float64Array>): void;
function stat(path: StringOrBuffer, useBigint: boolean, req: undefined, ctx: FSSyncContext): Float64Array | BigUint64Array;
function stat(path: StringOrBuffer,
useBigint: boolean,
req: undefined,
ctx: FSSyncContext): Float64Array | BigUint64Array;
function stat(path: StringOrBuffer, useBigint: true, req: undefined, ctx: FSSyncContext): BigUint64Array;
function stat(path: StringOrBuffer, useBigint: false, req: undefined, ctx: FSSyncContext): Float64Array;
function stat(path: StringOrBuffer, useBigint: boolean, usePromises: typeof kUsePromises): Promise<Float64Array | BigUint64Array>;
function stat(path: StringOrBuffer,
useBigint: boolean,
usePromises: typeof kUsePromises): Promise<Float64Array | BigUint64Array>;
function stat(path: StringOrBuffer, useBigint: true, usePromises: typeof kUsePromises): Promise<BigUint64Array>;
function stat(path: StringOrBuffer, useBigint: false, usePromises: typeof kUsePromises): Promise<Float64Array>;

function symlink(target: StringOrBuffer, path: StringOrBuffer, type: number, req: FSReqCallback): void;
function symlink(target: StringOrBuffer, path: StringOrBuffer, type: number, req: undefined, ctx: FSSyncContext): void;
function symlink(target: StringOrBuffer, path: StringOrBuffer, type: number, usePromises: typeof kUsePromises): Promise<void>;
function symlink(target: StringOrBuffer,
path: StringOrBuffer,
type: number,
req: undefined,
ctx: FSSyncContext): void;
function symlink(target: StringOrBuffer,
path: StringOrBuffer,
type: number,
usePromises: typeof kUsePromises): Promise<void>;
function symlink(target: StringOrBuffer, path: StringOrBuffer, type: number): void;

function unlink(path: string, req: FSReqCallback): void;
Expand All @@ -225,17 +296,51 @@ declare namespace InternalFSBinding {
function utimes(path: string, atime: number, mtime: number): void;
function utimes(path: string, atime: number, mtime: number, usePromises: typeof kUsePromises): Promise<void>;

function writeBuffer(fd: number, buffer: ArrayBufferView, offset: number, length: number, position: number | null, req: FSReqCallback<number>): void;
function writeBuffer(fd: number, buffer: ArrayBufferView, offset: number, length: number, position: number | null, req: undefined, ctx: FSSyncContext): number;
function writeBuffer(fd: number, buffer: ArrayBufferView, offset: number, length: number, position: number | null, usePromises: typeof kUsePromises): Promise<number>;

function writeBuffers(fd: number, buffers: ArrayBufferView[], position: number, req: FSReqCallback<number>): void;
function writeBuffers(fd: number, buffers: ArrayBufferView[], position: number, req: undefined, ctx: FSSyncContext): number;
function writeBuffers(fd: number, buffers: ArrayBufferView[], position: number, usePromises: typeof kUsePromises): Promise<number>;
function writeBuffer(fd: number,
buffer: ArrayBufferView,
offset: number,
length: number,
position: number | null,
req: FSReqCallback<number>): void;
function writeBuffer(fd: number,
buffer: ArrayBufferView,
offset: number,
length: number,
position: number | null,
req: undefined,
ctx: FSSyncContext): number;
function writeBuffer(fd: number,
buffer: ArrayBufferView,
offset: number, length: number,
position: number | null,
usePromises: typeof kUsePromises): Promise<number>;

function writeBuffers(fd: number,
buffers: ArrayBufferView[],
position: number,
req: FSReqCallback<number>): void;
function writeBuffers(fd: number,
buffers: ArrayBufferView[],
position: number,
req: undefined,
ctx: FSSyncContext): number;
function writeBuffers(fd: number,
buffers: ArrayBufferView[],
position: number,
usePromises: typeof kUsePromises): Promise<number>;

function writeString(fd: number, value: string, pos: unknown, encoding: unknown, req: FSReqCallback<number>): void;
function writeString(fd: number, value: string, pos: unknown, encoding: unknown, req: undefined, ctx: FSSyncContext): number;
function writeString(fd: number, value: string, pos: unknown, encoding: unknown, usePromises: typeof kUsePromises): Promise<number>;
function writeString(fd: number,
value: string,
pos: unknown,
encoding: unknown,
req: undefined,
ctx: FSSyncContext): number;
function writeString(fd: number,
value: string,
pos: unknown,
encoding: unknown,
usePromises: typeof kUsePromises): Promise<number>;

function getFormatOfExtensionlessFile(url: string): ConstantsBinding['internal'];

Expand Down
3 changes: 2 additions & 1 deletion typings/internalBinding/messaging.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export interface MessagingBinding {
stopMessagePort(port: typeof InternalMessagingBinding.MessagePort): void;
drainMessagePort(port: typeof InternalMessagingBinding.MessagePort): void;
receiveMessageOnPort(port: typeof InternalMessagingBinding.MessagePort): any;
moveMessagePortToContext(port: typeof InternalMessagingBinding.MessagePort, context: any): typeof InternalMessagingBinding.MessagePort;
moveMessagePortToContext(port: typeof InternalMessagingBinding.MessagePort,
context: any): typeof InternalMessagingBinding.MessagePort;
setDeserializerCreateObjectFunction(func: (deserializeInfo: string) => any): void;
broadcastChannel(name: string): typeof InternalMessagingBinding.MessagePort;
}
2 changes: 1 addition & 1 deletion typings/internalBinding/process.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
interface CpuUsageValue {
interface CpuUsageValue {
user: number;
system: number;
}
Expand Down
4 changes: 2 additions & 2 deletions typings/internalBinding/quic.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ interface QuicCallbacks {
supports: number[]) => void;
onStreamCreated: (stream: Stream) => void;
onStreamBlocked: () => void;
onStreamClose: (error: [number,bigint,string]) => void;
onStreamReset: (error: [number,bigint,string]) => void;
onStreamClose: (error: [number, bigint, string]) => void;
onStreamReset: (error: [number, bigint, string]) => void;
onStreamHeaders: (headers: string[], kind: number) => void;
onStreamTrailers: () => void;
}
Expand Down
12 changes: 6 additions & 6 deletions typings/internalBinding/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ export interface TypesBinding {
isAnyArrayBuffer(value: unknown): value is (ArrayBuffer | SharedArrayBuffer);
isArrayBuffer(value: unknown): value is ArrayBuffer;
isArgumentsObject(value: unknown): value is ArrayLike<unknown>;
isBoxedPrimitive(value: unknown): value is (BigInt | Boolean | Number | String | Symbol);
isBoxedPrimitive(value: unknown): value is (bigint | boolean | number | string | symbol);
isDataView(value: unknown): value is DataView;
isExternal(value: unknown): value is Object;
isExternal(value: unknown): value is object;
isMap(value: unknown): value is Map<unknown, unknown>;
isMapIterator: (value: unknown) => value is IterableIterator<unknown>;
isModuleNamespaceObject: (value: unknown) => value is { [Symbol.toStringTag]: 'Module' };
Expand All @@ -19,8 +19,8 @@ export interface TypesBinding {
isRegExp: (value: unknown) => RegExp;
isDate: (value: unknown) => Date;
isTypedArray: (value: unknown) => value is TypedArray;
isStringObject: (value: unknown) => value is String;
isNumberObject: (value: unknown) => value is Number;
isBooleanObject: (value: unknown) => value is Boolean,
isBigIntObject: (value: unknown) => value is BigInt;
isStringObject: (value: unknown) => value is string;
isNumberObject: (value: unknown) => value is number;
isBooleanObject: (value: unknown) => value is boolean,
isBigIntObject: (value: unknown) => value is bigint;
}
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy