WIP: bootstrap and partial real Solana watcher implementation
This commit is contained in:
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"is.d.ts","sourceRoot":"","sources":["../../src/ast/is.ts"],"names":[],"mappings":"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"}
|
||||
@@ -0,0 +1,166 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.scrypt = scrypt;
|
||||
exports.pbkdf2 = pbkdf2;
|
||||
exports.deriveMainSeed = deriveMainSeed;
|
||||
exports.eskdf = eskdf;
|
||||
/**
|
||||
* Experimental KDF for AES.
|
||||
*/
|
||||
const hkdf_ts_1 = require("./hkdf.js");
|
||||
const pbkdf2_ts_1 = require("./pbkdf2.js");
|
||||
const scrypt_ts_1 = require("./scrypt.js");
|
||||
const sha256_ts_1 = require("./sha256.js");
|
||||
const utils_ts_1 = require("./utils.js");
|
||||
// A tiny KDF for various applications like AES key-gen.
|
||||
// Uses HKDF in a non-standard way, so it's not "KDF-secure", only "PRF-secure".
|
||||
// Which is good enough: assume sha2-256 retained preimage resistance.
|
||||
const SCRYPT_FACTOR = 2 ** 19;
|
||||
const PBKDF2_FACTOR = 2 ** 17;
|
||||
// Scrypt KDF
|
||||
function scrypt(password, salt) {
|
||||
return (0, scrypt_ts_1.scrypt)(password, salt, { N: SCRYPT_FACTOR, r: 8, p: 1, dkLen: 32 });
|
||||
}
|
||||
// PBKDF2-HMAC-SHA256
|
||||
function pbkdf2(password, salt) {
|
||||
return (0, pbkdf2_ts_1.pbkdf2)(sha256_ts_1.sha256, password, salt, { c: PBKDF2_FACTOR, dkLen: 32 });
|
||||
}
|
||||
// Combines two 32-byte byte arrays
|
||||
function xor32(a, b) {
|
||||
(0, utils_ts_1.abytes)(a, 32);
|
||||
(0, utils_ts_1.abytes)(b, 32);
|
||||
const arr = new Uint8Array(32);
|
||||
for (let i = 0; i < 32; i++) {
|
||||
arr[i] = a[i] ^ b[i];
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
function strHasLength(str, min, max) {
|
||||
return typeof str === 'string' && str.length >= min && str.length <= max;
|
||||
}
|
||||
/**
|
||||
* Derives main seed. Takes a lot of time. Prefer `eskdf` method instead.
|
||||
*/
|
||||
function deriveMainSeed(username, password) {
|
||||
if (!strHasLength(username, 8, 255))
|
||||
throw new Error('invalid username');
|
||||
if (!strHasLength(password, 8, 255))
|
||||
throw new Error('invalid password');
|
||||
// Declared like this to throw off minifiers which auto-convert .fromCharCode(1) to actual string.
|
||||
// String with non-ascii may be problematic in some envs
|
||||
const codes = { _1: 1, _2: 2 };
|
||||
const sep = { s: String.fromCharCode(codes._1), p: String.fromCharCode(codes._2) };
|
||||
const scr = scrypt(password + sep.s, username + sep.s);
|
||||
const pbk = pbkdf2(password + sep.p, username + sep.p);
|
||||
const res = xor32(scr, pbk);
|
||||
(0, utils_ts_1.clean)(scr, pbk);
|
||||
return res;
|
||||
}
|
||||
/**
|
||||
* Converts protocol & accountId pair to HKDF salt & info params.
|
||||
*/
|
||||
function getSaltInfo(protocol, accountId = 0) {
|
||||
// Note that length here also repeats two lines below
|
||||
// We do an additional length check here to reduce the scope of DoS attacks
|
||||
if (!(strHasLength(protocol, 3, 15) && /^[a-z0-9]{3,15}$/.test(protocol))) {
|
||||
throw new Error('invalid protocol');
|
||||
}
|
||||
// Allow string account ids for some protocols
|
||||
const allowsStr = /^password\d{0,3}|ssh|tor|file$/.test(protocol);
|
||||
let salt; // Extract salt. Default is undefined.
|
||||
if (typeof accountId === 'string') {
|
||||
if (!allowsStr)
|
||||
throw new Error('accountId must be a number');
|
||||
if (!strHasLength(accountId, 1, 255))
|
||||
throw new Error('accountId must be string of length 1..255');
|
||||
salt = (0, utils_ts_1.kdfInputToBytes)(accountId);
|
||||
}
|
||||
else if (Number.isSafeInteger(accountId)) {
|
||||
if (accountId < 0 || accountId > Math.pow(2, 32) - 1)
|
||||
throw new Error('invalid accountId');
|
||||
// Convert to Big Endian Uint32
|
||||
salt = new Uint8Array(4);
|
||||
(0, utils_ts_1.createView)(salt).setUint32(0, accountId, false);
|
||||
}
|
||||
else {
|
||||
throw new Error('accountId must be a number' + (allowsStr ? ' or string' : ''));
|
||||
}
|
||||
const info = (0, utils_ts_1.kdfInputToBytes)(protocol);
|
||||
return { salt, info };
|
||||
}
|
||||
function countBytes(num) {
|
||||
if (typeof num !== 'bigint' || num <= BigInt(128))
|
||||
throw new Error('invalid number');
|
||||
return Math.ceil(num.toString(2).length / 8);
|
||||
}
|
||||
/**
|
||||
* Parses keyLength and modulus options to extract length of result key.
|
||||
* If modulus is used, adds 64 bits to it as per FIPS 186 B.4.1 to combat modulo bias.
|
||||
*/
|
||||
function getKeyLength(options) {
|
||||
if (!options || typeof options !== 'object')
|
||||
return 32;
|
||||
const hasLen = 'keyLength' in options;
|
||||
const hasMod = 'modulus' in options;
|
||||
if (hasLen && hasMod)
|
||||
throw new Error('cannot combine keyLength and modulus options');
|
||||
if (!hasLen && !hasMod)
|
||||
throw new Error('must have either keyLength or modulus option');
|
||||
// FIPS 186 B.4.1 requires at least 64 more bits
|
||||
const l = hasMod ? countBytes(options.modulus) + 8 : options.keyLength;
|
||||
if (!(typeof l === 'number' && l >= 16 && l <= 8192))
|
||||
throw new Error('invalid keyLength');
|
||||
return l;
|
||||
}
|
||||
/**
|
||||
* Converts key to bigint and divides it by modulus. Big Endian.
|
||||
* Implements FIPS 186 B.4.1, which removes 0 and modulo bias from output.
|
||||
*/
|
||||
function modReduceKey(key, modulus) {
|
||||
const _1 = BigInt(1);
|
||||
const num = BigInt('0x' + (0, utils_ts_1.bytesToHex)(key)); // check for ui8a, then bytesToNumber()
|
||||
const res = (num % (modulus - _1)) + _1; // Remove 0 from output
|
||||
if (res < _1)
|
||||
throw new Error('expected positive number'); // Guard against bad values
|
||||
const len = key.length - 8; // FIPS requires 64 more bits = 8 bytes
|
||||
const hex = res.toString(16).padStart(len * 2, '0'); // numberToHex()
|
||||
const bytes = (0, utils_ts_1.hexToBytes)(hex);
|
||||
if (bytes.length !== len)
|
||||
throw new Error('invalid length of result key');
|
||||
return bytes;
|
||||
}
|
||||
/**
|
||||
* ESKDF
|
||||
* @param username - username, email, or identifier, min: 8 characters, should have enough entropy
|
||||
* @param password - password, min: 8 characters, should have enough entropy
|
||||
* @example
|
||||
* const kdf = await eskdf('example-university', 'beginning-new-example');
|
||||
* const key = kdf.deriveChildKey('aes', 0);
|
||||
* console.log(kdf.fingerprint);
|
||||
* kdf.expire();
|
||||
*/
|
||||
async function eskdf(username, password) {
|
||||
// We are using closure + object instead of class because
|
||||
// we want to make `seed` non-accessible for any external function.
|
||||
let seed = deriveMainSeed(username, password);
|
||||
function deriveCK(protocol, accountId = 0, options) {
|
||||
(0, utils_ts_1.abytes)(seed, 32);
|
||||
const { salt, info } = getSaltInfo(protocol, accountId); // validate protocol & accountId
|
||||
const keyLength = getKeyLength(options); // validate options
|
||||
const key = (0, hkdf_ts_1.hkdf)(sha256_ts_1.sha256, seed, salt, info, keyLength);
|
||||
// Modulus has already been validated
|
||||
return options && 'modulus' in options ? modReduceKey(key, options.modulus) : key;
|
||||
}
|
||||
function expire() {
|
||||
if (seed)
|
||||
seed.fill(1);
|
||||
seed = undefined;
|
||||
}
|
||||
// prettier-ignore
|
||||
const fingerprint = Array.from(deriveCK('fingerprint', 0))
|
||||
.slice(0, 6)
|
||||
.map((char) => char.toString(16).padStart(2, '0').toUpperCase())
|
||||
.join(':');
|
||||
return Object.freeze({ deriveChildKey: deriveCK, expire, fingerprint });
|
||||
}
|
||||
//# sourceMappingURL=eskdf.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../../src/ast/ast.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,0CAA0C;AAM1C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAc/C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,cAAc,oBAAoB,CAAC"}
|
||||
@@ -0,0 +1,45 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import * as z from "zod/v4";
|
||||
|
||||
describe("Recursive Tuples Regression #5089", () => {
|
||||
it("creates recursive tuple without crash", () => {
|
||||
expect(() => {
|
||||
const y = z.lazy((): any => z.tuple([y, y]).or(z.string()));
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
it("parses recursive tuple data correctly", () => {
|
||||
const y = z.lazy((): any => z.tuple([y, y]).or(z.string()));
|
||||
|
||||
// Base case
|
||||
expect(y.parse("hello")).toBe("hello");
|
||||
|
||||
// Recursive cases
|
||||
expect(() => y.parse(["a", "b"])).not.toThrow();
|
||||
expect(() => y.parse(["a", ["b", "c"]])).not.toThrow();
|
||||
});
|
||||
|
||||
it("matches #5089 expected behavior", () => {
|
||||
// Exact code from the issue
|
||||
expect(() => {
|
||||
const y = z.lazy((): any => z.tuple([y, y]).or(z.string()));
|
||||
y.parse(["a", ["b", "c"]]);
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
it("handles workaround pattern", () => {
|
||||
// Alternative pattern from issue discussion
|
||||
expect(() => {
|
||||
const y = z.lazy((): any => z.string().or(z.lazy(() => z.tuple([y, y]))));
|
||||
y.parse(["a", ["b", "c"]]);
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
it("recursive arrays still work (comparison)", () => {
|
||||
const y = z.lazy((): any => z.array(y).or(z.string()));
|
||||
|
||||
expect(y.parse("hello")).toBe("hello");
|
||||
expect(y.parse(["hello", "world"])).toEqual(["hello", "world"]);
|
||||
expect(y.parse(["a", ["b", "c"]])).toEqual(["a", ["b", "c"]]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,13 @@
|
||||
import type { ZodErrorMap } from "./ZodError.js";
|
||||
import defaultErrorMap from "./locales/en.js";
|
||||
|
||||
let overrideErrorMap = defaultErrorMap;
|
||||
export { defaultErrorMap };
|
||||
|
||||
export function setErrorMap(map: ZodErrorMap) {
|
||||
overrideErrorMap = map;
|
||||
}
|
||||
|
||||
export function getErrorMap() {
|
||||
return overrideErrorMap;
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.VisitorBase = void 0;
|
||||
const visitor_keys_1 = require("@typescript-eslint/visitor-keys");
|
||||
function isObject(obj) {
|
||||
return typeof obj === 'object' && obj != null;
|
||||
}
|
||||
function isNode(node) {
|
||||
return isObject(node) && typeof node.type === 'string';
|
||||
}
|
||||
class VisitorBase {
|
||||
#childVisitorKeys;
|
||||
#visitChildrenEvenIfSelectorExists;
|
||||
constructor(options) {
|
||||
this.#childVisitorKeys = options.childVisitorKeys ?? visitor_keys_1.visitorKeys;
|
||||
this.#visitChildrenEvenIfSelectorExists =
|
||||
options.visitChildrenEvenIfSelectorExists ?? false;
|
||||
}
|
||||
/**
|
||||
* Default method for visiting children.
|
||||
* @param node the node whose children should be visited
|
||||
* @param excludeArr a list of keys to not visit
|
||||
*/
|
||||
visitChildren(node, excludeArr = []) {
|
||||
if (node?.type == null) {
|
||||
return;
|
||||
}
|
||||
const exclude = new Set([...excludeArr, 'parent']);
|
||||
const children = this.#childVisitorKeys[node.type] ?? Object.keys(node);
|
||||
for (const key of children) {
|
||||
if (exclude.has(key)) {
|
||||
continue;
|
||||
}
|
||||
const child = node[key];
|
||||
if (!child) {
|
||||
continue;
|
||||
}
|
||||
if (Array.isArray(child)) {
|
||||
for (const subChild of child) {
|
||||
if (isNode(subChild)) {
|
||||
this.visit(subChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (isNode(child)) {
|
||||
this.visit(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Dispatching node.
|
||||
*/
|
||||
visit(node) {
|
||||
if (node?.type == null) {
|
||||
return;
|
||||
}
|
||||
const visitor = this[node.type];
|
||||
if (visitor) {
|
||||
visitor.call(this, node);
|
||||
if (!this.#visitChildrenEvenIfSelectorExists) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.visitChildren(node);
|
||||
}
|
||||
}
|
||||
exports.VisitorBase = VisitorBase;
|
||||
@@ -0,0 +1,23 @@
|
||||
/*! *****************************************************************************
|
||||
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 namespace Intl {
|
||||
interface DateTimeFormatPartTypesRegistry {
|
||||
unknown: never;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const execa = require('execa')
|
||||
const fs = require('node:fs')
|
||||
|
||||
const existsSync = fs.existsSync
|
||||
const stat = fs.promises.stat
|
||||
|
||||
// Hardcoded parameters
|
||||
const esVersions = ['es5', 'es6', 'es2017', 'esnext']
|
||||
const filesToTranspile = ['to-file-transport.ts']
|
||||
|
||||
async function transpile () {
|
||||
process.chdir(__dirname)
|
||||
|
||||
for (const sourceFileName of filesToTranspile) {
|
||||
const sourceStat = await stat(sourceFileName)
|
||||
|
||||
for (const esVersion of esVersions) {
|
||||
const intermediateFileName = sourceFileName.replace(/\.ts$/, '.js')
|
||||
const targetFileName = sourceFileName.replace(/\.ts$/, `.${esVersion}.cjs`)
|
||||
|
||||
const shouldTranspile = !existsSync(targetFileName) || (await stat(targetFileName)).mtimeMs < sourceStat.mtimeMs
|
||||
|
||||
if (shouldTranspile) {
|
||||
await execa('tsc', ['--target', esVersion, '--module', 'commonjs', sourceFileName])
|
||||
await execa('mv', [intermediateFileName, targetFileName])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
transpile().catch(err => {
|
||||
process.exitCode = 1
|
||||
throw err
|
||||
})
|
||||
@@ -0,0 +1,70 @@
|
||||
var table = require('markdown-table');
|
||||
|
||||
// Crude, but should be enough internally
|
||||
function toFixedWidth(value, maxChars) {
|
||||
var result = value.toFixed(2).substr(0, maxChars);
|
||||
if (result[result.length - 1] == '.') {
|
||||
result = result.substr(0, result.length - 2) + ' ';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {DataSetComparisonResult[]} results
|
||||
* @param {Object} [options]
|
||||
*/
|
||||
function createTable(results, options) {
|
||||
options || (options = {});
|
||||
var columnAlign = ['l', 'l'];
|
||||
var header = ['Suite', 'Browser'];
|
||||
var libNames = [];
|
||||
var rows = [];
|
||||
var errorCell = 'X';
|
||||
var emptyCell = '?';
|
||||
var hideColumns = options.hideColumns || [];
|
||||
var compareTo = options.compareTo;
|
||||
results.forEach(function(comparisonResult) {
|
||||
var resultMap = comparisonResult.resultMap;
|
||||
var libName;
|
||||
var libResults;
|
||||
var result;
|
||||
var compareRHZ = resultMap[compareTo] && resultMap[compareTo].rhz || 1;
|
||||
for (libName in resultMap) {
|
||||
// dictates order
|
||||
if (libNames.indexOf(libName) === -1 && hideColumns.indexOf(libName) === -1) {
|
||||
libNames.push(libName);
|
||||
columnAlign.push('r');
|
||||
rows.forEach(function(row) {
|
||||
// new column added, push empty element
|
||||
row.push(emptyCell);
|
||||
})
|
||||
}
|
||||
}
|
||||
libResults = libNames.map(function(libName) {
|
||||
result = resultMap[libName];
|
||||
if (result) {
|
||||
if (result.success) {
|
||||
return (result.fastest ? '*' : '')
|
||||
+ (100 * result.rhz / compareRHZ).toFixed(2) + '% '
|
||||
+ '(\xb1' + toFixedWidth(100 * (result.rhz / compareRHZ) * result.rme, 4) + '%)';
|
||||
} else {
|
||||
return errorCell;
|
||||
}
|
||||
} else {
|
||||
return emptyCell;
|
||||
}
|
||||
});
|
||||
|
||||
rows.push([comparisonResult.suite, comparisonResult.browser].concat(libResults));
|
||||
});
|
||||
|
||||
// slap header before it
|
||||
rows.unshift(header.concat(libNames));
|
||||
|
||||
return table(rows, { align: columnAlign });
|
||||
}
|
||||
|
||||
module.exports = function(data, options) {
|
||||
return createTable(data, options);
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
const Method = require('./method');
|
||||
const jayson = require('../../');
|
||||
|
||||
/**
|
||||
* Constructor for a Jayson Promise Server
|
||||
* @see Server
|
||||
* @class PromiseServer
|
||||
* @extends Server
|
||||
* @return {PromiseServer}
|
||||
*/
|
||||
const PromiseServer = function(methods, options) {
|
||||
if(!(this instanceof PromiseServer)) {
|
||||
return new PromiseServer(methods, options);
|
||||
}
|
||||
options = options || {};
|
||||
options.methodConstructor = options.methodConstructor || Method;
|
||||
jayson.Server.call(this, methods, options);
|
||||
};
|
||||
require('util').inherits(PromiseServer, jayson.Server);
|
||||
|
||||
module.exports = PromiseServer;
|
||||
@@ -0,0 +1,69 @@
|
||||
import * as http from 'http';
|
||||
import * as https from 'https';
|
||||
import * as net from 'net';
|
||||
|
||||
interface PlainObject {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
declare class _HttpAgent extends http.Agent {
|
||||
constructor(opts?: AgentKeepAlive.HttpOptions);
|
||||
readonly statusChanged: boolean;
|
||||
createConnection(options: net.NetConnectOpts, cb?: Function): net.Socket;
|
||||
createSocket(req: http.IncomingMessage, options: http.RequestOptions, cb: Function): void;
|
||||
getCurrentStatus(): AgentKeepAlive.AgentStatus;
|
||||
}
|
||||
|
||||
interface Constants {
|
||||
CURRENT_ID: Symbol;
|
||||
CREATE_ID: Symbol;
|
||||
INIT_SOCKET: Symbol;
|
||||
CREATE_HTTPS_CONNECTION: Symbol;
|
||||
SOCKET_CREATED_TIME: Symbol;
|
||||
SOCKET_NAME: Symbol;
|
||||
SOCKET_REQUEST_COUNT: Symbol;
|
||||
SOCKET_REQUEST_FINISHED_COUNT: Symbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated instead use `import { HttpAgent } from 'agentkeepalive'; or `const HttpAgent = require('agentkeepalive').HttpAgent;`
|
||||
*/
|
||||
declare class AgentKeepAlive extends _HttpAgent {}
|
||||
|
||||
declare namespace AgentKeepAlive {
|
||||
export interface AgentStatus {
|
||||
createSocketCount: number;
|
||||
createSocketErrorCount: number;
|
||||
closeSocketCount: number;
|
||||
errorSocketCount: number;
|
||||
timeoutSocketCount: number;
|
||||
requestCount: number;
|
||||
freeSockets: PlainObject;
|
||||
sockets: PlainObject;
|
||||
requests: PlainObject;
|
||||
}
|
||||
|
||||
interface CommonHttpOption {
|
||||
keepAlive?: boolean | undefined;
|
||||
freeSocketTimeout?: number | undefined;
|
||||
freeSocketKeepAliveTimeout?: number | undefined;
|
||||
timeout?: number | undefined;
|
||||
socketActiveTTL?: number | undefined;
|
||||
}
|
||||
|
||||
export interface HttpOptions extends http.AgentOptions, CommonHttpOption { }
|
||||
export interface HttpsOptions extends https.AgentOptions, CommonHttpOption { }
|
||||
|
||||
export class HttpAgent extends _HttpAgent {}
|
||||
export class HttpsAgent extends https.Agent {
|
||||
constructor(opts?: HttpsOptions);
|
||||
readonly statusChanged: boolean;
|
||||
createConnection(options: net.NetConnectOpts, cb?: Function): net.Socket;
|
||||
createSocket(req: http.IncomingMessage, options: http.RequestOptions, cb: Function): void;
|
||||
getCurrentStatus(): AgentStatus;
|
||||
}
|
||||
|
||||
export const constants: Constants;
|
||||
}
|
||||
|
||||
export = AgentKeepAlive;
|
||||
@@ -0,0 +1,6 @@
|
||||
export var CommentDirectiveType;
|
||||
(function (CommentDirectiveType) {
|
||||
CommentDirectiveType[CommentDirectiveType["ExpectError"] = 0] = "ExpectError";
|
||||
CommentDirectiveType[CommentDirectiveType["Ignore"] = 1] = "Ignore";
|
||||
})(CommentDirectiveType || (CommentDirectiveType = {}));
|
||||
//# sourceMappingURL=commentDirectiveType.enum.js.map
|
||||
@@ -0,0 +1,12 @@
|
||||
import * as jayson from '../../../..';
|
||||
|
||||
type PromiseClientBrowserCallServerFunction = (request:string) => Promise<string>;
|
||||
|
||||
declare class PromiseClientBrowser {
|
||||
constructor(callServer:PromiseClientBrowserCallServerFunction, options?:jayson.ClientOptions);
|
||||
request(method:string, params:jayson.RequestParamsLike, id:jayson.JSONRPCIDLike | undefined, shouldCall:false): jayson.JSONRPCRequest;
|
||||
request(method:string, params:jayson.RequestParamsLike, id?:jayson.JSONRPCIDLike): Promise<jayson.JSONRPCResultLike>;
|
||||
request(method: Array<jayson.JSONRPCRequestLike>): Promise<jayson.JSONRPCResultLike>;
|
||||
}
|
||||
|
||||
export = PromiseClientBrowser;
|
||||
@@ -0,0 +1,11 @@
|
||||
export type PreferOptionalChainMessageIds = 'optionalChainSuggest' | 'preferOptionalChain';
|
||||
export interface PreferOptionalChainOptions {
|
||||
allowPotentiallyUnsafeFixesThatModifyTheReturnTypeIKnowWhatImDoing?: boolean;
|
||||
checkAny?: boolean;
|
||||
checkBigInt?: boolean;
|
||||
checkBoolean?: boolean;
|
||||
checkNumber?: boolean;
|
||||
checkString?: boolean;
|
||||
checkUnknown?: boolean;
|
||||
requireNullish?: boolean;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import type { TSESTree } from '@typescript-eslint/types';
|
||||
import { DefinitionBase } from './DefinitionBase';
|
||||
import { DefinitionType } from './DefinitionType';
|
||||
export declare class TypeDefinition extends DefinitionBase<DefinitionType.Type, TSESTree.TSInterfaceDeclaration | TSESTree.TSMappedType | TSESTree.TSTypeAliasDeclaration | TSESTree.TSTypeParameter, null, TSESTree.Identifier> {
|
||||
readonly isTypeDefinition = true;
|
||||
readonly isVariableDefinition = false;
|
||||
constructor(name: TSESTree.Identifier, node: TypeDefinition['node']);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
declare module 'querystring' {
|
||||
interface StringifyOptions {
|
||||
encodeURIComponent?: ((str: string) => string) | undefined;
|
||||
}
|
||||
|
||||
interface ParseOptions {
|
||||
maxKeys?: number | undefined;
|
||||
decodeURIComponent?: ((str: string) => string) | undefined;
|
||||
}
|
||||
|
||||
interface ParsedUrlQuery { [key: string]: string | string[]; }
|
||||
|
||||
interface ParsedUrlQueryInput {
|
||||
[key: string]: string | number | boolean | ReadonlyArray<string> | ReadonlyArray<number> | ReadonlyArray<boolean> | undefined | null;
|
||||
}
|
||||
|
||||
function stringify(obj?: ParsedUrlQueryInput, sep?: string, eq?: string, options?: StringifyOptions): string;
|
||||
function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): ParsedUrlQuery;
|
||||
/**
|
||||
* The querystring.encode() function is an alias for querystring.stringify().
|
||||
*/
|
||||
const encode: typeof stringify;
|
||||
/**
|
||||
* The querystring.decode() function is an alias for querystring.parse().
|
||||
*/
|
||||
const decode: typeof parse;
|
||||
function escape(str: string): string;
|
||||
function unescape(str: string): string;
|
||||
}
|
||||
@@ -0,0 +1,278 @@
|
||||
import * as core from "./core.js";
|
||||
import type * as errors from "./errors.js";
|
||||
import type * as schemas from "./schemas.js";
|
||||
import * as util from "./util.js";
|
||||
export interface $ZodCheckDef {
|
||||
check: string;
|
||||
error?: errors.$ZodErrorMap<never> | undefined;
|
||||
/** If true, no later checks will be executed if this check fails. Default `false`. */
|
||||
abort?: boolean | undefined;
|
||||
/** If provided, the check runs only when this returns `true`. By default, it is skipped if prior parsing produced aborting issues. */
|
||||
when?: ((payload: schemas.ParsePayload) => boolean) | undefined;
|
||||
}
|
||||
export interface $ZodCheckInternals<T> {
|
||||
def: $ZodCheckDef;
|
||||
/** The set of issues this check might throw. */
|
||||
issc?: errors.$ZodIssueBase;
|
||||
check(payload: schemas.ParsePayload<T>): util.MaybeAsync<void>;
|
||||
onattach: ((schema: schemas.$ZodType) => void)[];
|
||||
}
|
||||
export interface $ZodCheck<in T = never> {
|
||||
_zod: $ZodCheckInternals<T>;
|
||||
}
|
||||
export declare const $ZodCheck: core.$constructor<$ZodCheck<any>>;
|
||||
export interface $ZodCheckLessThanDef extends $ZodCheckDef {
|
||||
check: "less_than";
|
||||
value: util.Numeric;
|
||||
inclusive: boolean;
|
||||
}
|
||||
export interface $ZodCheckLessThanInternals<T extends util.Numeric = util.Numeric> extends $ZodCheckInternals<T> {
|
||||
def: $ZodCheckLessThanDef;
|
||||
issc: errors.$ZodIssueTooBig<T>;
|
||||
}
|
||||
export interface $ZodCheckLessThan<T extends util.Numeric = util.Numeric> extends $ZodCheck<T> {
|
||||
_zod: $ZodCheckLessThanInternals<T>;
|
||||
}
|
||||
export declare const $ZodCheckLessThan: core.$constructor<$ZodCheckLessThan>;
|
||||
export interface $ZodCheckGreaterThanDef extends $ZodCheckDef {
|
||||
check: "greater_than";
|
||||
value: util.Numeric;
|
||||
inclusive: boolean;
|
||||
}
|
||||
export interface $ZodCheckGreaterThanInternals<T extends util.Numeric = util.Numeric> extends $ZodCheckInternals<T> {
|
||||
def: $ZodCheckGreaterThanDef;
|
||||
issc: errors.$ZodIssueTooSmall<T>;
|
||||
}
|
||||
export interface $ZodCheckGreaterThan<T extends util.Numeric = util.Numeric> extends $ZodCheck<T> {
|
||||
_zod: $ZodCheckGreaterThanInternals<T>;
|
||||
}
|
||||
export declare const $ZodCheckGreaterThan: core.$constructor<$ZodCheckGreaterThan>;
|
||||
export interface $ZodCheckMultipleOfDef<T extends number | bigint = number | bigint> extends $ZodCheckDef {
|
||||
check: "multiple_of";
|
||||
value: T;
|
||||
}
|
||||
export interface $ZodCheckMultipleOfInternals<T extends number | bigint = number | bigint> extends $ZodCheckInternals<T> {
|
||||
def: $ZodCheckMultipleOfDef<T>;
|
||||
issc: errors.$ZodIssueNotMultipleOf;
|
||||
}
|
||||
export interface $ZodCheckMultipleOf<T extends number | bigint = number | bigint> extends $ZodCheck<T> {
|
||||
_zod: $ZodCheckMultipleOfInternals<T>;
|
||||
}
|
||||
export declare const $ZodCheckMultipleOf: core.$constructor<$ZodCheckMultipleOf<number | bigint>>;
|
||||
export type $ZodNumberFormats = "int32" | "uint32" | "float32" | "float64" | "safeint";
|
||||
export interface $ZodCheckNumberFormatDef extends $ZodCheckDef {
|
||||
check: "number_format";
|
||||
format: $ZodNumberFormats;
|
||||
}
|
||||
export interface $ZodCheckNumberFormatInternals extends $ZodCheckInternals<number> {
|
||||
def: $ZodCheckNumberFormatDef;
|
||||
issc: errors.$ZodIssueInvalidType | errors.$ZodIssueTooBig<"number"> | errors.$ZodIssueTooSmall<"number">;
|
||||
}
|
||||
export interface $ZodCheckNumberFormat extends $ZodCheck<number> {
|
||||
_zod: $ZodCheckNumberFormatInternals;
|
||||
}
|
||||
export declare const $ZodCheckNumberFormat: core.$constructor<$ZodCheckNumberFormat>;
|
||||
export type $ZodBigIntFormats = "int64" | "uint64";
|
||||
export interface $ZodCheckBigIntFormatDef extends $ZodCheckDef {
|
||||
check: "bigint_format";
|
||||
format: $ZodBigIntFormats | undefined;
|
||||
}
|
||||
export interface $ZodCheckBigIntFormatInternals extends $ZodCheckInternals<bigint> {
|
||||
def: $ZodCheckBigIntFormatDef;
|
||||
issc: errors.$ZodIssueTooBig<"bigint"> | errors.$ZodIssueTooSmall<"bigint">;
|
||||
}
|
||||
export interface $ZodCheckBigIntFormat extends $ZodCheck<bigint> {
|
||||
_zod: $ZodCheckBigIntFormatInternals;
|
||||
}
|
||||
export declare const $ZodCheckBigIntFormat: core.$constructor<$ZodCheckBigIntFormat>;
|
||||
export interface $ZodCheckMaxSizeDef extends $ZodCheckDef {
|
||||
check: "max_size";
|
||||
maximum: number;
|
||||
}
|
||||
export interface $ZodCheckMaxSizeInternals<T extends util.HasSize = util.HasSize> extends $ZodCheckInternals<T> {
|
||||
def: $ZodCheckMaxSizeDef;
|
||||
issc: errors.$ZodIssueTooBig<T>;
|
||||
}
|
||||
export interface $ZodCheckMaxSize<T extends util.HasSize = util.HasSize> extends $ZodCheck<T> {
|
||||
_zod: $ZodCheckMaxSizeInternals<T>;
|
||||
}
|
||||
export declare const $ZodCheckMaxSize: core.$constructor<$ZodCheckMaxSize>;
|
||||
export interface $ZodCheckMinSizeDef extends $ZodCheckDef {
|
||||
check: "min_size";
|
||||
minimum: number;
|
||||
}
|
||||
export interface $ZodCheckMinSizeInternals<T extends util.HasSize = util.HasSize> extends $ZodCheckInternals<T> {
|
||||
def: $ZodCheckMinSizeDef;
|
||||
issc: errors.$ZodIssueTooSmall<T>;
|
||||
}
|
||||
export interface $ZodCheckMinSize<T extends util.HasSize = util.HasSize> extends $ZodCheck<T> {
|
||||
_zod: $ZodCheckMinSizeInternals<T>;
|
||||
}
|
||||
export declare const $ZodCheckMinSize: core.$constructor<$ZodCheckMinSize>;
|
||||
export interface $ZodCheckSizeEqualsDef extends $ZodCheckDef {
|
||||
check: "size_equals";
|
||||
size: number;
|
||||
}
|
||||
export interface $ZodCheckSizeEqualsInternals<T extends util.HasSize = util.HasSize> extends $ZodCheckInternals<T> {
|
||||
def: $ZodCheckSizeEqualsDef;
|
||||
issc: errors.$ZodIssueTooBig<T> | errors.$ZodIssueTooSmall<T>;
|
||||
}
|
||||
export interface $ZodCheckSizeEquals<T extends util.HasSize = util.HasSize> extends $ZodCheck<T> {
|
||||
_zod: $ZodCheckSizeEqualsInternals<T>;
|
||||
}
|
||||
export declare const $ZodCheckSizeEquals: core.$constructor<$ZodCheckSizeEquals>;
|
||||
export interface $ZodCheckMaxLengthDef extends $ZodCheckDef {
|
||||
check: "max_length";
|
||||
maximum: number;
|
||||
}
|
||||
export interface $ZodCheckMaxLengthInternals<T extends util.HasLength = util.HasLength> extends $ZodCheckInternals<T> {
|
||||
def: $ZodCheckMaxLengthDef;
|
||||
issc: errors.$ZodIssueTooBig<T>;
|
||||
}
|
||||
export interface $ZodCheckMaxLength<T extends util.HasLength = util.HasLength> extends $ZodCheck<T> {
|
||||
_zod: $ZodCheckMaxLengthInternals<T>;
|
||||
}
|
||||
export declare const $ZodCheckMaxLength: core.$constructor<$ZodCheckMaxLength>;
|
||||
export interface $ZodCheckMinLengthDef extends $ZodCheckDef {
|
||||
check: "min_length";
|
||||
minimum: number;
|
||||
}
|
||||
export interface $ZodCheckMinLengthInternals<T extends util.HasLength = util.HasLength> extends $ZodCheckInternals<T> {
|
||||
def: $ZodCheckMinLengthDef;
|
||||
issc: errors.$ZodIssueTooSmall<T>;
|
||||
}
|
||||
export interface $ZodCheckMinLength<T extends util.HasLength = util.HasLength> extends $ZodCheck<T> {
|
||||
_zod: $ZodCheckMinLengthInternals<T>;
|
||||
}
|
||||
export declare const $ZodCheckMinLength: core.$constructor<$ZodCheckMinLength>;
|
||||
export interface $ZodCheckLengthEqualsDef extends $ZodCheckDef {
|
||||
check: "length_equals";
|
||||
length: number;
|
||||
}
|
||||
export interface $ZodCheckLengthEqualsInternals<T extends util.HasLength = util.HasLength> extends $ZodCheckInternals<T> {
|
||||
def: $ZodCheckLengthEqualsDef;
|
||||
issc: errors.$ZodIssueTooBig<T> | errors.$ZodIssueTooSmall<T>;
|
||||
}
|
||||
export interface $ZodCheckLengthEquals<T extends util.HasLength = util.HasLength> extends $ZodCheck<T> {
|
||||
_zod: $ZodCheckLengthEqualsInternals<T>;
|
||||
}
|
||||
export declare const $ZodCheckLengthEquals: core.$constructor<$ZodCheckLengthEquals>;
|
||||
export type $ZodStringFormats = "email" | "url" | "emoji" | "uuid" | "guid" | "nanoid" | "cuid" | "cuid2" | "ulid" | "xid" | "ksuid" | "datetime" | "date" | "time" | "duration" | "ipv4" | "ipv6" | "cidrv4" | "cidrv6" | "base64" | "base64url" | "json_string" | "e164" | "lowercase" | "uppercase" | "regex" | "jwt" | "starts_with" | "ends_with" | "includes";
|
||||
export interface $ZodCheckStringFormatDef<Format extends string = string> extends $ZodCheckDef {
|
||||
check: "string_format";
|
||||
format: Format;
|
||||
pattern?: RegExp | undefined;
|
||||
}
|
||||
export interface $ZodCheckStringFormatInternals extends $ZodCheckInternals<string> {
|
||||
def: $ZodCheckStringFormatDef;
|
||||
issc: errors.$ZodIssueInvalidStringFormat;
|
||||
}
|
||||
export interface $ZodCheckStringFormat extends $ZodCheck<string> {
|
||||
_zod: $ZodCheckStringFormatInternals;
|
||||
}
|
||||
export declare const $ZodCheckStringFormat: core.$constructor<$ZodCheckStringFormat>;
|
||||
export interface $ZodCheckRegexDef extends $ZodCheckStringFormatDef {
|
||||
format: "regex";
|
||||
pattern: RegExp;
|
||||
}
|
||||
export interface $ZodCheckRegexInternals extends $ZodCheckInternals<string> {
|
||||
def: $ZodCheckRegexDef;
|
||||
issc: errors.$ZodIssueInvalidStringFormat;
|
||||
}
|
||||
export interface $ZodCheckRegex extends $ZodCheck<string> {
|
||||
_zod: $ZodCheckRegexInternals;
|
||||
}
|
||||
export declare const $ZodCheckRegex: core.$constructor<$ZodCheckRegex>;
|
||||
export interface $ZodCheckLowerCaseDef extends $ZodCheckStringFormatDef<"lowercase"> {
|
||||
}
|
||||
export interface $ZodCheckLowerCaseInternals extends $ZodCheckInternals<string> {
|
||||
def: $ZodCheckLowerCaseDef;
|
||||
issc: errors.$ZodIssueInvalidStringFormat;
|
||||
}
|
||||
export interface $ZodCheckLowerCase extends $ZodCheck<string> {
|
||||
_zod: $ZodCheckLowerCaseInternals;
|
||||
}
|
||||
export declare const $ZodCheckLowerCase: core.$constructor<$ZodCheckLowerCase>;
|
||||
export interface $ZodCheckUpperCaseDef extends $ZodCheckStringFormatDef<"uppercase"> {
|
||||
}
|
||||
export interface $ZodCheckUpperCaseInternals extends $ZodCheckInternals<string> {
|
||||
def: $ZodCheckUpperCaseDef;
|
||||
issc: errors.$ZodIssueInvalidStringFormat;
|
||||
}
|
||||
export interface $ZodCheckUpperCase extends $ZodCheck<string> {
|
||||
_zod: $ZodCheckUpperCaseInternals;
|
||||
}
|
||||
export declare const $ZodCheckUpperCase: core.$constructor<$ZodCheckUpperCase>;
|
||||
export interface $ZodCheckIncludesDef extends $ZodCheckStringFormatDef<"includes"> {
|
||||
includes: string;
|
||||
position?: number | undefined;
|
||||
}
|
||||
export interface $ZodCheckIncludesInternals extends $ZodCheckInternals<string> {
|
||||
def: $ZodCheckIncludesDef;
|
||||
issc: errors.$ZodIssueInvalidStringFormat;
|
||||
}
|
||||
export interface $ZodCheckIncludes extends $ZodCheck<string> {
|
||||
_zod: $ZodCheckIncludesInternals;
|
||||
}
|
||||
export declare const $ZodCheckIncludes: core.$constructor<$ZodCheckIncludes>;
|
||||
export interface $ZodCheckStartsWithDef extends $ZodCheckStringFormatDef<"starts_with"> {
|
||||
prefix: string;
|
||||
}
|
||||
export interface $ZodCheckStartsWithInternals extends $ZodCheckInternals<string> {
|
||||
def: $ZodCheckStartsWithDef;
|
||||
issc: errors.$ZodIssueInvalidStringFormat;
|
||||
}
|
||||
export interface $ZodCheckStartsWith extends $ZodCheck<string> {
|
||||
_zod: $ZodCheckStartsWithInternals;
|
||||
}
|
||||
export declare const $ZodCheckStartsWith: core.$constructor<$ZodCheckStartsWith>;
|
||||
export interface $ZodCheckEndsWithDef extends $ZodCheckStringFormatDef<"ends_with"> {
|
||||
suffix: string;
|
||||
}
|
||||
export interface $ZodCheckEndsWithInternals extends $ZodCheckInternals<string> {
|
||||
def: $ZodCheckEndsWithDef;
|
||||
issc: errors.$ZodIssueInvalidStringFormat;
|
||||
}
|
||||
export interface $ZodCheckEndsWith extends $ZodCheckInternals<string> {
|
||||
_zod: $ZodCheckEndsWithInternals;
|
||||
}
|
||||
export declare const $ZodCheckEndsWith: core.$constructor<$ZodCheckEndsWith>;
|
||||
export interface $ZodCheckPropertyDef extends $ZodCheckDef {
|
||||
check: "property";
|
||||
property: string;
|
||||
schema: schemas.$ZodType;
|
||||
}
|
||||
export interface $ZodCheckPropertyInternals<T extends object = object> extends $ZodCheckInternals<T> {
|
||||
def: $ZodCheckPropertyDef;
|
||||
issc: errors.$ZodIssue;
|
||||
}
|
||||
export interface $ZodCheckProperty<T extends object = object> extends $ZodCheck<T> {
|
||||
_zod: $ZodCheckPropertyInternals<T>;
|
||||
}
|
||||
export declare const $ZodCheckProperty: core.$constructor<$ZodCheckProperty>;
|
||||
export interface $ZodCheckMimeTypeDef extends $ZodCheckDef {
|
||||
check: "mime_type";
|
||||
mime: util.MimeTypes[];
|
||||
}
|
||||
export interface $ZodCheckMimeTypeInternals<T extends schemas.File = schemas.File> extends $ZodCheckInternals<T> {
|
||||
def: $ZodCheckMimeTypeDef;
|
||||
issc: errors.$ZodIssueInvalidValue;
|
||||
}
|
||||
export interface $ZodCheckMimeType<T extends schemas.File = schemas.File> extends $ZodCheck<T> {
|
||||
_zod: $ZodCheckMimeTypeInternals<T>;
|
||||
}
|
||||
export declare const $ZodCheckMimeType: core.$constructor<$ZodCheckMimeType>;
|
||||
export interface $ZodCheckOverwriteDef<T = unknown> extends $ZodCheckDef {
|
||||
check: "overwrite";
|
||||
tx(value: T): T;
|
||||
}
|
||||
export interface $ZodCheckOverwriteInternals<T = unknown> extends $ZodCheckInternals<T> {
|
||||
def: $ZodCheckOverwriteDef<T>;
|
||||
issc: never;
|
||||
}
|
||||
export interface $ZodCheckOverwrite<T = unknown> extends $ZodCheck<T> {
|
||||
_zod: $ZodCheckOverwriteInternals<T>;
|
||||
}
|
||||
export declare const $ZodCheckOverwrite: core.$constructor<$ZodCheckOverwrite>;
|
||||
export type $ZodChecks = $ZodCheckLessThan | $ZodCheckGreaterThan | $ZodCheckMultipleOf | $ZodCheckNumberFormat | $ZodCheckBigIntFormat | $ZodCheckMaxSize | $ZodCheckMinSize | $ZodCheckSizeEquals | $ZodCheckMaxLength | $ZodCheckMinLength | $ZodCheckLengthEquals | $ZodCheckStringFormat | $ZodCheckProperty | $ZodCheckMimeType | $ZodCheckOverwrite;
|
||||
export type $ZodStringFormatChecks = $ZodCheckRegex | $ZodCheckLowerCase | $ZodCheckUpperCase | $ZodCheckIncludes | $ZodCheckStartsWith | $ZodCheckEndsWith | schemas.$ZodStringFormatTypes;
|
||||
@@ -0,0 +1,4 @@
|
||||
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"mismatch", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
||||
name: string;
|
||||
};
|
||||
export default _default;
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,145 @@
|
||||
/**
|
||||
* @fileoverview Rule to disallow duplicate conditions in if-else-if chains
|
||||
* @author Milos Djermanovic
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const astUtils = require("./utils/ast-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Determines whether the first given array is a subset of the second given array.
|
||||
* @param {Function} comparator A function to compare two elements, should return `true` if they are equal.
|
||||
* @param {Array} arrA The array to compare from.
|
||||
* @param {Array} arrB The array to compare against.
|
||||
* @returns {boolean} `true` if the array `arrA` is a subset of the array `arrB`.
|
||||
*/
|
||||
function isSubsetByComparator(comparator, arrA, arrB) {
|
||||
return arrA.every(a => arrB.some(b => comparator(a, b)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits the given node by the given logical operator.
|
||||
* @param {string} operator Logical operator `||` or `&&`.
|
||||
* @param {ASTNode} node The node to split.
|
||||
* @returns {ASTNode[]} Array of conditions that makes the node when joined by the operator.
|
||||
*/
|
||||
function splitByLogicalOperator(operator, node) {
|
||||
if (node.type === "LogicalExpression" && node.operator === operator) {
|
||||
return [
|
||||
...splitByLogicalOperator(operator, node.left),
|
||||
...splitByLogicalOperator(operator, node.right),
|
||||
];
|
||||
}
|
||||
return [node];
|
||||
}
|
||||
|
||||
const splitByOr = splitByLogicalOperator.bind(null, "||");
|
||||
const splitByAnd = splitByLogicalOperator.bind(null, "&&");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../types').Rule.RuleModule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "problem",
|
||||
|
||||
docs: {
|
||||
description: "Disallow duplicate conditions in if-else-if chains",
|
||||
recommended: true,
|
||||
url: "https://eslint.org/docs/latest/rules/no-dupe-else-if",
|
||||
},
|
||||
|
||||
schema: [],
|
||||
|
||||
messages: {
|
||||
unexpected:
|
||||
"This branch can never execute. Its condition is a duplicate or covered by previous conditions in the if-else-if chain.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Determines whether the two given nodes are considered to be equal. In particular, given that the nodes
|
||||
* represent expressions in a boolean context, `||` and `&&` can be considered as commutative operators.
|
||||
* @param {ASTNode} a First node.
|
||||
* @param {ASTNode} b Second node.
|
||||
* @returns {boolean} `true` if the nodes are considered to be equal.
|
||||
*/
|
||||
function equal(a, b) {
|
||||
if (a.type !== b.type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
a.type === "LogicalExpression" &&
|
||||
(a.operator === "||" || a.operator === "&&") &&
|
||||
a.operator === b.operator
|
||||
) {
|
||||
return (
|
||||
(equal(a.left, b.left) && equal(a.right, b.right)) ||
|
||||
(equal(a.left, b.right) && equal(a.right, b.left))
|
||||
);
|
||||
}
|
||||
|
||||
return astUtils.equalTokens(a, b, sourceCode);
|
||||
}
|
||||
|
||||
const isSubset = isSubsetByComparator.bind(null, equal);
|
||||
|
||||
return {
|
||||
IfStatement(node) {
|
||||
const test = node.test,
|
||||
conditionsToCheck =
|
||||
test.type === "LogicalExpression" &&
|
||||
test.operator === "&&"
|
||||
? [test, ...splitByAnd(test)]
|
||||
: [test];
|
||||
let current = node,
|
||||
listToCheck = conditionsToCheck.map(c =>
|
||||
splitByOr(c).map(splitByAnd),
|
||||
);
|
||||
|
||||
while (
|
||||
current.parent &&
|
||||
current.parent.type === "IfStatement" &&
|
||||
current.parent.alternate === current
|
||||
) {
|
||||
current = current.parent;
|
||||
|
||||
const currentOrOperands = splitByOr(current.test).map(
|
||||
splitByAnd,
|
||||
);
|
||||
|
||||
listToCheck = listToCheck.map(orOperands =>
|
||||
orOperands.filter(
|
||||
orOperand =>
|
||||
!currentOrOperands.some(currentOrOperand =>
|
||||
isSubset(currentOrOperand, orOperand),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (
|
||||
listToCheck.some(orOperands => orOperands.length === 0)
|
||||
) {
|
||||
context.report({ node: test, messageId: "unexpected" });
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
type Awaitable<T> = T | PromiseLike<T>;
|
||||
type Nullable<T> = T | null | undefined;
|
||||
type Arrayable<T> = T | Array<T>;
|
||||
type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
|
||||
type MergeInsertions<T> = T extends object ? { [K in keyof T] : MergeInsertions<T[K]> } : T;
|
||||
type DeepMerge<
|
||||
F,
|
||||
S
|
||||
> = MergeInsertions<{ [K in keyof F | keyof S] : K extends keyof S & keyof F ? DeepMerge<F[K], S[K]> : K extends keyof S ? S[K] : K extends keyof F ? F[K] : never }>;
|
||||
interface Constructable {
|
||||
new (...args: any[]): any;
|
||||
}
|
||||
interface ParsedStack {
|
||||
method: string;
|
||||
file: string;
|
||||
line: number;
|
||||
column: number;
|
||||
}
|
||||
interface SerializedError {
|
||||
message: string;
|
||||
stacks?: ParsedStack[];
|
||||
stack?: string;
|
||||
name?: string;
|
||||
cause?: SerializedError;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
interface TestError extends SerializedError {
|
||||
cause?: TestError;
|
||||
diff?: string;
|
||||
actual?: string;
|
||||
expected?: string;
|
||||
}
|
||||
|
||||
export type { ArgumentsType, Arrayable, Awaitable, Constructable, DeepMerge, MergeInsertions, Nullable, ParsedStack, SerializedError, TestError };
|
||||
@@ -0,0 +1 @@
|
||||
export declare function isArray(arg: unknown): arg is readonly unknown[];
|
||||
@@ -0,0 +1,22 @@
|
||||
/* @minVersion 7.22.0 */
|
||||
|
||||
function _using(stack, value, isAwait) {
|
||||
if (value === null || value === void 0) return value;
|
||||
if (Object(value) !== value) {
|
||||
throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
|
||||
}
|
||||
// core-js-pure uses Symbol.for for polyfilling well-known symbols
|
||||
if (isAwait) {
|
||||
var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
|
||||
}
|
||||
if (dispose === null || dispose === void 0) {
|
||||
dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
|
||||
}
|
||||
if (typeof dispose !== "function") {
|
||||
throw new TypeError(`Property [Symbol.dispose] is not a function.`);
|
||||
}
|
||||
stack.push({ v: value, d: dispose, a: isAwait });
|
||||
return value;
|
||||
}
|
||||
|
||||
export { _using as _ };
|
||||
@@ -0,0 +1,58 @@
|
||||
import {Buffer} from 'buffer';
|
||||
import * as BufferLayout from '@solana/buffer-layout';
|
||||
|
||||
import * as Layout from './layout';
|
||||
|
||||
export interface IInstructionInputData {
|
||||
readonly instruction: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type InstructionType<TInputData extends IInstructionInputData> = {
|
||||
/** The Instruction index (from solana upstream program) */
|
||||
index: number;
|
||||
/** The BufferLayout to use to build data */
|
||||
layout: BufferLayout.Layout<TInputData>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Populate a buffer of instruction data using an InstructionType
|
||||
* @internal
|
||||
*/
|
||||
export function encodeData<TInputData extends IInstructionInputData>(
|
||||
type: InstructionType<TInputData>,
|
||||
fields?: any,
|
||||
): Buffer {
|
||||
const allocLength =
|
||||
type.layout.span >= 0 ? type.layout.span : Layout.getAlloc(type, fields);
|
||||
const data = Buffer.alloc(allocLength);
|
||||
const layoutFields = Object.assign({instruction: type.index}, fields);
|
||||
type.layout.encode(layoutFields, data);
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode instruction data buffer using an InstructionType
|
||||
* @internal
|
||||
*/
|
||||
export function decodeData<TInputData extends IInstructionInputData>(
|
||||
type: InstructionType<TInputData>,
|
||||
buffer: Buffer,
|
||||
): TInputData {
|
||||
let data: TInputData;
|
||||
try {
|
||||
data = type.layout.decode(buffer);
|
||||
} catch (err) {
|
||||
throw new Error('invalid instruction; ' + err);
|
||||
}
|
||||
|
||||
if (data.instruction !== type.index) {
|
||||
throw new Error(
|
||||
`invalid instruction; instruction index mismatch ${data.instruction} != ${type.index}`,
|
||||
);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
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: "توکي", verb: "ولري" },
|
||||
file: { unit: "بایټس", verb: "ولري" },
|
||||
array: { unit: "توکي", verb: "ولري" },
|
||||
set: { unit: "توکي", verb: "ولري" },
|
||||
};
|
||||
|
||||
function getSizing(origin: string): { unit: string; verb: string } | null {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
|
||||
const FormatDictionary: {
|
||||
[k in $ZodStringFormats | (string & {})]?: string;
|
||||
} = {
|
||||
regex: "ورودي",
|
||||
email: "بریښنالیک",
|
||||
url: "یو آر ال",
|
||||
emoji: "ایموجي",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "نیټه او وخت",
|
||||
date: "نېټه",
|
||||
time: "وخت",
|
||||
duration: "موده",
|
||||
ipv4: "د IPv4 پته",
|
||||
ipv6: "د IPv6 پته",
|
||||
cidrv4: "د IPv4 ساحه",
|
||||
cidrv6: "د IPv6 ساحه",
|
||||
base64: "base64-encoded متن",
|
||||
base64url: "base64url-encoded متن",
|
||||
json_string: "JSON متن",
|
||||
e164: "د E.164 شمېره",
|
||||
jwt: "JWT",
|
||||
template_literal: "ورودي",
|
||||
};
|
||||
|
||||
const TypeDictionary: {
|
||||
[k in errors.$ZodInvalidTypeExpected | (string & {})]?: string;
|
||||
} = {
|
||||
nan: "NaN",
|
||||
number: "عدد",
|
||||
array: "ارې",
|
||||
};
|
||||
|
||||
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 `ناسم ورودي: باید instanceof ${issue.expected} وای, مګر ${received} ترلاسه شو`;
|
||||
}
|
||||
return `ناسم ورودي: باید ${expected} وای, مګر ${received} ترلاسه شو`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1) {
|
||||
return `ناسم ورودي: باید ${util.stringifyPrimitive(issue.values[0])} وای`;
|
||||
}
|
||||
return `ناسم انتخاب: باید یو له ${util.joinValues(issue.values, "|")} څخه وای`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `ډیر لوی: ${issue.origin ?? "ارزښت"} باید ${adj}${issue.maximum.toString()} ${sizing.unit ?? "عنصرونه"} ولري`;
|
||||
}
|
||||
return `ډیر لوی: ${issue.origin ?? "ارزښت"} باید ${adj}${issue.maximum.toString()} وي`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `ډیر کوچنی: ${issue.origin} باید ${adj}${issue.minimum.toString()} ${sizing.unit} ولري`;
|
||||
}
|
||||
return `ډیر کوچنی: ${issue.origin} باید ${adj}${issue.minimum.toString()} وي`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue as errors.$ZodStringFormatIssues;
|
||||
if (_issue.format === "starts_with") {
|
||||
return `ناسم متن: باید د "${_issue.prefix}" سره پیل شي`;
|
||||
}
|
||||
if (_issue.format === "ends_with") {
|
||||
return `ناسم متن: باید د "${_issue.suffix}" سره پای ته ورسيږي`;
|
||||
}
|
||||
if (_issue.format === "includes") {
|
||||
return `ناسم متن: باید "${_issue.includes}" ولري`;
|
||||
}
|
||||
if (_issue.format === "regex") {
|
||||
return `ناسم متن: باید د ${_issue.pattern} سره مطابقت ولري`;
|
||||
}
|
||||
return `${FormatDictionary[_issue.format] ?? issue.format} ناسم دی`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `ناسم عدد: باید د ${issue.divisor} مضرب وي`;
|
||||
case "unrecognized_keys":
|
||||
return `ناسم ${issue.keys.length > 1 ? "کلیډونه" : "کلیډ"}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `ناسم کلیډ په ${issue.origin} کې`;
|
||||
case "invalid_union":
|
||||
return `ناسمه ورودي`;
|
||||
case "invalid_element":
|
||||
return `ناسم عنصر په ${issue.origin} کې`;
|
||||
default:
|
||||
return `ناسمه ورودي`;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export default function (): { localeError: errors.$ZodErrorMap } {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
export {};
|
||||
|
||||
import * as url from "node:url";
|
||||
|
||||
declare global {
|
||||
interface URL extends url.URL {}
|
||||
var URL: typeof globalThis extends { onmessage: any; URL: infer T } ? T : typeof url.URL;
|
||||
|
||||
interface URLPattern extends url.URLPattern {}
|
||||
var URLPattern: typeof globalThis extends {
|
||||
onmessage: any;
|
||||
scheduler: any; // Must be a var introduced at the same time as URLPattern.
|
||||
URLPattern: infer T;
|
||||
} ? T
|
||||
: typeof url.URLPattern;
|
||||
|
||||
interface URLPatternInit extends url.URLPatternInit {}
|
||||
|
||||
interface URLPatternResult extends url.URLPatternResult {}
|
||||
|
||||
interface URLSearchParams extends url.URLSearchParams {}
|
||||
var URLSearchParams: typeof globalThis extends { onmessage: any; URLSearchParams: infer T } ? T
|
||||
: typeof url.URLSearchParams;
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
"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;
|
||||
};
|
||||
})();
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getProjectConfigFiles = getProjectConfigFiles;
|
||||
const debug_1 = __importDefault(require("debug"));
|
||||
const fs = __importStar(require("node:fs"));
|
||||
const path = __importStar(require("node:path"));
|
||||
const log = (0, debug_1.default)('typescript-eslint:typescript-estree:parseSettings:getProjectConfigFiles');
|
||||
/**
|
||||
* Checks for a matching TSConfig to a file including its parent directories,
|
||||
* permanently caching results under each directory it checks.
|
||||
*
|
||||
* @remarks
|
||||
* We don't (yet!) have a way to attach file watchers on disk, but still need to
|
||||
* cache file checks for rapid subsequent calls to fs.existsSync. See discussion
|
||||
* in https://github.com/typescript-eslint/typescript-eslint/issues/101.
|
||||
*/
|
||||
function getProjectConfigFiles(parseSettings, project) {
|
||||
if (project !== true) {
|
||||
if (project == null || project === false) {
|
||||
return null;
|
||||
}
|
||||
if (Array.isArray(project)) {
|
||||
return project;
|
||||
}
|
||||
return [project];
|
||||
}
|
||||
log('Looking for tsconfig.json at or above file: %s', parseSettings.filePath);
|
||||
let directory = path.dirname(parseSettings.filePath);
|
||||
const checkedDirectories = [directory];
|
||||
do {
|
||||
log('Checking tsconfig.json path: %s', directory);
|
||||
const tsconfigPath = path.join(directory, 'tsconfig.json');
|
||||
const cached = parseSettings.tsconfigMatchCache.get(directory) ??
|
||||
(fs.existsSync(tsconfigPath) && tsconfigPath);
|
||||
if (cached) {
|
||||
for (const directory of checkedDirectories) {
|
||||
parseSettings.tsconfigMatchCache.set(directory, cached);
|
||||
}
|
||||
return [cached];
|
||||
}
|
||||
directory = path.dirname(directory);
|
||||
checkedDirectories.push(directory);
|
||||
} while (directory.length > 1 &&
|
||||
directory.length >= parseSettings.tsconfigRootDir.length);
|
||||
throw new Error(`project was set to \`true\` but couldn't find any tsconfig.json relative to '${parseSettings.filePath}' within '${parseSettings.tsconfigRootDir}'.`);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
import {
|
||||
noop,
|
||||
resolve as _resolve
|
||||
} from '../-internal';
|
||||
|
||||
/**
|
||||
`Promise.resolve` returns a promise that will become resolved with the
|
||||
passed `value`. It is shorthand for the following:
|
||||
|
||||
```javascript
|
||||
let promise = new Promise(function(resolve, reject){
|
||||
resolve(1);
|
||||
});
|
||||
|
||||
promise.then(function(value){
|
||||
// value === 1
|
||||
});
|
||||
```
|
||||
|
||||
Instead of writing the above, your code now simply becomes the following:
|
||||
|
||||
```javascript
|
||||
let promise = Promise.resolve(1);
|
||||
|
||||
promise.then(function(value){
|
||||
// value === 1
|
||||
});
|
||||
```
|
||||
|
||||
@method resolve
|
||||
@static
|
||||
@param {Any} value value that the returned promise will be resolved with
|
||||
Useful for tooling.
|
||||
@return {Promise} a promise that will become fulfilled with the given
|
||||
`value`
|
||||
*/
|
||||
export default function resolve(object) {
|
||||
/*jshint validthis:true */
|
||||
let Constructor = this;
|
||||
|
||||
if (object && typeof object === 'object' && object.constructor === Constructor) {
|
||||
return object;
|
||||
}
|
||||
|
||||
let promise = new Constructor(noop);
|
||||
_resolve(promise, object);
|
||||
return promise;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export { _ as default } from "../esm/_wrap_native_super.js";
|
||||
Reference in New Issue
Block a user