WIP: bootstrap and partial real Solana watcher implementation

This commit is contained in:
2026-08-16 09:17:45 +00:00
commit dc23412c3f
7232 changed files with 1687637 additions and 0 deletions

View File

@@ -0,0 +1,247 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const tsutils = __importStar(require("ts-api-utils"));
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'prefer-find',
meta: {
type: 'suggestion',
docs: {
description: 'Enforce the use of Array.prototype.find() over Array.prototype.filter() followed by [0] when looking for a single result',
recommended: 'stylistic',
requiresTypeChecking: true,
},
hasSuggestions: true,
messages: {
preferFind: 'Prefer .find(...) instead of .filter(...)[0].',
preferFindSuggestion: 'Use .find(...) instead of .filter(...)[0].',
},
schema: [],
},
defaultOptions: [],
create(context) {
const globalScope = context.sourceCode.getScope(context.sourceCode.ast);
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();
function parseArrayFilterExpressions(expression) {
const node = (0, util_1.skipChainExpression)(expression);
if (node.type === utils_1.AST_NODE_TYPES.SequenceExpression) {
// Only the last expression in (a, b, [1, 2, 3].filter(condition))[0] matters
const lastExpression = (0, util_1.nullThrows)(node.expressions.at(-1), 'Expected to have more than zero expressions in a sequence expression');
return parseArrayFilterExpressions(lastExpression);
}
// This is the only reason we're returning a list rather than a single value.
if (node.type === utils_1.AST_NODE_TYPES.ConditionalExpression) {
// Both branches of the ternary _must_ return results.
const consequentResult = parseArrayFilterExpressions(node.consequent);
if (consequentResult.length === 0) {
return [];
}
const alternateResult = parseArrayFilterExpressions(node.alternate);
if (alternateResult.length === 0) {
return [];
}
// Accumulate the results from both sides and pass up the chain.
return [...consequentResult, ...alternateResult];
}
// Check if it looks like <<stuff>>(...), but not <<stuff>>?.(...)
if (node.type === utils_1.AST_NODE_TYPES.CallExpression && !node.optional) {
const callee = node.callee;
// Check if it looks like <<stuff>>.filter(...) or <<stuff>>['filter'](...),
// or the optional chaining variants.
if (callee.type === utils_1.AST_NODE_TYPES.MemberExpression) {
const isBracketSyntaxForFilter = callee.computed;
if ((0, util_1.isStaticMemberAccessOfValue)(callee, context, 'filter')) {
const filterNode = callee.property;
const filteredObjectType = (0, util_1.getConstrainedTypeAtLocation)(services, callee.object);
// As long as the object is a (possibly nullable) array,
// this is an Array.prototype.filter expression.
if (isArrayish(filteredObjectType)) {
return [
{
filterNode,
isBracketSyntaxForFilter,
},
];
}
}
}
}
// not a filter expression.
return [];
}
/**
* Tells whether the type is a possibly nullable array/tuple or union thereof.
*/
function isArrayish(type) {
let isAtLeastOneArrayishComponent = false;
for (const unionPart of tsutils.unionConstituents(type)) {
if (tsutils.isIntrinsicNullType(unionPart) ||
tsutils.isIntrinsicUndefinedType(unionPart)) {
continue;
}
// apparently checker.isArrayType(T[] & S[]) => false.
// so we need to check the intersection parts individually.
const isArrayOrIntersectionThereof = tsutils
.intersectionConstituents(unionPart)
.every(intersectionPart => checker.isArrayType(intersectionPart) ||
checker.isTupleType(intersectionPart));
if (!isArrayOrIntersectionThereof) {
// There is a non-array, non-nullish type component,
// so it's not an array.
return false;
}
isAtLeastOneArrayishComponent = true;
}
return isAtLeastOneArrayishComponent;
}
function getObjectIfArrayAtZeroExpression(node) {
// .at() should take exactly one argument.
if (node.arguments.length !== 1) {
return undefined;
}
const callee = node.callee;
if (callee.type === utils_1.AST_NODE_TYPES.MemberExpression &&
!callee.optional &&
(0, util_1.isStaticMemberAccessOfValue)(callee, context, 'at')) {
const atArgument = (0, util_1.getStaticValue)(node.arguments[0], globalScope);
if (atArgument != null && isTreatedAsZeroByArrayAt(atArgument.value)) {
return callee.object;
}
}
return undefined;
}
/**
* Implements the algorithm for array indexing by `.at()` method.
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at#parameters
*/
function isTreatedAsZeroByArrayAt(value) {
// This would cause the number constructor coercion to throw. Other static
// values are safe.
if (typeof value === 'symbol') {
return false;
}
const asNumber = Number(value);
if (isNaN(asNumber)) {
return true;
}
return Math.trunc(asNumber) === 0;
}
function isMemberAccessOfZero(node) {
const property = (0, util_1.getStaticValue)(node.property, globalScope);
// Check if it looks like <<stuff>>[0] or <<stuff>>['0'], but not <<stuff>>?.[0]
return (!node.optional &&
property != null &&
isTreatedAsZeroByMemberAccess(property.value));
}
/**
* Implements the algorithm for array indexing by member operator.
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#array_indices
*/
function isTreatedAsZeroByMemberAccess(value) {
return String(value) === '0';
}
function generateFixToRemoveArrayElementAccess(fixer, arrayNode, wholeExpressionBeingFlagged) {
const tokenToStartDeletingFrom = (0, util_1.nullThrows)(
// The next `.` or `[` is what we're looking for.
// think of (...).at(0) or (...)[0] or even (...)["at"](0).
context.sourceCode.getTokenAfter(arrayNode, token => token.value === '.' || token.value === '['), 'Expected to find a member access token!');
return fixer.removeRange([
tokenToStartDeletingFrom.range[0],
wholeExpressionBeingFlagged.range[1],
]);
}
function generateFixToReplaceFilterWithFind(fixer, filterExpression) {
return fixer.replaceText(filterExpression.filterNode, filterExpression.isBracketSyntaxForFilter ? '"find"' : 'find');
}
return {
// This query will be used to find things like `filteredResults.at(0)`.
CallExpression(node) {
const object = getObjectIfArrayAtZeroExpression(node);
if (object) {
const filterExpressions = parseArrayFilterExpressions(object);
if (filterExpressions.length !== 0) {
context.report({
node,
messageId: 'preferFind',
suggest: [
{
messageId: 'preferFindSuggestion',
fix: (fixer) => {
return [
...filterExpressions.map(filterExpression => generateFixToReplaceFilterWithFind(fixer, filterExpression)),
// Get rid of the .at(0) or ['at'](0).
generateFixToRemoveArrayElementAccess(fixer, object, node),
];
},
},
],
});
}
}
},
// This query will be used to find things like `filteredResults[0]`.
//
// Note: we're always looking for array member access to be "computed",
// i.e. `filteredResults[0]`, since `filteredResults.0` isn't a thing.
'MemberExpression[computed=true]'(node) {
if (isMemberAccessOfZero(node)) {
const object = node.object;
const filterExpressions = parseArrayFilterExpressions(object);
if (filterExpressions.length !== 0) {
context.report({
node,
messageId: 'preferFind',
suggest: [
{
messageId: 'preferFindSuggestion',
fix: (fixer) => {
return [
...filterExpressions.map(filterExpression => generateFixToReplaceFilterWithFind(fixer, filterExpression)),
// Get rid of the [0].
generateFixToRemoveArrayElementAccess(fixer, object, node),
];
},
},
],
});
}
}
},
};
},
});

