WIP: bootstrap and partial real Solana watcher implementation
This commit is contained in:
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"newLineKind.enum.d.ts","sourceRoot":"","sources":["../../src/enums/newLineKind.enum.ts"],"names":[],"mappings":"AAEA,oBAAY,WAAW;IACnB,IAAI,IAAI;IACR,IAAI,IAAI;IACR,EAAE,IAAI;CACT"}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"_blake.js","sourceRoot":"","sources":["src/_blake.ts"],"names":[],"mappings":";;;AAmCA,kBAMC;AAED,kBAMC;AAjDD;;;GAGG;AACH,yCAAkC;AAElC;;;GAGG;AACH,kBAAkB;AACL,QAAA,MAAM,GAA+B,UAAU,CAAC,IAAI,CAAC;IAChE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;IACpD,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IACpD,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IACpD,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;IACpD,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE;IACpD,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;IACpD,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE;IACpD,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE;IACpD,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;IACpD,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;IACpD,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;IACpD,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IACpD,2BAA2B;IAC3B,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IACpD,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;IACpD,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE;IACpD,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;CACrD,CAAC,CAAC;AAKH,0CAA0C;AAC1C,SAAgB,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS;IACvE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC,GAAG,IAAA,eAAI,EAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;IACpB,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAChB,CAAC,GAAG,IAAA,eAAI,EAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;IACpB,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AACxB,CAAC;AAED,SAAgB,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS;IACvE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC,GAAG,IAAA,eAAI,EAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACnB,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAChB,CAAC,GAAG,IAAA,eAAI,EAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACnB,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AACxB,CAAC"}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,5 @@
|
||||
function _classPrivateFieldBase(e, t) {
|
||||
if (!{}.hasOwnProperty.call(e, t)) throw new TypeError("attempted to use private field on non-instance");
|
||||
return e;
|
||||
}
|
||||
module.exports = _classPrivateFieldBase, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,109 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "znaków", verb: "mieć" },
|
||||
file: { unit: "bajtów", verb: "mieć" },
|
||||
array: { unit: "elementów", verb: "mieć" },
|
||||
set: { unit: "elementów", verb: "mieć" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "wyrażenie",
|
||||
email: "adres email",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "data i godzina w formacie ISO",
|
||||
date: "data w formacie ISO",
|
||||
time: "godzina w formacie ISO",
|
||||
duration: "czas trwania ISO",
|
||||
ipv4: "adres IPv4",
|
||||
ipv6: "adres IPv6",
|
||||
cidrv4: "zakres IPv4",
|
||||
cidrv6: "zakres IPv6",
|
||||
base64: "ciąg znaków zakodowany w formacie base64",
|
||||
base64url: "ciąg znaków zakodowany w formacie base64url",
|
||||
json_string: "ciąg znaków w formacie JSON",
|
||||
e164: "liczba E.164",
|
||||
jwt: "JWT",
|
||||
template_literal: "wejście",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
number: "liczba",
|
||||
array: "tablica",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Nieprawidłowe dane wejściowe: oczekiwano instanceof ${issue.expected}, otrzymano ${received}`;
|
||||
}
|
||||
return `Nieprawidłowe dane wejściowe: oczekiwano ${expected}, otrzymano ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Nieprawidłowe dane wejściowe: oczekiwano ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Nieprawidłowa opcja: oczekiwano jednej z wartości ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Za duża wartość: oczekiwano, że ${issue.origin ?? "wartość"} będzie mieć ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elementów"}`;
|
||||
}
|
||||
return `Zbyt duż(y/a/e): oczekiwano, że ${issue.origin ?? "wartość"} będzie wynosić ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Za mała wartość: oczekiwano, że ${issue.origin ?? "wartość"} będzie mieć ${adj}${issue.minimum.toString()} ${sizing.unit ?? "elementów"}`;
|
||||
}
|
||||
return `Zbyt mał(y/a/e): oczekiwano, że ${issue.origin ?? "wartość"} będzie wynosić ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Nieprawidłowy ciąg znaków: musi zaczynać się od "${_issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Nieprawidłowy ciąg znaków: musi kończyć się na "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Nieprawidłowy ciąg znaków: musi zawierać "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Nieprawidłowy ciąg znaków: musi odpowiadać wzorcowi ${_issue.pattern}`;
|
||||
return `Nieprawidłow(y/a/e) ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Nieprawidłowa liczba: musi być wielokrotnością ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Nierozpoznane klucze${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Nieprawidłowy klucz w ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Nieprawidłowe dane wejściowe";
|
||||
case "invalid_element":
|
||||
return `Nieprawidłowa wartość w ${issue.origin}`;
|
||||
default:
|
||||
return `Nieprawidłowe dane wejściowe`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"name": "@eslint/config-helpers",
|
||||
"version": "0.7.0",
|
||||
"description": "Helper utilities for creating ESLint configuration",
|
||||
"type": "module",
|
||||
"main": "dist/esm/index.js",
|
||||
"types": "dist/esm/index.d.ts",
|
||||
"exports": {
|
||||
"require": {
|
||||
"types": "./dist/cjs/index.d.cts",
|
||||
"default": "./dist/cjs/index.cjs"
|
||||
},
|
||||
"import": {
|
||||
"types": "./dist/esm/index.d.ts",
|
||||
"default": "./dist/esm/index.js"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"directories": {
|
||||
"test": "tests"
|
||||
},
|
||||
"scripts": {
|
||||
"build:dedupe-types": "node ../../tools/dedupe-types.js dist/cjs/index.cjs dist/esm/index.js",
|
||||
"build:cts": "node ../../tools/build-cts.js dist/esm/index.d.ts dist/cjs/index.d.cts",
|
||||
"build": "rollup -c && npm run build:dedupe-types && tsc -p tsconfig.esm.json && npm run build:cts",
|
||||
"lint:types": "attw --pack",
|
||||
"pretest": "npm run build",
|
||||
"test": "npm run test:types && npm run test:unit",
|
||||
"test:coverage": "c8 npm run test:unit",
|
||||
"test:jsr": "npx -y jsr@latest publish --dry-run",
|
||||
"test:pnpm": "cd tests/pnpm && pnpm install && pnpm exec tsc",
|
||||
"test:types": "tsc -p tests/types/tsconfig.json",
|
||||
"test:unit": "mocha \"tests/**/*.test.js\""
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/eslint/rewrite.git",
|
||||
"directory": "packages/config-helpers"
|
||||
},
|
||||
"keywords": [
|
||||
"eslint"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/eslint/rewrite/issues"
|
||||
},
|
||||
"homepage": "https://github.com/eslint/rewrite/tree/main/packages/config-helpers#readme",
|
||||
"dependencies": {
|
||||
"@eslint/core": "^1.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rollup-plugin-copy": "^3.5.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^20.19.0 || ^22.13.0 || >=24"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"unsafeOfAnyTypeAssertion" | "unsafeToAnyTypeAssertion" | "unsafeToUnconstrainedTypeAssertion" | "unsafeTypeAssertion" | "unsafeTypeAssertionAssignableToConstraint", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
||||
name: string;
|
||||
};
|
||||
export default _default;
|
||||
@@ -0,0 +1,197 @@
|
||||
declare module 'v8' {
|
||||
import { Readable } from 'stream';
|
||||
|
||||
interface HeapSpaceInfo {
|
||||
space_name: string;
|
||||
space_size: number;
|
||||
space_used_size: number;
|
||||
space_available_size: number;
|
||||
physical_space_size: number;
|
||||
}
|
||||
|
||||
// ** Signifies if the --zap_code_space option is enabled or not. 1 == enabled, 0 == disabled. */
|
||||
type DoesZapCodeSpaceFlag = 0 | 1;
|
||||
|
||||
interface HeapInfo {
|
||||
total_heap_size: number;
|
||||
total_heap_size_executable: number;
|
||||
total_physical_size: number;
|
||||
total_available_size: number;
|
||||
used_heap_size: number;
|
||||
heap_size_limit: number;
|
||||
malloced_memory: number;
|
||||
peak_malloced_memory: number;
|
||||
does_zap_garbage: DoesZapCodeSpaceFlag;
|
||||
number_of_native_contexts: number;
|
||||
number_of_detached_contexts: number;
|
||||
}
|
||||
|
||||
interface HeapCodeStatistics {
|
||||
code_and_metadata_size: number;
|
||||
bytecode_and_metadata_size: number;
|
||||
external_script_source_size: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an integer representing a "version tag" derived from the V8 version, command line flags and detected CPU features.
|
||||
* This is useful for determining whether a vm.Script cachedData buffer is compatible with this instance of V8.
|
||||
*/
|
||||
function cachedDataVersionTag(): number;
|
||||
|
||||
function getHeapStatistics(): HeapInfo;
|
||||
function getHeapSpaceStatistics(): HeapSpaceInfo[];
|
||||
function setFlagsFromString(flags: string): void;
|
||||
/**
|
||||
* Generates a snapshot of the current V8 heap and returns a Readable
|
||||
* Stream that may be used to read the JSON serialized representation.
|
||||
* This conversation was marked as resolved by joyeecheung
|
||||
* This JSON stream format is intended to be used with tools such as
|
||||
* Chrome DevTools. The JSON schema is undocumented and specific to the
|
||||
* V8 engine, and may change from one version of V8 to the next.
|
||||
*/
|
||||
function getHeapSnapshot(): Readable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fileName The file path where the V8 heap snapshot is to be
|
||||
* saved. If not specified, a file name with the pattern
|
||||
* `'Heap-${yyyymmdd}-${hhmmss}-${pid}-${thread_id}.heapsnapshot'` will be
|
||||
* generated, where `{pid}` will be the PID of the Node.js process,
|
||||
* `{thread_id}` will be `0` when `writeHeapSnapshot()` is called from
|
||||
* the main Node.js thread or the id of a worker thread.
|
||||
*/
|
||||
function writeHeapSnapshot(fileName?: string): string;
|
||||
|
||||
function getHeapCodeStatistics(): HeapCodeStatistics;
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
*/
|
||||
class Serializer {
|
||||
/**
|
||||
* Writes out a header, which includes the serialization format version.
|
||||
*/
|
||||
writeHeader(): void;
|
||||
|
||||
/**
|
||||
* Serializes a JavaScript value and adds the serialized representation to the internal buffer.
|
||||
* This throws an error if value cannot be serialized.
|
||||
*/
|
||||
writeValue(val: any): boolean;
|
||||
|
||||
/**
|
||||
* Returns the stored internal buffer.
|
||||
* This serializer should not be used once the buffer is released.
|
||||
* Calling this method results in undefined behavior if a previous write has failed.
|
||||
*/
|
||||
releaseBuffer(): Buffer;
|
||||
|
||||
/**
|
||||
* Marks an ArrayBuffer as having its contents transferred out of band.\
|
||||
* Pass the corresponding ArrayBuffer in the deserializing context to deserializer.transferArrayBuffer().
|
||||
*/
|
||||
transferArrayBuffer(id: number, arrayBuffer: ArrayBuffer): void;
|
||||
|
||||
/**
|
||||
* Write a raw 32-bit unsigned integer.
|
||||
*/
|
||||
writeUint32(value: number): void;
|
||||
|
||||
/**
|
||||
* Write a raw 64-bit unsigned integer, split into high and low 32-bit parts.
|
||||
*/
|
||||
writeUint64(hi: number, lo: number): void;
|
||||
|
||||
/**
|
||||
* Write a JS number value.
|
||||
*/
|
||||
writeDouble(value: number): void;
|
||||
|
||||
/**
|
||||
* Write raw bytes into the serializer’s internal buffer.
|
||||
* The deserializer will require a way to compute the length of the buffer.
|
||||
*/
|
||||
writeRawBytes(buffer: NodeJS.TypedArray): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* A subclass of `Serializer` that serializes `TypedArray` (in particular `Buffer`) and `DataView` objects as host objects,
|
||||
* and only stores the part of their underlying `ArrayBuffers` that they are referring to.
|
||||
* @experimental
|
||||
*/
|
||||
class DefaultSerializer extends Serializer {
|
||||
}
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
*/
|
||||
class Deserializer {
|
||||
constructor(data: NodeJS.TypedArray);
|
||||
/**
|
||||
* Reads and validates a header (including the format version).
|
||||
* May, for example, reject an invalid or unsupported wire format.
|
||||
* In that case, an Error is thrown.
|
||||
*/
|
||||
readHeader(): boolean;
|
||||
|
||||
/**
|
||||
* Deserializes a JavaScript value from the buffer and returns it.
|
||||
*/
|
||||
readValue(): any;
|
||||
|
||||
/**
|
||||
* Marks an ArrayBuffer as having its contents transferred out of band.
|
||||
* Pass the corresponding `ArrayBuffer` in the serializing context to serializer.transferArrayBuffer()
|
||||
* (or return the id from serializer._getSharedArrayBufferId() in the case of SharedArrayBuffers).
|
||||
*/
|
||||
transferArrayBuffer(id: number, arrayBuffer: ArrayBuffer): void;
|
||||
|
||||
/**
|
||||
* Reads the underlying wire format version.
|
||||
* Likely mostly to be useful to legacy code reading old wire format versions.
|
||||
* May not be called before .readHeader().
|
||||
*/
|
||||
getWireFormatVersion(): number;
|
||||
|
||||
/**
|
||||
* Read a raw 32-bit unsigned integer and return it.
|
||||
*/
|
||||
readUint32(): number;
|
||||
|
||||
/**
|
||||
* Read a raw 64-bit unsigned integer and return it as an array [hi, lo] with two 32-bit unsigned integer entries.
|
||||
*/
|
||||
readUint64(): [number, number];
|
||||
|
||||
/**
|
||||
* Read a JS number value.
|
||||
*/
|
||||
readDouble(): number;
|
||||
|
||||
/**
|
||||
* Read raw bytes from the deserializer’s internal buffer.
|
||||
* The length parameter must correspond to the length of the buffer that was passed to serializer.writeRawBytes().
|
||||
*/
|
||||
readRawBytes(length: number): Buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* A subclass of `Serializer` that serializes `TypedArray` (in particular `Buffer`) and `DataView` objects as host objects,
|
||||
* and only stores the part of their underlying `ArrayBuffers` that they are referring to.
|
||||
* @experimental
|
||||
*/
|
||||
class DefaultDeserializer extends Deserializer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses a `DefaultSerializer` to serialize value into a buffer.
|
||||
* @experimental
|
||||
*/
|
||||
function serialize(value: any): Buffer;
|
||||
|
||||
/**
|
||||
* Uses a `DefaultDeserializer` with default options to read a JS value from a buffer.
|
||||
* @experimental
|
||||
*/
|
||||
function deserialize(data: NodeJS.TypedArray): any;
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
/**
|
||||
* @fileoverview Rule to enforce consistent naming of "this" context variables
|
||||
* @author Raphael Pigulla
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../types').Rule.RuleModule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description:
|
||||
"Enforce consistent naming when capturing the current execution context",
|
||||
recommended: false,
|
||||
frozen: true,
|
||||
url: "https://eslint.org/docs/latest/rules/consistent-this",
|
||||
},
|
||||
|
||||
schema: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "string",
|
||||
minLength: 1,
|
||||
},
|
||||
uniqueItems: true,
|
||||
},
|
||||
|
||||
defaultOptions: ["that"],
|
||||
|
||||
messages: {
|
||||
aliasNotAssignedToThis:
|
||||
"Designated alias '{{name}}' is not assigned to 'this'.",
|
||||
unexpectedAlias: "Unexpected alias '{{name}}' for 'this'.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const aliases = context.options;
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Reports that a variable declarator or assignment expression is assigning
|
||||
* a non-'this' value to the specified alias.
|
||||
* @param {ASTNode} node The assigning node.
|
||||
* @param {string} name the name of the alias that was incorrectly used.
|
||||
* @returns {void}
|
||||
*/
|
||||
function reportBadAssignment(node, name) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "aliasNotAssignedToThis",
|
||||
data: { name },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that an assignment to an identifier only assigns 'this' to the
|
||||
* appropriate alias, and the alias is only assigned to 'this'.
|
||||
* @param {ASTNode} node The assigning node.
|
||||
* @param {Identifier} name The name of the variable assigned to.
|
||||
* @param {Expression} value The value of the assignment.
|
||||
* @returns {void}
|
||||
*/
|
||||
function checkAssignment(node, name, value) {
|
||||
const isThis = value.type === "ThisExpression";
|
||||
|
||||
if (aliases.includes(name)) {
|
||||
if (!isThis || (node.operator && node.operator !== "=")) {
|
||||
reportBadAssignment(node, name);
|
||||
}
|
||||
} else if (isThis) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "unexpectedAlias",
|
||||
data: { name },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that a variable declaration of the alias in a program or function
|
||||
* is assigned to the correct value.
|
||||
* @param {string} alias alias the check the assignment of.
|
||||
* @param {Object} scope scope of the current code we are checking.
|
||||
* @private
|
||||
* @returns {void}
|
||||
*/
|
||||
function checkWasAssigned(alias, scope) {
|
||||
const variable = scope.set.get(alias);
|
||||
|
||||
if (!variable) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
variable.defs.some(
|
||||
def =>
|
||||
def.node.type === "VariableDeclarator" &&
|
||||
def.node.init !== null,
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* The alias has been declared and not assigned: check it was
|
||||
* assigned later in the same scope.
|
||||
*/
|
||||
if (
|
||||
!variable.references.some(reference => {
|
||||
const write = reference.writeExpr;
|
||||
|
||||
return (
|
||||
reference.from === scope &&
|
||||
write &&
|
||||
write.type === "ThisExpression" &&
|
||||
write.parent.operator === "="
|
||||
);
|
||||
})
|
||||
) {
|
||||
variable.defs
|
||||
.map(def => def.node)
|
||||
.forEach(node => {
|
||||
reportBadAssignment(node, alias);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check each alias to ensure that is was assigned to the correct value.
|
||||
* @param {ASTNode} node The node that represents the scope to check.
|
||||
* @returns {void}
|
||||
*/
|
||||
function ensureWasAssigned(node) {
|
||||
const scope = sourceCode.getScope(node);
|
||||
|
||||
// if this is program scope we also need to check module scope
|
||||
const extraScope =
|
||||
node.type === "Program" && node.sourceType === "module"
|
||||
? scope.childScopes[0]
|
||||
: null;
|
||||
|
||||
aliases.forEach(alias => {
|
||||
checkWasAssigned(alias, scope);
|
||||
|
||||
if (extraScope) {
|
||||
checkWasAssigned(alias, extraScope);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
"Program:exit": ensureWasAssigned,
|
||||
"FunctionExpression:exit": ensureWasAssigned,
|
||||
"FunctionDeclaration:exit": ensureWasAssigned,
|
||||
|
||||
VariableDeclarator(node) {
|
||||
const id = node.id;
|
||||
const isDestructuring =
|
||||
id.type === "ArrayPattern" || id.type === "ObjectPattern";
|
||||
|
||||
if (node.init !== null && !isDestructuring) {
|
||||
checkAssignment(node, id.name, node.init);
|
||||
}
|
||||
},
|
||||
|
||||
AssignmentExpression(node) {
|
||||
if (node.left.type === "Identifier") {
|
||||
checkAssignment(node, node.left.name, node.right);
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
import { _ as _array_with_holes } from "./_array_with_holes.js";
|
||||
import { _ as _iterable_to_array } from "./_iterable_to_array.js";
|
||||
import { _ as _non_iterable_rest } from "./_non_iterable_rest.js";
|
||||
import { _ as _unsupported_iterable_to_array } from "./_unsupported_iterable_to_array.js";
|
||||
|
||||
function _to_array(arr) {
|
||||
return _array_with_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_rest();
|
||||
}
|
||||
export { _to_array as _ };
|
||||
@@ -0,0 +1,47 @@
|
||||
'use strict'
|
||||
|
||||
let Container = require('./container')
|
||||
let { my } = require('./symbols')
|
||||
|
||||
class Warning {
|
||||
constructor(text, opts = {}) {
|
||||
this.type = 'warning'
|
||||
this.text = text
|
||||
|
||||
if (opts.node && opts.node.source) {
|
||||
if (!opts.node[my]) {
|
||||
// The node comes from another PostCSS copy in node_modules, so it does
|
||||
// not have this copy’s methods. Container#normalize() rebuilds such
|
||||
// nodes on insert, but a node passed straight to Result#warn() never
|
||||
// goes through it.
|
||||
Container.rebuild(opts.node)
|
||||
}
|
||||
let range = opts.node.rangeBy(opts)
|
||||
this.line = range.start.line
|
||||
this.column = range.start.column
|
||||
this.endLine = range.end.line
|
||||
this.endColumn = range.end.column
|
||||
}
|
||||
|
||||
for (let opt in opts) this[opt] = opts[opt]
|
||||
}
|
||||
|
||||
toString() {
|
||||
if (this.node) {
|
||||
return this.node.error(this.text, {
|
||||
index: this.index,
|
||||
plugin: this.plugin,
|
||||
word: this.word
|
||||
}).message
|
||||
}
|
||||
|
||||
if (this.plugin) {
|
||||
return this.plugin + ': ' + this.text
|
||||
}
|
||||
|
||||
return this.text
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Warning
|
||||
Warning.default = Warning
|
||||
@@ -0,0 +1,7 @@
|
||||
import type { FlatConfig } from '@typescript-eslint/utils/ts-eslint';
|
||||
export default _default;
|
||||
/**
|
||||
* Recommended rules for code correctness that you can drop in without additional configuration.
|
||||
* @see {@link https://typescript-eslint.io/users/configs#recommended}
|
||||
*/
|
||||
declare function _default(plugin: FlatConfig.Plugin, parser: FlatConfig.Parser): FlatConfig.ConfigArray;
|
||||
@@ -0,0 +1,201 @@
|
||||
'use strict';
|
||||
|
||||
const {Transform} = require('stream');
|
||||
|
||||
class FilterBase extends Transform {
|
||||
static stringFilter(string, separator) {
|
||||
return stack => {
|
||||
const path = stack.join(separator);
|
||||
return (
|
||||
(path.length === string.length && path === string) ||
|
||||
(path.length > string.length && path.substr(0, string.length) === string && path.substr(string.length, separator.length) === separator)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
static regExpFilter(regExp, separator) {
|
||||
return stack => regExp.test(stack.join(separator));
|
||||
}
|
||||
|
||||
static arrayReplacement(array) {
|
||||
return () => array;
|
||||
}
|
||||
|
||||
constructor(options) {
|
||||
super(Object.assign({}, options, {writableObjectMode: true, readableObjectMode: true}));
|
||||
this._transform = this._check;
|
||||
this._stack = [];
|
||||
|
||||
const filter = options && options.filter,
|
||||
separator = (options && options.pathSeparator) || '.';
|
||||
if (typeof filter == 'string') {
|
||||
this._filter = FilterBase.stringFilter(filter, separator);
|
||||
} else if (typeof filter == 'function') {
|
||||
this._filter = filter;
|
||||
} else if (filter instanceof RegExp) {
|
||||
this._filter = FilterBase.regExpFilter(filter, separator);
|
||||
}
|
||||
|
||||
const replacement = options && options.replacement;
|
||||
if (typeof replacement == 'function') {
|
||||
this._replacement = replacement;
|
||||
} else {
|
||||
this._replacement = FilterBase.arrayReplacement(replacement || FilterBase.defaultReplacement);
|
||||
}
|
||||
this._allowEmptyReplacement = options && options.allowEmptyReplacement;
|
||||
|
||||
this._streamKeys = true;
|
||||
if (options) {
|
||||
'streamValues' in options && (this._streamKeys = options.streamValues);
|
||||
'streamKeys' in options && (this._streamKeys = options.streamKeys);
|
||||
}
|
||||
|
||||
this._once = options && options.once;
|
||||
this._previousToken = '';
|
||||
}
|
||||
|
||||
_check(chunk, _, callback) {
|
||||
// update the last stack key
|
||||
switch (chunk.name) {
|
||||
case 'startObject':
|
||||
case 'startArray':
|
||||
case 'startString':
|
||||
case 'startNumber':
|
||||
case 'nullValue':
|
||||
case 'trueValue':
|
||||
case 'falseValue':
|
||||
if (typeof this._stack[this._stack.length - 1] == 'number') {
|
||||
// array
|
||||
++this._stack[this._stack.length - 1];
|
||||
}
|
||||
break;
|
||||
case 'keyValue':
|
||||
this._stack[this._stack.length - 1] = chunk.value;
|
||||
break;
|
||||
case 'numberValue':
|
||||
if (this._previousToken !== 'endNumber' && typeof this._stack[this._stack.length - 1] == 'number') {
|
||||
// array
|
||||
++this._stack[this._stack.length - 1];
|
||||
}
|
||||
break;
|
||||
case 'stringValue':
|
||||
if (this._previousToken !== 'endString' && typeof this._stack[this._stack.length - 1] == 'number') {
|
||||
// array
|
||||
++this._stack[this._stack.length - 1];
|
||||
}
|
||||
break;
|
||||
}
|
||||
this._previousToken = chunk.name;
|
||||
// check, if we allow a chunk
|
||||
if (this._checkChunk(chunk)) {
|
||||
return callback(null);
|
||||
}
|
||||
// update the stack
|
||||
switch (chunk.name) {
|
||||
case 'startObject':
|
||||
this._stack.push(null);
|
||||
break;
|
||||
case 'startArray':
|
||||
this._stack.push(-1);
|
||||
break;
|
||||
case 'endObject':
|
||||
case 'endArray':
|
||||
this._stack.pop();
|
||||
break;
|
||||
}
|
||||
callback(null);
|
||||
}
|
||||
|
||||
_passObject(chunk, _, callback) {
|
||||
this.push(chunk);
|
||||
switch (chunk.name) {
|
||||
case 'startObject':
|
||||
case 'startArray':
|
||||
++this._depth;
|
||||
break;
|
||||
case 'endObject':
|
||||
case 'endArray':
|
||||
--this._depth;
|
||||
break;
|
||||
}
|
||||
if (!this._depth) {
|
||||
this._transform = this._once ? this._skip : this._check;
|
||||
}
|
||||
callback(null);
|
||||
}
|
||||
|
||||
_pass(chunk, _, callback) {
|
||||
this.push(chunk);
|
||||
callback(null);
|
||||
}
|
||||
|
||||
_skipObject(chunk, _, callback) {
|
||||
switch (chunk.name) {
|
||||
case 'startObject':
|
||||
case 'startArray':
|
||||
++this._depth;
|
||||
break;
|
||||
case 'endObject':
|
||||
case 'endArray':
|
||||
--this._depth;
|
||||
break;
|
||||
}
|
||||
if (!this._depth) {
|
||||
this._transform = this._once ? this._pass : this._check;
|
||||
}
|
||||
callback(null);
|
||||
}
|
||||
|
||||
_skip(chunk, _, callback) {
|
||||
callback(null);
|
||||
}
|
||||
}
|
||||
|
||||
FilterBase.defaultReplacement = [{name: 'nullValue', value: null}];
|
||||
|
||||
const passValue = (last, post) =>
|
||||
function(chunk, _, callback) {
|
||||
if (this._expected) {
|
||||
const expected = this._expected;
|
||||
this._expected = '';
|
||||
this._transform = this._once ? this._skip : this._check;
|
||||
if (expected === chunk.name) {
|
||||
this.push(chunk);
|
||||
} else {
|
||||
return this._transform(chunk, _, callback);
|
||||
}
|
||||
} else {
|
||||
this.push(chunk);
|
||||
if (chunk.name === last) {
|
||||
this._expected = post;
|
||||
}
|
||||
}
|
||||
callback(null);
|
||||
};
|
||||
|
||||
FilterBase.prototype._passNumber = passValue('endNumber', 'numberValue');
|
||||
FilterBase.prototype._passString = passValue('endString', 'stringValue');
|
||||
FilterBase.prototype._passKey = passValue('endKey', 'keyValue');
|
||||
|
||||
const skipValue = (last, post) =>
|
||||
function(chunk, _, callback) {
|
||||
if (this._expected) {
|
||||
const expected = this._expected;
|
||||
this._expected = '';
|
||||
this._transform = this._once ? this._pass : this._check;
|
||||
if (expected !== chunk.name) {
|
||||
return this._transform(chunk, _, callback);
|
||||
}
|
||||
} else {
|
||||
if (chunk.name === last) {
|
||||
this._expected = post;
|
||||
}
|
||||
}
|
||||
callback(null);
|
||||
};
|
||||
|
||||
FilterBase.prototype._skipNumber = skipValue('endNumber', 'numberValue');
|
||||
FilterBase.prototype._skipString = skipValue('endString', 'stringValue');
|
||||
FilterBase.prototype._skipKey = skipValue('endKey', 'keyValue');
|
||||
|
||||
module.exports = FilterBase;
|
||||
@@ -0,0 +1,83 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- 'docs/**'
|
||||
- '*.md'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- 'docs/**'
|
||||
- '*.md'
|
||||
|
||||
# This allows a subsequently queued workflow run to interrupt previous runs
|
||||
concurrency:
|
||||
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
dependency-review:
|
||||
name: Dependency Review
|
||||
if: github.event_name == 'pull_request'
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- name: Check out repo
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Dependency review
|
||||
uses: actions/dependency-review-action@v4
|
||||
|
||||
test:
|
||||
name: Test
|
||||
runs-on: ${{ matrix.os }}
|
||||
permissions:
|
||||
contents: read
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [20, 22, 24]
|
||||
os: [ubuntu-latest]
|
||||
pino-version: [^9.0.0]
|
||||
steps:
|
||||
- name: Check out repo
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup Node ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- name: Restore cached dependencies
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: node_modules
|
||||
key: node-modules-${{ hashFiles('package.json') }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm i --ignore-scripts
|
||||
|
||||
- name: Install pino ${{ matrix.pino-version }}
|
||||
run: npm i --no-save pino@${{ matrix.pino-version }}
|
||||
|
||||
- name: Run tests
|
||||
run: npm run ci
|
||||
|
||||
automerge:
|
||||
name: Automerge Dependabot PRs
|
||||
if: >
|
||||
github.event_name == 'pull_request' &&
|
||||
github.event.pull_request.user.login == 'dependabot[bot]'
|
||||
needs: test
|
||||
permissions:
|
||||
pull-requests: write
|
||||
contents: write
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: fastify/github-action-merge-dependabot@v3
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -0,0 +1,272 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util_1 = require("../util");
|
||||
var Group;
|
||||
(function (Group) {
|
||||
Group["conditional"] = "conditional";
|
||||
Group["function"] = "function";
|
||||
Group["import"] = "import";
|
||||
Group["intersection"] = "intersection";
|
||||
Group["keyword"] = "keyword";
|
||||
Group["nullish"] = "nullish";
|
||||
Group["literal"] = "literal";
|
||||
Group["named"] = "named";
|
||||
Group["object"] = "object";
|
||||
Group["operator"] = "operator";
|
||||
Group["tuple"] = "tuple";
|
||||
Group["union"] = "union";
|
||||
})(Group || (Group = {}));
|
||||
function getGroup(node) {
|
||||
switch (node.type) {
|
||||
case utils_1.AST_NODE_TYPES.TSConditionalType:
|
||||
return Group.conditional;
|
||||
case utils_1.AST_NODE_TYPES.TSConstructorType:
|
||||
case utils_1.AST_NODE_TYPES.TSFunctionType:
|
||||
return Group.function;
|
||||
case utils_1.AST_NODE_TYPES.TSImportType:
|
||||
return Group.import;
|
||||
case utils_1.AST_NODE_TYPES.TSIntersectionType:
|
||||
return Group.intersection;
|
||||
case utils_1.AST_NODE_TYPES.TSAnyKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSBigIntKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSBooleanKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSNeverKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSNumberKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSObjectKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSStringKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSSymbolKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSThisType:
|
||||
case utils_1.AST_NODE_TYPES.TSUnknownKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSIntrinsicKeyword:
|
||||
return Group.keyword;
|
||||
case utils_1.AST_NODE_TYPES.TSNullKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSUndefinedKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSVoidKeyword:
|
||||
return Group.nullish;
|
||||
case utils_1.AST_NODE_TYPES.TSLiteralType:
|
||||
case utils_1.AST_NODE_TYPES.TSTemplateLiteralType:
|
||||
return Group.literal;
|
||||
case utils_1.AST_NODE_TYPES.TSArrayType:
|
||||
case utils_1.AST_NODE_TYPES.TSIndexedAccessType:
|
||||
case utils_1.AST_NODE_TYPES.TSInferType:
|
||||
case utils_1.AST_NODE_TYPES.TSTypeReference:
|
||||
case utils_1.AST_NODE_TYPES.TSQualifiedName:
|
||||
return Group.named;
|
||||
case utils_1.AST_NODE_TYPES.TSMappedType:
|
||||
case utils_1.AST_NODE_TYPES.TSTypeLiteral:
|
||||
return Group.object;
|
||||
case utils_1.AST_NODE_TYPES.TSTypeOperator:
|
||||
case utils_1.AST_NODE_TYPES.TSTypeQuery:
|
||||
return Group.operator;
|
||||
case utils_1.AST_NODE_TYPES.TSTupleType:
|
||||
return Group.tuple;
|
||||
case utils_1.AST_NODE_TYPES.TSUnionType:
|
||||
return Group.union;
|
||||
// These types should never occur as part of a union/intersection
|
||||
case utils_1.AST_NODE_TYPES.TSAbstractKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSAsyncKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSDeclareKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSExportKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSNamedTupleMember:
|
||||
case utils_1.AST_NODE_TYPES.TSOptionalType:
|
||||
case utils_1.AST_NODE_TYPES.TSPrivateKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSProtectedKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSPublicKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSReadonlyKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSRestType:
|
||||
case utils_1.AST_NODE_TYPES.TSStaticKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSTypePredicate:
|
||||
/* istanbul ignore next */
|
||||
throw new Error(`Unexpected Type ${node.type}`);
|
||||
}
|
||||
}
|
||||
function caseSensitiveSort(a, b) {
|
||||
if (a < b) {
|
||||
return -1;
|
||||
}
|
||||
if (a > b) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
exports.default = (0, util_1.createRule)({
|
||||
name: 'sort-type-constituents',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
deprecated: {
|
||||
deprecatedSince: '7.13.0',
|
||||
replacedBy: [
|
||||
{
|
||||
plugin: {
|
||||
name: 'eslint-plugin-perfectionist',
|
||||
url: 'https://perfectionist.dev',
|
||||
},
|
||||
rule: {
|
||||
name: 'perfectionist/sort-intersection-types',
|
||||
url: 'https://perfectionist.dev/rules/sort-intersection-types',
|
||||
},
|
||||
},
|
||||
{
|
||||
plugin: {
|
||||
name: 'eslint-plugin-perfectionist',
|
||||
url: 'https://perfectionist.dev',
|
||||
},
|
||||
rule: {
|
||||
name: 'perfectionist/sort-union-types',
|
||||
url: 'https://perfectionist.dev/rules/sort-union-types',
|
||||
},
|
||||
},
|
||||
],
|
||||
url: 'https://github.com/typescript-eslint/typescript-eslint/pull/9253',
|
||||
},
|
||||
docs: {
|
||||
description: 'Enforce constituents of a type union/intersection to be sorted alphabetically',
|
||||
},
|
||||
fixable: 'code',
|
||||
hasSuggestions: true,
|
||||
messages: {
|
||||
notSorted: '{{type}} type constituents must be sorted.',
|
||||
notSortedNamed: '{{type}} type {{name}} constituents must be sorted.',
|
||||
suggestFix: 'Sort constituents of type (removes all comments).',
|
||||
},
|
||||
replacedBy: [
|
||||
'perfectionist/sort-intersection-types',
|
||||
'perfectionist/sort-union-types',
|
||||
],
|
||||
schema: [
|
||||
{
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
caseSensitive: {
|
||||
type: 'boolean',
|
||||
description: 'Whether to sort using case sensitive string comparisons.',
|
||||
},
|
||||
checkIntersections: {
|
||||
type: 'boolean',
|
||||
description: 'Whether to check intersection types (`&`).',
|
||||
},
|
||||
checkUnions: {
|
||||
type: 'boolean',
|
||||
description: 'Whether to check union types (`|`).',
|
||||
},
|
||||
groupOrder: {
|
||||
type: 'array',
|
||||
description: 'Ordering of the groups.',
|
||||
items: {
|
||||
type: 'string',
|
||||
enum: (0, util_1.getEnumNames)(Group),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
caseSensitive: false,
|
||||
checkIntersections: true,
|
||||
checkUnions: true,
|
||||
groupOrder: [
|
||||
Group.named,
|
||||
Group.keyword,
|
||||
Group.operator,
|
||||
Group.literal,
|
||||
Group.function,
|
||||
Group.import,
|
||||
Group.conditional,
|
||||
Group.object,
|
||||
Group.tuple,
|
||||
Group.intersection,
|
||||
Group.union,
|
||||
Group.nullish,
|
||||
],
|
||||
},
|
||||
],
|
||||
create(context, [{ caseSensitive, checkIntersections, checkUnions, groupOrder }]) {
|
||||
const collator = new Intl.Collator('en', {
|
||||
numeric: true,
|
||||
sensitivity: 'base',
|
||||
});
|
||||
function checkSorting(node) {
|
||||
const sourceOrder = node.types.map(type => {
|
||||
const group = groupOrder?.indexOf(getGroup(type)) ?? -1;
|
||||
return {
|
||||
node: type,
|
||||
group: group === -1 ? Number.MAX_SAFE_INTEGER : group,
|
||||
text: context.sourceCode.getText(type),
|
||||
};
|
||||
});
|
||||
const expectedOrder = [...sourceOrder].sort((a, b) => {
|
||||
if (a.group !== b.group) {
|
||||
return a.group - b.group;
|
||||
}
|
||||
if (caseSensitive) {
|
||||
return caseSensitiveSort(a.text, b.text);
|
||||
}
|
||||
return (collator.compare(a.text, b.text) ||
|
||||
(a.text < b.text ? -1 : a.text > b.text ? 1 : 0));
|
||||
});
|
||||
const hasComments = node.types.some(type => {
|
||||
const count = context.sourceCode.getCommentsBefore(type).length +
|
||||
context.sourceCode.getCommentsAfter(type).length;
|
||||
return count > 0;
|
||||
});
|
||||
for (let i = 0; i < expectedOrder.length; i += 1) {
|
||||
if (expectedOrder[i].node !== sourceOrder[i].node) {
|
||||
let messageId = 'notSorted';
|
||||
const data = {
|
||||
name: '',
|
||||
type: node.type === utils_1.AST_NODE_TYPES.TSIntersectionType
|
||||
? 'Intersection'
|
||||
: 'Union',
|
||||
};
|
||||
if (node.parent.type === utils_1.AST_NODE_TYPES.TSTypeAliasDeclaration) {
|
||||
messageId = 'notSortedNamed';
|
||||
data.name = node.parent.id.name;
|
||||
}
|
||||
const fix = fixer => {
|
||||
const sorted = expectedOrder
|
||||
.map(t => (0, util_1.typeNodeRequiresParentheses)(t.node, t.text) ||
|
||||
(node.type === utils_1.AST_NODE_TYPES.TSIntersectionType &&
|
||||
t.node.type === utils_1.AST_NODE_TYPES.TSUnionType)
|
||||
? `(${t.text})`
|
||||
: t.text)
|
||||
.join(node.type === utils_1.AST_NODE_TYPES.TSIntersectionType ? ' & ' : ' | ');
|
||||
return fixer.replaceText(node, sorted);
|
||||
};
|
||||
return context.report({
|
||||
node,
|
||||
messageId,
|
||||
data,
|
||||
// don't autofix if any of the types have leading/trailing comments
|
||||
// the logic for preserving them correctly is a pain - we may implement this later
|
||||
...(hasComments
|
||||
? {
|
||||
suggest: [
|
||||
{
|
||||
messageId: 'suggestFix',
|
||||
fix,
|
||||
},
|
||||
],
|
||||
}
|
||||
: { fix }),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
...(checkIntersections && {
|
||||
TSIntersectionType(node) {
|
||||
checkSorting(node);
|
||||
},
|
||||
}),
|
||||
...(checkUnions && {
|
||||
TSUnionType(node) {
|
||||
checkSorting(node);
|
||||
},
|
||||
}),
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
import km from "./km.js";
|
||||
/** @deprecated Use `km` instead. */
|
||||
export default function () {
|
||||
return km();
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
var unsupportedIterableToArray = require("./unsupportedIterableToArray.js");
|
||||
function _createForOfIteratorHelper(r, e) {
|
||||
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
||||
if (!t) {
|
||||
if (Array.isArray(r) || (t = unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
|
||||
t && (r = t);
|
||||
var _n = 0,
|
||||
F = function F() {};
|
||||
return {
|
||||
s: F,
|
||||
n: function n() {
|
||||
return _n >= r.length ? {
|
||||
done: !0
|
||||
} : {
|
||||
done: !1,
|
||||
value: r[_n++]
|
||||
};
|
||||
},
|
||||
e: function e(r) {
|
||||
throw r;
|
||||
},
|
||||
f: F
|
||||
};
|
||||
}
|
||||
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
||||
}
|
||||
var o,
|
||||
a = !0,
|
||||
u = !1;
|
||||
return {
|
||||
s: function s() {
|
||||
t = t.call(r);
|
||||
},
|
||||
n: function n() {
|
||||
var r = t.next();
|
||||
return a = r.done, r;
|
||||
},
|
||||
e: function e(r) {
|
||||
u = !0, o = r;
|
||||
},
|
||||
f: function f() {
|
||||
try {
|
||||
a || null == t["return"] || t["return"]();
|
||||
} finally {
|
||||
if (u) throw o;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
module.exports = _createForOfIteratorHelper, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"commentDirectiveType.enum.js","sourceRoot":"","sources":["../../src/enums/commentDirectiveType.enum.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC5B,6EAAe,CAAA;IACf,mEAAU,CAAA;AACd,CAAC,EAHW,oBAAoB,KAApB,oBAAoB,QAG/B"}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,171 @@
|
||||
# pino-abstract-transport
|
||||
[](https://www.npmjs.com/package/pino-abstract-transport)
|
||||
[](https://github.com/pinojs/pino-abstract-transport/actions)
|
||||
[](https://standardjs.com/)
|
||||
|
||||
Write Pino transports easily.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm i pino-abstract-transport
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import build from 'pino-abstract-transport'
|
||||
|
||||
export default async function (opts) {
|
||||
return build(async function (source) {
|
||||
for await (let obj of source) {
|
||||
console.log(obj)
|
||||
}
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
or in CommonJS and streams:
|
||||
|
||||
```js
|
||||
'use strict'
|
||||
|
||||
const build = require('pino-abstract-transport')
|
||||
|
||||
module.exports = function (opts) {
|
||||
return build(function (source) {
|
||||
source.on('data', function (obj) {
|
||||
console.log(obj)
|
||||
})
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
## Typescript usage
|
||||
|
||||
Install the type definitions for node. Make sure the major version of the type definitions matches the node version you are using.
|
||||
|
||||
#### Node 16
|
||||
|
||||
```sh
|
||||
npm i -D @types/node@16
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### build(fn, opts) => Stream
|
||||
|
||||
Create a [`split2`](http://npm.im/split2) instance and returns it.
|
||||
This same instance is also passed to the given function, which is called
|
||||
synchronously.
|
||||
|
||||
If `opts.transform` is `true`, `pino-abstract-transform` will
|
||||
wrap the split2 instance and the returned stream using [`duplexify`](https://www.npmjs.com/package/duplexify),
|
||||
so they can be concatenated into multiple transports.
|
||||
|
||||
#### Events emitted
|
||||
|
||||
In addition to all events emitted by a [`Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable)
|
||||
stream, it emits the following events:
|
||||
|
||||
* `unknown` where an unparsable line is found, both the line and optional error is emitted.
|
||||
|
||||
#### Options
|
||||
|
||||
* `parse` an option to change to data format passed to build function. When this option is set to `lines`,
|
||||
the data is passed as a string, otherwise the data is passed as an object. Default: `undefined`.
|
||||
|
||||
* `close(err, cb)` a function that is called to shutdown the transport. It's called both on error and non-error shutdowns.
|
||||
It can also return a promise. In this case discard the the `cb` argument.
|
||||
|
||||
* `parseLine(line)` a function that is used to parse line received from `pino`.
|
||||
|
||||
* `expectPinoConfig` a boolean that indicates if the transport expects Pino to add some of its configuration to the stream. Default: `false`.
|
||||
|
||||
## Example
|
||||
|
||||
### custom parseLine
|
||||
|
||||
You can allow custom `parseLine` from users while providing a simple and safe default parseLine.
|
||||
|
||||
```js
|
||||
'use strict'
|
||||
|
||||
const build = require('pino-abstract-transport')
|
||||
|
||||
function defaultParseLine (line) {
|
||||
const obj = JSON.parse(line)
|
||||
// property foo will be added on each line
|
||||
obj.foo = 'bar'
|
||||
return obj
|
||||
}
|
||||
|
||||
module.exports = function (opts) {
|
||||
const parseLine = typeof opts.parseLine === 'function' ? opts.parseLine : defaultParseLine
|
||||
return build(function (source) {
|
||||
source.on('data', function (obj) {
|
||||
console.log(obj)
|
||||
})
|
||||
}, {
|
||||
parseLine: parseLine
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
### Stream concatenation / pipeline
|
||||
|
||||
You can pipeline multiple transports:
|
||||
|
||||
```js
|
||||
const build = require('pino-abstract-transport')
|
||||
const { Transform, pipeline } = require('stream')
|
||||
|
||||
function buildTransform () {
|
||||
return build(function (source) {
|
||||
return new Transform({
|
||||
objectMode: true,
|
||||
autoDestroy: true,
|
||||
transform (line, enc, cb) {
|
||||
line.service = 'bob'
|
||||
cb(null, JSON.stringify(line))
|
||||
}
|
||||
})
|
||||
}, { enablePipelining: true })
|
||||
}
|
||||
|
||||
function buildDestination () {
|
||||
return build(function (source) {
|
||||
source.on('data', function (obj) {
|
||||
console.log(obj)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
pipeline(process.stdin, buildTransform(), buildDestination(), function (err) {
|
||||
console.log('pipeline completed!', err)
|
||||
})
|
||||
```
|
||||
|
||||
### Using pino config
|
||||
|
||||
Setting `expectPinoConfig` to `true` will make the transport wait for pino to send its configuration before starting to process logs. It will add `levels`, `messageKey` and `errorKey` to the stream.
|
||||
|
||||
When used with an incompatible version of pino, the stream will immediately error.
|
||||
|
||||
```js
|
||||
import build from 'pino-abstract-transport'
|
||||
|
||||
export default function (opts) {
|
||||
return build(async function (source) {
|
||||
for await (const obj of source) {
|
||||
console.log(`[${source.levels.labels[obj.level]}]: ${obj[source.messageKey]}`)
|
||||
}
|
||||
}, {
|
||||
expectPinoConfig: true
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FunctionNameDefinition = void 0;
|
||||
const DefinitionBase_1 = require("./DefinitionBase");
|
||||
const DefinitionType_1 = require("./DefinitionType");
|
||||
class FunctionNameDefinition extends DefinitionBase_1.DefinitionBase {
|
||||
isTypeDefinition = false;
|
||||
isVariableDefinition = true;
|
||||
constructor(name, node) {
|
||||
super(DefinitionType_1.DefinitionType.FunctionName, name, node, null);
|
||||
}
|
||||
}
|
||||
exports.FunctionNameDefinition = FunctionNameDefinition;
|
||||
@@ -0,0 +1,99 @@
|
||||
{
|
||||
"name": "@typescript-eslint/types",
|
||||
"version": "8.67.0",
|
||||
"description": "Types for the TypeScript-ESTree AST spec",
|
||||
"files": [
|
||||
"dist",
|
||||
"!**/*.tsbuildinfo"
|
||||
],
|
||||
"type": "commonjs",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"types": "./dist/index.d.ts",
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/typescript-eslint/typescript-eslint.git",
|
||||
"directory": "packages/types"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/typescript-eslint/typescript-eslint/issues"
|
||||
},
|
||||
"homepage": "https://typescript-eslint.io",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"eslint",
|
||||
"typescript",
|
||||
"estree"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@typescript/native": "npm:typescript@^7.0.2",
|
||||
"@vitest/coverage-v8": "^4.0.18",
|
||||
"eslint": "^10.0.0",
|
||||
"rimraf": "^5.0.10",
|
||||
"tsx": "^4.7.2",
|
||||
"typescript": ">=4.8.4 <6.1.0",
|
||||
"vitest": "^4.0.18"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"nx": {
|
||||
"name": "types",
|
||||
"implicitDependencies": [
|
||||
"ast-spec"
|
||||
],
|
||||
"includedScripts": [
|
||||
"clean"
|
||||
],
|
||||
"targets": {
|
||||
"build": {
|
||||
"dependsOn": [
|
||||
"copy-ast-spec"
|
||||
]
|
||||
},
|
||||
"copy-ast-spec": {
|
||||
"cache": false,
|
||||
"command": "tsx tools/copy-ast-spec.mts",
|
||||
"dependsOn": [
|
||||
"ast-spec:build"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "{projectRoot}"
|
||||
},
|
||||
"outputs": [
|
||||
"{projectRoot}/src/generated"
|
||||
]
|
||||
},
|
||||
"lint": {
|
||||
"command": "eslint",
|
||||
"dependsOn": [
|
||||
"typescript-eslint:build",
|
||||
"eslint-plugin-internal:build"
|
||||
]
|
||||
},
|
||||
"typecheck:tsgo": {},
|
||||
"attw-check": {}
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"build": "pnpm exec nx build",
|
||||
"clean": "rimraf dist/ src/generated/ coverage/",
|
||||
"copy-ast-spec": "tsx ./tools/copy-ast-spec.mts",
|
||||
"format": "pnpm -w run format",
|
||||
"generate-lib": "pnpm -w exec nx run scope-manager:generate-lib",
|
||||
"lint": "pnpm -w exec nx lint",
|
||||
"test": "pnpm -w exec nx test",
|
||||
"typecheck": "pnpm -w exec nx typecheck",
|
||||
"typecheck:tsgo": "pnpm -w exec nx typecheck:tsgo",
|
||||
"attw-check": "pnpm -w exec nx attw-check"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
/* eslint-disable @typescript-eslint/consistent-indexed-object-style, @typescript-eslint/no-namespace */
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
@@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _validate = _interopRequireDefault(require("./validate.js"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function parse(uuid) {
|
||||
if (!(0, _validate.default)(uuid)) {
|
||||
throw TypeError('Invalid UUID');
|
||||
}
|
||||
|
||||
let v;
|
||||
const arr = new Uint8Array(16); // Parse ########-....-....-....-............
|
||||
|
||||
arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
|
||||
arr[1] = v >>> 16 & 0xff;
|
||||
arr[2] = v >>> 8 & 0xff;
|
||||
arr[3] = v & 0xff; // Parse ........-####-....-....-............
|
||||
|
||||
arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
|
||||
arr[5] = v & 0xff; // Parse ........-....-####-....-............
|
||||
|
||||
arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
|
||||
arr[7] = v & 0xff; // Parse ........-....-....-####-............
|
||||
|
||||
arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
|
||||
arr[9] = v & 0xff; // Parse ........-....-....-....-############
|
||||
// (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
|
||||
|
||||
arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
|
||||
arr[11] = v / 0x100000000 & 0xff;
|
||||
arr[12] = v >>> 24 & 0xff;
|
||||
arr[13] = v >>> 16 & 0xff;
|
||||
arr[14] = v >>> 8 & 0xff;
|
||||
arr[15] = v & 0xff;
|
||||
return arr;
|
||||
}
|
||||
|
||||
var _default = parse;
|
||||
exports.default = _default;
|
||||
@@ -0,0 +1,21 @@
|
||||
'use strict'
|
||||
|
||||
const { Writable } = require('stream')
|
||||
|
||||
// Nop console.error to avoid printing things out
|
||||
console.error = () => {}
|
||||
|
||||
setImmediate(function () {
|
||||
Promise.reject(new Error('kaboom'))
|
||||
})
|
||||
|
||||
async function run (opts) {
|
||||
const stream = new Writable({
|
||||
write (chunk, enc, cb) {
|
||||
cb()
|
||||
}
|
||||
})
|
||||
return stream
|
||||
}
|
||||
|
||||
module.exports = run
|
||||
Reference in New Issue
Block a user