WIP: bootstrap and partial real Solana watcher implementation
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
import type { ClassicConfig } from '../Config';
|
||||
import type { Linter } from '../Linter';
|
||||
import type * as Shared from './ESLintShared';
|
||||
declare class LegacyESLintBase extends Shared.ESLintBase<ClassicConfig.Config, LegacyESLint.ESLintOptions> {
|
||||
static readonly configType: 'eslintrc';
|
||||
}
|
||||
declare const LegacyESLint_base: typeof LegacyESLintBase;
|
||||
/**
|
||||
* The ESLint class is the primary class to use in Node.js applications.
|
||||
* This class depends on the Node.js fs module and the file system, so you cannot use it in browsers.
|
||||
*
|
||||
* If you want to lint code on browsers, use the Linter class instead.
|
||||
*/
|
||||
export declare class LegacyESLint extends LegacyESLint_base {
|
||||
}
|
||||
export declare namespace LegacyESLint {
|
||||
interface ESLintOptions extends Shared.ESLintOptions<ClassicConfig.Config> {
|
||||
/**
|
||||
* If you pass directory paths to the eslint.lintFiles() method, ESLint checks the files in those directories that
|
||||
* have the given extensions. For example, when passing the src/ directory and extensions is [".js", ".ts"], ESLint
|
||||
* will lint *.js and *.ts files in src/. If extensions is null, ESLint checks *.js files and files that match
|
||||
* overrides[].files patterns in your configuration.
|
||||
* Note: This option only applies when you pass directory paths to the eslint.lintFiles() method.
|
||||
* If you pass glob patterns, ESLint will lint all files matching the glob pattern regardless of extension.
|
||||
*/
|
||||
extensions?: string[] | null;
|
||||
/**
|
||||
* If false is present, the eslint.lintFiles() method doesn't respect `.eslintignore` files in your configuration.
|
||||
* @default true
|
||||
*/
|
||||
ignore?: boolean;
|
||||
/**
|
||||
* The path to a file ESLint uses instead of `$CWD/.eslintignore`.
|
||||
* If a path is present and the file doesn't exist, this constructor will throw an error.
|
||||
*/
|
||||
ignorePath?: string;
|
||||
/**
|
||||
* The path to a configuration file, overrides all configurations used with this instance.
|
||||
* The options.overrideConfig option is applied after this option is applied.
|
||||
*/
|
||||
overrideConfigFile?: string | null;
|
||||
/**
|
||||
* The severity to report unused eslint-disable directives.
|
||||
* If this option is a severity, it overrides the reportUnusedDisableDirectives setting in your configurations.
|
||||
*/
|
||||
reportUnusedDisableDirectives?: Linter.SeverityString | null;
|
||||
/**
|
||||
* The path to a directory where plugins should be resolved from.
|
||||
* If null is present, ESLint loads plugins from the location of the configuration file that contains the plugin
|
||||
* setting.
|
||||
* If a path is present, ESLint loads all plugins from there.
|
||||
*/
|
||||
resolvePluginsRelativeTo?: string | null;
|
||||
/**
|
||||
* An array of paths to directories to load custom rules from.
|
||||
*/
|
||||
rulePaths?: string[];
|
||||
/**
|
||||
* If false is present, ESLint doesn't load configuration files (.eslintrc.* files).
|
||||
* Only the configuration of the constructor options is valid.
|
||||
*/
|
||||
useEslintrc?: boolean;
|
||||
}
|
||||
type DeprecatedRuleInfo = Shared.DeprecatedRuleInfo;
|
||||
type EditInfo = Shared.EditInfo;
|
||||
type Formatter = Shared.Formatter;
|
||||
type LintMessage = Shared.LintMessage;
|
||||
type LintResult = Omit<Shared.LintResult, 'stats'>;
|
||||
type LintTextOptions = Shared.LintTextOptions;
|
||||
type SuppressedLintMessage = Shared.SuppressedLintMessage;
|
||||
}
|
||||
export {};
|
||||
@@ -0,0 +1,80 @@
|
||||
// @ts-ignore TS6133
|
||||
import { expect, test } from "vitest";
|
||||
|
||||
import * as z from "zod/v3";
|
||||
import { util } from "../helpers/util.js";
|
||||
|
||||
test("create enum", () => {
|
||||
const MyEnum = z.enum(["Red", "Green", "Blue"]);
|
||||
expect(MyEnum.Values.Red).toEqual("Red");
|
||||
expect(MyEnum.Enum.Red).toEqual("Red");
|
||||
expect(MyEnum.enum.Red).toEqual("Red");
|
||||
});
|
||||
|
||||
test("infer enum", () => {
|
||||
const MyEnum = z.enum(["Red", "Green", "Blue"]);
|
||||
type MyEnum = z.infer<typeof MyEnum>;
|
||||
util.assertEqual<MyEnum, "Red" | "Green" | "Blue">(true);
|
||||
});
|
||||
|
||||
test("get options", () => {
|
||||
expect(z.enum(["tuna", "trout"]).options).toEqual(["tuna", "trout"]);
|
||||
});
|
||||
|
||||
test("readonly enum", () => {
|
||||
const HTTP_SUCCESS = ["200", "201"] as const;
|
||||
const arg = z.enum(HTTP_SUCCESS);
|
||||
type arg = z.infer<typeof arg>;
|
||||
util.assertEqual<arg, "200" | "201">(true);
|
||||
|
||||
arg.parse("201");
|
||||
expect(() => arg.parse("202")).toThrow();
|
||||
});
|
||||
|
||||
test("error params", () => {
|
||||
const result = z.enum(["test"], { required_error: "REQUIRED" }).safeParse(undefined);
|
||||
expect(result.success).toEqual(false);
|
||||
if (!result.success) {
|
||||
expect(result.error.issues[0].message).toEqual("REQUIRED");
|
||||
}
|
||||
});
|
||||
|
||||
test("extract/exclude", () => {
|
||||
const foods = ["Pasta", "Pizza", "Tacos", "Burgers", "Salad"] as const;
|
||||
const FoodEnum = z.enum(foods);
|
||||
const ItalianEnum = FoodEnum.extract(["Pasta", "Pizza"]);
|
||||
const UnhealthyEnum = FoodEnum.exclude(["Salad"]);
|
||||
const EmptyFoodEnum = FoodEnum.exclude(foods);
|
||||
|
||||
util.assertEqual<z.infer<typeof ItalianEnum>, "Pasta" | "Pizza">(true);
|
||||
util.assertEqual<z.infer<typeof UnhealthyEnum>, "Pasta" | "Pizza" | "Tacos" | "Burgers">(true);
|
||||
// @ts-expect-error TS2344
|
||||
util.assertEqual<typeof EmptyFoodEnum, z.ZodEnum<[]>>(true);
|
||||
util.assertEqual<z.infer<typeof EmptyFoodEnum>, never>(true);
|
||||
});
|
||||
|
||||
test("error map in extract/exclude", () => {
|
||||
const foods = ["Pasta", "Pizza", "Tacos", "Burgers", "Salad"] as const;
|
||||
const FoodEnum = z.enum(foods, {
|
||||
errorMap: () => ({ message: "This is not food!" }),
|
||||
});
|
||||
const ItalianEnum = FoodEnum.extract(["Pasta", "Pizza"]);
|
||||
const foodsError = FoodEnum.safeParse("Cucumbers");
|
||||
const italianError = ItalianEnum.safeParse("Tacos");
|
||||
if (!foodsError.success && !italianError.success) {
|
||||
expect(foodsError.error.issues[0].message).toEqual(italianError.error.issues[0].message);
|
||||
}
|
||||
|
||||
const UnhealthyEnum = FoodEnum.exclude(["Salad"], {
|
||||
errorMap: () => ({ message: "This is not healthy food!" }),
|
||||
});
|
||||
const unhealthyError = UnhealthyEnum.safeParse("Salad");
|
||||
if (!unhealthyError.success) {
|
||||
expect(unhealthyError.error.issues[0].message).toEqual("This is not healthy food!");
|
||||
}
|
||||
});
|
||||
|
||||
test("readonly in ZodEnumDef", () => {
|
||||
let _t!: z.ZodEnumDef<readonly ["a", "b"]>;
|
||||
_t;
|
||||
});
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @fileoverview Universal module importer
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Imports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
import { createRequire } from "module";
|
||||
import { fileURLToPath } from "url";
|
||||
import { dirname } from "path";
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
const require = createRequire(__dirname + "/");
|
||||
const { ModuleImporter } = require("./module-importer.cjs");
|
||||
|
||||
export { ModuleImporter };
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,4 @@
|
||||
import v35 from './v35.js';
|
||||
import sha1 from './sha1.js';
|
||||
const v5 = v35('v5', 0x50, sha1);
|
||||
export default v5;
|
||||
@@ -0,0 +1,9 @@
|
||||
export { decodeOriginalScopes, encodeOriginalScopes, decodeGeneratedRanges, encodeGeneratedRanges, } from './scopes.cts';
|
||||
export type { OriginalScope, GeneratedRange, CallSite, BindingExpressionRange } from './scopes.cts';
|
||||
export type SourceMapSegment = [number] | [number, number, number, number] | [number, number, number, number, number];
|
||||
export type SourceMapLine = SourceMapSegment[];
|
||||
export type SourceMapMappings = SourceMapLine[];
|
||||
export declare function decode(mappings: string): SourceMapMappings;
|
||||
export declare function encode(decoded: SourceMapMappings): string;
|
||||
export declare function encode(decoded: Readonly<SourceMapMappings>): string;
|
||||
//# sourceMappingURL=sourcemap-codec.d.ts.map
|
||||
@@ -0,0 +1,119 @@
|
||||
import * as util from "../core/util.js";
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "caractere", verb: "să aibă" },
|
||||
file: { unit: "octeți", verb: "să aibă" },
|
||||
array: { unit: "elemente", verb: "să aibă" },
|
||||
set: { unit: "elemente", verb: "să aibă" },
|
||||
map: { unit: "intrări", verb: "să aibă" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "intrare",
|
||||
email: "adresă de email",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "dată și oră ISO",
|
||||
date: "dată ISO",
|
||||
time: "oră ISO",
|
||||
duration: "durată ISO",
|
||||
ipv4: "adresă IPv4",
|
||||
ipv6: "adresă IPv6",
|
||||
mac: "adresă MAC",
|
||||
cidrv4: "interval IPv4",
|
||||
cidrv6: "interval IPv6",
|
||||
base64: "șir codat base64",
|
||||
base64url: "șir codat base64url",
|
||||
json_string: "șir JSON",
|
||||
e164: "număr E.164",
|
||||
jwt: "JWT",
|
||||
template_literal: "intrare",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
string: "șir",
|
||||
number: "număr",
|
||||
boolean: "boolean",
|
||||
function: "funcție",
|
||||
array: "matrice",
|
||||
object: "obiect",
|
||||
undefined: "nedefinit",
|
||||
symbol: "simbol",
|
||||
bigint: "număr mare",
|
||||
void: "void",
|
||||
never: "never",
|
||||
map: "hartă",
|
||||
set: "set",
|
||||
};
|
||||
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;
|
||||
return `Intrare invalidă: așteptat ${expected}, primit ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Intrare invalidă: așteptat ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Opțiune invalidă: așteptat una dintre ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Prea mare: așteptat ca ${issue.origin ?? "valoarea"} ${sizing.verb} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elemente"}`;
|
||||
return `Prea mare: așteptat ca ${issue.origin ?? "valoarea"} să fie ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Prea mic: așteptat ca ${issue.origin} ${sizing.verb} ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `Prea mic: așteptat ca ${issue.origin} să fie ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with") {
|
||||
return `Șir invalid: trebuie să înceapă cu "${_issue.prefix}"`;
|
||||
}
|
||||
if (_issue.format === "ends_with")
|
||||
return `Șir invalid: trebuie să se termine cu "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Șir invalid: trebuie să includă "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Șir invalid: trebuie să se potrivească cu modelul ${_issue.pattern}`;
|
||||
return `Format invalid: ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Număr invalid: trebuie să fie multiplu de ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Chei nerecunoscute: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Cheie invalidă în ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Intrare invalidă";
|
||||
case "invalid_element":
|
||||
return `Valoare invalidă în ${issue.origin}`;
|
||||
default:
|
||||
return `Intrare invalidă`;
|
||||
}
|
||||
};
|
||||
};
|
||||
export default function () {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2019, Sideway Inc, and project contributors
|
||||
Copyright (c) 2019-present The Fastify team
|
||||
All rights reserved.
|
||||
|
||||
The Fastify team members are listed at https://github.com/fastify/fastify#team.
|
||||
|
||||
The complete list of contributors can be found at:
|
||||
- https://github.com/hapijs/bourne/graphs/contributors
|
||||
- https://github.com/fastify/secure-json-parse/graphs/contributors
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -0,0 +1,8 @@
|
||||
export namespace errorUtil {
|
||||
export type ErrMessage = string | { message?: string | undefined };
|
||||
export const errToObj = (message?: ErrMessage): { message?: string | undefined } =>
|
||||
typeof message === "string" ? { message } : message || {};
|
||||
// biome-ignore lint:
|
||||
export const toString = (message?: ErrMessage): string | undefined =>
|
||||
typeof message === "string" ? message : message?.message;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
This is the x86_64-unknown-linux-gnu build of lightningcss. See https://github.com/parcel-bundler/lightningcss for details.
|
||||
@@ -0,0 +1,47 @@
|
||||
"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 (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.string = string;
|
||||
exports.number = number;
|
||||
exports.boolean = boolean;
|
||||
exports.bigint = bigint;
|
||||
exports.date = date;
|
||||
const core = __importStar(require("../core/index.cjs"));
|
||||
const schemas = __importStar(require("./schemas.cjs"));
|
||||
function string(params) {
|
||||
return core._coercedString(schemas.ZodString, params);
|
||||
}
|
||||
function number(params) {
|
||||
return core._coercedNumber(schemas.ZodNumber, params);
|
||||
}
|
||||
function boolean(params) {
|
||||
return core._coercedBoolean(schemas.ZodBoolean, params);
|
||||
}
|
||||
function bigint(params) {
|
||||
return core._coercedBigint(schemas.ZodBigInt, params);
|
||||
}
|
||||
function date(params) {
|
||||
return core._coercedDate(schemas.ZodDate, params);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
# Installation
|
||||
> `npm install --save @types/uuid`
|
||||
|
||||
# Summary
|
||||
This package contains type definitions for uuid (https://github.com/uuidjs/uuid).
|
||||
|
||||
# Details
|
||||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/uuid.
|
||||
|
||||
### Additional Details
|
||||
* Last updated: Thu, 20 Jun 2024 21:07:25 GMT
|
||||
* Dependencies: none
|
||||
|
||||
# Credits
|
||||
These definitions were written by [Oliver Hoffmann](https://github.com/iamolivinius), [Felipe Ochoa](https://github.com/felipeochoa), [Chris Barth](https://github.com/cjbarth), [Linus Unnebäck](https://github.com/LinusU), and [Christoph Tavan](https://github.com/ctavan).
|
||||
@@ -0,0 +1,81 @@
|
||||
'use strict';
|
||||
module.exports = function generate_contains(it, $keyword, $ruleType) {
|
||||
var out = ' ';
|
||||
var $lvl = it.level;
|
||||
var $dataLvl = it.dataLevel;
|
||||
var $schema = it.schema[$keyword];
|
||||
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
||||
var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
|
||||
var $breakOnError = !it.opts.allErrors;
|
||||
var $data = 'data' + ($dataLvl || '');
|
||||
var $valid = 'valid' + $lvl;
|
||||
var $errs = 'errs__' + $lvl;
|
||||
var $it = it.util.copy(it);
|
||||
var $closingBraces = '';
|
||||
$it.level++;
|
||||
var $nextValid = 'valid' + $it.level;
|
||||
var $idx = 'i' + $lvl,
|
||||
$dataNxt = $it.dataLevel = it.dataLevel + 1,
|
||||
$nextData = 'data' + $dataNxt,
|
||||
$currentBaseId = it.baseId,
|
||||
$nonEmptySchema = (it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all));
|
||||
out += 'var ' + ($errs) + ' = errors;var ' + ($valid) + ';';
|
||||
if ($nonEmptySchema) {
|
||||
var $wasComposite = it.compositeRule;
|
||||
it.compositeRule = $it.compositeRule = true;
|
||||
$it.schema = $schema;
|
||||
$it.schemaPath = $schemaPath;
|
||||
$it.errSchemaPath = $errSchemaPath;
|
||||
out += ' var ' + ($nextValid) + ' = false; for (var ' + ($idx) + ' = 0; ' + ($idx) + ' < ' + ($data) + '.length; ' + ($idx) + '++) { ';
|
||||
$it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
|
||||
var $passData = $data + '[' + $idx + ']';
|
||||
$it.dataPathArr[$dataNxt] = $idx;
|
||||
var $code = it.validate($it);
|
||||
$it.baseId = $currentBaseId;
|
||||
if (it.util.varOccurences($code, $nextData) < 2) {
|
||||
out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
|
||||
} else {
|
||||
out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
|
||||
}
|
||||
out += ' if (' + ($nextValid) + ') break; } ';
|
||||
it.compositeRule = $it.compositeRule = $wasComposite;
|
||||
out += ' ' + ($closingBraces) + ' if (!' + ($nextValid) + ') {';
|
||||
} else {
|
||||
out += ' if (' + ($data) + '.length == 0) {';
|
||||
}
|
||||
var $$outStack = $$outStack || [];
|
||||
$$outStack.push(out);
|
||||
out = ''; /* istanbul ignore else */
|
||||
if (it.createErrors !== false) {
|
||||
out += ' { keyword: \'' + ('contains') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
|
||||
if (it.opts.messages !== false) {
|
||||
out += ' , message: \'should contain a valid item\' ';
|
||||
}
|
||||
if (it.opts.verbose) {
|
||||
out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
|
||||
}
|
||||
out += ' } ';
|
||||
} else {
|
||||
out += ' {} ';
|
||||
}
|
||||
var __err = out;
|
||||
out = $$outStack.pop();
|
||||
if (!it.compositeRule && $breakOnError) {
|
||||
/* istanbul ignore if */
|
||||
if (it.async) {
|
||||
out += ' throw new ValidationError([' + (__err) + ']); ';
|
||||
} else {
|
||||
out += ' validate.errors = [' + (__err) + ']; return false; ';
|
||||
}
|
||||
} else {
|
||||
out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
|
||||
}
|
||||
out += ' } else { ';
|
||||
if ($nonEmptySchema) {
|
||||
out += ' errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } ';
|
||||
}
|
||||
if (it.opts.allErrors) {
|
||||
out += ' } ';
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
export declare namespace Touch {
|
||||
const None: 0;
|
||||
const First: 1;
|
||||
const AsOld: 1;
|
||||
const Last: 2;
|
||||
const AsNew: 2;
|
||||
}
|
||||
export type Touch = 0 | 1 | 2;
|
||||
export declare class LinkedMap<K, V> {
|
||||
readonly [Symbol.toStringTag] = "LinkedMap";
|
||||
private _map;
|
||||
private _head;
|
||||
private _tail;
|
||||
private _size;
|
||||
private _state;
|
||||
constructor();
|
||||
clear(): void;
|
||||
isEmpty(): boolean;
|
||||
get size(): number;
|
||||
get first(): V | undefined;
|
||||
get last(): V | undefined;
|
||||
before(key: K): V | undefined;
|
||||
after(key: K): V | undefined;
|
||||
has(key: K): boolean;
|
||||
get(key: K, touch?: Touch): V | undefined;
|
||||
set(key: K, value: V, touch?: Touch): this;
|
||||
delete(key: K): boolean;
|
||||
remove(key: K): V | undefined;
|
||||
shift(): V | undefined;
|
||||
forEach(callbackfn: (value: V, key: K, map: LinkedMap<K, V>) => void, thisArg?: any): void;
|
||||
keys(): IterableIterator<K>;
|
||||
values(): IterableIterator<V>;
|
||||
entries(): IterableIterator<[K, V]>;
|
||||
[Symbol.iterator](): IterableIterator<[K, V]>;
|
||||
protected trimOld(newSize: number): void;
|
||||
private addItemFirst;
|
||||
private addItemLast;
|
||||
private removeItem;
|
||||
private touch;
|
||||
toJSON(): [K, V][];
|
||||
fromJSON(data: [K, V][]): void;
|
||||
}
|
||||
export declare class LRUCache<K, V> extends LinkedMap<K, V> {
|
||||
private _limit;
|
||||
private _ratio;
|
||||
constructor(limit: number, ratio?: number);
|
||||
get limit(): number;
|
||||
set limit(limit: number);
|
||||
get ratio(): number;
|
||||
set ratio(ratio: number);
|
||||
get(key: K, touch?: Touch): V | undefined;
|
||||
peek(key: K): V | undefined;
|
||||
set(key: K, value: V): this;
|
||||
private checkTrim;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// RUN THE FOLLOWING COMMAND FROM THE WORKSPACE ROOT TO REGENERATE:
|
||||
// npx nx generate-lib repo
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.decorators_legacy = void 0;
|
||||
const base_config_1 = require("./base-config");
|
||||
exports.decorators_legacy = {
|
||||
libs: [],
|
||||
variables: [
|
||||
['ClassDecorator', base_config_1.TYPE],
|
||||
['PropertyDecorator', base_config_1.TYPE],
|
||||
['MethodDecorator', base_config_1.TYPE],
|
||||
['ParameterDecorator', base_config_1.TYPE],
|
||||
],
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,3 @@
|
||||
# pg-protocol
|
||||
|
||||
Low level postgres wire protocol parser and serializer written in Typescript. Used by node-postgres. Needs more documentation. :smile:
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "shebang-regex",
|
||||
"version": "3.0.0",
|
||||
"description": "Regular expression for matching a shebang line",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/shebang-regex",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"regex",
|
||||
"regexp",
|
||||
"shebang",
|
||||
"match",
|
||||
"test",
|
||||
"line"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,241 @@
|
||||
'use strict'
|
||||
/* eslint no-prototype-builtins: 0 */
|
||||
const {
|
||||
lsCacheSym,
|
||||
levelValSym,
|
||||
useOnlyCustomLevelsSym,
|
||||
streamSym,
|
||||
formattersSym,
|
||||
hooksSym,
|
||||
levelCompSym
|
||||
} = require('./symbols')
|
||||
const { noop, genLog } = require('./tools')
|
||||
const { DEFAULT_LEVELS, SORTING_ORDER } = require('./constants')
|
||||
|
||||
const levelMethods = {
|
||||
fatal: (hook) => {
|
||||
const logFatal = genLog(DEFAULT_LEVELS.fatal, hook)
|
||||
return function (...args) {
|
||||
const stream = this[streamSym]
|
||||
logFatal.call(this, ...args)
|
||||
if (typeof stream.flushSync === 'function') {
|
||||
try {
|
||||
stream.flushSync()
|
||||
} catch (e) {
|
||||
// https://github.com/pinojs/pino/pull/740#discussion_r346788313
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
error: (hook) => genLog(DEFAULT_LEVELS.error, hook),
|
||||
warn: (hook) => genLog(DEFAULT_LEVELS.warn, hook),
|
||||
info: (hook) => genLog(DEFAULT_LEVELS.info, hook),
|
||||
debug: (hook) => genLog(DEFAULT_LEVELS.debug, hook),
|
||||
trace: (hook) => genLog(DEFAULT_LEVELS.trace, hook)
|
||||
}
|
||||
|
||||
const nums = Object.keys(DEFAULT_LEVELS).reduce((o, k) => {
|
||||
o[DEFAULT_LEVELS[k]] = k
|
||||
return o
|
||||
}, {})
|
||||
|
||||
const initialLsCache = Object.keys(nums).reduce((o, k) => {
|
||||
o[k] = '{"level":' + Number(k)
|
||||
return o
|
||||
}, {})
|
||||
|
||||
function genLsCache (instance) {
|
||||
const formatter = instance[formattersSym].level
|
||||
const { labels } = instance.levels
|
||||
const cache = {}
|
||||
for (const label in labels) {
|
||||
const level = formatter(labels[label], Number(label))
|
||||
cache[label] = JSON.stringify(level).slice(0, -1)
|
||||
}
|
||||
instance[lsCacheSym] = cache
|
||||
return instance
|
||||
}
|
||||
|
||||
function isStandardLevel (level, useOnlyCustomLevels) {
|
||||
if (useOnlyCustomLevels) {
|
||||
return false
|
||||
}
|
||||
|
||||
switch (level) {
|
||||
case 'fatal':
|
||||
case 'error':
|
||||
case 'warn':
|
||||
case 'info':
|
||||
case 'debug':
|
||||
case 'trace':
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function setLevel (level) {
|
||||
const { labels, values } = this.levels
|
||||
if (typeof level === 'number') {
|
||||
if (labels[level] === undefined) throw Error('unknown level value' + level)
|
||||
level = labels[level]
|
||||
}
|
||||
if (values[level] === undefined) throw Error('unknown level ' + level)
|
||||
const preLevelVal = this[levelValSym]
|
||||
const levelVal = this[levelValSym] = values[level]
|
||||
const useOnlyCustomLevelsVal = this[useOnlyCustomLevelsSym]
|
||||
const levelComparison = this[levelCompSym]
|
||||
const hook = this[hooksSym].logMethod
|
||||
|
||||
for (const key in values) {
|
||||
if (levelComparison(values[key], levelVal) === false) {
|
||||
this[key] = noop
|
||||
continue
|
||||
}
|
||||
this[key] = isStandardLevel(key, useOnlyCustomLevelsVal) ? levelMethods[key](hook) : genLog(values[key], hook)
|
||||
}
|
||||
|
||||
this.emit(
|
||||
'level-change',
|
||||
level,
|
||||
levelVal,
|
||||
labels[preLevelVal],
|
||||
preLevelVal,
|
||||
this
|
||||
)
|
||||
}
|
||||
|
||||
function getLevel (level) {
|
||||
const { levels, levelVal } = this
|
||||
// protection against potential loss of Pino scope from serializers (edge case with circular refs - https://github.com/pinojs/pino/issues/833)
|
||||
return (levels && levels.labels) ? levels.labels[levelVal] : ''
|
||||
}
|
||||
|
||||
function isLevelEnabled (logLevel) {
|
||||
const { values } = this.levels
|
||||
const logLevelVal = values[logLevel]
|
||||
return logLevelVal !== undefined && this[levelCompSym](logLevelVal, this[levelValSym])
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given `current` level is enabled by comparing it
|
||||
* against the current threshold (`expected`).
|
||||
*
|
||||
* @param {SORTING_ORDER} direction comparison direction "ASC" or "DESC"
|
||||
* @param {number} current current log level number representation
|
||||
* @param {number} expected threshold value to compare with
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function compareLevel (direction, current, expected) {
|
||||
if (direction === SORTING_ORDER.DESC) {
|
||||
return current <= expected
|
||||
}
|
||||
|
||||
return current >= expected
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a level comparison function based on `levelComparison`
|
||||
* it could a default function which compares levels either in "ascending" or "descending" order or custom comparison function
|
||||
*
|
||||
* @param {SORTING_ORDER | Function} levelComparison sort levels order direction or custom comparison function
|
||||
* @returns Function
|
||||
*/
|
||||
function genLevelComparison (levelComparison) {
|
||||
if (typeof levelComparison === 'string') {
|
||||
return compareLevel.bind(null, levelComparison)
|
||||
}
|
||||
|
||||
return levelComparison
|
||||
}
|
||||
|
||||
function mappings (customLevels = null, useOnlyCustomLevels = false) {
|
||||
const customNums = customLevels
|
||||
/* eslint-disable */
|
||||
? Object.keys(customLevels).reduce((o, k) => {
|
||||
o[customLevels[k]] = k
|
||||
return o
|
||||
}, {})
|
||||
: null
|
||||
/* eslint-enable */
|
||||
|
||||
const labels = Object.assign(
|
||||
Object.create(Object.prototype, { Infinity: { value: 'silent' } }),
|
||||
useOnlyCustomLevels ? null : nums,
|
||||
customNums
|
||||
)
|
||||
const values = Object.assign(
|
||||
Object.create(Object.prototype, { silent: { value: Infinity } }),
|
||||
useOnlyCustomLevels ? null : DEFAULT_LEVELS,
|
||||
customLevels
|
||||
)
|
||||
return { labels, values }
|
||||
}
|
||||
|
||||
function assertDefaultLevelFound (defaultLevel, customLevels, useOnlyCustomLevels) {
|
||||
if (typeof defaultLevel === 'number') {
|
||||
const values = [].concat(
|
||||
Object.keys(customLevels || {}).map(key => customLevels[key]),
|
||||
useOnlyCustomLevels ? [] : Object.keys(nums).map(level => +level),
|
||||
Infinity
|
||||
)
|
||||
if (!values.includes(defaultLevel)) {
|
||||
throw Error(`default level:${defaultLevel} must be included in custom levels`)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
const labels = Object.assign(
|
||||
Object.create(Object.prototype, { silent: { value: Infinity } }),
|
||||
useOnlyCustomLevels ? null : DEFAULT_LEVELS,
|
||||
customLevels
|
||||
)
|
||||
if (!(defaultLevel in labels)) {
|
||||
throw Error(`default level:${defaultLevel} must be included in custom levels`)
|
||||
}
|
||||
}
|
||||
|
||||
function assertNoLevelCollisions (levels, customLevels) {
|
||||
const { labels, values } = levels
|
||||
for (const k in customLevels) {
|
||||
if (k in values) {
|
||||
throw Error('levels cannot be overridden')
|
||||
}
|
||||
if (customLevels[k] in labels) {
|
||||
throw Error('pre-existing level values cannot be used for new levels')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates whether `levelComparison` is correct
|
||||
*
|
||||
* @throws Error
|
||||
* @param {SORTING_ORDER | Function} levelComparison - value to validate
|
||||
* @returns
|
||||
*/
|
||||
function assertLevelComparison (levelComparison) {
|
||||
if (typeof levelComparison === 'function') {
|
||||
return
|
||||
}
|
||||
|
||||
if (typeof levelComparison === 'string' && Object.values(SORTING_ORDER).includes(levelComparison)) {
|
||||
return
|
||||
}
|
||||
|
||||
throw new Error('Levels comparison should be one of "ASC", "DESC" or "function" type')
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
initialLsCache,
|
||||
genLsCache,
|
||||
levelMethods,
|
||||
getLevel,
|
||||
setLevel,
|
||||
isLevelEnabled,
|
||||
mappings,
|
||||
assertNoLevelCollisions,
|
||||
assertDefaultLevelFound,
|
||||
genLevelComparison,
|
||||
assertLevelComparison
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
/* eslint-disable @typescript-eslint/no-namespace, no-restricted-syntax */
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
@@ -0,0 +1,74 @@
|
||||
"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 });
|
||||
exports.isTypeBrandedLiteralLike = isTypeBrandedLiteralLike;
|
||||
const tsutils = __importStar(require("ts-api-utils"));
|
||||
const ts = __importStar(require("typescript"));
|
||||
function isLiteralOrTaggablePrimitiveLike(type) {
|
||||
return (type.isLiteral() ||
|
||||
tsutils.isTypeFlagSet(type, ts.TypeFlags.BigInt |
|
||||
ts.TypeFlags.Number |
|
||||
ts.TypeFlags.String |
|
||||
ts.TypeFlags.TemplateLiteral));
|
||||
}
|
||||
function isObjectLiteralLike(type) {
|
||||
return (!type.getCallSignatures().length &&
|
||||
!type.getConstructSignatures().length &&
|
||||
tsutils.isObjectType(type));
|
||||
}
|
||||
function isTypeBrandedLiteral(type) {
|
||||
if (!type.isIntersection()) {
|
||||
return false;
|
||||
}
|
||||
let hadObjectLike = false;
|
||||
let hadPrimitiveLike = false;
|
||||
for (const constituent of type.types) {
|
||||
if (isObjectLiteralLike(constituent)) {
|
||||
hadPrimitiveLike = true;
|
||||
}
|
||||
else if (isLiteralOrTaggablePrimitiveLike(constituent)) {
|
||||
hadObjectLike = true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return hadPrimitiveLike && hadObjectLike;
|
||||
}
|
||||
function isTypeBrandedLiteralLike(type) {
|
||||
return type.isUnion()
|
||||
? type.types.every(isTypeBrandedLiteral)
|
||||
: isTypeBrandedLiteral(type);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
Copyright (c) Elpheria j.d.o.o.
|
||||
|
||||
rpc-websockets is an Open Source project licensed under the terms of
|
||||
the LGPLv3 license. Please see <https://www.gnu.org/licenses/lgpl-3.0.html>
|
||||
for license text.
|
||||
|
||||
rpc-websockets Pro has a commercial-friendly license allowing private forks
|
||||
and modifications of rpc-websockets.
|
||||
Please see https://www.elpheria.com/products/rpc-websockets-pro.html
|
||||
or email us at info@elpheria.com for more detail.
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,116 @@
|
||||
/**
|
||||
* @fileoverview A rule to disallow duplicate name in class members.
|
||||
* @author Toru Nagashima
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const astUtils = require("./utils/ast-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../types').Rule.RuleModule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "problem",
|
||||
|
||||
docs: {
|
||||
description: "Disallow duplicate class members",
|
||||
dialects: ["JavaScript", "TypeScript"],
|
||||
recommended: true,
|
||||
url: "https://eslint.org/docs/latest/rules/no-dupe-class-members",
|
||||
},
|
||||
|
||||
schema: [],
|
||||
|
||||
messages: {
|
||||
unexpected: "Duplicate name '{{name}}'.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
let stack = [];
|
||||
|
||||
/**
|
||||
* Gets state of a given member name.
|
||||
* @param {string} name A name of a member.
|
||||
* @param {boolean} isStatic A flag which specifies that is a static member.
|
||||
* @returns {Object} A state of a given member name.
|
||||
* - retv.init {boolean} A flag which shows the name is declared as normal member.
|
||||
* - retv.get {boolean} A flag which shows the name is declared as getter.
|
||||
* - retv.set {boolean} A flag which shows the name is declared as setter.
|
||||
*/
|
||||
function getState(name, isStatic) {
|
||||
const stateMap = stack.at(-1);
|
||||
const key = `$${name}`; // to avoid "__proto__".
|
||||
|
||||
if (!stateMap[key]) {
|
||||
stateMap[key] = {
|
||||
nonStatic: { init: false, get: false, set: false },
|
||||
static: { init: false, get: false, set: false },
|
||||
};
|
||||
}
|
||||
|
||||
return stateMap[key][isStatic ? "static" : "nonStatic"];
|
||||
}
|
||||
|
||||
return {
|
||||
// Initializes the stack of state of member declarations.
|
||||
Program() {
|
||||
stack = [];
|
||||
},
|
||||
|
||||
// Initializes state of member declarations for the class.
|
||||
ClassBody() {
|
||||
stack.push(Object.create(null));
|
||||
},
|
||||
|
||||
// Disposes the state for the class.
|
||||
"ClassBody:exit"() {
|
||||
stack.pop();
|
||||
},
|
||||
|
||||
// Reports the node if its name has been declared already.
|
||||
"MethodDefinition, PropertyDefinition"(node) {
|
||||
if (
|
||||
node.value &&
|
||||
node.value.type === "TSEmptyBodyFunctionExpression"
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const name = astUtils.getStaticPropertyName(node);
|
||||
const kind =
|
||||
node.type === "MethodDefinition" ? node.kind : "field";
|
||||
|
||||
if (name === null || kind === "constructor") {
|
||||
return;
|
||||
}
|
||||
|
||||
const state = getState(name, node.static);
|
||||
let isDuplicate;
|
||||
|
||||
if (kind === "get") {
|
||||
isDuplicate = state.init || state.get;
|
||||
state.get = true;
|
||||
} else if (kind === "set") {
|
||||
isDuplicate = state.init || state.set;
|
||||
state.set = true;
|
||||
} else {
|
||||
isDuplicate = state.init || state.get || state.set;
|
||||
state.init = true;
|
||||
}
|
||||
|
||||
if (isDuplicate) {
|
||||
context.report({
|
||||
loc: node.key.loc,
|
||||
messageId: "unexpected",
|
||||
data: { name },
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,181 @@
|
||||
/**
|
||||
* @fileoverview A rule to set the maximum depth block can be nested in a function.
|
||||
* @author Ian Christian Myers
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../types').Rule.RuleModule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description: "Enforce a maximum depth that blocks can be nested",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/max-depth",
|
||||
},
|
||||
|
||||
schema: [
|
||||
{
|
||||
oneOf: [
|
||||
{
|
||||
type: "integer",
|
||||
minimum: 0,
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
maximum: {
|
||||
type: "integer",
|
||||
minimum: 0,
|
||||
},
|
||||
max: {
|
||||
type: "integer",
|
||||
minimum: 0,
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
defaultOptions: [4],
|
||||
|
||||
messages: {
|
||||
tooDeeply:
|
||||
"Blocks are nested too deeply ({{depth}}). Maximum allowed is {{maxDepth}}.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
const functionStack = [],
|
||||
option = context.options[0];
|
||||
let maxDepth = 4;
|
||||
|
||||
if (
|
||||
typeof option === "object" &&
|
||||
(Object.hasOwn(option, "maximum") || Object.hasOwn(option, "max"))
|
||||
) {
|
||||
maxDepth = option.maximum || option.max;
|
||||
}
|
||||
if (typeof option === "number") {
|
||||
maxDepth = option;
|
||||
}
|
||||
|
||||
/**
|
||||
* When parsing a new function, store it in our function stack
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
function startFunction() {
|
||||
functionStack.push(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* When parsing is done then pop out the reference
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
function endFunction() {
|
||||
functionStack.pop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the block and Evaluate the node
|
||||
* @param {ASTNode} node node to evaluate
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
function pushBlock(node) {
|
||||
const len = ++functionStack[functionStack.length - 1];
|
||||
|
||||
if (len > maxDepth) {
|
||||
context.report({
|
||||
node,
|
||||
loc: sourceCode.getFirstToken(node).loc,
|
||||
messageId: "tooDeeply",
|
||||
data: { depth: len, maxDepth },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pop the saved block
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
function popBlock() {
|
||||
functionStack[functionStack.length - 1]--;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a node is an else-if statement.
|
||||
* @param {ASTNode} node node to evaluate
|
||||
* @returns {boolean} Whether the node is an else-if statement
|
||||
*/
|
||||
function isElseIf(node) {
|
||||
return (
|
||||
node.parent.type === "IfStatement" &&
|
||||
node.parent.alternate === node
|
||||
);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Public API
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
return {
|
||||
Program: startFunction,
|
||||
FunctionDeclaration: startFunction,
|
||||
FunctionExpression: startFunction,
|
||||
ArrowFunctionExpression: startFunction,
|
||||
StaticBlock: startFunction,
|
||||
|
||||
IfStatement(node) {
|
||||
if (!isElseIf(node)) {
|
||||
pushBlock(node);
|
||||
}
|
||||
},
|
||||
SwitchStatement: pushBlock,
|
||||
TryStatement: pushBlock,
|
||||
DoWhileStatement: pushBlock,
|
||||
WhileStatement: pushBlock,
|
||||
WithStatement: pushBlock,
|
||||
ForStatement: pushBlock,
|
||||
ForInStatement: pushBlock,
|
||||
ForOfStatement: pushBlock,
|
||||
|
||||
"IfStatement:exit"(node) {
|
||||
if (!isElseIf(node)) {
|
||||
popBlock();
|
||||
}
|
||||
},
|
||||
"SwitchStatement:exit": popBlock,
|
||||
"TryStatement:exit": popBlock,
|
||||
"DoWhileStatement:exit": popBlock,
|
||||
"WhileStatement:exit": popBlock,
|
||||
"WithStatement:exit": popBlock,
|
||||
"ForStatement:exit": popBlock,
|
||||
"ForInStatement:exit": popBlock,
|
||||
"ForOfStatement:exit": popBlock,
|
||||
|
||||
"FunctionDeclaration:exit": endFunction,
|
||||
"FunctionExpression:exit": endFunction,
|
||||
"ArrowFunctionExpression:exit": endFunction,
|
||||
"StaticBlock:exit": endFunction,
|
||||
"Program:exit": endFunction,
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
# Installation
|
||||
> `npm install --save @types/pg`
|
||||
|
||||
# Summary
|
||||
This package contains type definitions for pg (https://github.com/brianc/node-postgres).
|
||||
|
||||
# Details
|
||||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/pg.
|
||||
|
||||
### Additional Details
|
||||
* Last updated: Fri, 07 Aug 2026 19:20:26 GMT
|
||||
* Dependencies: [@types/node](https://npmjs.com/package/@types/node), [pg-protocol](https://npmjs.com/package/pg-protocol), [pg-types](https://npmjs.com/package/pg-types)
|
||||
|
||||
# Credits
|
||||
These definitions were written by [Phips Peter](https://github.com/pspeter3).
|
||||
Reference in New Issue
Block a user