View File

@@ -0,0 +1,32 @@
export {
_lt as lt,
_lte as lte,
_gt as gt,
_gte as gte,
_positive as positive,
_negative as negative,
_nonpositive as nonpositive,
_nonnegative as nonnegative,
_multipleOf as multipleOf,
_maxSize as maxSize,
_minSize as minSize,
_size as size,
_maxLength as maxLength,
_minLength as minLength,
_length as length,
_regex as regex,
_lowercase as lowercase,
_uppercase as uppercase,
_includes as includes,
_startsWith as startsWith,
_endsWith as endsWith,
_property as property,
_mime as mime,
_overwrite as overwrite,
_normalize as normalize,
_trim as trim,
_toLowerCase as toLowerCase,
_toUpperCase as toUpperCase,
_slugify as slugify,
type $RefinementCtx as RefinementCtx,
} from "../core/index.js";

View File

@@ -0,0 +1,157 @@
import {Buffer} from 'buffer';
import * as BufferLayout from '@solana/buffer-layout';
import {Keypair} from '../keypair';
import {PublicKey} from '../publickey';
import {TransactionInstruction} from '../transaction';
import assert from '../utils/assert';
import {sign} from '../utils/ed25519';
const PRIVATE_KEY_BYTES = 64;
const PUBLIC_KEY_BYTES = 32;
const SIGNATURE_BYTES = 64;
/**
* Params for creating an ed25519 instruction using a public key
*/
export type CreateEd25519InstructionWithPublicKeyParams = {
publicKey: Uint8Array;
message: Uint8Array;
signature: Uint8Array;
instructionIndex?: number;
};
/**
* Params for creating an ed25519 instruction using a private key
*/
export type CreateEd25519InstructionWithPrivateKeyParams = {
privateKey: Uint8Array;
message: Uint8Array;
instructionIndex?: number;
};
const ED25519_INSTRUCTION_LAYOUT = BufferLayout.struct<
Readonly<{
messageDataOffset: number;
messageDataSize: number;
messageInstructionIndex: number;
numSignatures: number;
padding: number;
publicKeyInstructionIndex: number;
publicKeyOffset: number;
signatureInstructionIndex: number;
signatureOffset: number;
}>
>([
BufferLayout.u8('numSignatures'),
BufferLayout.u8('padding'),
BufferLayout.u16('signatureOffset'),
BufferLayout.u16('signatureInstructionIndex'),
BufferLayout.u16('publicKeyOffset'),
BufferLayout.u16('publicKeyInstructionIndex'),
BufferLayout.u16('messageDataOffset'),
BufferLayout.u16('messageDataSize'),
BufferLayout.u16('messageInstructionIndex'),
]);
export class Ed25519Program {
/**
* @internal
*/
constructor() {}
/**
* Public key that identifies the ed25519 program
*/
static programId: PublicKey = new PublicKey(
'Ed25519SigVerify111111111111111111111111111',
);
/**
* Create an ed25519 instruction with a public key and signature. The
* public key must be a buffer that is 32 bytes long, and the signature
* must be a buffer of 64 bytes.
*/
static createInstructionWithPublicKey(
params: CreateEd25519InstructionWithPublicKeyParams,
): TransactionInstruction {
const {publicKey, message, signature, instructionIndex} = params;
assert(
publicKey.length === PUBLIC_KEY_BYTES,
`Public Key must be ${PUBLIC_KEY_BYTES} bytes but received ${publicKey.length} bytes`,
);
assert(
signature.length === SIGNATURE_BYTES,
`Signature must be ${SIGNATURE_BYTES} bytes but received ${signature.length} bytes`,
);
const publicKeyOffset = ED25519_INSTRUCTION_LAYOUT.span;
const signatureOffset = publicKeyOffset + publicKey.length;
const messageDataOffset = signatureOffset + signature.length;
const numSignatures = 1;
const instructionData = Buffer.alloc(messageDataOffset + message.length);
const index =
instructionIndex == null
? 0xffff // An index of `u16::MAX` makes it default to the current instruction.
: instructionIndex;
ED25519_INSTRUCTION_LAYOUT.encode(
{
numSignatures,
padding: 0,
signatureOffset,
signatureInstructionIndex: index,
publicKeyOffset,
publicKeyInstructionIndex: index,
messageDataOffset,
messageDataSize: message.length,
messageInstructionIndex: index,
},
instructionData,
);
instructionData.fill(publicKey, publicKeyOffset);
instructionData.fill(signature, signatureOffset);
instructionData.fill(message, messageDataOffset);
return new TransactionInstruction({
keys: [],
programId: Ed25519Program.programId,
data: instructionData,
});
}
/**
* Create an ed25519 instruction with a private key. The private key
* must be a buffer that is 64 bytes long.
*/
static createInstructionWithPrivateKey(
params: CreateEd25519InstructionWithPrivateKeyParams,
): TransactionInstruction {
const {privateKey, message, instructionIndex} = params;
assert(
privateKey.length === PRIVATE_KEY_BYTES,
`Private key must be ${PRIVATE_KEY_BYTES} bytes but received ${privateKey.length} bytes`,
);
try {
const keypair = Keypair.fromSecretKey(privateKey);
const publicKey = keypair.publicKey.toBytes();
const signature = sign(message, keypair.secretKey);
return this.createInstructionWithPublicKey({
publicKey,
message,
signature,
instructionIndex,
});
} catch (error) {
throw new Error(`Error creating instruction; ${error}`);
}
}
}

View File

