WIP: bootstrap and partial real Solana watcher implementation
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
let urlAlphabet =
|
||||
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
|
||||
|
||||
let customAlphabet = (alphabet, defaultSize = 21) => {
|
||||
return (size = defaultSize) => {
|
||||
let id = ''
|
||||
let i = size | 0
|
||||
while (i-- > 0) {
|
||||
id += alphabet[(Math.random() * alphabet.length) | 0]
|
||||
}
|
||||
return id
|
||||
}
|
||||
}
|
||||
|
||||
let nanoid = (size = 21) => {
|
||||
let id = ''
|
||||
let i = size | 0
|
||||
while (i-- > 0) {
|
||||
id += urlAlphabet[(Math.random() * 64) | 0]
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
export { nanoid, customAlphabet }
|
||||
@@ -0,0 +1,2 @@
|
||||
import type { LibDefinition } from '../variable';
|
||||
export declare const es2018_asyncgenerator: LibDefinition;
|
||||
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* @fileoverview A rule to suggest using of the spread operator instead of `.apply()`.
|
||||
* @author Toru Nagashima
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const astUtils = require("./utils/ast-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Checks whether or not a node is a `.apply()` for variadic.
|
||||
* @param {ASTNode} node A CallExpression node to check.
|
||||
* @returns {boolean} Whether or not the node is a `.apply()` for variadic.
|
||||
*/
|
||||
function isVariadicApplyCalling(node) {
|
||||
return (
|
||||
astUtils.isSpecificMemberAccess(node.callee, null, "apply") &&
|
||||
node.arguments.length === 2 &&
|
||||
node.arguments[1].type !== "ArrayExpression" &&
|
||||
node.arguments[1].type !== "SpreadElement"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether or not `thisArg` is not changed by `.apply()`.
|
||||
* @param {ASTNode|null} expectedThis The node that is the owner of the applied function.
|
||||
* @param {ASTNode} thisArg The node that is given to the first argument of the `.apply()`.
|
||||
* @param {RuleContext} context The ESLint rule context object.
|
||||
* @returns {boolean} Whether or not `thisArg` is not changed by `.apply()`.
|
||||
*/
|
||||
function isValidThisArg(expectedThis, thisArg, context) {
|
||||
if (!expectedThis) {
|
||||
return astUtils.isNullOrUndefined(thisArg);
|
||||
}
|
||||
return astUtils.equalTokens(expectedThis, thisArg, context);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../types').Rule.RuleModule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description: "Require spread operators instead of `.apply()`",
|
||||
recommended: false,
|
||||
frozen: true,
|
||||
url: "https://eslint.org/docs/latest/rules/prefer-spread",
|
||||
},
|
||||
|
||||
schema: [],
|
||||
fixable: null,
|
||||
|
||||
messages: {
|
||||
preferSpread: "Use the spread operator instead of '.apply()'.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
return {
|
||||
CallExpression(node) {
|
||||
if (!isVariadicApplyCalling(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const applied = astUtils.skipChainExpression(
|
||||
astUtils.skipChainExpression(node.callee).object,
|
||||
);
|
||||
const expectedThis =
|
||||
applied.type === "MemberExpression" ? applied.object : null;
|
||||
const thisArg = node.arguments[0];
|
||||
|
||||
if (isValidThisArg(expectedThis, thisArg, sourceCode)) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "preferSpread",
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @fileoverview Expose out ESLint and CLI to require.
|
||||
* @author Ian Christian Myers
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
const { ESLint } = require("./eslint/eslint");
|
||||
const { Linter } = require("./linter");
|
||||
const { RuleTester } = require("./rule-tester");
|
||||
const { SourceCode } = require("./languages/js/source-code");
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Functions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Loads the correct `ESLint` constructor.
|
||||
* @returns {Promise<ESLint>} The ESLint constructor.
|
||||
*/
|
||||
async function loadESLint() {
|
||||
return ESLint;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Exports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
module.exports = {
|
||||
Linter,
|
||||
loadESLint,
|
||||
ESLint,
|
||||
RuleTester,
|
||||
SourceCode,
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"main": "../../cjs/_object_spread.cjs",
|
||||
"module": "../../esm/_object_spread.js"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
function _extends() {
|
||||
return module.exports = _extends = Object.assign ? Object.assign.bind() : function (n) {
|
||||
for (var e = 1; e < arguments.length; e++) {
|
||||
var t = arguments[e];
|
||||
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
||||
}
|
||||
return n;
|
||||
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _extends.apply(null, arguments);
|
||||
}
|
||||
module.exports = _extends, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,153 @@
|
||||
/**
|
||||
* @fileoverview Stylish reporter
|
||||
* @author Sindre Sorhus
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const util = require("node:util"),
|
||||
table = require("../../shared/text-table");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns a styling function based on the color option.
|
||||
* @param {boolean|undefined} color Indicates whether to use colors.
|
||||
* @returns {Function} A function that styles text.
|
||||
*/
|
||||
function getStyleText(color) {
|
||||
if (typeof color === "undefined") {
|
||||
return (format, text) =>
|
||||
util.styleText(format, text, { validateStream: true });
|
||||
}
|
||||
if (color) {
|
||||
return (format, text) =>
|
||||
util.styleText(format, text, { validateStream: false });
|
||||
}
|
||||
return (_, text) => text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a word and a count, append an s if count is not one.
|
||||
* @param {string} word A word in its singular form.
|
||||
* @param {number} count A number controlling whether word should be pluralized.
|
||||
* @returns {string} The original word with an s on the end if count is not one.
|
||||
*/
|
||||
function pluralize(word, count) {
|
||||
return count === 1 ? word : `${word}s`;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public Interface
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
module.exports = function (results, data) {
|
||||
const styleText = getStyleText(data?.color);
|
||||
|
||||
let output = "\n",
|
||||
errorCount = 0,
|
||||
warningCount = 0,
|
||||
fixableErrorCount = 0,
|
||||
fixableWarningCount = 0,
|
||||
summaryColor = "yellow";
|
||||
|
||||
results.forEach(result => {
|
||||
const messages = result.messages;
|
||||
|
||||
if (messages.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
errorCount += result.errorCount;
|
||||
warningCount += result.warningCount;
|
||||
fixableErrorCount += result.fixableErrorCount;
|
||||
fixableWarningCount += result.fixableWarningCount;
|
||||
|
||||
output += `${styleText("underline", result.filePath)}\n`;
|
||||
|
||||
output += `${table(
|
||||
messages.map(message => {
|
||||
let messageType;
|
||||
|
||||
if (message.fatal || message.severity === 2) {
|
||||
messageType = styleText("red", "error");
|
||||
summaryColor = "red";
|
||||
} else {
|
||||
messageType = styleText("yellow", "warning");
|
||||
}
|
||||
|
||||
return [
|
||||
"",
|
||||
String(message.line || 0),
|
||||
String(message.column || 0),
|
||||
messageType,
|
||||
message.message.replace(/([^ ])\.$/u, "$1"),
|
||||
message.ruleId ? styleText("dim", message.ruleId) : "",
|
||||
];
|
||||
}),
|
||||
{
|
||||
align: ["", "r", "l"],
|
||||
stringLength(str) {
|
||||
return util.stripVTControlCharacters(str).length;
|
||||
},
|
||||
},
|
||||
)
|
||||
.split("\n")
|
||||
.map(el =>
|
||||
el.replace(/(\d+)\s+(\d+)/u, (m, p1, p2) =>
|
||||
styleText("dim", `${p1}:${p2}`),
|
||||
),
|
||||
)
|
||||
.join("\n")}\n\n`;
|
||||
});
|
||||
|
||||
const total = errorCount + warningCount;
|
||||
|
||||
/*
|
||||
* We can't use a single `styleText` call like `styleText([summaryColor, "bold"], text)` here.
|
||||
* This is a bug in `util.styleText` in Node.js versions earlier than v22.15.0 (https://github.com/nodejs/node/issues/56717).
|
||||
* As a workaround, we use nested `styleText` calls.
|
||||
*/
|
||||
if (total > 0) {
|
||||
output += `${styleText(
|
||||
summaryColor,
|
||||
styleText(
|
||||
"bold",
|
||||
[
|
||||
"\u2716 ",
|
||||
total,
|
||||
pluralize(" problem", total),
|
||||
" (",
|
||||
errorCount,
|
||||
pluralize(" error", errorCount),
|
||||
", ",
|
||||
warningCount,
|
||||
pluralize(" warning", warningCount),
|
||||
")",
|
||||
].join(""),
|
||||
),
|
||||
)}\n`;
|
||||
|
||||
if (fixableErrorCount > 0 || fixableWarningCount > 0) {
|
||||
output += `${styleText(
|
||||
summaryColor,
|
||||
styleText(
|
||||
"bold",
|
||||
[
|
||||
" ",
|
||||
fixableErrorCount,
|
||||
pluralize(" error", fixableErrorCount),
|
||||
" and ",
|
||||
fixableWarningCount,
|
||||
pluralize(" warning", fixableWarningCount),
|
||||
" potentially fixable with the `--fix` option.",
|
||||
].join(""),
|
||||
),
|
||||
)}\n`;
|
||||
}
|
||||
}
|
||||
|
||||
// Resets output color, for prevent change on top level
|
||||
return total > 0 ? styleText("reset", output) : "";
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
const e=globalThis.process?.env||Object.create(null),t=globalThis.process||{env:e},n=t!==void 0&&t.env&&t.env.NODE_ENV||void 0,r=[[`claude`,[`CLAUDECODE`,`CLAUDE_CODE`]],[`replit`,[`REPL_ID`]],[`gemini`,[`GEMINI_CLI`]],[`codex`,[`CODEX_SANDBOX`,`CODEX_THREAD_ID`]],[`opencode`,[`OPENCODE`]],[`pi`,[i(`PATH`,/\.pi[\\/]agent/)]],[`auggie`,[`AUGMENT_AGENT`]],[`goose`,[`GOOSE_PROVIDER`]],[`junie`,[`JUNIE_DATA`,`JUNIE_SHIM_PATH`]],[`devin`,[i(`EDITOR`,/devin/)]],[`cursor`,[`CURSOR_AGENT`]],[`kiro`,[i(`TERM_PROGRAM`,/kiro/,{noTTY:!0})]]];function i(n,r,i){return()=>{if(i?.noTTY&&t.stdout?.isTTY)return!1;let a=e[n];return a?r.test(a):!1}}function a(){let t=e.AI_AGENT;if(t)return{name:t.toLowerCase()};for(let[t,n]of r)for(let r of n)if(typeof r==`string`?e[r]:r())return{name:t};return{}}const o=a(),s=o.name,c=!!o.name,l=[[`APPVEYOR`],[`AWS_AMPLIFY`,`AWS_APP_ID`,{ci:!0}],[`AZURE_PIPELINES`,`SYSTEM_TEAMFOUNDATIONCOLLECTIONURI`],[`AZURE_STATIC`,`INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN`],[`APPCIRCLE`,`AC_APPCIRCLE`],[`BAMBOO`,`bamboo_planKey`],[`BITBUCKET`,`BITBUCKET_COMMIT`],[`BITRISE`,`BITRISE_IO`],[`BUDDY`,`BUDDY_WORKSPACE_ID`],[`BUILDKITE`],[`CIRCLE`,`CIRCLECI`],[`CIRRUS`,`CIRRUS_CI`],[`CLOUDFLARE_PAGES`,`CF_PAGES`,{ci:!0}],[`CLOUDFLARE_WORKERS`,`WORKERS_CI`,{ci:!0}],[`GOOGLE_CLOUDRUN`,`K_SERVICE`],[`GOOGLE_CLOUDRUN_JOB`,`CLOUD_RUN_JOB`],[`CODEBUILD`,`CODEBUILD_BUILD_ARN`],[`CODEFRESH`,`CF_BUILD_ID`],[`DRONE`],[`DRONE`,`DRONE_BUILD_EVENT`],[`DSARI`],[`GITHUB_ACTIONS`],[`GITLAB`,`GITLAB_CI`],[`GITLAB`,`CI_MERGE_REQUEST_ID`],[`GOCD`,`GO_PIPELINE_LABEL`],[`LAYERCI`],[`JENKINS`,`JENKINS_URL`],[`HUDSON`,`HUDSON_URL`],[`MAGNUM`],[`NETLIFY`],[`NETLIFY`,`NETLIFY_LOCAL`,{ci:!1}],[`NEVERCODE`],[`RENDER`],[`SAIL`,`SAILCI`],[`SEMAPHORE`],[`SCREWDRIVER`],[`SHIPPABLE`],[`SOLANO`,`TDDIUM`],[`STRIDER`],[`TEAMCITY`,`TEAMCITY_VERSION`],[`TRAVIS`],[`VERCEL`,`NOW_BUILDER`],[`VERCEL`,`VERCEL`,{ci:!1}],[`VERCEL`,`VERCEL_ENV`,{ci:!1}],[`APPCENTER`,`APPCENTER_BUILD_ID`],[`CODESANDBOX`,`CODESANDBOX_SSE`,{ci:!1}],[`CODESANDBOX`,`CODESANDBOX_HOST`,{ci:!1}],[`STACKBLITZ`],[`STORMKIT`],[`CLEAVR`],[`ZEABUR`],[`CODESPHERE`,`CODESPHERE_APP_ID`,{ci:!0}],[`RAILWAY`,`RAILWAY_PROJECT_ID`],[`RAILWAY`,`RAILWAY_SERVICE_ID`],[`DENO-DEPLOY`,`DENO_DEPLOY`],[`DENO-DEPLOY`,`DENO_DEPLOYMENT_ID`],[`FIREBASE_APP_HOSTING`,`FIREBASE_APP_HOSTING`,{ci:!0}],[`EDGEONE_PAGES`,`EO_PAGES_CI`,{ci:!0}]];function u(){for(let t of l)if(e[t[1]||t[0]])return{name:t[0].toLowerCase(),...t[2]};return e.SHELL===`/bin/jsh`&&t.versions?.webcontainer?{name:`stackblitz`,ci:!1}:{name:``,ci:!1}}const d=u(),f=d.name,p=t.platform||``,m=!!e.CI||d.ci!==!1,h=!!t.stdout?.isTTY,g=typeof window<`u`,_=!!e.DEBUG,v=n===`test`||!!e.TEST,y=n===`production`||e.MODE===`production`,b=n===`dev`||n===`development`||e.MODE===`development`,x=!!e.MINIMAL||m||v||!h,S=/^win/i.test(p),C=/^linux/i.test(p),w=/^darwin/i.test(p),T=!e.NO_COLOR&&(!!e.FORCE_COLOR||(h||S)&&e.TERM!==`dumb`||m),E=(t.versions?.node||``).replace(/^v/,``)||null,D=Number(E?.split(`.`)[0])||null,O=!!t?.versions?.node,k=`Bun`in globalThis,A=`Deno`in globalThis,j=`fastly`in globalThis,M=`Netlify`in globalThis,N=`EdgeRuntime`in globalThis,P=globalThis.navigator?.userAgent===`Cloudflare-Workers`,F=[[M,`netlify`],[N,`edge-light`],[P,`workerd`],[j,`fastly`],[A,`deno`],[k,`bun`],[O,`node`]];function I(){let e=F.find(e=>e[0]);if(e)return{name:e[1]}}const L=I(),R=L?.name||``;export{s as agent,o as agentInfo,a as detectAgent,u as detectProvider,e as env,h as hasTTY,g as hasWindow,c as isAgent,k as isBun,m as isCI,T as isColorSupported,_ as isDebug,A as isDeno,b as isDevelopment,N as isEdgeLight,j as isFastly,C as isLinux,w as isMacOS,x as isMinimal,M as isNetlify,O as isNode,y as isProduction,v as isTest,S as isWindows,P as isWorkerd,n as nodeENV,D as nodeMajorVersion,E as nodeVersion,p as platform,t as process,f as provider,d as providerInfo,R as runtime,L as runtimeInfo};
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"blake2s.d.ts","sourceRoot":"","sources":["src/blake2s.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,GAAG,IAAI,KAAK,EAAE,GAAG,IAAI,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,OAAO,IAAI,GAAG,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AACrF,+DAA+D;AAC/D,eAAO,MAAM,MAAM,EAAE,WAAuB,CAAC;AAC7C,+DAA+D;AAC/D,eAAO,MAAM,GAAG,EAAE,OAAO,KAAa,CAAC;AACvC,+DAA+D;AAC/D,eAAO,MAAM,GAAG,EAAE,OAAO,KAAa,CAAC;AACvC,+DAA+D;AAC/D,eAAO,MAAM,QAAQ,EAAE,OAAO,UAAuB,CAAC;AACtD,+DAA+D;AAC/D,eAAO,MAAM,OAAO,EAAE,OAAO,GAAS,CAAC;AACvC,+DAA+D;AAC/D,eAAO,MAAM,OAAO,EAAE,OAAO,GAAS,CAAC"}
|
||||
@@ -0,0 +1,70 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Pooya Parsa <pooya@pi0.io> - Daniel Roe <daniel@roe.dev>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
---
|
||||
|
||||
Copyright Joyent, Inc. and other Node contributors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
---
|
||||
|
||||
Bundled zeptomatch (https://github.com/fabiospampinato/zeptomatch)
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2023-present Fabio Spampinato
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,325 @@
|
||||
import * as checks from "./checks.cjs";
|
||||
import type * as core from "./core.cjs";
|
||||
import type * as errors from "./errors.cjs";
|
||||
import * as registries from "./registries.cjs";
|
||||
import * as schemas from "./schemas.cjs";
|
||||
import * as util from "./util.cjs";
|
||||
export type Params<T extends schemas.$ZodType | checks.$ZodCheck, IssueTypes extends errors.$ZodIssueBase, OmitKeys extends keyof T["_zod"]["def"] = never> = util.Flatten<Partial<util.EmptyToNever<Omit<T["_zod"]["def"], OmitKeys> & ([IssueTypes] extends [never] ? {} : {
|
||||
error?: string | errors.$ZodErrorMap<IssueTypes> | undefined;
|
||||
/** @deprecated This parameter is deprecated. Use `error` instead. */
|
||||
message?: string | undefined;
|
||||
})>>>;
|
||||
export type TypeParams<T extends schemas.$ZodType = schemas.$ZodType & {
|
||||
_isst: never;
|
||||
}, AlsoOmit extends Exclude<keyof T["_zod"]["def"], "type" | "checks" | "error"> = never> = Params<T, NonNullable<T["_zod"]["isst"]>, "type" | "checks" | "error" | AlsoOmit>;
|
||||
export type CheckParams<T extends checks.$ZodCheck = checks.$ZodCheck, // & { _issc: never },
|
||||
AlsoOmit extends Exclude<keyof T["_zod"]["def"], "check" | "error"> = never> = Params<T, NonNullable<T["_zod"]["issc"]>, "check" | "error" | AlsoOmit>;
|
||||
export type StringFormatParams<T extends schemas.$ZodStringFormat = schemas.$ZodStringFormat, AlsoOmit extends Exclude<keyof T["_zod"]["def"], "type" | "coerce" | "checks" | "error" | "check" | "format"> = never> = Params<T, NonNullable<T["_zod"]["isst"] | T["_zod"]["issc"]>, "type" | "coerce" | "checks" | "error" | "check" | "format" | AlsoOmit>;
|
||||
export type CheckStringFormatParams<T extends schemas.$ZodStringFormat = schemas.$ZodStringFormat, AlsoOmit extends Exclude<keyof T["_zod"]["def"], "type" | "coerce" | "checks" | "error" | "check" | "format"> = never> = Params<T, NonNullable<T["_zod"]["issc"]>, "type" | "coerce" | "checks" | "error" | "check" | "format" | AlsoOmit>;
|
||||
export type CheckTypeParams<T extends schemas.$ZodType & checks.$ZodCheck = schemas.$ZodType & checks.$ZodCheck, AlsoOmit extends Exclude<keyof T["_zod"]["def"], "type" | "checks" | "error" | "check"> = never> = Params<T, NonNullable<T["_zod"]["isst"] | T["_zod"]["issc"]>, "type" | "checks" | "error" | "check" | AlsoOmit>;
|
||||
export type $ZodStringParams = TypeParams<schemas.$ZodString<string>, "coerce">;
|
||||
export declare function _string<T extends schemas.$ZodString>(Class: util.SchemaClass<T>, params?: string | $ZodStringParams): T;
|
||||
export declare function _coercedString<T extends schemas.$ZodString>(Class: util.SchemaClass<T>, params?: string | $ZodStringParams): T;
|
||||
export type $ZodStringFormatParams = CheckTypeParams<schemas.$ZodStringFormat, "format" | "coerce" | "when" | "pattern">;
|
||||
export type $ZodCheckStringFormatParams = CheckParams<checks.$ZodCheckStringFormat, "format">;
|
||||
export type $ZodEmailParams = StringFormatParams<schemas.$ZodEmail, "when">;
|
||||
export type $ZodCheckEmailParams = CheckStringFormatParams<schemas.$ZodEmail, "when">;
|
||||
export declare function _email<T extends schemas.$ZodEmail>(Class: util.SchemaClass<T>, params?: string | $ZodEmailParams | $ZodCheckEmailParams): T;
|
||||
export type $ZodGUIDParams = StringFormatParams<schemas.$ZodGUID, "pattern" | "when">;
|
||||
export type $ZodCheckGUIDParams = CheckStringFormatParams<schemas.$ZodGUID, "pattern" | "when">;
|
||||
export declare function _guid<T extends schemas.$ZodGUID>(Class: util.SchemaClass<T>, params?: string | $ZodGUIDParams | $ZodCheckGUIDParams): T;
|
||||
export type $ZodUUIDParams = StringFormatParams<schemas.$ZodUUID, "pattern" | "when">;
|
||||
export type $ZodCheckUUIDParams = CheckStringFormatParams<schemas.$ZodUUID, "pattern" | "when">;
|
||||
export declare function _uuid<T extends schemas.$ZodUUID>(Class: util.SchemaClass<T>, params?: string | $ZodUUIDParams | $ZodCheckUUIDParams): T;
|
||||
export type $ZodUUIDv4Params = StringFormatParams<schemas.$ZodUUID, "pattern" | "when">;
|
||||
export type $ZodCheckUUIDv4Params = CheckStringFormatParams<schemas.$ZodUUID, "pattern" | "when">;
|
||||
export declare function _uuidv4<T extends schemas.$ZodUUID>(Class: util.SchemaClass<T>, params?: string | $ZodUUIDv4Params | $ZodCheckUUIDv4Params): T;
|
||||
export type $ZodUUIDv6Params = StringFormatParams<schemas.$ZodUUID, "pattern" | "when">;
|
||||
export type $ZodCheckUUIDv6Params = CheckStringFormatParams<schemas.$ZodUUID, "pattern" | "when">;
|
||||
export declare function _uuidv6<T extends schemas.$ZodUUID>(Class: util.SchemaClass<T>, params?: string | $ZodUUIDv6Params | $ZodCheckUUIDv6Params): T;
|
||||
export type $ZodUUIDv7Params = StringFormatParams<schemas.$ZodUUID, "pattern" | "when">;
|
||||
export type $ZodCheckUUIDv7Params = CheckStringFormatParams<schemas.$ZodUUID, "pattern" | "when">;
|
||||
export declare function _uuidv7<T extends schemas.$ZodUUID>(Class: util.SchemaClass<T>, params?: string | $ZodUUIDv7Params | $ZodCheckUUIDv7Params): T;
|
||||
export type $ZodURLParams = StringFormatParams<schemas.$ZodURL, "when">;
|
||||
export type $ZodCheckURLParams = CheckStringFormatParams<schemas.$ZodURL, "when">;
|
||||
export declare function _url<T extends schemas.$ZodURL>(Class: util.SchemaClass<T>, params?: string | $ZodURLParams | $ZodCheckURLParams): T;
|
||||
export type $ZodEmojiParams = StringFormatParams<schemas.$ZodEmoji, "when">;
|
||||
export type $ZodCheckEmojiParams = CheckStringFormatParams<schemas.$ZodEmoji, "when">;
|
||||
export declare function _emoji<T extends schemas.$ZodEmoji>(Class: util.SchemaClass<T>, params?: string | $ZodEmojiParams | $ZodCheckEmojiParams): T;
|
||||
export type $ZodNanoIDParams = StringFormatParams<schemas.$ZodNanoID, "when">;
|
||||
export type $ZodCheckNanoIDParams = CheckStringFormatParams<schemas.$ZodNanoID, "when">;
|
||||
export declare function _nanoid<T extends schemas.$ZodNanoID>(Class: util.SchemaClass<T>, params?: string | $ZodNanoIDParams | $ZodCheckNanoIDParams): T;
|
||||
/**
|
||||
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
||||
* (timestamps embedded in the id). Use {@link _cuid2} instead.
|
||||
* See https://github.com/paralleldrive/cuid.
|
||||
*/
|
||||
export type $ZodCUIDParams = StringFormatParams<schemas.$ZodCUID, "when">;
|
||||
/**
|
||||
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
||||
* (timestamps embedded in the id). Use {@link _cuid2} instead.
|
||||
* See https://github.com/paralleldrive/cuid.
|
||||
*/
|
||||
export type $ZodCheckCUIDParams = CheckStringFormatParams<schemas.$ZodCUID, "when">;
|
||||
/**
|
||||
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
||||
* (timestamps embedded in the id). Use {@link _cuid2} instead.
|
||||
* See https://github.com/paralleldrive/cuid.
|
||||
*/
|
||||
export declare function _cuid<T extends schemas.$ZodCUID>(Class: util.SchemaClass<T>, params?: string | $ZodCUIDParams | $ZodCheckCUIDParams): T;
|
||||
export type $ZodCUID2Params = StringFormatParams<schemas.$ZodCUID2, "when">;
|
||||
export type $ZodCheckCUID2Params = CheckStringFormatParams<schemas.$ZodCUID2, "when">;
|
||||
export declare function _cuid2<T extends schemas.$ZodCUID2>(Class: util.SchemaClass<T>, params?: string | $ZodCUID2Params | $ZodCheckCUID2Params): T;
|
||||
export type $ZodULIDParams = StringFormatParams<schemas.$ZodULID, "when">;
|
||||
export type $ZodCheckULIDParams = CheckStringFormatParams<schemas.$ZodULID, "when">;
|
||||
export declare function _ulid<T extends schemas.$ZodULID>(Class: util.SchemaClass<T>, params?: string | $ZodULIDParams | $ZodCheckULIDParams): T;
|
||||
export type $ZodXIDParams = StringFormatParams<schemas.$ZodXID, "when">;
|
||||
export type $ZodCheckXIDParams = CheckStringFormatParams<schemas.$ZodXID, "when">;
|
||||
export declare function _xid<T extends schemas.$ZodXID>(Class: util.SchemaClass<T>, params?: string | $ZodXIDParams | $ZodCheckXIDParams): T;
|
||||
export type $ZodKSUIDParams = StringFormatParams<schemas.$ZodKSUID, "when">;
|
||||
export type $ZodCheckKSUIDParams = CheckStringFormatParams<schemas.$ZodKSUID, "when">;
|
||||
export declare function _ksuid<T extends schemas.$ZodKSUID>(Class: util.SchemaClass<T>, params?: string | $ZodKSUIDParams | $ZodCheckKSUIDParams): T;
|
||||
export type $ZodIPv4Params = StringFormatParams<schemas.$ZodIPv4, "pattern" | "when" | "version">;
|
||||
export type $ZodCheckIPv4Params = CheckStringFormatParams<schemas.$ZodIPv4, "pattern" | "when" | "version">;
|
||||
export declare function _ipv4<T extends schemas.$ZodIPv4>(Class: util.SchemaClass<T>, params?: string | $ZodIPv4Params | $ZodCheckIPv4Params): T;
|
||||
export type $ZodIPv6Params = StringFormatParams<schemas.$ZodIPv6, "pattern" | "when" | "version">;
|
||||
export type $ZodCheckIPv6Params = CheckStringFormatParams<schemas.$ZodIPv6, "pattern" | "when" | "version">;
|
||||
export declare function _ipv6<T extends schemas.$ZodIPv6>(Class: util.SchemaClass<T>, params?: string | $ZodIPv6Params | $ZodCheckIPv6Params): T;
|
||||
export type $ZodMACParams = StringFormatParams<schemas.$ZodMAC, "pattern" | "when">;
|
||||
export type $ZodCheckMACParams = CheckStringFormatParams<schemas.$ZodMAC, "pattern" | "when">;
|
||||
export declare function _mac<T extends schemas.$ZodMAC>(Class: util.SchemaClass<T>, params?: string | $ZodMACParams | $ZodCheckMACParams): T;
|
||||
export type $ZodCIDRv4Params = StringFormatParams<schemas.$ZodCIDRv4, "pattern" | "when">;
|
||||
export type $ZodCheckCIDRv4Params = CheckStringFormatParams<schemas.$ZodCIDRv4, "pattern" | "when">;
|
||||
export declare function _cidrv4<T extends schemas.$ZodCIDRv4>(Class: util.SchemaClass<T>, params?: string | $ZodCIDRv4Params | $ZodCheckCIDRv4Params): T;
|
||||
export type $ZodCIDRv6Params = StringFormatParams<schemas.$ZodCIDRv6, "pattern" | "when">;
|
||||
export type $ZodCheckCIDRv6Params = CheckStringFormatParams<schemas.$ZodCIDRv6, "pattern" | "when">;
|
||||
export declare function _cidrv6<T extends schemas.$ZodCIDRv6>(Class: util.SchemaClass<T>, params?: string | $ZodCIDRv6Params | $ZodCheckCIDRv6Params): T;
|
||||
export type $ZodBase64Params = StringFormatParams<schemas.$ZodBase64, "pattern" | "when">;
|
||||
export type $ZodCheckBase64Params = CheckStringFormatParams<schemas.$ZodBase64, "pattern" | "when">;
|
||||
export declare function _base64<T extends schemas.$ZodBase64>(Class: util.SchemaClass<T>, params?: string | $ZodBase64Params | $ZodCheckBase64Params): T;
|
||||
export type $ZodBase64URLParams = StringFormatParams<schemas.$ZodBase64URL, "pattern" | "when">;
|
||||
export type $ZodCheckBase64URLParams = CheckStringFormatParams<schemas.$ZodBase64URL, "pattern" | "when">;
|
||||
export declare function _base64url<T extends schemas.$ZodBase64URL>(Class: util.SchemaClass<T>, params?: string | $ZodBase64URLParams | $ZodCheckBase64URLParams): T;
|
||||
export type $ZodE164Params = StringFormatParams<schemas.$ZodE164, "when">;
|
||||
export type $ZodCheckE164Params = CheckStringFormatParams<schemas.$ZodE164, "when">;
|
||||
export declare function _e164<T extends schemas.$ZodE164>(Class: util.SchemaClass<T>, params?: string | $ZodE164Params | $ZodCheckE164Params): T;
|
||||
export type $ZodJWTParams = StringFormatParams<schemas.$ZodJWT, "pattern" | "when">;
|
||||
export type $ZodCheckJWTParams = CheckStringFormatParams<schemas.$ZodJWT, "pattern" | "when">;
|
||||
export declare function _jwt<T extends schemas.$ZodJWT>(Class: util.SchemaClass<T>, params?: string | $ZodJWTParams | $ZodCheckJWTParams): T;
|
||||
export declare const TimePrecision: {
|
||||
readonly Any: null;
|
||||
readonly Minute: -1;
|
||||
readonly Second: 0;
|
||||
readonly Millisecond: 3;
|
||||
readonly Microsecond: 6;
|
||||
};
|
||||
export type $ZodISODateTimeParams = StringFormatParams<schemas.$ZodISODateTime, "pattern" | "when">;
|
||||
export type $ZodCheckISODateTimeParams = CheckStringFormatParams<schemas.$ZodISODateTime, "pattern" | "when">;
|
||||
export declare function _isoDateTime<T extends schemas.$ZodISODateTime>(Class: util.SchemaClass<T>, params?: string | $ZodISODateTimeParams | $ZodCheckISODateTimeParams): T;
|
||||
export type $ZodISODateParams = StringFormatParams<schemas.$ZodISODate, "pattern" | "when">;
|
||||
export type $ZodCheckISODateParams = CheckStringFormatParams<schemas.$ZodISODate, "pattern" | "when">;
|
||||
export declare function _isoDate<T extends schemas.$ZodISODate>(Class: util.SchemaClass<T>, params?: string | $ZodISODateParams | $ZodCheckISODateParams): T;
|
||||
export type $ZodISOTimeParams = StringFormatParams<schemas.$ZodISOTime, "pattern" | "when">;
|
||||
export type $ZodCheckISOTimeParams = CheckStringFormatParams<schemas.$ZodISOTime, "pattern" | "when">;
|
||||
export declare function _isoTime<T extends schemas.$ZodISOTime>(Class: util.SchemaClass<T>, params?: string | $ZodISOTimeParams | $ZodCheckISOTimeParams): T;
|
||||
export type $ZodISODurationParams = StringFormatParams<schemas.$ZodISODuration, "when">;
|
||||
export type $ZodCheckISODurationParams = CheckStringFormatParams<schemas.$ZodISODuration, "when">;
|
||||
export declare function _isoDuration<T extends schemas.$ZodISODuration>(Class: util.SchemaClass<T>, params?: string | $ZodISODurationParams | $ZodCheckISODurationParams): T;
|
||||
export type $ZodNumberParams = TypeParams<schemas.$ZodNumber<number>, "coerce">;
|
||||
export type $ZodNumberFormatParams = CheckTypeParams<schemas.$ZodNumberFormat, "format" | "coerce">;
|
||||
export type $ZodCheckNumberFormatParams = CheckParams<checks.$ZodCheckNumberFormat, "format" | "when">;
|
||||
export declare function _number<T extends schemas.$ZodNumber>(Class: util.SchemaClass<T>, params?: string | $ZodNumberParams): T;
|
||||
export declare function _coercedNumber<T extends schemas.$ZodNumber>(Class: util.SchemaClass<T>, params?: string | $ZodNumberParams): T;
|
||||
export declare function _int<T extends schemas.$ZodNumberFormat>(Class: util.SchemaClass<T>, params?: string | $ZodCheckNumberFormatParams): T;
|
||||
export declare function _float32<T extends schemas.$ZodNumberFormat>(Class: util.SchemaClass<T>, params?: string | $ZodCheckNumberFormatParams): T;
|
||||
export declare function _float64<T extends schemas.$ZodNumberFormat>(Class: util.SchemaClass<T>, params?: string | $ZodCheckNumberFormatParams): T;
|
||||
export declare function _int32<T extends schemas.$ZodNumberFormat>(Class: util.SchemaClass<T>, params?: string | $ZodCheckNumberFormatParams): T;
|
||||
export declare function _uint32<T extends schemas.$ZodNumberFormat>(Class: util.SchemaClass<T>, params?: string | $ZodCheckNumberFormatParams): T;
|
||||
export type $ZodBooleanParams = TypeParams<schemas.$ZodBoolean<boolean>, "coerce">;
|
||||
export declare function _boolean<T extends schemas.$ZodBoolean>(Class: util.SchemaClass<T>, params?: string | $ZodBooleanParams): T;
|
||||
export declare function _coercedBoolean<T extends schemas.$ZodBoolean>(Class: util.SchemaClass<T>, params?: string | $ZodBooleanParams): T;
|
||||
export type $ZodBigIntParams = TypeParams<schemas.$ZodBigInt<bigint>>;
|
||||
export type $ZodBigIntFormatParams = CheckTypeParams<schemas.$ZodBigIntFormat, "format" | "coerce">;
|
||||
export type $ZodCheckBigIntFormatParams = CheckParams<checks.$ZodCheckBigIntFormat, "format" | "when">;
|
||||
export declare function _bigint<T extends schemas.$ZodBigInt>(Class: util.SchemaClass<T>, params?: string | $ZodBigIntParams): T;
|
||||
export declare function _coercedBigint<T extends schemas.$ZodBigInt>(Class: util.SchemaClass<T>, params?: string | $ZodBigIntParams): T;
|
||||
export declare function _int64<T extends schemas.$ZodBigIntFormat>(Class: util.SchemaClass<T>, params?: string | $ZodBigIntFormatParams): T;
|
||||
export declare function _uint64<T extends schemas.$ZodBigIntFormat>(Class: util.SchemaClass<T>, params?: string | $ZodBigIntFormatParams): T;
|
||||
export type $ZodSymbolParams = TypeParams<schemas.$ZodSymbol>;
|
||||
export declare function _symbol<T extends schemas.$ZodSymbol>(Class: util.SchemaClass<T>, params?: string | $ZodSymbolParams): T;
|
||||
export type $ZodUndefinedParams = TypeParams<schemas.$ZodUndefined>;
|
||||
export declare function _undefined<T extends schemas.$ZodUndefined>(Class: util.SchemaClass<T>, params?: string | $ZodUndefinedParams): T;
|
||||
export type $ZodNullParams = TypeParams<schemas.$ZodNull>;
|
||||
export declare function _null<T extends schemas.$ZodNull>(Class: util.SchemaClass<T>, params?: string | $ZodNullParams): T;
|
||||
export type $ZodAnyParams = TypeParams<schemas.$ZodAny>;
|
||||
export declare function _any<T extends schemas.$ZodAny>(Class: util.SchemaClass<T>): T;
|
||||
export type $ZodUnknownParams = TypeParams<schemas.$ZodUnknown>;
|
||||
export declare function _unknown<T extends schemas.$ZodUnknown>(Class: util.SchemaClass<T>): T;
|
||||
export type $ZodNeverParams = TypeParams<schemas.$ZodNever>;
|
||||
export declare function _never<T extends schemas.$ZodNever>(Class: util.SchemaClass<T>, params?: string | $ZodNeverParams): T;
|
||||
export type $ZodVoidParams = TypeParams<schemas.$ZodVoid>;
|
||||
export declare function _void<T extends schemas.$ZodVoid>(Class: util.SchemaClass<T>, params?: string | $ZodVoidParams): T;
|
||||
export type $ZodDateParams = TypeParams<schemas.$ZodDate, "coerce">;
|
||||
export declare function _date<T extends schemas.$ZodDate>(Class: util.SchemaClass<T>, params?: string | $ZodDateParams): T;
|
||||
export declare function _coercedDate<T extends schemas.$ZodDate>(Class: util.SchemaClass<T>, params?: string | $ZodDateParams): T;
|
||||
export type $ZodNaNParams = TypeParams<schemas.$ZodNaN>;
|
||||
export declare function _nan<T extends schemas.$ZodNaN>(Class: util.SchemaClass<T>, params?: string | $ZodNaNParams): T;
|
||||
export type $ZodCheckLessThanParams = CheckParams<checks.$ZodCheckLessThan, "inclusive" | "value" | "when">;
|
||||
export declare function _lt(value: util.Numeric, params?: string | $ZodCheckLessThanParams): checks.$ZodCheckLessThan<util.Numeric>;
|
||||
export declare function _lte(value: util.Numeric, params?: string | $ZodCheckLessThanParams): checks.$ZodCheckLessThan<util.Numeric>;
|
||||
export {
|
||||
/** @deprecated Use `z.lte()` instead. */
|
||||
_lte as _max, };
|
||||
export type $ZodCheckGreaterThanParams = CheckParams<checks.$ZodCheckGreaterThan, "inclusive" | "value" | "when">;
|
||||
export declare function _gt(value: util.Numeric, params?: string | $ZodCheckGreaterThanParams): checks.$ZodCheckGreaterThan;
|
||||
export declare function _gte(value: util.Numeric, params?: string | $ZodCheckGreaterThanParams): checks.$ZodCheckGreaterThan;
|
||||
export {
|
||||
/** @deprecated Use `z.gte()` instead. */
|
||||
_gte as _min, };
|
||||
export declare function _positive(params?: string | $ZodCheckGreaterThanParams): checks.$ZodCheckGreaterThan;
|
||||
export declare function _negative(params?: string | $ZodCheckLessThanParams): checks.$ZodCheckLessThan;
|
||||
export declare function _nonpositive(params?: string | $ZodCheckLessThanParams): checks.$ZodCheckLessThan;
|
||||
export declare function _nonnegative(params?: string | $ZodCheckGreaterThanParams): checks.$ZodCheckGreaterThan;
|
||||
export type $ZodCheckMultipleOfParams = CheckParams<checks.$ZodCheckMultipleOf, "value" | "when">;
|
||||
export declare function _multipleOf(value: number | bigint, params?: string | $ZodCheckMultipleOfParams): checks.$ZodCheckMultipleOf;
|
||||
export type $ZodCheckMaxSizeParams = CheckParams<checks.$ZodCheckMaxSize, "maximum" | "when">;
|
||||
export declare function _maxSize(maximum: number, params?: string | $ZodCheckMaxSizeParams): checks.$ZodCheckMaxSize<util.HasSize>;
|
||||
export type $ZodCheckMinSizeParams = CheckParams<checks.$ZodCheckMinSize, "minimum" | "when">;
|
||||
export declare function _minSize(minimum: number, params?: string | $ZodCheckMinSizeParams): checks.$ZodCheckMinSize<util.HasSize>;
|
||||
export type $ZodCheckSizeEqualsParams = CheckParams<checks.$ZodCheckSizeEquals, "size" | "when">;
|
||||
export declare function _size(size: number, params?: string | $ZodCheckSizeEqualsParams): checks.$ZodCheckSizeEquals<util.HasSize>;
|
||||
export type $ZodCheckMaxLengthParams = CheckParams<checks.$ZodCheckMaxLength, "maximum" | "when">;
|
||||
export declare function _maxLength(maximum: number, params?: string | $ZodCheckMaxLengthParams): checks.$ZodCheckMaxLength<util.HasLength>;
|
||||
export type $ZodCheckMinLengthParams = CheckParams<checks.$ZodCheckMinLength, "minimum" | "when">;
|
||||
export declare function _minLength(minimum: number, params?: string | $ZodCheckMinLengthParams): checks.$ZodCheckMinLength<util.HasLength>;
|
||||
export type $ZodCheckLengthEqualsParams = CheckParams<checks.$ZodCheckLengthEquals, "length" | "when">;
|
||||
export declare function _length(length: number, params?: string | $ZodCheckLengthEqualsParams): checks.$ZodCheckLengthEquals<util.HasLength>;
|
||||
export type $ZodCheckRegexParams = CheckParams<checks.$ZodCheckRegex, "format" | "pattern" | "when">;
|
||||
export declare function _regex(pattern: RegExp, params?: string | $ZodCheckRegexParams): checks.$ZodCheckRegex;
|
||||
export type $ZodCheckLowerCaseParams = CheckParams<checks.$ZodCheckLowerCase, "format" | "when">;
|
||||
export declare function _lowercase(params?: string | $ZodCheckLowerCaseParams): checks.$ZodCheckLowerCase;
|
||||
export type $ZodCheckUpperCaseParams = CheckParams<checks.$ZodCheckUpperCase, "format" | "when">;
|
||||
export declare function _uppercase(params?: string | $ZodCheckUpperCaseParams): checks.$ZodCheckUpperCase;
|
||||
export type $ZodCheckIncludesParams = CheckParams<checks.$ZodCheckIncludes, "includes" | "format" | "when" | "pattern">;
|
||||
export declare function _includes(includes: string, params?: string | $ZodCheckIncludesParams): checks.$ZodCheckIncludes;
|
||||
export type $ZodCheckStartsWithParams = CheckParams<checks.$ZodCheckStartsWith, "prefix" | "format" | "when" | "pattern">;
|
||||
export declare function _startsWith(prefix: string, params?: string | $ZodCheckStartsWithParams): checks.$ZodCheckStartsWith;
|
||||
export type $ZodCheckEndsWithParams = CheckParams<checks.$ZodCheckEndsWith, "suffix" | "format" | "pattern" | "when">;
|
||||
export declare function _endsWith(suffix: string, params?: string | $ZodCheckEndsWithParams): checks.$ZodCheckEndsWith;
|
||||
export type $ZodCheckPropertyParams = CheckParams<checks.$ZodCheckProperty, "property" | "schema" | "when">;
|
||||
export declare function _property<K extends string, T extends schemas.$ZodType>(property: K, schema: T, params?: string | $ZodCheckPropertyParams): checks.$ZodCheckProperty<{
|
||||
[k in K]: core.output<T>;
|
||||
}>;
|
||||
export type $ZodCheckMimeTypeParams = CheckParams<checks.$ZodCheckMimeType, "mime" | "when">;
|
||||
export declare function _mime(types: util.MimeTypes[], params?: string | $ZodCheckMimeTypeParams): checks.$ZodCheckMimeType;
|
||||
export declare function _overwrite<T>(tx: (input: T) => T): checks.$ZodCheckOverwrite<T>;
|
||||
export declare function _normalize(form?: "NFC" | "NFD" | "NFKC" | "NFKD" | (string & {})): checks.$ZodCheckOverwrite<string>;
|
||||
export declare function _trim(): checks.$ZodCheckOverwrite<string>;
|
||||
export declare function _toLowerCase(): checks.$ZodCheckOverwrite<string>;
|
||||
export declare function _toUpperCase(): checks.$ZodCheckOverwrite<string>;
|
||||
export declare function _slugify(): checks.$ZodCheckOverwrite<string>;
|
||||
export type $ZodArrayParams = TypeParams<schemas.$ZodArray, "element">;
|
||||
export declare function _array<T extends schemas.$ZodType>(Class: util.SchemaClass<schemas.$ZodArray>, element: T, params?: string | $ZodArrayParams): schemas.$ZodArray<T>;
|
||||
export type $ZodObjectParams = TypeParams<schemas.$ZodObject, "shape" | "catchall">;
|
||||
export type $ZodUnionParams = TypeParams<schemas.$ZodUnion, "options">;
|
||||
export declare function _union<const T extends readonly schemas.$ZodObject[]>(Class: util.SchemaClass<schemas.$ZodUnion>, options: T, params?: string | $ZodUnionParams): schemas.$ZodUnion<T>;
|
||||
export type $ZodXorParams = TypeParams<schemas.$ZodXor, "options">;
|
||||
export declare function _xor<const T extends readonly schemas.$ZodObject[]>(Class: util.SchemaClass<schemas.$ZodXor>, options: T, params?: string | $ZodXorParams): schemas.$ZodXor<T>;
|
||||
export interface $ZodTypeDiscriminableInternals<Disc extends string = string> extends schemas.$ZodTypeInternals<unknown, {
|
||||
[K in Disc]?: unknown;
|
||||
}> {
|
||||
propValues: util.PropValues;
|
||||
}
|
||||
export interface $ZodTypeDiscriminable<Disc extends string = string> extends schemas.$ZodType {
|
||||
_zod: $ZodTypeDiscriminableInternals<Disc>;
|
||||
}
|
||||
export type $ZodDiscriminatedUnionParams = TypeParams<schemas.$ZodDiscriminatedUnion, "options" | "discriminator">;
|
||||
export declare function _discriminatedUnion<Types extends [$ZodTypeDiscriminable<Disc>, ...$ZodTypeDiscriminable<Disc>[]], Disc extends string>(Class: util.SchemaClass<schemas.$ZodDiscriminatedUnion>, discriminator: Disc, options: Types, params?: string | $ZodDiscriminatedUnionParams): schemas.$ZodDiscriminatedUnion<Types, Disc>;
|
||||
export type $ZodIntersectionParams = TypeParams<schemas.$ZodIntersection, "left" | "right">;
|
||||
export declare function _intersection<T extends schemas.$ZodObject, U extends schemas.$ZodObject>(Class: util.SchemaClass<schemas.$ZodIntersection>, left: T, right: U): schemas.$ZodIntersection<T, U>;
|
||||
export type $ZodTupleParams = TypeParams<schemas.$ZodTuple, "items" | "rest">;
|
||||
export declare function _tuple<T extends readonly [schemas.$ZodType, ...schemas.$ZodType[]]>(Class: util.SchemaClass<schemas.$ZodTuple>, items: T, params?: string | $ZodTupleParams): schemas.$ZodTuple<T, null>;
|
||||
export declare function _tuple<T extends readonly [schemas.$ZodType, ...schemas.$ZodType[]], Rest extends schemas.$ZodType>(Class: util.SchemaClass<schemas.$ZodTuple>, items: T, rest: Rest, params?: string | $ZodTupleParams): schemas.$ZodTuple<T, Rest>;
|
||||
export type $ZodRecordParams = TypeParams<schemas.$ZodRecord, "keyType" | "valueType">;
|
||||
export declare function _record<Key extends schemas.$ZodRecordKey, Value extends schemas.$ZodObject>(Class: util.SchemaClass<schemas.$ZodRecord>, keyType: Key, valueType: Value, params?: string | $ZodRecordParams): schemas.$ZodRecord<Key, Value>;
|
||||
export type $ZodMapParams = TypeParams<schemas.$ZodMap, "keyType" | "valueType">;
|
||||
export declare function _map<Key extends schemas.$ZodObject, Value extends schemas.$ZodObject>(Class: util.SchemaClass<schemas.$ZodMap>, keyType: Key, valueType: Value, params?: string | $ZodMapParams): schemas.$ZodMap<Key, Value>;
|
||||
export type $ZodSetParams = TypeParams<schemas.$ZodSet, "valueType">;
|
||||
export declare function _set<Value extends schemas.$ZodObject>(Class: util.SchemaClass<schemas.$ZodSet>, valueType: Value, params?: string | $ZodSetParams): schemas.$ZodSet<Value>;
|
||||
export type $ZodEnumParams = TypeParams<schemas.$ZodEnum, "entries">;
|
||||
export declare function _enum<const T extends string[]>(Class: util.SchemaClass<schemas.$ZodEnum>, values: T, params?: string | $ZodEnumParams): schemas.$ZodEnum<util.ToEnum<T[number]>>;
|
||||
export declare function _enum<T extends util.EnumLike>(Class: util.SchemaClass<schemas.$ZodEnum>, entries: T, params?: string | $ZodEnumParams): schemas.$ZodEnum<T>;
|
||||
/** @deprecated This API has been merged into `z.enum()`. Use `z.enum()` instead.
|
||||
*
|
||||
* ```ts
|
||||
* enum Colors { red, green, blue }
|
||||
* z.enum(Colors);
|
||||
* ```
|
||||
*/
|
||||
export declare function _nativeEnum<T extends util.EnumLike>(Class: util.SchemaClass<schemas.$ZodEnum>, entries: T, params?: string | $ZodEnumParams): schemas.$ZodEnum<T>;
|
||||
export type $ZodLiteralParams = TypeParams<schemas.$ZodLiteral, "values">;
|
||||
export declare function _literal<const T extends Array<util.Literal>>(Class: util.SchemaClass<schemas.$ZodLiteral>, value: T, params?: string | $ZodLiteralParams): schemas.$ZodLiteral<T[number]>;
|
||||
export declare function _literal<const T extends util.Literal>(Class: util.SchemaClass<schemas.$ZodLiteral>, value: T, params?: string | $ZodLiteralParams): schemas.$ZodLiteral<T>;
|
||||
export type $ZodFileParams = TypeParams<schemas.$ZodFile>;
|
||||
export declare function _file(Class: util.SchemaClass<schemas.$ZodFile>, params?: string | $ZodFileParams): schemas.$ZodFile;
|
||||
export type $ZodTransformParams = TypeParams<schemas.$ZodTransform, "transform">;
|
||||
export declare function _transform<I = unknown, O = I>(Class: util.SchemaClass<schemas.$ZodTransform>, fn: (input: I, ctx?: schemas.ParsePayload) => O): schemas.$ZodTransform<Awaited<O>, I>;
|
||||
export type $ZodOptionalParams = TypeParams<schemas.$ZodOptional, "innerType">;
|
||||
export declare function _optional<T extends schemas.$ZodObject>(Class: util.SchemaClass<schemas.$ZodOptional>, innerType: T): schemas.$ZodOptional<T>;
|
||||
export type $ZodNullableParams = TypeParams<schemas.$ZodNullable, "innerType">;
|
||||
export declare function _nullable<T extends schemas.$ZodObject>(Class: util.SchemaClass<schemas.$ZodNullable>, innerType: T): schemas.$ZodNullable<T>;
|
||||
export type $ZodDefaultParams = TypeParams<schemas.$ZodDefault, "innerType" | "defaultValue">;
|
||||
export declare function _default<T extends schemas.$ZodObject>(Class: util.SchemaClass<schemas.$ZodDefault>, innerType: T, defaultValue: util.NoUndefined<core.output<T>> | (() => util.NoUndefined<core.output<T>>)): schemas.$ZodDefault<T>;
|
||||
export type $ZodNonOptionalParams = TypeParams<schemas.$ZodNonOptional, "innerType">;
|
||||
export declare function _nonoptional<T extends schemas.$ZodObject>(Class: util.SchemaClass<schemas.$ZodNonOptional>, innerType: T, params?: string | $ZodNonOptionalParams): schemas.$ZodNonOptional<T>;
|
||||
export type $ZodSuccessParams = TypeParams<schemas.$ZodSuccess, "innerType">;
|
||||
export declare function _success<T extends schemas.$ZodObject>(Class: util.SchemaClass<schemas.$ZodSuccess>, innerType: T): schemas.$ZodSuccess<T>;
|
||||
export type $ZodCatchParams = TypeParams<schemas.$ZodCatch, "innerType" | "catchValue">;
|
||||
export declare function _catch<T extends schemas.$ZodObject>(Class: util.SchemaClass<schemas.$ZodCatch>, innerType: T, catchValue: core.output<T> | ((ctx: schemas.$ZodCatchCtx) => core.output<T>)): schemas.$ZodCatch<T>;
|
||||
export type $ZodPipeParams = TypeParams<schemas.$ZodPipe, "in" | "out">;
|
||||
export declare function _pipe<const A extends schemas.$ZodType, B extends schemas.$ZodType<unknown, core.output<A>> = schemas.$ZodType<unknown, core.output<A>>>(Class: util.SchemaClass<schemas.$ZodPipe>, in_: A, out: B | schemas.$ZodType<unknown, core.output<A>>): schemas.$ZodPipe<A, B>;
|
||||
export type $ZodReadonlyParams = TypeParams<schemas.$ZodReadonly, "innerType">;
|
||||
export declare function _readonly<T extends schemas.$ZodObject>(Class: util.SchemaClass<schemas.$ZodReadonly>, innerType: T): schemas.$ZodReadonly<T>;
|
||||
export type $ZodTemplateLiteralParams = TypeParams<schemas.$ZodTemplateLiteral, "parts">;
|
||||
export declare function _templateLiteral<const Parts extends schemas.$ZodTemplateLiteralPart[]>(Class: util.SchemaClass<schemas.$ZodTemplateLiteral>, parts: Parts, params?: string | $ZodTemplateLiteralParams): schemas.$ZodTemplateLiteral<schemas.$PartsToTemplateLiteral<Parts>>;
|
||||
export type $ZodLazyParams = TypeParams<schemas.$ZodLazy, "getter">;
|
||||
export declare function _lazy<T extends schemas.$ZodType>(Class: util.SchemaClass<schemas.$ZodLazy>, getter: () => T): schemas.$ZodLazy<T>;
|
||||
export type $ZodPromiseParams = TypeParams<schemas.$ZodPromise, "innerType">;
|
||||
export declare function _promise<T extends schemas.$ZodObject>(Class: util.SchemaClass<schemas.$ZodPromise>, innerType: T): schemas.$ZodPromise<T>;
|
||||
export type $ZodCustomParams = CheckTypeParams<schemas.$ZodCustom, "fn">;
|
||||
export declare function _custom<O = unknown, I = O>(Class: util.SchemaClass<schemas.$ZodCustom>, fn: (data: O) => unknown, _params: string | $ZodCustomParams | undefined): schemas.$ZodCustom<O, I>;
|
||||
export declare function _refine<O = unknown, I = O>(Class: util.SchemaClass<schemas.$ZodCustom>, fn: (data: O) => unknown, _params: string | $ZodCustomParams | undefined): schemas.$ZodCustom<O, I>;
|
||||
export type $ZodSuperRefineIssue<T extends errors.$ZodIssueBase = errors.$ZodIssue> = T extends any ? RawIssue<T> : never;
|
||||
type RawIssue<T extends errors.$ZodIssueBase> = T extends any ? util.Flatten<util.MakePartial<T, "message" | "path"> & {
|
||||
/** The schema or check that originated this issue. */
|
||||
readonly inst?: schemas.$ZodType | checks.$ZodCheck;
|
||||
/** If `true`, Zod will execute subsequent checks/refinements instead of immediately aborting */
|
||||
readonly continue?: boolean | undefined;
|
||||
} & Record<string, unknown>> : never;
|
||||
export interface $RefinementCtx<T = unknown> extends schemas.ParsePayload<T> {
|
||||
addIssue(arg: string | $ZodSuperRefineIssue): void;
|
||||
}
|
||||
export interface $ZodSuperRefineParams {
|
||||
/** If provided, the refinement runs only when this returns `true`. By default, it is skipped if prior parsing produced aborting issues. */
|
||||
when?: ((payload: schemas.ParsePayload) => boolean) | undefined;
|
||||
}
|
||||
export declare function _superRefine<T>(fn: (arg: T, payload: $RefinementCtx<T>) => void | Promise<void>, params?: $ZodSuperRefineParams): checks.$ZodCheck<T>;
|
||||
export declare function _check<O = unknown>(fn: schemas.CheckFn<O>, params?: string | $ZodCustomParams): checks.$ZodCheck<O>;
|
||||
export declare function describe<T>(description: string): checks.$ZodCheck<T>;
|
||||
export declare function meta<T>(metadata: registries.GlobalMeta): checks.$ZodCheck<T>;
|
||||
export interface $ZodStringBoolParams extends TypeParams {
|
||||
truthy?: string[];
|
||||
falsy?: string[];
|
||||
/**
|
||||
* Options: `"sensitive"`, `"insensitive"`
|
||||
*
|
||||
* @default `"insensitive"`
|
||||
*/
|
||||
case?: "sensitive" | "insensitive" | undefined;
|
||||
}
|
||||
export declare function _stringbool(Classes: {
|
||||
Codec?: typeof schemas.$ZodCodec;
|
||||
Boolean?: typeof schemas.$ZodBoolean;
|
||||
String?: typeof schemas.$ZodString;
|
||||
}, _params?: string | $ZodStringBoolParams): schemas.$ZodCodec<schemas.$ZodString, schemas.$ZodBoolean>;
|
||||
export declare function _stringFormat<Format extends string>(Class: typeof schemas.$ZodCustomStringFormat, format: Format, fnOrRegex: ((arg: string) => util.MaybeAsync<unknown>) | RegExp, _params?: string | $ZodStringFormatParams): schemas.$ZodCustomStringFormat<Format>;
|
||||
@@ -0,0 +1,12 @@
|
||||
'use strict'
|
||||
|
||||
const pino = require('./pino')
|
||||
const { once } = require('node:events')
|
||||
|
||||
module.exports = async function (opts = {}) {
|
||||
const destOpts = Object.assign({}, opts, { dest: opts.destination || 1, sync: false })
|
||||
delete destOpts.destination
|
||||
const destination = pino.destination(destOpts)
|
||||
await once(destination, 'ready')
|
||||
return destination
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,51 @@
|
||||
# real-require
|
||||
|
||||
[](https://npm.im/real-require)
|
||||
[](https://libraries.io/npm/real-require)
|
||||
[](https://github.com/pinojs/real-require/actions?query=workflow%3ACI)
|
||||
|
||||
Keep require and import consistent after bundling or transpiling.
|
||||
|
||||
## Installation
|
||||
|
||||
Just run:
|
||||
|
||||
```bash
|
||||
npm install real-require
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
The package provides two drop-ins functions, `realRequire` and `realImport`, which can be used in scenarios where tools like transpilers or bundlers change the native `require` or `await import` calls.
|
||||
|
||||
The current `realRequire` functions only handles webpack at the moment, wrapping the `__non_webpack__require__` implementation that webpack provides for the final bundle.
|
||||
|
||||
### Example
|
||||
|
||||
```js
|
||||
// After bundling, real-require will be embedded in the bundle
|
||||
const { realImport, realRequire } = require('real-require')
|
||||
|
||||
/*
|
||||
By using realRequire, at build time the module will not be embedded and at runtime it will try to load path from the local filesytem.
|
||||
This is useful in situations where the build tool does not support skipping modules to embed.
|
||||
*/
|
||||
const { join } = realRequire('path')
|
||||
|
||||
async function main() {
|
||||
// Similarly, this make sure the import call is not modified by the build tools
|
||||
const localFunction = await realImport('./source.js')
|
||||
|
||||
localFunction()
|
||||
}
|
||||
|
||||
main().catch(console.error)
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
See [CONTRIBUTING.md](./CONTRIBUTING.md)
|
||||
|
||||
## License
|
||||
|
||||
Copyright Paolo Insogna and real-require contributors 2021. Licensed under the [MIT License](http://www.apache.org/licenses/MIT).
|
||||
@@ -0,0 +1,15 @@
|
||||
export type Options = [
|
||||
{
|
||||
allowAny?: boolean;
|
||||
allowedPromiseNames?: string[];
|
||||
checkArrowFunctions?: boolean;
|
||||
checkFunctionDeclarations?: boolean;
|
||||
checkFunctionExpressions?: boolean;
|
||||
checkMethodDeclarations?: boolean;
|
||||
}
|
||||
];
|
||||
export type MessageIds = 'missingAsync' | 'missingAsyncHybridReturn';
|
||||
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<MessageIds, Options, import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
||||
name: string;
|
||||
};
|
||||
export default _default;
|
||||
@@ -0,0 +1,12 @@
|
||||
import _typeof from "./typeof.js";
|
||||
function toPrimitive(t, r) {
|
||||
if ("object" != _typeof(t) || !t) return t;
|
||||
var e = t[Symbol.toPrimitive];
|
||||
if (void 0 !== e) {
|
||||
var i = e.call(t, r || "default");
|
||||
if ("object" != _typeof(i)) return i;
|
||||
throw new TypeError("@@toPrimitive must return a primitive value.");
|
||||
}
|
||||
return ("string" === r ? String : Number)(t);
|
||||
}
|
||||
export { toPrimitive as default };
|
||||
@@ -0,0 +1,391 @@
|
||||
'use strict';
|
||||
|
||||
const utils = require('./utils');
|
||||
const {
|
||||
CHAR_ASTERISK, /* * */
|
||||
CHAR_AT, /* @ */
|
||||
CHAR_BACKWARD_SLASH, /* \ */
|
||||
CHAR_COMMA, /* , */
|
||||
CHAR_DOT, /* . */
|
||||
CHAR_EXCLAMATION_MARK, /* ! */
|
||||
CHAR_FORWARD_SLASH, /* / */
|
||||
CHAR_LEFT_CURLY_BRACE, /* { */
|
||||
CHAR_LEFT_PARENTHESES, /* ( */
|
||||
CHAR_LEFT_SQUARE_BRACKET, /* [ */
|
||||
CHAR_PLUS, /* + */
|
||||
CHAR_QUESTION_MARK, /* ? */
|
||||
CHAR_RIGHT_CURLY_BRACE, /* } */
|
||||
CHAR_RIGHT_PARENTHESES, /* ) */
|
||||
CHAR_RIGHT_SQUARE_BRACKET /* ] */
|
||||
} = require('./constants');
|
||||
|
||||
const isPathSeparator = code => {
|
||||
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
||||
};
|
||||
|
||||
const depth = token => {
|
||||
if (token.isPrefix !== true) {
|
||||
token.depth = token.isGlobstar ? Infinity : 1;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Quickly scans a glob pattern and returns an object with a handful of
|
||||
* useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
|
||||
* `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
|
||||
* with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
|
||||
*
|
||||
* ```js
|
||||
* const pm = require('picomatch');
|
||||
* console.log(pm.scan('foo/bar/*.js'));
|
||||
* { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
|
||||
* ```
|
||||
* @param {String} `str`
|
||||
* @param {Object} `options`
|
||||
* @return {Object} Returns an object with tokens and regex source string.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
const scan = (input, options) => {
|
||||
const opts = options || {};
|
||||
|
||||
const length = input.length - 1;
|
||||
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
||||
const slashes = [];
|
||||
const tokens = [];
|
||||
const parts = [];
|
||||
|
||||
let str = input;
|
||||
let index = -1;
|
||||
let start = 0;
|
||||
let lastIndex = 0;
|
||||
let isBrace = false;
|
||||
let isBracket = false;
|
||||
let isGlob = false;
|
||||
let isExtglob = false;
|
||||
let isGlobstar = false;
|
||||
let braceEscaped = false;
|
||||
let backslashes = false;
|
||||
let negated = false;
|
||||
let negatedExtglob = false;
|
||||
let finished = false;
|
||||
let braces = 0;
|
||||
let prev;
|
||||
let code;
|
||||
let token = { value: '', depth: 0, isGlob: false };
|
||||
|
||||
const eos = () => index >= length;
|
||||
const peek = () => str.charCodeAt(index + 1);
|
||||
const advance = () => {
|
||||
prev = code;
|
||||
return str.charCodeAt(++index);
|
||||
};
|
||||
|
||||
while (index < length) {
|
||||
code = advance();
|
||||
let next;
|
||||
|
||||
if (code === CHAR_BACKWARD_SLASH) {
|
||||
backslashes = token.backslashes = true;
|
||||
code = advance();
|
||||
|
||||
if (code === CHAR_LEFT_CURLY_BRACE) {
|
||||
braceEscaped = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
||||
braces++;
|
||||
|
||||
while (eos() !== true && (code = advance())) {
|
||||
if (code === CHAR_BACKWARD_SLASH) {
|
||||
backslashes = token.backslashes = true;
|
||||
advance();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (code === CHAR_LEFT_CURLY_BRACE) {
|
||||
braces++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
||||
isBrace = token.isBrace = true;
|
||||
isGlob = token.isGlob = true;
|
||||
finished = true;
|
||||
|
||||
if (scanToEnd === true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (braceEscaped !== true && code === CHAR_COMMA) {
|
||||
isBrace = token.isBrace = true;
|
||||
isGlob = token.isGlob = true;
|
||||
finished = true;
|
||||
|
||||
if (scanToEnd === true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
||||
braces--;
|
||||
|
||||
if (braces === 0) {
|
||||
braceEscaped = false;
|
||||
isBrace = token.isBrace = true;
|
||||
finished = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (scanToEnd === true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (code === CHAR_FORWARD_SLASH) {
|
||||
slashes.push(index);
|
||||
tokens.push(token);
|
||||
token = { value: '', depth: 0, isGlob: false };
|
||||
|
||||
if (finished === true) continue;
|
||||
if (prev === CHAR_DOT && index === (start + 1)) {
|
||||
start += 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
lastIndex = index + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (opts.noext !== true) {
|
||||
const isExtglobChar = code === CHAR_PLUS
|
||||
|| code === CHAR_AT
|
||||
|| code === CHAR_ASTERISK
|
||||
|| code === CHAR_QUESTION_MARK
|
||||
|| code === CHAR_EXCLAMATION_MARK;
|
||||
|
||||
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
||||
isGlob = token.isGlob = true;
|
||||
isExtglob = token.isExtglob = true;
|
||||
finished = true;
|
||||
if (code === CHAR_EXCLAMATION_MARK && index === start) {
|
||||
negatedExtglob = true;
|
||||
}
|
||||
|
||||
if (scanToEnd === true) {
|
||||
while (eos() !== true && (code = advance())) {
|
||||
if (code === CHAR_BACKWARD_SLASH) {
|
||||
backslashes = token.backslashes = true;
|
||||
code = advance();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (code === CHAR_RIGHT_PARENTHESES) {
|
||||
isGlob = token.isGlob = true;
|
||||
finished = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (code === CHAR_ASTERISK) {
|
||||
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
||||
isGlob = token.isGlob = true;
|
||||
finished = true;
|
||||
|
||||
if (scanToEnd === true) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (code === CHAR_QUESTION_MARK) {
|
||||
isGlob = token.isGlob = true;
|
||||
finished = true;
|
||||
|
||||
if (scanToEnd === true) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
||||
while (eos() !== true && (next = advance())) {
|
||||
if (next === CHAR_BACKWARD_SLASH) {
|
||||
backslashes = token.backslashes = true;
|
||||
advance();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
||||
isBracket = token.isBracket = true;
|
||||
isGlob = token.isGlob = true;
|
||||
finished = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (scanToEnd === true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
||||
negated = token.negated = true;
|
||||
start++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
||||
isGlob = token.isGlob = true;
|
||||
|
||||
if (scanToEnd === true) {
|
||||
while (eos() !== true && (code = advance())) {
|
||||
if (code === CHAR_LEFT_PARENTHESES) {
|
||||
backslashes = token.backslashes = true;
|
||||
code = advance();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (code === CHAR_RIGHT_PARENTHESES) {
|
||||
finished = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (isGlob === true) {
|
||||
finished = true;
|
||||
|
||||
if (scanToEnd === true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (opts.noext === true) {
|
||||
isExtglob = false;
|
||||
isGlob = false;
|
||||
}
|
||||
|
||||
let base = str;
|
||||
let prefix = '';
|
||||
let glob = '';
|
||||
|
||||
if (start > 0) {
|
||||
prefix = str.slice(0, start);
|
||||
str = str.slice(start);
|
||||
lastIndex -= start;
|
||||
}
|
||||
|
||||
if (base && isGlob === true && lastIndex > 0) {
|
||||
base = str.slice(0, lastIndex);
|
||||
glob = str.slice(lastIndex);
|
||||
} else if (isGlob === true) {
|
||||
base = '';
|
||||
glob = str;
|
||||
} else {
|
||||
base = str;
|
||||
}
|
||||
|
||||
if (base && base !== '' && base !== '/' && base !== str) {
|
||||
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
||||
base = base.slice(0, -1);
|
||||
}
|
||||
}
|
||||
|
||||
if (opts.unescape === true) {
|
||||
if (glob) glob = utils.removeBackslashes(glob);
|
||||
|
||||
if (base && backslashes === true) {
|
||||
base = utils.removeBackslashes(base);
|
||||
}
|
||||
}
|
||||
|
||||
const state = {
|
||||
prefix,
|
||||
input,
|
||||
start,
|
||||
base,
|
||||
glob,
|
||||
isBrace,
|
||||
isBracket,
|
||||
isGlob,
|
||||
isExtglob,
|
||||
isGlobstar,
|
||||
negated,
|
||||
negatedExtglob
|
||||
};
|
||||
|
||||
if (opts.tokens === true) {
|
||||
state.maxDepth = 0;
|
||||
if (!isPathSeparator(code)) {
|
||||
tokens.push(token);
|
||||
}
|
||||
state.tokens = tokens;
|
||||
}
|
||||
|
||||
if (opts.parts === true || opts.tokens === true) {
|
||||
let prevIndex;
|
||||
|
||||
for (let idx = 0; idx < slashes.length; idx++) {
|
||||
const n = prevIndex ? prevIndex + 1 : start;
|
||||
const i = slashes[idx];
|
||||
const value = input.slice(n, i);
|
||||
if (opts.tokens) {
|
||||
if (idx === 0 && start !== 0) {
|
||||
tokens[idx].isPrefix = true;
|
||||
tokens[idx].value = prefix;
|
||||
} else {
|
||||
tokens[idx].value = value;
|
||||
}
|
||||
depth(tokens[idx]);
|
||||
state.maxDepth += tokens[idx].depth;
|
||||
}
|
||||
if (idx !== 0 || value !== '') {
|
||||
parts.push(value);
|
||||
}
|
||||
prevIndex = i;
|
||||
}
|
||||
|
||||
if (prevIndex && prevIndex + 1 < input.length) {
|
||||
const value = input.slice(prevIndex + 1);
|
||||
parts.push(value);
|
||||
|
||||
if (opts.tokens) {
|
||||
tokens[tokens.length - 1].value = value;
|
||||
depth(tokens[tokens.length - 1]);
|
||||
state.maxDepth += tokens[tokens.length - 1].depth;
|
||||
}
|
||||
}
|
||||
|
||||
state.slashes = slashes;
|
||||
state.parts = parts;
|
||||
}
|
||||
|
||||
return state;
|
||||
};
|
||||
|
||||
module.exports = scan;
|
||||
@@ -0,0 +1,71 @@
|
||||
'use strict'
|
||||
|
||||
process.env.TZ = 'UTC'
|
||||
|
||||
const { test } = require('node:test')
|
||||
const formatTime = require('./format-time')
|
||||
|
||||
const dateStr = '2019-04-06T13:30:00.000-04:00'
|
||||
const epoch = new Date(dateStr)
|
||||
const epochMS = epoch.getTime()
|
||||
|
||||
test('passes through epoch if `translateTime` is `false`', t => {
|
||||
const formattedTime = formatTime(epochMS)
|
||||
t.assert.strictEqual(formattedTime, epochMS)
|
||||
})
|
||||
|
||||
test('passes through epoch if date is invalid', t => {
|
||||
const input = 'this is not a date'
|
||||
const formattedTime = formatTime(input, true)
|
||||
t.assert.strictEqual(formattedTime, input)
|
||||
})
|
||||
|
||||
test('translates epoch milliseconds if `translateTime` is `true`', t => {
|
||||
const formattedTime = formatTime(epochMS, true)
|
||||
t.assert.strictEqual(formattedTime, '17:30:00.000')
|
||||
})
|
||||
|
||||
test('translates epoch milliseconds to UTC string given format', t => {
|
||||
const formattedTime = formatTime(epochMS, 'd mmm yyyy H:MM')
|
||||
t.assert.strictEqual(formattedTime, '6 Apr 2019 17:30')
|
||||
})
|
||||
|
||||
test('translates epoch milliseconds to SYS:STANDARD', t => {
|
||||
const formattedTime = formatTime(epochMS, 'SYS:STANDARD')
|
||||
t.assert.match(formattedTime, /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3} [-+]?\d{4}/)
|
||||
})
|
||||
|
||||
test('translates epoch milliseconds to SYS:<FORMAT>', t => {
|
||||
const formattedTime = formatTime(epochMS, 'SYS:d mmm yyyy H:MM')
|
||||
t.assert.match(formattedTime, /\d{1} \w{3} \d{4} \d{1,2}:\d{2}/)
|
||||
})
|
||||
|
||||
test('passes through date string if `translateTime` is `false`', t => {
|
||||
const formattedTime = formatTime(dateStr)
|
||||
t.assert.strictEqual(formattedTime, dateStr)
|
||||
})
|
||||
|
||||
test('translates date string if `translateTime` is `true`', t => {
|
||||
const formattedTime = formatTime(dateStr, true)
|
||||
t.assert.strictEqual(formattedTime, '17:30:00.000')
|
||||
})
|
||||
|
||||
test('translates date string to UTC string given format', t => {
|
||||
const formattedTime = formatTime(dateStr, 'd mmm yyyy H:MM')
|
||||
t.assert.strictEqual(formattedTime, '6 Apr 2019 17:30')
|
||||
})
|
||||
|
||||
test('translates date string to SYS:STANDARD', t => {
|
||||
const formattedTime = formatTime(dateStr, 'SYS:STANDARD')
|
||||
t.assert.match(formattedTime, /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3} [-+]?\d{4}/)
|
||||
})
|
||||
|
||||
test('translates date string to UTC:<FORMAT>', t => {
|
||||
const formattedTime = formatTime(dateStr, 'UTC:d mmm yyyy H:MM')
|
||||
t.assert.strictEqual(formattedTime, '6 Apr 2019 17:30')
|
||||
})
|
||||
|
||||
test('translates date string to SYS:<FORMAT>', t => {
|
||||
const formattedTime = formatTime(dateStr, 'SYS:d mmm yyyy H:MM')
|
||||
t.assert.match(formattedTime, /\d{1} \w{3} \d{4} \d{1,2}:\d{2}/)
|
||||
})
|
||||
@@ -0,0 +1,370 @@
|
||||
/**
|
||||
* @fileoverview Rule to flag statements that use magic numbers (adapted from https://github.com/danielstjules/buddy.js)
|
||||
* @author Vincent Lemeunier
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const astUtils = require("./utils/ast-utils");
|
||||
|
||||
// Maximum array length by the ECMAScript Specification.
|
||||
const MAX_ARRAY_LENGTH = 2 ** 32 - 1;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Convert the value to bigint if it's a string. Otherwise return the value as-is.
|
||||
* @param {bigint|number|string} x The value to normalize.
|
||||
* @returns {bigint|number} The normalized value.
|
||||
*/
|
||||
function normalizeIgnoreValue(x) {
|
||||
if (typeof x === "string") {
|
||||
return BigInt(x.slice(0, -1));
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the node parent is a TypeScript enum member
|
||||
* @param {ASTNode} node The node to be validated
|
||||
* @returns {boolean} True if the node parent is a TypeScript enum member
|
||||
*/
|
||||
function isParentTSEnumDeclaration(node) {
|
||||
return node.parent.type === "TSEnumMember";
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the node is a valid TypeScript numeric literal type.
|
||||
* @param {ASTNode} node The node to be validated
|
||||
* @returns {boolean} True if the node is a TypeScript numeric literal type
|
||||
*/
|
||||
function isTSNumericLiteralType(node) {
|
||||
let ancestor = node.parent;
|
||||
|
||||
// Go up while we're part of a type union
|
||||
while (ancestor.parent.type === "TSUnionType") {
|
||||
ancestor = ancestor.parent;
|
||||
}
|
||||
|
||||
// Check if the final ancestor is in a type alias declaration
|
||||
return ancestor.parent.type === "TSTypeAliasDeclaration";
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the node parent is a readonly class property
|
||||
* @param {ASTNode} node The node to be validated
|
||||
* @returns {boolean} True if the node parent is a readonly class property
|
||||
*/
|
||||
function isParentTSReadonlyPropertyDefinition(node) {
|
||||
if (node.parent?.type === "PropertyDefinition" && node.parent.readonly) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the node is part of a type indexed access (eg. Foo[4])
|
||||
* @param {ASTNode} node The node to be validated
|
||||
* @returns {boolean} True if the node is part of an indexed access
|
||||
*/
|
||||
function isAncestorTSIndexedAccessType(node) {
|
||||
let ancestor = node.parent;
|
||||
|
||||
/*
|
||||
* Go up another level while we're part of a type union (eg. 1 | 2) or
|
||||
* intersection (eg. 1 & 2)
|
||||
*/
|
||||
while (
|
||||
ancestor.parent.type === "TSUnionType" ||
|
||||
ancestor.parent.type === "TSIntersectionType"
|
||||
) {
|
||||
ancestor = ancestor.parent;
|
||||
}
|
||||
|
||||
return ancestor.parent.type === "TSIndexedAccessType";
|
||||
}
|
||||
|
||||
/** @type {import('../types').Rule.RuleModule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description: "Disallow magic numbers",
|
||||
dialects: ["JavaScript", "TypeScript"],
|
||||
recommended: false,
|
||||
frozen: true,
|
||||
url: "https://eslint.org/docs/latest/rules/no-magic-numbers",
|
||||
},
|
||||
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
detectObjects: {
|
||||
type: "boolean",
|
||||
},
|
||||
enforceConst: {
|
||||
type: "boolean",
|
||||
},
|
||||
ignore: {
|
||||
type: "array",
|
||||
items: {
|
||||
anyOf: [
|
||||
{ type: "number" },
|
||||
{
|
||||
type: "string",
|
||||
pattern: "^[+-]?(?:0|[1-9][0-9]*)n$",
|
||||
},
|
||||
],
|
||||
},
|
||||
uniqueItems: true,
|
||||
},
|
||||
ignoreArrayIndexes: {
|
||||
type: "boolean",
|
||||
},
|
||||
ignoreDefaultValues: {
|
||||
type: "boolean",
|
||||
},
|
||||
ignoreClassFieldInitialValues: {
|
||||
type: "boolean",
|
||||
},
|
||||
ignoreEnums: {
|
||||
type: "boolean",
|
||||
},
|
||||
ignoreNumericLiteralTypes: {
|
||||
type: "boolean",
|
||||
},
|
||||
ignoreReadonlyClassProperties: {
|
||||
type: "boolean",
|
||||
},
|
||||
ignoreTypeIndexes: {
|
||||
type: "boolean",
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
|
||||
defaultOptions: [
|
||||
{
|
||||
detectObjects: false,
|
||||
enforceConst: false,
|
||||
ignore: [],
|
||||
ignoreArrayIndexes: false,
|
||||
ignoreDefaultValues: false,
|
||||
ignoreClassFieldInitialValues: false,
|
||||
ignoreEnums: false,
|
||||
ignoreNumericLiteralTypes: false,
|
||||
ignoreReadonlyClassProperties: false,
|
||||
ignoreTypeIndexes: false,
|
||||
},
|
||||
],
|
||||
|
||||
messages: {
|
||||
useConst: "Number constants declarations must use 'const'.",
|
||||
noMagic: "No magic number: {{raw}}.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const {
|
||||
detectObjects,
|
||||
enforceConst,
|
||||
ignore: rawIgnore,
|
||||
ignoreArrayIndexes,
|
||||
ignoreDefaultValues,
|
||||
ignoreClassFieldInitialValues,
|
||||
ignoreEnums,
|
||||
ignoreNumericLiteralTypes,
|
||||
ignoreReadonlyClassProperties,
|
||||
ignoreTypeIndexes,
|
||||
} = context.options[0];
|
||||
const ignore = new Set(rawIgnore.map(normalizeIgnoreValue));
|
||||
|
||||
const okTypes = detectObjects
|
||||
? []
|
||||
: ["ObjectExpression", "Property", "AssignmentExpression"];
|
||||
|
||||
/**
|
||||
* Returns whether the rule is configured to ignore the given value
|
||||
* @param {bigint|number} value The value to check
|
||||
* @returns {boolean} true if the value is ignored
|
||||
*/
|
||||
function isIgnoredValue(value) {
|
||||
return ignore.has(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the number is a default value assignment.
|
||||
* @param {ASTNode} fullNumberNode `Literal` or `UnaryExpression` full number node
|
||||
* @returns {boolean} true if the number is a default value
|
||||
*/
|
||||
function isDefaultValue(fullNumberNode) {
|
||||
const parent = fullNumberNode.parent;
|
||||
|
||||
return (
|
||||
parent.type === "AssignmentPattern" &&
|
||||
parent.right === fullNumberNode
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the number is the initial value of a class field.
|
||||
* @param {ASTNode} fullNumberNode `Literal` or `UnaryExpression` full number node
|
||||
* @returns {boolean} true if the number is the initial value of a class field.
|
||||
*/
|
||||
function isClassFieldInitialValue(fullNumberNode) {
|
||||
const parent = fullNumberNode.parent;
|
||||
|
||||
return (
|
||||
parent.type === "PropertyDefinition" &&
|
||||
parent.value === fullNumberNode
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given node is used as a radix within parseInt() or Number.parseInt()
|
||||
* @param {ASTNode} fullNumberNode `Literal` or `UnaryExpression` full number node
|
||||
* @returns {boolean} true if the node is radix
|
||||
*/
|
||||
function isParseIntRadix(fullNumberNode) {
|
||||
const parent = fullNumberNode.parent;
|
||||
|
||||
return (
|
||||
parent.type === "CallExpression" &&
|
||||
fullNumberNode === parent.arguments[1] &&
|
||||
(astUtils.isSpecificId(parent.callee, "parseInt") ||
|
||||
astUtils.isSpecificMemberAccess(
|
||||
parent.callee,
|
||||
"Number",
|
||||
"parseInt",
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given node is a direct child of a JSX node.
|
||||
* In particular, it aims to detect numbers used as prop values in JSX tags.
|
||||
* Example: <input maxLength={10} />
|
||||
* @param {ASTNode} fullNumberNode `Literal` or `UnaryExpression` full number node
|
||||
* @returns {boolean} true if the node is a JSX number
|
||||
*/
|
||||
function isJSXNumber(fullNumberNode) {
|
||||
return fullNumberNode.parent.type.indexOf("JSX") === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given node is used as an array index.
|
||||
* Value must coerce to a valid array index name: "0", "1", "2" ... "4294967294".
|
||||
*
|
||||
* All other values, like "-1", "2.5", or "4294967295", are just "normal" object properties,
|
||||
* which can be created and accessed on an array in addition to the array index properties,
|
||||
* but they don't affect array's length and are not considered by methods such as .map(), .forEach() etc.
|
||||
*
|
||||
* The maximum array length by the specification is 2 ** 32 - 1 = 4294967295,
|
||||
* thus the maximum valid index is 2 ** 32 - 2 = 4294967294.
|
||||
*
|
||||
* All notations are allowed, as long as the value coerces to one of "0", "1", "2" ... "4294967294".
|
||||
*
|
||||
* Valid examples:
|
||||
* a[0], a[1], a[1.2e1], a[0xAB], a[0n], a[1n]
|
||||
* a[-0] (same as a[0] because -0 coerces to "0")
|
||||
* a[-0n] (-0n evaluates to 0n)
|
||||
*
|
||||
* Invalid examples:
|
||||
* a[-1], a[-0xAB], a[-1n], a[2.5], a[1.23e1], a[12e-1]
|
||||
* a[4294967295] (above the max index, it's an access to a regular property a["4294967295"])
|
||||
* a[999999999999999999999] (even if it wasn't above the max index, it would be a["1e+21"])
|
||||
* a[1e310] (same as a["Infinity"])
|
||||
* @param {ASTNode} fullNumberNode `Literal` or `UnaryExpression` full number node
|
||||
* @param {bigint|number} value Value expressed by the fullNumberNode
|
||||
* @returns {boolean} true if the node is a valid array index
|
||||
*/
|
||||
function isArrayIndex(fullNumberNode, value) {
|
||||
const parent = fullNumberNode.parent;
|
||||
|
||||
return (
|
||||
parent.type === "MemberExpression" &&
|
||||
parent.property === fullNumberNode &&
|
||||
(Number.isInteger(value) || typeof value === "bigint") &&
|
||||
value >= 0 &&
|
||||
value < MAX_ARRAY_LENGTH
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
Literal(node) {
|
||||
if (!astUtils.isNumericLiteral(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let fullNumberNode;
|
||||
let value;
|
||||
let raw;
|
||||
|
||||
// Treat unary minus/plus as a part of the number
|
||||
if (
|
||||
node.parent.type === "UnaryExpression" &&
|
||||
["-", "+"].includes(node.parent.operator)
|
||||
) {
|
||||
fullNumberNode = node.parent;
|
||||
value =
|
||||
node.parent.operator === "-" ? -node.value : node.value;
|
||||
raw = `${node.parent.operator}${node.raw}`;
|
||||
} else {
|
||||
fullNumberNode = node;
|
||||
value = node.value;
|
||||
raw = node.raw;
|
||||
}
|
||||
|
||||
const parent = fullNumberNode.parent;
|
||||
|
||||
// Always allow radix arguments and JSX props
|
||||
if (
|
||||
isIgnoredValue(value) ||
|
||||
(ignoreDefaultValues && isDefaultValue(fullNumberNode)) ||
|
||||
(ignoreClassFieldInitialValues &&
|
||||
isClassFieldInitialValue(fullNumberNode)) ||
|
||||
(ignoreEnums &&
|
||||
isParentTSEnumDeclaration(fullNumberNode)) ||
|
||||
(ignoreNumericLiteralTypes &&
|
||||
isTSNumericLiteralType(fullNumberNode)) ||
|
||||
(ignoreTypeIndexes &&
|
||||
isAncestorTSIndexedAccessType(fullNumberNode)) ||
|
||||
(ignoreReadonlyClassProperties &&
|
||||
isParentTSReadonlyPropertyDefinition(fullNumberNode)) ||
|
||||
isParseIntRadix(fullNumberNode) ||
|
||||
isJSXNumber(fullNumberNode) ||
|
||||
(ignoreArrayIndexes && isArrayIndex(fullNumberNode, value))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (parent.type === "VariableDeclarator") {
|
||||
if (enforceConst && parent.parent.kind !== "const") {
|
||||
context.report({
|
||||
node: fullNumberNode,
|
||||
messageId: "useConst",
|
||||
});
|
||||
}
|
||||
} else if (
|
||||
!okTypes.includes(parent.type) ||
|
||||
(parent.type === "AssignmentExpression" &&
|
||||
parent.left.type === "Identifier")
|
||||
) {
|
||||
context.report({
|
||||
node: fullNumberNode,
|
||||
messageId: "noMagic",
|
||||
data: {
|
||||
raw,
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,2 @@
|
||||
import type { LibDefinition } from '../variable';
|
||||
export declare const es2021: LibDefinition;
|
||||
@@ -0,0 +1,12 @@
|
||||
function _using(o, n, e) {
|
||||
if (null == n) return n;
|
||||
if (Object(n) !== n) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
|
||||
if (e) var r = n[Symbol.asyncDispose || Symbol["for"]("Symbol.asyncDispose")];
|
||||
if (null == r && (r = n[Symbol.dispose || Symbol["for"]("Symbol.dispose")]), "function" != typeof r) throw new TypeError("Property [Symbol.dispose] is not a function.");
|
||||
return o.push({
|
||||
v: n,
|
||||
d: r,
|
||||
a: e
|
||||
}), n;
|
||||
}
|
||||
export { _using as default };
|
||||
@@ -0,0 +1,26 @@
|
||||
/*! *****************************************************************************
|
||||
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"/>
|
||||
|
||||
interface ObjectConstructor {
|
||||
/**
|
||||
* Determines whether an object has a property with the specified name.
|
||||
* @param o An object.
|
||||
* @param v A property name.
|
||||
*/
|
||||
hasOwn(o: object, v: PropertyKey): boolean;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
import type { LibDefinition } from '../variable';
|
||||
export declare const es2022_intl: LibDefinition;
|
||||
@@ -0,0 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
const SEQ_INDEX = 2
|
||||
const WRITE_INDEX = 4
|
||||
const READ_INDEX = 8
|
||||
|
||||
module.exports = {
|
||||
WRITE_INDEX,
|
||||
READ_INDEX,
|
||||
SEQ_INDEX
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import type { TSESTree } from '@typescript-eslint/types';
|
||||
import { DefinitionBase } from './DefinitionBase';
|
||||
import { DefinitionType } from './DefinitionType';
|
||||
export declare class ClassNameDefinition extends DefinitionBase<DefinitionType.ClassName, TSESTree.ClassDeclaration | TSESTree.ClassExpression, null, TSESTree.Identifier> {
|
||||
readonly isTypeDefinition = true;
|
||||
readonly isVariableDefinition = true;
|
||||
constructor(name: TSESTree.Identifier, node: ClassNameDefinition['node']);
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
"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.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "символів", verb: "матиме" },
|
||||
file: { unit: "байтів", verb: "матиме" },
|
||||
array: { unit: "елементів", verb: "матиме" },
|
||||
set: { unit: "елементів", verb: "матиме" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "вхідні дані",
|
||||
email: "адреса електронної пошти",
|
||||
url: "URL",
|
||||
emoji: "емодзі",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "дата та час ISO",
|
||||
date: "дата ISO",
|
||||
time: "час ISO",
|
||||
duration: "тривалість ISO",
|
||||
ipv4: "адреса IPv4",
|
||||
ipv6: "адреса IPv6",
|
||||
cidrv4: "діапазон IPv4",
|
||||
cidrv6: "діапазон IPv6",
|
||||
base64: "рядок у кодуванні base64",
|
||||
base64url: "рядок у кодуванні base64url",
|
||||
json_string: "рядок JSON",
|
||||
e164: "номер E.164",
|
||||
jwt: "JWT",
|
||||
template_literal: "вхідні дані",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
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 ?? "значення"} ${sizing.verb} ${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} ${sizing.verb} ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
||||
}
|
||||
return `Занадто мале: очікується, що ${issue.origin} буде ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
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 `Неправильні вхідні дані`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
Reference in New Issue
Block a user