@@ -0,0 +1,118 @@
import type { $ZodStringFormats } from "../core/checks.js";
import type * as errors from "../core/errors.js";
import * as util from "../core/util.js";
const error: () => errors.$ZodErrorMap = () => {
const Sizable: Record<string, { unit: string; verb: string }> = {
string: { unit: "znakov", verb: "imeti" },
file: { unit: "bajtov", verb: "imeti" },
array: { unit: "elementov", verb: "imeti" },
set: { unit: "elementov", verb: "imeti" },
};
function getSizing(origin: string): { unit: string; verb: string } | null {
return Sizable[origin] ?? null;
}
const FormatDictionary: {
[k in $ZodStringFormats | (string & {})]?: string;
} = {
regex: "vnos",
email: "e-poštni naslov",
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: "ISO datum in čas",
date: "ISO datum",
time: "ISO čas",
duration: "ISO trajanje",
ipv4: "IPv4 naslov",
ipv6: "IPv6 naslov",
cidrv4: "obseg IPv4",
cidrv6: "obseg IPv6",
base64: "base64 kodiran niz",
base64url: "base64url kodiran niz",
json_string: "JSON niz",
e164: "E.164 številka",
jwt: "JWT",
template_literal: "vnos",
};
const TypeDictionary: {
[k in errors.$ZodInvalidTypeExpected | (string & {})]?: string;
} = {
nan: "NaN",
number: "število",
array: "tabela",
};
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 `Neveljaven vnos: pričakovano instanceof ${issue.expected}, prejeto ${received}`;
}
return `Neveljaven vnos: pričakovano ${expected}, prejeto ${received}`;
}
case "invalid_value":
if (issue.values.length === 1)
return `Neveljaven vnos: pričakovano ${util.stringifyPrimitive(issue.values[0])}`;
return `Neveljavna možnost: pričakovano eno izmed ${util.joinValues(issue.values, "|")}`;
case "too_big": {
const adj = issue.inclusive ? "<=" : "<";
const sizing = getSizing(issue.origin);
if (sizing)
return `Preveliko: pričakovano, da bo ${issue.origin ?? "vrednost"} imelo ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elementov"}`;
return `Preveliko: pričakovano, da bo ${issue.origin ?? "vrednost"} ${adj}${issue.maximum.toString()}`;
}
case "too_small": {
const adj = issue.inclusive ? ">=" : ">";
const sizing = getSizing(issue.origin);
if (sizing) {
return `Premajhno: pričakovano, da bo ${issue.origin} imelo ${adj}${issue.minimum.toString()} ${sizing.unit}`;
}
return `Premajhno: pričakovano, da bo ${issue.origin} ${adj}${issue.minimum.toString()}`;
}
case "invalid_format": {
const _issue = issue as errors.$ZodStringFormatIssues;
if (_issue.format === "starts_with") {
return `Neveljaven niz: mora se začeti z "${_issue.prefix}"`;
}
if (_issue.format === "ends_with") return `Neveljaven niz: mora se končati z "${_issue.suffix}"`;
if (_issue.format === "includes") return `Neveljaven niz: mora vsebovati "${_issue.includes}"`;
if (_issue.format === "regex") return `Neveljaven niz: mora ustrezati vzorcu ${_issue.pattern}`;
return `Neveljaven ${FormatDictionary[_issue.format] ?? issue.format}`;
}
case "not_multiple_of":
return `Neveljavno število: mora biti večkratnik ${issue.divisor}`;
case "unrecognized_keys":
return `Neprepoznan${issue.keys.length > 1 ? "i ključi" : " ključ"}: ${util.joinValues(issue.keys, ", ")}`;
case "invalid_key":
return `Neveljaven ključ v ${issue.origin}`;
case "invalid_union":
return "Neveljaven vnos";
case "invalid_element":
return `Neveljavna vrednost v ${issue.origin}`;
default:
return "Neveljaven vnos";
}
};
};
export default function (): { localeError: errors.$ZodErrorMap } {
return {
localeError: error(),
};
}

View File

@@ -0,0 +1,11 @@
import { Parser, Printer } from "../index.js";
export declare const parsers: {
css: Parser;
less: Parser;
scss: Parser;
};
export declare const printers: {
postcss: Printer;
};

View File

@@ -0,0 +1,12 @@
'use strict'
const { test } = require('node:test')
const noop = require('./noop')
test('is a function', t => {
t.assert.strictEqual(typeof noop, 'function')
})
test('does nothing', t => {
t.assert.strictEqual(noop('stuff'), undefined)
})

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Feross Aboukhadijeh
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1 @@
{"version":3,"file":"modular.d.ts","sourceRoot":"","sources":["../src/abstract/modular.ts"],"names":[],"mappings":"AA0BA,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAGhD;AACD;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,4DAA4D;AAC5D,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAOrE;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAoB7D;AAqDD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAgEtE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,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b,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE,6BAA6B;AAChE,IAAI,UAAQ,EACZ,IAAI,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GAC3B,QAAQ,CAAC,OAAO,CAAC,CA6FnB;AAgBD,wBAAgB,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAIrD;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAItD;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,GAAG,UAAU,EACzB,UAAU,EAAE,MAAM,EAClB,IAAI,UAAQ,GACX,MAAM,CAUR;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAI9D;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAG3D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,UAAQ,GAAG,UAAU,CAW5F"}

View File

@@ -0,0 +1,15 @@
import type { TSESTree } from '@typescript-eslint/utils';
import type { InferMessageIdsTypeFromRule, InferOptionsTypeFromRule } from '../util';
declare const baseRule: import("@typescript-eslint/utils/ts-eslint").RuleModule<"unexpectedThis", [({
capIsConstructor?: boolean;
} | undefined)?], unknown, {
ThisExpression(node: TSESTree.ThisExpression): void;
}>;
export type Options = InferOptionsTypeFromRule<typeof baseRule>;
export type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"unexpectedThis", [({
capIsConstructor?: boolean;
} | undefined)?], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
name: string;
};
export default _default;

View File

@@ -0,0 +1,22 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
declare type ParameterDecorator = (target: Object, propertyKey: string | symbol | undefined, parameterIndex: number) => void;

View File

@@ -0,0 +1,30 @@
import * as core from "../core/index.cjs";
import { $ZodError } from "../core/index.cjs";
/** @deprecated Use `z.core.$ZodIssue` from `@zod/core` instead, especially if you are building a library on top of Zod. */
export type ZodIssue = core.$ZodIssue;
/** An Error-like class used to store Zod validation issues. */
export interface ZodError<T = unknown> extends $ZodError<T> {
/** @deprecated Use the `z.treeifyError(err)` function instead. */
format(): core.$ZodFormattedError<T>;
format<U>(mapper: (issue: core.$ZodIssue) => U): core.$ZodFormattedError<T, U>;
/** @deprecated Use the `z.treeifyError(err)` function instead. */
flatten(): core.$ZodFlattenedError<T>;
flatten<U>(mapper: (issue: core.$ZodIssue) => U): core.$ZodFlattenedError<T, U>;
/** @deprecated Push directly to `.issues` instead. */
addIssue(issue: core.$ZodIssue): void;
/** @deprecated Push directly to `.issues` instead. */
addIssues(issues: core.$ZodIssue[]): void;
/** @deprecated Check `err.issues.length === 0` instead. */
isEmpty: boolean;
}
export declare const ZodError: core.$constructor<ZodError>;
export declare const ZodRealError: core.$constructor<ZodError>;
export type {
/** @deprecated Use `z.core.$ZodFlattenedError` instead. */
$ZodFlattenedError as ZodFlattenedError,
/** @deprecated Use `z.core.$ZodFormattedError` instead. */
$ZodFormattedError as ZodFormattedError,
/** @deprecated Use `z.core.$ZodErrorMap` instead. */
$ZodErrorMap as ZodErrorMap, } from "../core/index.cjs";
/** @deprecated Use `z.core.$ZodRawIssue` instead. */
export type IssueData = core.$ZodRawIssue;

View File

@@ -0,0 +1,107 @@
'use strict'
const test = require('node:test')
const os = require('node:os')
const diagChan = require('node:diagnostics_channel')
const { AsyncLocalStorage } = require('node:async_hooks')
const { Writable } = require('node:stream')
const tspl = require('@matteo.collina/tspl')
const pino = require('../pino')
const hostname = os.hostname()
const { pid } = process
const AS_JSON_START = 'tracing:pino_asJson:start'
const AS_JSON_END = 'tracing:pino_asJson:end'
// Skip tests if diagnostics_channel.tracingChannel is not available (Node < 18.19)
const skip = typeof diagChan.tracingChannel !== 'function'
test.beforeEach(ctx => {
ctx.pino = {
ts: 1757512800000, // 2025-09-10T10:00:00.000-05:00
now: Date.now
}
Date.now = () => ctx.pino.ts
ctx.pino.dest = new Writable({
objectMode: true,
write (data, enc, cb) {
cb()
}
})
})
test.afterEach(ctx => {
Date.now = ctx.pino.now
})
test('asJson emits events', { skip }, async (t) => {
const plan = tspl(t, { plan: 8 })
const { dest } = t.pino
const logger = pino({}, dest)
const expectedArguments = [
{},
'testing',
30,
`,"time":${t.pino.ts}`
]
let startEvent
diagChan.subscribe(AS_JSON_START, startHandler)
diagChan.subscribe(AS_JSON_END, endHandler)
logger.info('testing')
await plan
diagChan.unsubscribe(AS_JSON_START, startHandler)
diagChan.unsubscribe(AS_JSON_END, endHandler)
function startHandler (event) {
startEvent = event
plan.equal(Object.prototype.toString.call(event.instance), '[object Pino]')
plan.equal(event.instance === logger, true)
plan.deepStrictEqual(Array.from(event.arguments ?? []), expectedArguments)
}
function endHandler (event) {
plan.equal(Object.prototype.toString.call(event.instance), '[object Pino]')
plan.equal(event.instance === logger, true)
plan.deepStrictEqual(Array.from(event.arguments ?? []), expectedArguments)
plan.equal(
event.result,
`{"level":30,"time":${t.pino.ts},"pid":${pid},"hostname":"${hostname}","msg":"testing"}\n`
)
plan.equal(event.arguments === startEvent.arguments, true, 'same event object is supplied to both events')
}
})
test('asJson context is not lost', { skip }, async (t) => {
const plan = tspl(t, { plan: 2 })
const { dest } = t.pino
const logger = pino({}, dest)
const asyncLocalStorage = new AsyncLocalStorage()
const localStore = { foo: 'bar' }
diagChan.subscribe(AS_JSON_START, startHandler)
diagChan.subscribe(AS_JSON_END, endHandler)
asyncLocalStorage.run(localStore, () => {
logger.info('testing')
})
await plan
diagChan.unsubscribe(AS_JSON_START, startHandler)
diagChan.unsubscribe(AS_JSON_END, endHandler)
function startHandler () {
const store = asyncLocalStorage.getStore()
plan.equal(store === localStore, true)
}
function endHandler () {
const store = asyncLocalStorage.getStore()
plan.equal(store === localStore, true)
}
})

View File

@@ -0,0 +1,47 @@
{
"name": "tslib",
"author": "Microsoft Corp.",
"homepage": "https://www.typescriptlang.org/",
"version": "2.8.1",
"license": "0BSD",
"description": "Runtime library for TypeScript helper functions",
"keywords": [
"TypeScript",
"Microsoft",
"compiler",
"language",
"javascript",
"tslib",
"runtime"
],
"bugs": {
"url": "https://github.com/Microsoft/TypeScript/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/tslib.git"
},
"main": "tslib.js",
"module": "tslib.es6.js",
"jsnext:main": "tslib.es6.js",
"typings": "tslib.d.ts",
"sideEffects": false,
"exports": {
".": {
"module": {
"types": "./modules/index.d.ts",
"default": "./tslib.es6.mjs"
},
"import": {
"node": "./modules/index.js",
"default": {
"types": "./modules/index.d.ts",
"default": "./tslib.es6.mjs"
}
},
"default": "./tslib.js"
},
"./*": "./*",
"./": "./"
}
}

View File

@@ -0,0 +1 @@
export { _ as default } from "../esm/_check_private_redeclaration.js";

View File

@@ -0,0 +1,7 @@
import { _ as _check_private_redeclaration } from "./_check_private_redeclaration.js";
function _class_private_field_init(obj, privateMap, value) {
_check_private_redeclaration(obj, privateMap);
privateMap.set(obj, value);
}
export { _class_private_field_init as _ };

View File

@@ -0,0 +1,53 @@
"use strict";
var _overload_yield = require("./_overload_yield.cjs");
function _async_generator_delegate(inner) {
var iter = {}, waiting = false;
function pump(key, value) {
waiting = true;
value = new Promise(function(resolve) {
resolve(inner[key](value));
});
return { done: false, value: new _overload_yield._(value, /* kind: delegate */ 1) };
}
iter[(typeof Symbol !== "undefined" && Symbol.iterator) || "@@iterator"] = function() {
return this;
};
iter.next = function(value) {
if (waiting) {
waiting = false;
return value;
}
return pump("next", value);
};
if (typeof inner.throw === "function") {
iter.throw = function(value) {
if (waiting) {
waiting = false;
throw value;
}
return pump("throw", value);
};
}
if (typeof inner.return === "function") {
iter.return = function(value) {
if (waiting) {
waiting = false;
return value;
}
return pump("return", value);
};
}
return iter;
}
exports._ = _async_generator_delegate;

View File

@@ -0,0 +1,22 @@
import * as core from "../core/index.js";
import * as schemas from "./schemas.js";
export interface ZodMiniISODateTime extends schemas.ZodMiniStringFormat<"datetime"> {
_zod: core.$ZodISODateTimeInternals;
}
export declare const ZodMiniISODateTime: core.$constructor<ZodMiniISODateTime>;
export declare function datetime(params?: string | core.$ZodISODateTimeParams): ZodMiniISODateTime;
export interface ZodMiniISODate extends schemas.ZodMiniStringFormat<"date"> {
_zod: core.$ZodISODateInternals;
}
export declare const ZodMiniISODate: core.$constructor<ZodMiniISODate>;
export declare function date(params?: string | core.$ZodISODateParams): ZodMiniISODate;
export interface ZodMiniISOTime extends schemas.ZodMiniStringFormat<"time"> {
_zod: core.$ZodISOTimeInternals;
}
export declare const ZodMiniISOTime: core.$constructor<ZodMiniISOTime>;
export declare function time(params?: string | core.$ZodISOTimeParams): ZodMiniISOTime;
export interface ZodMiniISODuration extends schemas.ZodMiniStringFormat<"duration"> {
_zod: core.$ZodISODurationInternals;
}
export declare const ZodMiniISODuration: core.$constructor<ZodMiniISODuration>;
export declare function duration(params?: string | core.$ZodISODurationParams): ZodMiniISODuration;

View File

@@ -0,0 +1,246 @@
"use strict";
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReadableStreamMessageReader = exports.AbstractMessageReader = exports.MessageReader = void 0;
const ral_1 = __importDefault(require("./ral"));
const Is = __importStar(require("./is"));
const events_1 = require("./events");
const semaphore_1 = require("./semaphore");
var MessageReader;
(function (MessageReader) {
function is(value) {
const candidate = value;
return candidate && Is.func(candidate.listen) && Is.func(candidate.dispose) &&
Is.func(candidate.onError) && Is.func(candidate.onClose) && Is.func(candidate.onPartialMessage);
}
MessageReader.is = is;
})(MessageReader || (exports.MessageReader = MessageReader = {}));
class AbstractMessageReader {
errorEmitter;
closeEmitter;
partialMessageEmitter;
constructor() {
this.errorEmitter = new events_1.Emitter();
this.closeEmitter = new events_1.Emitter();
this.partialMessageEmitter = new events_1.Emitter();
}
dispose() {
this.errorEmitter.dispose();
this.closeEmitter.dispose();
this.partialMessageEmitter.dispose();
}
get onError() {
return this.errorEmitter.event;
}
fireError(error) {
this.errorEmitter.fire(this.asError(error));
}
get onClose() {
return this.closeEmitter.event;
}
fireClose() {
this.closeEmitter.fire(undefined);
}
get onPartialMessage() {
return this.partialMessageEmitter.event;
}
firePartialMessage(info) {
this.partialMessageEmitter.fire(info);
}
asError(error) {
if (error instanceof Error) {
return error;
}
else {
return new Error(`Reader received error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);
}
}
}
exports.AbstractMessageReader = AbstractMessageReader;
var ResolvedMessageReaderOptions;
(function (ResolvedMessageReaderOptions) {
function fromOptions(options) {
let charset;
let result;
let contentDecoder;
const contentDecoders = new Map();
let contentTypeDecoder;
const contentTypeDecoders = new Map();
if (options === undefined || typeof options === 'string') {
charset = options ?? 'utf-8';
}
else {
charset = options.charset ?? 'utf-8';
if (options.contentDecoder !== undefined) {
contentDecoder = options.contentDecoder;
contentDecoders.set(contentDecoder.name, contentDecoder);
}
if (options.contentDecoders !== undefined) {
for (const decoder of options.contentDecoders) {
contentDecoders.set(decoder.name, decoder);
}
}
if (options.contentTypeDecoder !== undefined) {
contentTypeDecoder = options.contentTypeDecoder;
contentTypeDecoders.set(contentTypeDecoder.name, contentTypeDecoder);
}
if (options.contentTypeDecoders !== undefined) {
for (const decoder of options.contentTypeDecoders) {
contentTypeDecoders.set(decoder.name, decoder);
}
}
}
if (contentTypeDecoder === undefined) {
contentTypeDecoder = (0, ral_1.default)().applicationJson.decoder;
contentTypeDecoders.set(contentTypeDecoder.name, contentTypeDecoder);
}
return { charset, contentDecoder, contentDecoders, contentTypeDecoder, contentTypeDecoders };
}
ResolvedMessageReaderOptions.fromOptions = fromOptions;
})(ResolvedMessageReaderOptions || (ResolvedMessageReaderOptions = {}));
class ReadableStreamMessageReader extends AbstractMessageReader {
readable;
options;
callback;
nextMessageLength;
messageToken;
buffer;
partialMessageTimer;
_partialMessageTimeout;
readSemaphore;
constructor(readable, options) {
super();
this.readable = readable;
this.options = ResolvedMessageReaderOptions.fromOptions(options);
this.buffer = (0, ral_1.default)().messageBuffer.create(this.options.charset);
this._partialMessageTimeout = 10000;
this.nextMessageLength = -1;
this.messageToken = 0;
this.readSemaphore = new semaphore_1.Semaphore(1);
}
set partialMessageTimeout(timeout) {
this._partialMessageTimeout = timeout;
}
get partialMessageTimeout() {
return this._partialMessageTimeout;
}
listen(callback) {
this.nextMessageLength = -1;
this.messageToken = 0;
this.partialMessageTimer = undefined;
this.callback = callback;
const result = this.readable.onData((data) => {
this.onData(data);
});
this.readable.onError((error) => this.fireError(error));
this.readable.onClose(() => this.fireClose());
return result;
}
onData(data) {
try {
this.buffer.append(data);
while (true) {
if (this.nextMessageLength === -1) {
const headers = this.buffer.tryReadHeaders(true);
if (!headers) {
return;
}
const contentLength = headers.get('content-length');
if (!contentLength) {
this.fireError(new Error(`Header must provide a Content-Length property.\n${JSON.stringify(Object.fromEntries(headers))}`));
return;
}
const length = parseInt(contentLength);
if (isNaN(length)) {
this.fireError(new Error(`Content-Length value must be a number. Got ${contentLength}`));
return;
}
this.nextMessageLength = length;
}
const body = this.buffer.tryReadBody(this.nextMessageLength);
if (body === undefined) {
/** We haven't received the full message yet. */
this.setPartialMessageTimer();
return;
}
this.clearPartialMessageTimer();
this.nextMessageLength = -1;
// Make sure that we convert one received message after the
// other. Otherwise it could happen that a decoding of a second
// smaller message finished before the decoding of a first larger
// message and then we would deliver the second message first.
this.readSemaphore.lock(async () => {
const bytes = this.options.contentDecoder !== undefined
? await this.options.contentDecoder.decode(body)
: body;
const message = await this.options.contentTypeDecoder.decode(bytes, this.options);
this.callback(message);
}).catch((error) => {
this.fireError(error);
});
}
}
catch (error) {
this.fireError(error);
}
}
clearPartialMessageTimer() {
if (this.partialMessageTimer) {
this.partialMessageTimer.dispose();
this.partialMessageTimer = undefined;
}
}
setPartialMessageTimer() {
this.clearPartialMessageTimer();
if (this._partialMessageTimeout <= 0) {
return;
}
this.partialMessageTimer = (0, ral_1.default)().timer.setTimeout((token, timeout) => {
this.partialMessageTimer = undefined;
if (token === this.messageToken) {
this.firePartialMessage({ messageToken: token, waitingTime: timeout });
this.setPartialMessageTimer();
}
}, this._partialMessageTimeout, this.messageToken, this._partialMessageTimeout);
}
}
exports.ReadableStreamMessageReader = ReadableStreamMessageReader;

View File

@@ -0,0 +1,7 @@
export declare function boolean(value: any): value is boolean;
export declare function string(value: any): value is string;
export declare function number(value: any): value is number;
export declare function error(value: any): value is Error;
export declare function func(value: any): value is Function;
export declare function array<T>(value: any): value is T[];
export declare function stringArray(value: any): value is string[];

View File

@@ -0,0 +1,5 @@
import { ESLintUtils } from '@typescript-eslint/utils';
import type { ESLintPluginDocs } from '../../rules';
export declare const createRule: <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, ESLintPluginDocs>>) => ESLintUtils.RuleModule<MessageIds, Options, ESLintPluginDocs, ESLintUtils.RuleListener> & {
name: string;
};

View File

@@ -0,0 +1,256 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const ts = __importStar(require("typescript"));
const util_1 = require("../util");
const getWrappedCode_1 = require("../util/getWrappedCode");
exports.default = (0, util_1.createRule)({
name: 'consistent-type-assertions',
meta: {
type: 'suggestion',
docs: {
description: 'Enforce consistent usage of type assertions',
recommended: 'stylistic',
},
fixable: 'code',
hasSuggestions: true,
messages: {
'angle-bracket': "Use '<{{cast}}>' instead of 'as {{cast}}'.",
as: "Use 'as {{cast}}' instead of '<{{cast}}>'.",
never: 'Do not use any type assertions.',
replaceArrayTypeAssertionWithAnnotation: 'Use const x: {{cast}} = [ ... ] instead.',
replaceArrayTypeAssertionWithSatisfies: 'Use const x = [ ... ] satisfies {{cast}} instead.',
replaceObjectTypeAssertionWithAnnotation: 'Use const x: {{cast}} = { ... } instead.',
replaceObjectTypeAssertionWithSatisfies: 'Use const x = { ... } satisfies {{cast}} instead.',
unexpectedArrayTypeAssertion: 'Always prefer const x: T[] = [ ... ].',
unexpectedObjectTypeAssertion: 'Always prefer const x: T = { ... }.',
},
schema: [
{
oneOf: [
{
type: 'object',
additionalProperties: false,
properties: {
assertionStyle: {
type: 'string',
description: 'The expected assertion style to enforce.',
enum: ['never'],
},
},
required: ['assertionStyle'],
},
{
type: 'object',
additionalProperties: false,
properties: {
arrayLiteralTypeAssertions: {
type: 'string',
description: 'Whether to always prefer type declarations for array literals used as variable initializers, rather than type assertions.',
enum: ['allow', 'allow-as-parameter', 'never'],
},
assertionStyle: {
type: 'string',
description: 'The expected assertion style to enforce.',
enum: ['as', 'angle-bracket'],
},
objectLiteralTypeAssertions: {
type: 'string',
description: 'Whether to always prefer type declarations for object literals used as variable initializers, rather than type assertions.',
enum: ['allow', 'allow-as-parameter', 'never'],
},
},
},
],
},
],
},
defaultOptions: [
{
arrayLiteralTypeAssertions: 'allow',
assertionStyle: 'as',
objectLiteralTypeAssertions: 'allow',
},
],
create(context, [options]) {
function isConst(node) {
if (node.type !== utils_1.AST_NODE_TYPES.TSTypeReference) {
return false;
}
return (node.typeName.type === utils_1.AST_NODE_TYPES.Identifier &&
node.typeName.name === 'const');
}
function reportIncorrectAssertionType(node) {
const messageId = options.assertionStyle;
// If this node is `as const`, then don't report an error.
if (isConst(node.typeAnnotation) && messageId === 'never') {
return;
}
context.report({
node,
messageId,
data: messageId !== 'never'
? { cast: context.sourceCode.getText(node.typeAnnotation) }
: {},
fix: messageId === 'as'
? (fixer) => {
// lazily access parserServices to avoid crashing on non TS files (#9860)
const tsNode = (0, util_1.getParserServices)(context, true).esTreeNodeToTSNodeMap.get(node);
const expressionCode = context.sourceCode.getText(node.expression);
const typeAnnotationCode = context.sourceCode.getText(node.typeAnnotation);
const asPrecedence = (0, util_1.getOperatorPrecedence)(ts.SyntaxKind.AsExpression, ts.SyntaxKind.Unknown);
const parentPrecedence = (0, util_1.getOperatorPrecedence)(tsNode.parent.kind, ts.isBinaryExpression(tsNode.parent)
? tsNode.parent.operatorToken.kind
: ts.SyntaxKind.Unknown, ts.isNewExpression(tsNode.parent)
? tsNode.parent.arguments != null &&
tsNode.parent.arguments.length > 0
: undefined);
const expressionPrecedence = (0, util_1.getOperatorPrecedenceForNode)(node.expression);
const expressionCodeWrapped = (0, getWrappedCode_1.getWrappedCode)(expressionCode, expressionPrecedence, asPrecedence);
const text = `${expressionCodeWrapped} as ${typeAnnotationCode}`;
return fixer.replaceText(node, (0, util_1.isParenthesized)(node, context.sourceCode)
? text
: (0, getWrappedCode_1.getWrappedCode)(text, asPrecedence, parentPrecedence));
}
: undefined,
});
}
function checkType(node) {
switch (node.type) {
case utils_1.AST_NODE_TYPES.TSAnyKeyword:
case utils_1.AST_NODE_TYPES.TSUnknownKeyword:
return false;
case utils_1.AST_NODE_TYPES.TSTypeReference:
return (
// Ignore `as const` and `<const>`
!isConst(node) ||
// Allow qualified names which have dots between identifiers, `Foo.Bar`
node.typeName.type === utils_1.AST_NODE_TYPES.TSQualifiedName);
default:
return true;
}
}
function getSuggestions(node, annotationMessageId, satisfiesMessageId) {
const suggestions = [];
if (node.parent.type === utils_1.AST_NODE_TYPES.VariableDeclarator &&
!node.parent.id.typeAnnotation) {
const { parent } = node;
suggestions.push({
messageId: annotationMessageId,
data: { cast: context.sourceCode.getText(node.typeAnnotation) },
fix: fixer => [
fixer.insertTextAfter(parent.id, `: ${context.sourceCode.getText(node.typeAnnotation)}`),
fixer.replaceText(node, (0, util_1.getTextWithParentheses)(context.sourceCode, node.expression)),
],
});
}
suggestions.push({
messageId: satisfiesMessageId,
data: { cast: context.sourceCode.getText(node.typeAnnotation) },
fix: fixer => [
fixer.replaceText(node, (0, util_1.getTextWithParentheses)(context.sourceCode, node.expression)),
fixer.insertTextAfter(node, ` satisfies ${context.sourceCode.getText(node.typeAnnotation)}`),
],
});
return suggestions;
}
function isAsParameter(node) {
return (node.parent.type === utils_1.AST_NODE_TYPES.NewExpression ||
node.parent.type === utils_1.AST_NODE_TYPES.CallExpression ||
node.parent.type === utils_1.AST_NODE_TYPES.ThrowStatement ||
node.parent.type === utils_1.AST_NODE_TYPES.AssignmentPattern ||
node.parent.type === utils_1.AST_NODE_TYPES.JSXExpressionContainer ||
(node.parent.type === utils_1.AST_NODE_TYPES.TemplateLiteral &&
node.parent.parent.type === utils_1.AST_NODE_TYPES.TaggedTemplateExpression));
}
function checkExpressionForObjectAssertion(node) {
if (options.assertionStyle === 'never' ||
options.objectLiteralTypeAssertions === 'allow' ||
node.expression.type !== utils_1.AST_NODE_TYPES.ObjectExpression) {
return;
}
if (options.objectLiteralTypeAssertions === 'allow-as-parameter' &&
isAsParameter(node)) {
return;
}
if (checkType(node.typeAnnotation)) {
const suggest = getSuggestions(node, 'replaceObjectTypeAssertionWithAnnotation', 'replaceObjectTypeAssertionWithSatisfies');
context.report({
node,
messageId: 'unexpectedObjectTypeAssertion',
suggest,
});
}
}
function checkExpressionForArrayAssertion(node) {
if (options.assertionStyle === 'never' ||
options.arrayLiteralTypeAssertions === 'allow' ||
node.expression.type !== utils_1.AST_NODE_TYPES.ArrayExpression) {
return;
}
if (options.arrayLiteralTypeAssertions === 'allow-as-parameter' &&
isAsParameter(node)) {
return;
}
if (checkType(node.typeAnnotation)) {
const suggest = getSuggestions(node, 'replaceArrayTypeAssertionWithAnnotation', 'replaceArrayTypeAssertionWithSatisfies');
context.report({
node,
messageId: 'unexpectedArrayTypeAssertion',
suggest,
});
}
}
return {
TSAsExpression(node) {
if (options.assertionStyle !== 'as') {
reportIncorrectAssertionType(node);
return;
}
checkExpressionForObjectAssertion(node);
checkExpressionForArrayAssertion(node);
},
TSTypeAssertion(node) {
if (options.assertionStyle !== 'angle-bracket') {
reportIncorrectAssertionType(node);
return;
}
checkExpressionForObjectAssertion(node);
checkExpressionForArrayAssertion(node);
},
};
},
});

View File

@@ -0,0 +1,62 @@
'use strict';
/**
* Checks if a given buffer contains only correct UTF-8.
* Ported from https://www.cl.cam.ac.uk/%7Emgk25/ucs/utf8_check.c by
* Markus Kuhn.
*
* @param {Buffer} buf The buffer to check
* @return {Boolean} `true` if `buf` contains only correct UTF-8, else `false`
* @public
*/
function isValidUTF8(buf) {
const len = buf.length;
let i = 0;
while (i < len) {
if ((buf[i] & 0x80) === 0x00) { // 0xxxxxxx
i++;
} else if ((buf[i] & 0xe0) === 0xc0) { // 110xxxxx 10xxxxxx
if (
i + 1 === len ||
(buf[i + 1] & 0xc0) !== 0x80 ||
(buf[i] & 0xfe) === 0xc0 // overlong
) {
return false;
}
i += 2;
} else if ((buf[i] & 0xf0) === 0xe0) { // 1110xxxx 10xxxxxx 10xxxxxx
if (
i + 2 >= len ||
(buf[i + 1] & 0xc0) !== 0x80 ||
(buf[i + 2] & 0xc0) !== 0x80 ||
buf[i] === 0xe0 && (buf[i + 1] & 0xe0) === 0x80 || // overlong
buf[i] === 0xed && (buf[i + 1] & 0xe0) === 0xa0 // surrogate (U+D800 - U+DFFF)
) {
return false;
}
i += 3;
} else if ((buf[i] & 0xf8) === 0xf0) { // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
if (
i + 3 >= len ||
(buf[i + 1] & 0xc0) !== 0x80 ||
(buf[i + 2] & 0xc0) !== 0x80 ||
(buf[i + 3] & 0xc0) !== 0x80 ||
buf[i] === 0xf0 && (buf[i + 1] & 0xf0) === 0x80 || // overlong
buf[i] === 0xf4 && buf[i + 1] > 0x8f || buf[i] > 0xf4 // > U+10FFFF
) {
return false;
}
i += 4;
} else {
return false;
}
}
return true;
}
module.exports = isValidUTF8;

View File

@@ -0,0 +1,3 @@
module.exports = {
completelyUnrelatedProperty: 'Just a very incorrect transport worker implementation'
}

View File

@@ -0,0 +1,207 @@
{
"name": "prettier",
"version": "3.9.6",
"description": "Prettier is an opinionated code formatter",
"bin": "./bin/prettier.cjs",
"repository": "prettier/prettier",
"funding": "https://github.com/prettier/prettier?sponsor=1",
"homepage": "https://prettier.io",
"author": "James Long",
"license": "MIT",
"main": "./index.cjs",
"browser": "./standalone.js",
"unpkg": "./standalone.js",
"exports": {
".": {
"types": "./index.d.ts",
"require": "./index.cjs",
"browser": {
"import": "./standalone.mjs",
"default": "./standalone.js"
},
"default": "./index.mjs"
},
"./*": "./*",
"./standalone": {
"types": "./standalone.d.ts",
"require": "./standalone.js",
"default": "./standalone.mjs"
},
"./doc": {
"types": "./doc.d.ts",
"require": "./doc.js",
"default": "./doc.mjs"
},
"./plugins/estree": {
"types": "./plugins/estree.d.ts",
"require": "./plugins/estree.js",
"default": "./plugins/estree.mjs"
},
"./plugins/babel": {
"types": "./plugins/babel.d.ts",
"require": "./plugins/babel.js",
"default": "./plugins/babel.mjs"
},
"./plugins/flow": {
"types": "./plugins/flow.d.ts",
"require": "./plugins/flow.js",
"default": "./plugins/flow.mjs"
},
"./plugins/typescript": {
"types": "./plugins/typescript.d.ts",
"require": "./plugins/typescript.js",
"default": "./plugins/typescript.mjs"
},
"./plugins/acorn": {
"types": "./plugins/acorn.d.ts",
"require": "./plugins/acorn.js",
"default": "./plugins/acorn.mjs"
},
"./plugins/meriyah": {
"types": "./plugins/meriyah.d.ts",
"require": "./plugins/meriyah.js",
"default": "./plugins/meriyah.mjs"
},
"./plugins/angular": {
"types": "./plugins/angular.d.ts",
"require": "./plugins/angular.js",
"default": "./plugins/angular.mjs"
},
"./plugins/postcss": {
"types": "./plugins/postcss.d.ts",
"require": "./plugins/postcss.js",
"default": "./plugins/postcss.mjs"
},
"./plugins/graphql": {
"types": "./plugins/graphql.d.ts",
"require": "./plugins/graphql.js",
"default": "./plugins/graphql.mjs"
},
"./plugins/markdown": {
"types": "./plugins/markdown.d.ts",
"require": "./plugins/markdown.js",
"default": "./plugins/markdown.mjs"
},
"./plugins/glimmer": {
"types": "./plugins/glimmer.d.ts",
"require": "./plugins/glimmer.js",
"default": "./plugins/glimmer.mjs"
},
"./plugins/html": {
"types": "./plugins/html.d.ts",
"require": "./plugins/html.js",
"default": "./plugins/html.mjs"
},
"./plugins/yaml": {
"types": "./plugins/yaml.d.ts",
"require": "./plugins/yaml.js",
"default": "./plugins/yaml.mjs"
},
"./esm/standalone.mjs": "./standalone.mjs",
"./parser-babel": "./plugins/babel.js",
"./parser-babel.js": "./plugins/babel.js",
"./esm/parser-babel.mjs": "./plugins/babel.mjs",
"./parser-flow": "./plugins/flow.js",
"./parser-flow.js": "./plugins/flow.js",
"./esm/parser-flow.mjs": "./plugins/flow.mjs",
"./parser-typescript": "./plugins/typescript.js",
"./parser-typescript.js": "./plugins/typescript.js",
"./esm/parser-typescript.mjs": "./plugins/typescript.mjs",
"./parser-espree": "./plugins/acorn.js",
"./parser-espree.js": "./plugins/acorn.js",
"./esm/parser-espree.mjs": "./plugins/acorn.mjs",
"./parser-meriyah": "./plugins/meriyah.js",
"./parser-meriyah.js": "./plugins/meriyah.js",
"./esm/parser-meriyah.mjs": "./plugins/meriyah.mjs",
"./parser-angular": "./plugins/angular.js",
"./parser-angular.js": "./plugins/angular.js",
"./esm/parser-angular.mjs": "./plugins/angular.mjs",
"./parser-postcss": "./plugins/postcss.js",
"./parser-postcss.js": "./plugins/postcss.js",
"./esm/parser-postcss.mjs": "./plugins/postcss.mjs",
"./parser-graphql": "./plugins/graphql.js",
"./parser-graphql.js": "./plugins/graphql.js",
"./esm/parser-graphql.mjs": "./plugins/graphql.mjs",
"./parser-markdown": "./plugins/markdown.js",
"./parser-markdown.js": "./plugins/markdown.js",
"./esm/parser-markdown.mjs": "./plugins/markdown.mjs",
"./parser-glimmer": "./plugins/glimmer.js",
"./parser-glimmer.js": "./plugins/glimmer.js",
"./esm/parser-glimmer.mjs": "./plugins/glimmer.mjs",
"./parser-html": "./plugins/html.js",
"./parser-html.js": "./plugins/html.js",
"./esm/parser-html.mjs": "./plugins/html.mjs",
"./parser-yaml": "./plugins/yaml.js",
"./parser-yaml.js": "./plugins/yaml.js",
"./esm/parser-yaml.mjs": "./plugins/yaml.mjs"
},
"engines": {
"node": ">=14"
},
"files": [
"LICENSE",
"README.md",
"THIRD-PARTY-NOTICES.md",
"bin/prettier.cjs",
"doc.d.ts",
"doc.js",
"doc.mjs",
"index.cjs",
"index.d.ts",
"index.d.ts",
"index.mjs",
"internal/experimental-cli-worker.mjs",
"internal/experimental-cli.mjs",
"internal/legacy-cli.mjs",
"package.json",
"plugins/acorn.d.ts",
"plugins/acorn.js",
"plugins/acorn.mjs",
"plugins/angular.d.ts",
"plugins/angular.js",
"plugins/angular.mjs",
"plugins/babel.d.ts",
"plugins/babel.js",
"plugins/babel.mjs",
"plugins/estree.d.ts",
"plugins/estree.js",
"plugins/estree.mjs",
"plugins/flow.d.ts",
"plugins/flow.js",
"plugins/flow.mjs",
"plugins/glimmer.d.ts",
"plugins/glimmer.js",
"plugins/glimmer.mjs",
"plugins/graphql.d.ts",
"plugins/graphql.js",
"plugins/graphql.mjs",
"plugins/html.d.ts",
"plugins/html.js",
"plugins/html.mjs",
"plugins/markdown.d.ts",
"plugins/markdown.js",
"plugins/markdown.mjs",
"plugins/meriyah.d.ts",
"plugins/meriyah.js",
"plugins/meriyah.mjs",
"plugins/postcss.d.ts",
"plugins/postcss.js",
"plugins/postcss.mjs",
"plugins/typescript.d.ts",
"plugins/typescript.js",
"plugins/typescript.mjs",
"plugins/yaml.d.ts",
"plugins/yaml.js",
"plugins/yaml.mjs",
"standalone.d.ts",
"standalone.js",
"standalone.mjs"
],
"preferUnplugged": true,
"sideEffects": false,
"type": "commonjs",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
}
}

View File

@@ -0,0 +1,49 @@
"use strict";
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// SEE https://typescript-eslint.io/users/configs
//
// For developers working in the typescript-eslint monorepo:
// You can regenerate it using `pnpm run generate-configs`
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const base_1 = __importDefault(require("./base"));
const eslint_recommended_1 = __importDefault(require("./eslint-recommended"));
/**
* Recommended rules for code correctness that you can drop in without additional configuration.
* @see {@link https://typescript-eslint.io/users/configs#recommended}
*/
exports.default = (plugin, parser) => [
(0, base_1.default)(plugin, parser),
(0, eslint_recommended_1.default)(plugin, parser),
{
name: 'typescript-eslint/recommended',
rules: {
'@typescript-eslint/ban-ts-comment': 'error',
'no-array-constructor': 'off',
'@typescript-eslint/no-array-constructor': 'error',
'@typescript-eslint/no-duplicate-enum-values': 'error',
'@typescript-eslint/no-empty-object-type': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-extra-non-null-assertion': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-this-alias': 'error',
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
'@typescript-eslint/no-unsafe-declaration-merging': 'error',
'@typescript-eslint/no-unsafe-function-type': 'error',
'no-unused-expressions': 'off',
'@typescript-eslint/no-unused-expressions': 'error',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-wrapper-object-types': 'error',
'@typescript-eslint/prefer-as-const': 'error',
'@typescript-eslint/prefer-namespace-keyword': 'error',
'@typescript-eslint/triple-slash-reference': 'error',
},
},
];

View File

@@ -0,0 +1,100 @@
/**
* @fileoverview Rule to disallow a negated condition
* @author Alberto Rodríguez
*/
"use strict";
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../types').Rule.RuleModule} */
module.exports = {
meta: {
type: "suggestion",
docs: {
description: "Disallow negated conditions",
recommended: false,
frozen: true,
url: "https://eslint.org/docs/latest/rules/no-negated-condition",
},
schema: [],
messages: {
unexpectedNegated: "Unexpected negated condition.",
},
},
create(context) {
/**
* Determines if a given node is an if-else without a condition on the else
* @param {ASTNode} node The node to check.
* @returns {boolean} True if the node has an else without an if.
* @private
*/
function hasElseWithoutCondition(node) {
return node.alternate && node.alternate.type !== "IfStatement";
}
/**
* Determines if a given node is a negated unary expression
* @param {Object} test The test object to check.
* @returns {boolean} True if the node is a negated unary expression.
* @private
*/
function isNegatedUnaryExpression(test) {
return test.type === "UnaryExpression" && test.operator === "!";
}
/**
* Determines if a given node is a negated binary expression
* @param {Test} test The test to check.
* @returns {boolean} True if the node is a negated binary expression.
* @private
*/
function isNegatedBinaryExpression(test) {
return (
test.type === "BinaryExpression" &&
(test.operator === "!=" || test.operator === "!==")
);
}
/**
* Determines if a given node has a negated if expression
* @param {ASTNode} node The node to check.
* @returns {boolean} True if the node has a negated if expression.
* @private
*/
function isNegatedIf(node) {
return (
isNegatedUnaryExpression(node.test) ||
isNegatedBinaryExpression(node.test)
);
}
return {
IfStatement(node) {
if (!hasElseWithoutCondition(node)) {
return;
}
if (isNegatedIf(node)) {
context.report({
node,
messageId: "unexpectedNegated",
});
}
},
ConditionalExpression(node) {
if (isNegatedIf(node)) {
context.report({
node,
messageId: "unexpectedNegated",
});
}
},
};
},
};

View File

@@ -0,0 +1 @@
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../../src/api/fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAuB9C,+EAA+E;AAC/E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,UAAU,EAAE,YAAY,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,UAAU,CAAU,CAAC;AAa1H,MAAM,UAAU,uBAAuB,CAAC,KAA6B;IACjE,MAAM,IAAI,GAAe;QACrB,IAAI,EAAE,WAAW;QACjB,QAAQ,EAAE,EAAE;KACf,CAAC;IACF,MAAM,OAAO,GAA2B,EAAE,CAAC;IAE3C,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACxC,OAAO,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;QACpC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACxB,CAAC;IAED,OAAO;QACH,eAAe;QACf,UAAU;QACV,oBAAoB;QACpB,QAAQ;QACR,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI;QACtB,SAAS;QACT,UAAU;KACb,CAAC;IAEF,SAAS,eAAe,CAAC,IAAY;QACjC,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,GAAG,EAAE,CAA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