WIP: bootstrap and partial real Solana watcher implementation
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
/**
|
||||
* @fileoverview Rule to check for tabs inside a file
|
||||
* @author Gyandeep Singh
|
||||
* @deprecated in ESLint v8.53.0
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const tabRegex = /\t+/gu;
|
||||
const anyNonWhitespaceRegex = /\S/u;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public Interface
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../types').Rule.RuleModule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
deprecated: {
|
||||
message: "Formatting rules are being moved out of ESLint core.",
|
||||
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
||||
deprecatedSince: "8.53.0",
|
||||
availableUntil: "11.0.0",
|
||||
replacedBy: [
|
||||
{
|
||||
message:
|
||||
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
||||
url: "https://eslint.style/guide/migration",
|
||||
plugin: {
|
||||
name: "@stylistic/eslint-plugin",
|
||||
url: "https://eslint.style",
|
||||
},
|
||||
rule: {
|
||||
name: "no-tabs",
|
||||
url: "https://eslint.style/rules/no-tabs",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
type: "layout",
|
||||
|
||||
docs: {
|
||||
description: "Disallow all tabs",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/no-tabs",
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
allowIndentationTabs: {
|
||||
type: "boolean",
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
|
||||
messages: {
|
||||
unexpectedTab: "Unexpected tab character.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const allowIndentationTabs =
|
||||
context.options &&
|
||||
context.options[0] &&
|
||||
context.options[0].allowIndentationTabs;
|
||||
|
||||
return {
|
||||
Program(node) {
|
||||
sourceCode.getLines().forEach((line, index) => {
|
||||
let match;
|
||||
|
||||
while ((match = tabRegex.exec(line)) !== null) {
|
||||
if (
|
||||
allowIndentationTabs &&
|
||||
!anyNonWhitespaceRegex.test(
|
||||
line.slice(0, match.index),
|
||||
)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
context.report({
|
||||
node,
|
||||
loc: {
|
||||
start: {
|
||||
line: index + 1,
|
||||
column: match.index,
|
||||
},
|
||||
end: {
|
||||
line: index + 1,
|
||||
column: match.index + match[0].length,
|
||||
},
|
||||
},
|
||||
messageId: "unexpectedTab",
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
export { Hfs } from "./hfs.js";
|
||||
export { Path } from "./path.js";
|
||||
export * from "./errors.js";
|
||||
@@ -0,0 +1,25 @@
|
||||
'use strict'
|
||||
|
||||
let Container = require('./container')
|
||||
|
||||
class AtRule extends Container {
|
||||
constructor(defaults) {
|
||||
super(defaults)
|
||||
this.type = 'atrule'
|
||||
}
|
||||
|
||||
append(...children) {
|
||||
if (!this.proxyOf.nodes) this.nodes = []
|
||||
return super.append(...children)
|
||||
}
|
||||
|
||||
prepend(...children) {
|
||||
if (!this.proxyOf.nodes) this.nodes = []
|
||||
return super.prepend(...children)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = AtRule
|
||||
AtRule.default = AtRule
|
||||
|
||||
Container.registerAtRule(AtRule)
|
||||
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
exports._ = require("tslib").__rewriteRelativeImportExtension;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,129 @@
|
||||
import { test } from "vitest";
|
||||
|
||||
import * as z from "zod/mini";
|
||||
|
||||
test("assignability", () => {
|
||||
// $ZodString
|
||||
z.string() satisfies z.core.$ZodString;
|
||||
|
||||
// $ZodNumber
|
||||
z.number() satisfies z.core.$ZodNumber;
|
||||
|
||||
// $ZodBigInt
|
||||
z.bigint() satisfies z.core.$ZodBigInt;
|
||||
|
||||
// $ZodBoolean
|
||||
z.boolean() satisfies z.core.$ZodBoolean;
|
||||
|
||||
// $ZodDate
|
||||
z.date() satisfies z.core.$ZodDate;
|
||||
|
||||
// $ZodSymbol
|
||||
z.symbol() satisfies z.core.$ZodSymbol;
|
||||
|
||||
// $ZodUndefined
|
||||
z.undefined() satisfies z.core.$ZodUndefined;
|
||||
|
||||
// $ZodNullable
|
||||
z.nullable(z.string()) satisfies z.core.$ZodNullable;
|
||||
|
||||
// $ZodNull
|
||||
z.null() satisfies z.core.$ZodNull;
|
||||
|
||||
// $ZodAny
|
||||
z.any() satisfies z.core.$ZodAny;
|
||||
|
||||
// $ZodUnknown
|
||||
z.unknown() satisfies z.core.$ZodUnknown;
|
||||
|
||||
// $ZodNever
|
||||
z.never() satisfies z.core.$ZodNever;
|
||||
|
||||
// $ZodVoid
|
||||
z.void() satisfies z.core.$ZodVoid;
|
||||
|
||||
// $ZodArray
|
||||
z.array(z.string()) satisfies z.core.$ZodArray;
|
||||
|
||||
// $ZodObject
|
||||
z.object({ key: z.string() }) satisfies z.core.$ZodObject;
|
||||
|
||||
// $ZodUnion
|
||||
z.union([z.string(), z.number()]) satisfies z.core.$ZodUnion;
|
||||
|
||||
// $ZodIntersection
|
||||
z.intersection(z.string(), z.number()) satisfies z.core.$ZodIntersection;
|
||||
|
||||
// $ZodTuple
|
||||
z.tuple([z.string(), z.number()]) satisfies z.core.$ZodTuple;
|
||||
|
||||
// $ZodRecord
|
||||
z.record(z.string(), z.number()) satisfies z.core.$ZodRecord;
|
||||
|
||||
// $ZodMap
|
||||
z.map(z.string(), z.number()) satisfies z.core.$ZodMap;
|
||||
|
||||
// $ZodSet
|
||||
z.set(z.string()) satisfies z.core.$ZodSet;
|
||||
|
||||
// $ZodLiteral
|
||||
z.literal("example") satisfies z.core.$ZodLiteral;
|
||||
|
||||
// $ZodEnum
|
||||
z.enum(["a", "b", "c"]) satisfies z.core.$ZodEnum;
|
||||
|
||||
// $ZodPromise
|
||||
z.promise(z.string()) satisfies z.core.$ZodPromise;
|
||||
|
||||
// $ZodLazy
|
||||
const lazySchema = z.lazy(() => z.string());
|
||||
lazySchema satisfies z.core.$ZodLazy;
|
||||
|
||||
// $ZodOptional
|
||||
z.optional(z.string()) satisfies z.core.$ZodOptional;
|
||||
|
||||
// $ZodDefault
|
||||
z._default(z.string(), "default") satisfies z.core.$ZodDefault;
|
||||
|
||||
// $ZodTemplateLiteral
|
||||
z.templateLiteral([z.literal("a"), z.literal("b")]) satisfies z.core.$ZodTemplateLiteral;
|
||||
|
||||
// $ZodCustom
|
||||
z.custom<string>((val) => typeof val === "string") satisfies z.core.$ZodCustom;
|
||||
|
||||
// $ZodTransform
|
||||
z.transform((val) => val as string) satisfies z.core.$ZodTransform;
|
||||
|
||||
// $ZodNonOptional
|
||||
z.nonoptional(z.optional(z.string())) satisfies z.core.$ZodNonOptional;
|
||||
|
||||
// $ZodReadonly
|
||||
z.readonly(z.object({ key: z.string() })) satisfies z.core.$ZodReadonly;
|
||||
|
||||
// $ZodNaN
|
||||
z.nan() satisfies z.core.$ZodNaN;
|
||||
|
||||
// $ZodPipe
|
||||
z.pipe(z.unknown(), z.number()) satisfies z.core.$ZodPipe;
|
||||
|
||||
// $ZodSuccess
|
||||
z.success(z.string()) satisfies z.core.$ZodSuccess;
|
||||
|
||||
// $ZodCatch
|
||||
z.catch(z.string(), "fallback") satisfies z.core.$ZodCatch;
|
||||
|
||||
// $ZodFile
|
||||
z.file() satisfies z.core.$ZodFile;
|
||||
});
|
||||
|
||||
test("assignability with type narrowing", () => {
|
||||
type _RefinedSchema<T extends z.ZodMiniType<object> | z.ZodMiniUnion> = T extends z.ZodMiniUnion
|
||||
? RefinedUnionSchema<T> // <-- Type instantiation is excessively deep and possibly infinite.
|
||||
: T extends z.ZodMiniType<object>
|
||||
? RefinedTypeSchema<z.output<T>> // <-- Type instantiation is excessively deep and possibly infinite.
|
||||
: never;
|
||||
|
||||
type RefinedTypeSchema<T extends object> = T;
|
||||
|
||||
type RefinedUnionSchema<T extends z.ZodMiniUnion> = T;
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
'use strict'
|
||||
|
||||
const numeric = /^[0-9]+$/
|
||||
const compareIdentifiers = (a, b) => {
|
||||
if (typeof a === 'number' && typeof b === 'number') {
|
||||
return a === b ? 0 : a < b ? -1 : 1
|
||||
}
|
||||
|
||||
const anum = numeric.test(a)
|
||||
const bnum = numeric.test(b)
|
||||
|
||||
if (anum && bnum) {
|
||||
a = +a
|
||||
b = +b
|
||||
}
|
||||
|
||||
return a === b ? 0
|
||||
: (anum && !bnum) ? -1
|
||||
: (bnum && !anum) ? 1
|
||||
: a < b ? -1
|
||||
: 1
|
||||
}
|
||||
|
||||
const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a)
|
||||
|
||||
module.exports = {
|
||||
compareIdentifiers,
|
||||
rcompareIdentifiers,
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,143 @@
|
||||
'use strict'
|
||||
|
||||
const ANY = Symbol('SemVer ANY')
|
||||
// hoisted class for cyclic dependency
|
||||
class Comparator {
|
||||
static get ANY () {
|
||||
return ANY
|
||||
}
|
||||
|
||||
constructor (comp, options) {
|
||||
options = parseOptions(options)
|
||||
|
||||
if (comp instanceof Comparator) {
|
||||
if (comp.loose === !!options.loose) {
|
||||
return comp
|
||||
} else {
|
||||
comp = comp.value
|
||||
}
|
||||
}
|
||||
|
||||
comp = comp.trim().split(/\s+/).join(' ')
|
||||
debug('comparator', comp, options)
|
||||
this.options = options
|
||||
this.loose = !!options.loose
|
||||
this.parse(comp)
|
||||
|
||||
if (this.semver === ANY) {
|
||||
this.value = ''
|
||||
} else {
|
||||
this.value = this.operator + this.semver.version
|
||||
}
|
||||
|
||||
debug('comp', this)
|
||||
}
|
||||
|
||||
parse (comp) {
|
||||
const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]
|
||||
const m = comp.match(r)
|
||||
|
||||
if (!m) {
|
||||
throw new TypeError(`Invalid comparator: ${comp}`)
|
||||
}
|
||||
|
||||
this.operator = m[1] !== undefined ? m[1] : ''
|
||||
if (this.operator === '=') {
|
||||
this.operator = ''
|
||||
}
|
||||
|
||||
// if it literally is just '>' or '' then allow anything.
|
||||
if (!m[2]) {
|
||||
this.semver = ANY
|
||||
} else {
|
||||
this.semver = new SemVer(m[2], this.options.loose)
|
||||
}
|
||||
}
|
||||
|
||||
toString () {
|
||||
return this.value
|
||||
}
|
||||
|
||||
test (version) {
|
||||
debug('Comparator.test', version, this.options.loose)
|
||||
|
||||
if (this.semver === ANY || version === ANY) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (typeof version === 'string') {
|
||||
try {
|
||||
version = new SemVer(version, this.options)
|
||||
} catch (er) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return cmp(version, this.operator, this.semver, this.options)
|
||||
}
|
||||
|
||||
intersects (comp, options) {
|
||||
if (!(comp instanceof Comparator)) {
|
||||
throw new TypeError('a Comparator is required')
|
||||
}
|
||||
|
||||
if (this.operator === '') {
|
||||
if (this.value === '') {
|
||||
return true
|
||||
}
|
||||
return new Range(comp.value, options).test(this.value)
|
||||
} else if (comp.operator === '') {
|
||||
if (comp.value === '') {
|
||||
return true
|
||||
}
|
||||
return new Range(this.value, options).test(comp.semver)
|
||||
}
|
||||
|
||||
options = parseOptions(options)
|
||||
|
||||
// Special cases where nothing can possibly be lower
|
||||
if (options.includePrerelease &&
|
||||
(this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) {
|
||||
return false
|
||||
}
|
||||
if (!options.includePrerelease &&
|
||||
(this.value.startsWith('<0.0.0') || comp.value.startsWith('<0.0.0'))) {
|
||||
return false
|
||||
}
|
||||
|
||||
// Same direction increasing (> or >=)
|
||||
if (this.operator.startsWith('>') && comp.operator.startsWith('>')) {
|
||||
return true
|
||||
}
|
||||
// Same direction decreasing (< or <=)
|
||||
if (this.operator.startsWith('<') && comp.operator.startsWith('<')) {
|
||||
return true
|
||||
}
|
||||
// same SemVer and both sides are inclusive (<= or >=)
|
||||
if (
|
||||
(this.semver.version === comp.semver.version) &&
|
||||
this.operator.includes('=') && comp.operator.includes('=')) {
|
||||
return true
|
||||
}
|
||||
// opposite directions less than
|
||||
if (cmp(this.semver, '<', comp.semver, options) &&
|
||||
this.operator.startsWith('>') && comp.operator.startsWith('<')) {
|
||||
return true
|
||||
}
|
||||
// opposite directions greater than
|
||||
if (cmp(this.semver, '>', comp.semver, options) &&
|
||||
this.operator.startsWith('<') && comp.operator.startsWith('>')) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Comparator
|
||||
|
||||
const parseOptions = require('../internal/parse-options')
|
||||
const { safeRe: re, t } = require('../internal/re')
|
||||
const cmp = require('../functions/cmp')
|
||||
const debug = require('../internal/debug')
|
||||
const SemVer = require('./semver')
|
||||
const Range = require('./range')
|
||||
@@ -0,0 +1,224 @@
|
||||
export namespace util {
|
||||
type AssertEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends <V>() => V extends U ? 1 : 2 ? true : false;
|
||||
|
||||
export type isAny<T> = 0 extends 1 & T ? true : false;
|
||||
export const assertEqual = <A, B>(_: AssertEqual<A, B>): void => {};
|
||||
export function assertIs<T>(_arg: T): void {}
|
||||
export function assertNever(_x: never): never {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
||||
export type OmitKeys<T, K extends string> = Pick<T, Exclude<keyof T, K>>;
|
||||
export type MakePartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
||||
export type Exactly<T, X> = T & Record<Exclude<keyof X, keyof T>, never>;
|
||||
export type InexactPartial<T> = { [k in keyof T]?: T[k] | undefined };
|
||||
export const arrayToEnum = <T extends string, U extends [T, ...T[]]>(items: U): { [k in U[number]]: k } => {
|
||||
const obj: any = {};
|
||||
for (const item of items) {
|
||||
obj[item] = item;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
|
||||
export const getValidEnumValues = (obj: any): any[] => {
|
||||
const validKeys = objectKeys(obj).filter((k: any) => typeof obj[obj[k]] !== "number");
|
||||
const filtered: any = {};
|
||||
for (const k of validKeys) {
|
||||
filtered[k] = obj[k];
|
||||
}
|
||||
return objectValues(filtered);
|
||||
};
|
||||
|
||||
export const objectValues = (obj: any): any[] => {
|
||||
return objectKeys(obj).map(function (e) {
|
||||
return obj[e];
|
||||
});
|
||||
};
|
||||
|
||||
export const objectKeys: ObjectConstructor["keys"] =
|
||||
typeof Object.keys === "function" // eslint-disable-line ban/ban
|
||||
? (obj: any) => Object.keys(obj) // eslint-disable-line ban/ban
|
||||
: (object: any) => {
|
||||
const keys = [];
|
||||
for (const key in object) {
|
||||
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
||||
keys.push(key);
|
||||
}
|
||||
}
|
||||
return keys;
|
||||
};
|
||||
|
||||
export const find = <T>(arr: T[], checker: (arg: T) => any): T | undefined => {
|
||||
for (const item of arr) {
|
||||
if (checker(item)) return item;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
export type identity<T> = objectUtil.identity<T>;
|
||||
export type flatten<T> = objectUtil.flatten<T>;
|
||||
|
||||
export type noUndefined<T> = T extends undefined ? never : T;
|
||||
|
||||
export const isInteger: NumberConstructor["isInteger"] =
|
||||
typeof Number.isInteger === "function"
|
||||
? (val) => Number.isInteger(val) // eslint-disable-line ban/ban
|
||||
: (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
|
||||
|
||||
export function joinValues<T extends any[]>(array: T, separator = " | "): string {
|
||||
return array.map((val) => (typeof val === "string" ? `'${val}'` : val)).join(separator);
|
||||
}
|
||||
|
||||
export const jsonStringifyReplacer = (_: string, value: any): any => {
|
||||
if (typeof value === "bigint") {
|
||||
return value.toString();
|
||||
}
|
||||
return value;
|
||||
};
|
||||
}
|
||||
|
||||
export namespace objectUtil {
|
||||
export type MergeShapes<U, V> =
|
||||
// fast path when there is no keys overlap
|
||||
keyof U & keyof V extends never
|
||||
? U & V
|
||||
: {
|
||||
[k in Exclude<keyof U, keyof V>]: U[k];
|
||||
} & V;
|
||||
|
||||
type optionalKeys<T extends object> = {
|
||||
[k in keyof T]: undefined extends T[k] ? k : never;
|
||||
}[keyof T];
|
||||
type requiredKeys<T extends object> = {
|
||||
[k in keyof T]: undefined extends T[k] ? never : k;
|
||||
}[keyof T];
|
||||
export type addQuestionMarks<T extends object, _O = any> = {
|
||||
[K in requiredKeys<T>]: T[K];
|
||||
} & {
|
||||
[K in optionalKeys<T>]?: T[K];
|
||||
} & { [k in keyof T]?: unknown };
|
||||
|
||||
export type identity<T> = T;
|
||||
export type flatten<T> = identity<{ [k in keyof T]: T[k] }>;
|
||||
|
||||
export type noNeverKeys<T> = {
|
||||
[k in keyof T]: [T[k]] extends [never] ? never : k;
|
||||
}[keyof T];
|
||||
|
||||
export type noNever<T> = identity<{
|
||||
[k in noNeverKeys<T>]: k extends keyof T ? T[k] : never;
|
||||
}>;
|
||||
|
||||
export const mergeShapes = <U, T>(first: U, second: T): T & U => {
|
||||
return {
|
||||
...first,
|
||||
...second, // second overwrites first
|
||||
};
|
||||
};
|
||||
|
||||
export type extendShape<A extends object, B extends object> = keyof A & keyof B extends never // fast path when there is no keys overlap
|
||||
? A & B
|
||||
: {
|
||||
[K in keyof A as K extends keyof B ? never : K]: A[K];
|
||||
} & {
|
||||
[K in keyof B]: B[K];
|
||||
};
|
||||
}
|
||||
|
||||
export const ZodParsedType: {
|
||||
string: "string";
|
||||
nan: "nan";
|
||||
number: "number";
|
||||
integer: "integer";
|
||||
float: "float";
|
||||
boolean: "boolean";
|
||||
date: "date";
|
||||
bigint: "bigint";
|
||||
symbol: "symbol";
|
||||
function: "function";
|
||||
undefined: "undefined";
|
||||
null: "null";
|
||||
array: "array";
|
||||
object: "object";
|
||||
unknown: "unknown";
|
||||
promise: "promise";
|
||||
void: "void";
|
||||
never: "never";
|
||||
map: "map";
|
||||
set: "set";
|
||||
} = util.arrayToEnum([
|
||||
"string",
|
||||
"nan",
|
||||
"number",
|
||||
"integer",
|
||||
"float",
|
||||
"boolean",
|
||||
"date",
|
||||
"bigint",
|
||||
"symbol",
|
||||
"function",
|
||||
"undefined",
|
||||
"null",
|
||||
"array",
|
||||
"object",
|
||||
"unknown",
|
||||
"promise",
|
||||
"void",
|
||||
"never",
|
||||
"map",
|
||||
"set",
|
||||
]);
|
||||
|
||||
export type ZodParsedType = keyof typeof ZodParsedType;
|
||||
|
||||
export const getParsedType = (data: any): ZodParsedType => {
|
||||
const t = typeof data;
|
||||
|
||||
switch (t) {
|
||||
case "undefined":
|
||||
return ZodParsedType.undefined;
|
||||
|
||||
case "string":
|
||||
return ZodParsedType.string;
|
||||
|
||||
case "number":
|
||||
return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
|
||||
|
||||
case "boolean":
|
||||
return ZodParsedType.boolean;
|
||||
|
||||
case "function":
|
||||
return ZodParsedType.function;
|
||||
|
||||
case "bigint":
|
||||
return ZodParsedType.bigint;
|
||||
|
||||
case "symbol":
|
||||
return ZodParsedType.symbol;
|
||||
|
||||
case "object":
|
||||
if (Array.isArray(data)) {
|
||||
return ZodParsedType.array;
|
||||
}
|
||||
if (data === null) {
|
||||
return ZodParsedType.null;
|
||||
}
|
||||
if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
|
||||
return ZodParsedType.promise;
|
||||
}
|
||||
if (typeof Map !== "undefined" && data instanceof Map) {
|
||||
return ZodParsedType.map;
|
||||
}
|
||||
if (typeof Set !== "undefined" && data instanceof Set) {
|
||||
return ZodParsedType.set;
|
||||
}
|
||||
if (typeof Date !== "undefined" && data instanceof Date) {
|
||||
return ZodParsedType.date;
|
||||
}
|
||||
return ZodParsedType.object;
|
||||
|
||||
default:
|
||||
return ZodParsedType.unknown;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
const {Transform} = require('stream');
|
||||
|
||||
class JsonlStringer extends Transform {
|
||||
static make(options) {
|
||||
return new JsonlStringer(options);
|
||||
}
|
||||
|
||||
constructor(options) {
|
||||
super(Object.assign({}, options, {writableObjectMode: true, readableObjectMode: false}));
|
||||
this._replacer = options && options.replacer;
|
||||
}
|
||||
|
||||
_transform(chunk, _, callback) {
|
||||
this.push(JSON.stringify(chunk, this._replacer));
|
||||
this._transform = this._nextTransform;
|
||||
callback(null);
|
||||
}
|
||||
|
||||
_nextTransform(chunk, _, callback) {
|
||||
this.push('\n' + JSON.stringify(chunk, this._replacer));
|
||||
callback(null);
|
||||
}
|
||||
}
|
||||
JsonlStringer.stringer = JsonlStringer.make;
|
||||
JsonlStringer.make.Constructor = JsonlStringer;
|
||||
|
||||
module.exports = JsonlStringer;
|
||||
@@ -0,0 +1,194 @@
|
||||
// @ts-ignore TS6133
|
||||
import { expect, test } from "vitest";
|
||||
|
||||
import * as z from "zod/v3";
|
||||
import { util } from "../helpers/util.js";
|
||||
|
||||
enum testEnum {
|
||||
A = 0,
|
||||
B = 1,
|
||||
}
|
||||
|
||||
const schemas = [
|
||||
z.string().readonly(),
|
||||
z.number().readonly(),
|
||||
z.nan().readonly(),
|
||||
z.bigint().readonly(),
|
||||
z.boolean().readonly(),
|
||||
z.date().readonly(),
|
||||
z.undefined().readonly(),
|
||||
z.null().readonly(),
|
||||
z.any().readonly(),
|
||||
z.unknown().readonly(),
|
||||
z.void().readonly(),
|
||||
z.function().args(z.string(), z.number()).readonly(),
|
||||
|
||||
z.array(z.string()).readonly(),
|
||||
z.tuple([z.string(), z.number()]).readonly(),
|
||||
z.map(z.string(), z.date()).readonly(),
|
||||
z.set(z.promise(z.string())).readonly(),
|
||||
z.record(z.string()).readonly(),
|
||||
z.record(z.string(), z.number()).readonly(),
|
||||
z.object({ a: z.string(), 1: z.number() }).readonly(),
|
||||
z.nativeEnum(testEnum).readonly(),
|
||||
z.promise(z.string()).readonly(),
|
||||
] as const;
|
||||
|
||||
test("flat inference", () => {
|
||||
util.assertEqual<z.infer<(typeof schemas)[0]>, string>(true);
|
||||
util.assertEqual<z.infer<(typeof schemas)[1]>, number>(true);
|
||||
util.assertEqual<z.infer<(typeof schemas)[2]>, number>(true);
|
||||
util.assertEqual<z.infer<(typeof schemas)[3]>, bigint>(true);
|
||||
util.assertEqual<z.infer<(typeof schemas)[4]>, boolean>(true);
|
||||
util.assertEqual<z.infer<(typeof schemas)[5]>, Date>(true);
|
||||
util.assertEqual<z.infer<(typeof schemas)[6]>, undefined>(true);
|
||||
util.assertEqual<z.infer<(typeof schemas)[7]>, null>(true);
|
||||
util.assertEqual<z.infer<(typeof schemas)[8]>, any>(true);
|
||||
util.assertEqual<z.infer<(typeof schemas)[9]>, Readonly<unknown>>(true);
|
||||
util.assertEqual<z.infer<(typeof schemas)[10]>, void>(true);
|
||||
util.assertEqual<z.infer<(typeof schemas)[11]>, (args_0: string, args_1: number, ...args_2: unknown[]) => unknown>(
|
||||
true
|
||||
);
|
||||
util.assertEqual<z.infer<(typeof schemas)[12]>, readonly string[]>(true);
|
||||
|
||||
util.assertEqual<z.infer<(typeof schemas)[13]>, readonly [string, number]>(true);
|
||||
util.assertEqual<z.infer<(typeof schemas)[14]>, ReadonlyMap<string, Date>>(true);
|
||||
util.assertEqual<z.infer<(typeof schemas)[15]>, ReadonlySet<Promise<string>>>(true);
|
||||
util.assertEqual<z.infer<(typeof schemas)[16]>, Readonly<Record<string, string>>>(true);
|
||||
util.assertEqual<z.infer<(typeof schemas)[17]>, Readonly<Record<string, number>>>(true);
|
||||
util.assertEqual<z.infer<(typeof schemas)[18]>, { readonly a: string; readonly 1: number }>(true);
|
||||
util.assertEqual<z.infer<(typeof schemas)[19]>, Readonly<testEnum>>(true);
|
||||
util.assertEqual<z.infer<(typeof schemas)[20]>, Promise<string>>(true);
|
||||
});
|
||||
|
||||
// test("deep inference", () => {
|
||||
// util.assertEqual<z.infer<(typeof deepReadonlySchemas_0)[0]>, string>(true);
|
||||
// util.assertEqual<z.infer<(typeof deepReadonlySchemas_0)[1]>, number>(true);
|
||||
// util.assertEqual<z.infer<(typeof deepReadonlySchemas_0)[2]>, number>(true);
|
||||
// util.assertEqual<z.infer<(typeof deepReadonlySchemas_0)[3]>, bigint>(true);
|
||||
// util.assertEqual<z.infer<(typeof deepReadonlySchemas_0)[4]>, boolean>(true);
|
||||
// util.assertEqual<z.infer<(typeof deepReadonlySchemas_0)[5]>, Date>(true);
|
||||
// util.assertEqual<z.infer<(typeof deepReadonlySchemas_0)[6]>, undefined>(true);
|
||||
// util.assertEqual<z.infer<(typeof deepReadonlySchemas_0)[7]>, null>(true);
|
||||
// util.assertEqual<z.infer<(typeof deepReadonlySchemas_0)[8]>, any>(true);
|
||||
// util.assertEqual<
|
||||
// z.infer<(typeof deepReadonlySchemas_0)[9]>,
|
||||
// Readonly<unknown>
|
||||
// >(true);
|
||||
// util.assertEqual<z.infer<(typeof deepReadonlySchemas_0)[10]>, void>(true);
|
||||
// util.assertEqual<
|
||||
// z.infer<(typeof deepReadonlySchemas_0)[11]>,
|
||||
// (args_0: string, args_1: number, ...args_2: unknown[]) => unknown
|
||||
// >(true);
|
||||
// util.assertEqual<
|
||||
// z.infer<(typeof deepReadonlySchemas_0)[12]>,
|
||||
// readonly string[]
|
||||
// >(true);
|
||||
// util.assertEqual<
|
||||
// z.infer<(typeof deepReadonlySchemas_0)[13]>,
|
||||
// readonly [string, number]
|
||||
// >(true);
|
||||
// util.assertEqual<
|
||||
// z.infer<(typeof deepReadonlySchemas_0)[14]>,
|
||||
// ReadonlyMap<string, Date>
|
||||
// >(true);
|
||||
// util.assertEqual<
|
||||
// z.infer<(typeof deepReadonlySchemas_0)[15]>,
|
||||
// ReadonlySet<Promise<string>>
|
||||
// >(true);
|
||||
// util.assertEqual<
|
||||
// z.infer<(typeof deepReadonlySchemas_0)[16]>,
|
||||
// Readonly<Record<string, string>>
|
||||
// >(true);
|
||||
// util.assertEqual<
|
||||
// z.infer<(typeof deepReadonlySchemas_0)[17]>,
|
||||
// Readonly<Record<string, number>>
|
||||
// >(true);
|
||||
// util.assertEqual<
|
||||
// z.infer<(typeof deepReadonlySchemas_0)[18]>,
|
||||
// { readonly a: string; readonly 1: number }
|
||||
// >(true);
|
||||
// util.assertEqual<
|
||||
// z.infer<(typeof deepReadonlySchemas_0)[19]>,
|
||||
// Readonly<testEnum>
|
||||
// >(true);
|
||||
// util.assertEqual<
|
||||
// z.infer<(typeof deepReadonlySchemas_0)[20]>,
|
||||
// Promise<string>
|
||||
// >(true);
|
||||
|
||||
// util.assertEqual<
|
||||
// z.infer<typeof crazyDeepReadonlySchema>,
|
||||
// ReadonlyMap<
|
||||
// ReadonlySet<readonly [string, number]>,
|
||||
// {
|
||||
// readonly a: {
|
||||
// readonly [x: string]: readonly any[];
|
||||
// };
|
||||
// readonly b: {
|
||||
// readonly c: {
|
||||
// readonly d: {
|
||||
// readonly e: {
|
||||
// readonly f: {
|
||||
// readonly g?: {};
|
||||
// };
|
||||
// };
|
||||
// };
|
||||
// };
|
||||
// };
|
||||
// }
|
||||
// >
|
||||
// >(true);
|
||||
// });
|
||||
|
||||
test("object freezing", () => {
|
||||
expect(Object.isFrozen(z.array(z.string()).readonly().parse(["a"]))).toBe(true);
|
||||
expect(Object.isFrozen(z.tuple([z.string(), z.number()]).readonly().parse(["a", 1]))).toBe(true);
|
||||
expect(
|
||||
Object.isFrozen(
|
||||
z
|
||||
.map(z.string(), z.date())
|
||||
.readonly()
|
||||
.parse(new Map([["a", new Date()]]))
|
||||
)
|
||||
).toBe(true);
|
||||
expect(
|
||||
Object.isFrozen(
|
||||
z
|
||||
.set(z.promise(z.string()))
|
||||
.readonly()
|
||||
.parse(new Set([Promise.resolve("a")]))
|
||||
)
|
||||
).toBe(true);
|
||||
expect(Object.isFrozen(z.record(z.string()).readonly().parse({ a: "b" }))).toBe(true);
|
||||
expect(Object.isFrozen(z.record(z.string(), z.number()).readonly().parse({ a: 1 }))).toBe(true);
|
||||
expect(Object.isFrozen(z.object({ a: z.string(), 1: z.number() }).readonly().parse({ a: "b", 1: 2 }))).toBe(true);
|
||||
expect(Object.isFrozen(z.promise(z.string()).readonly().parse(Promise.resolve("a")))).toBe(true);
|
||||
});
|
||||
|
||||
test("async object freezing", async () => {
|
||||
expect(Object.isFrozen(await z.array(z.string()).readonly().parseAsync(["a"]))).toBe(true);
|
||||
expect(Object.isFrozen(await z.tuple([z.string(), z.number()]).readonly().parseAsync(["a", 1]))).toBe(true);
|
||||
expect(
|
||||
Object.isFrozen(
|
||||
await z
|
||||
.map(z.string(), z.date())
|
||||
.readonly()
|
||||
.parseAsync(new Map([["a", new Date()]]))
|
||||
)
|
||||
).toBe(true);
|
||||
expect(
|
||||
Object.isFrozen(
|
||||
await z
|
||||
.set(z.promise(z.string()))
|
||||
.readonly()
|
||||
.parseAsync(new Set([Promise.resolve("a")]))
|
||||
)
|
||||
).toBe(true);
|
||||
expect(Object.isFrozen(await z.record(z.string()).readonly().parseAsync({ a: "b" }))).toBe(true);
|
||||
expect(Object.isFrozen(await z.record(z.string(), z.number()).readonly().parseAsync({ a: 1 }))).toBe(true);
|
||||
expect(
|
||||
Object.isFrozen(await z.object({ a: z.string(), 1: z.number() }).readonly().parseAsync({ a: "b", 1: 2 }))
|
||||
).toBe(true);
|
||||
expect(Object.isFrozen(await z.promise(z.string()).readonly().parseAsync(Promise.resolve("a")))).toBe(true);
|
||||
});
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Wrap words to a specified length.
|
||||
*/
|
||||
export = wrap;
|
||||
|
||||
declare function wrap(str: string, options?: wrap.IOptions): string;
|
||||
|
||||
declare namespace wrap {
|
||||
export interface IOptions {
|
||||
|
||||
/**
|
||||
* The width of the text before wrapping to a new line.
|
||||
* @default ´50´
|
||||
*/
|
||||
width?: number;
|
||||
|
||||
/**
|
||||
* The string to use at the beginning of each line.
|
||||
* @default ´ ´ (two spaces)
|
||||
*/
|
||||
indent?: string;
|
||||
|
||||
/**
|
||||
* The string to use at the end of each line.
|
||||
* @default ´\n´
|
||||
*/
|
||||
newline?: string;
|
||||
|
||||
/**
|
||||
* An escape function to run on each line after splitting them.
|
||||
* @default (str: string) => string;
|
||||
*/
|
||||
escape?: (str: string) => string;
|
||||
|
||||
/**
|
||||
* Trim trailing whitespace from the returned string.
|
||||
* This option is included since .trim() would also strip
|
||||
* the leading indentation from the first line.
|
||||
* @default true
|
||||
*/
|
||||
trim?: boolean;
|
||||
|
||||
/**
|
||||
* Break a word between any two letters when the word is longer
|
||||
* than the specified width.
|
||||
* @default false
|
||||
*/
|
||||
cut?: boolean;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*! *****************************************************************************
|
||||
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,
|
||||
MERCHANTABILITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
interface ObjectConstructor {
|
||||
/**
|
||||
* Groups members of an iterable according to the return value of the passed callback.
|
||||
* @param items An iterable.
|
||||
* @param keySelector A callback which will be invoked for each item in items.
|
||||
*/
|
||||
groupBy<K extends PropertyKey, T>(
|
||||
items: Iterable<T>,
|
||||
keySelector: (item: T, index: number) => K,
|
||||
): Partial<Record<K, T[]>>;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"main": "../../cjs/_identity.cjs",
|
||||
"module": "../../esm/_identity.js"
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"main": "../../cjs/_object_spread_props.cjs",
|
||||
"module": "../../esm/_object_spread_props.js"
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
"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: "znaków", verb: "mieć" },
|
||||
file: { unit: "bajtów", verb: "mieć" },
|
||||
array: { unit: "elementów", verb: "mieć" },
|
||||
set: { unit: "elementów", verb: "mieć" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "wyrażenie",
|
||||
email: "adres email",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "data i godzina w formacie ISO",
|
||||
date: "data w formacie ISO",
|
||||
time: "godzina w formacie ISO",
|
||||
duration: "czas trwania ISO",
|
||||
ipv4: "adres IPv4",
|
||||
ipv6: "adres IPv6",
|
||||
cidrv4: "zakres IPv4",
|
||||
cidrv6: "zakres IPv6",
|
||||
base64: "ciąg znaków zakodowany w formacie base64",
|
||||
base64url: "ciąg znaków zakodowany w formacie base64url",
|
||||
json_string: "ciąg znaków w formacie JSON",
|
||||
e164: "liczba E.164",
|
||||
jwt: "JWT",
|
||||
template_literal: "wejście",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
number: "liczba",
|
||||
array: "tablica",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Nieprawidłowe dane wejściowe: oczekiwano instanceof ${issue.expected}, otrzymano ${received}`;
|
||||
}
|
||||
return `Nieprawidłowe dane wejściowe: oczekiwano ${expected}, otrzymano ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Nieprawidłowe dane wejściowe: oczekiwano ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Nieprawidłowa opcja: oczekiwano jednej z wartości ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Za duża wartość: oczekiwano, że ${issue.origin ?? "wartość"} będzie mieć ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elementów"}`;
|
||||
}
|
||||
return `Zbyt duż(y/a/e): oczekiwano, że ${issue.origin ?? "wartość"} będzie wynosić ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Za mała wartość: oczekiwano, że ${issue.origin ?? "wartość"} będzie mieć ${adj}${issue.minimum.toString()} ${sizing.unit ?? "elementów"}`;
|
||||
}
|
||||
return `Zbyt mał(y/a/e): oczekiwano, że ${issue.origin ?? "wartość"} będzie wynosić ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Nieprawidłowy ciąg znaków: musi zaczynać się od "${_issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Nieprawidłowy ciąg znaków: musi kończyć się na "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Nieprawidłowy ciąg znaków: musi zawierać "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Nieprawidłowy ciąg znaków: musi odpowiadać wzorcowi ${_issue.pattern}`;
|
||||
return `Nieprawidłow(y/a/e) ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Nieprawidłowa liczba: musi być wielokrotnością ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Nierozpoznane klucze${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Nieprawidłowy klucz w ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Nieprawidłowe dane wejściowe";
|
||||
case "invalid_element":
|
||||
return `Nieprawidłowa wartość w ${issue.origin}`;
|
||||
default:
|
||||
return `Nieprawidłowe dane wejściowe`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
@@ -0,0 +1,150 @@
|
||||
/**
|
||||
* @fileoverview Enforce spacing between rest and spread operators and their expressions.
|
||||
* @author Kai Cataldo
|
||||
* @deprecated in ESLint v8.53.0
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../types').Rule.RuleModule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
deprecated: {
|
||||
message: "Formatting rules are being moved out of ESLint core.",
|
||||
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
||||
deprecatedSince: "8.53.0",
|
||||
availableUntil: "11.0.0",
|
||||
replacedBy: [
|
||||
{
|
||||
message:
|
||||
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
||||
url: "https://eslint.style/guide/migration",
|
||||
plugin: {
|
||||
name: "@stylistic/eslint-plugin",
|
||||
url: "https://eslint.style",
|
||||
},
|
||||
rule: {
|
||||
name: "rest-spread-spacing",
|
||||
url: "https://eslint.style/rules/rest-spread-spacing",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
type: "layout",
|
||||
|
||||
docs: {
|
||||
description:
|
||||
"Enforce spacing between rest and spread operators and their expressions",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/rest-spread-spacing",
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
|
||||
schema: [
|
||||
{
|
||||
enum: ["always", "never"],
|
||||
},
|
||||
],
|
||||
|
||||
messages: {
|
||||
unexpectedWhitespace:
|
||||
"Unexpected whitespace after {{type}} operator.",
|
||||
expectedWhitespace: "Expected whitespace after {{type}} operator.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode,
|
||||
alwaysSpace = context.options[0] === "always";
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Checks whitespace between rest/spread operators and their expressions
|
||||
* @param {ASTNode} node The node to check
|
||||
* @returns {void}
|
||||
*/
|
||||
function checkWhiteSpace(node) {
|
||||
const operator = sourceCode.getFirstToken(node),
|
||||
nextToken = sourceCode.getTokenAfter(operator),
|
||||
hasWhitespace = sourceCode.isSpaceBetween(operator, nextToken);
|
||||
let type;
|
||||
|
||||
switch (node.type) {
|
||||
case "SpreadElement":
|
||||
type = "spread";
|
||||
if (node.parent.type === "ObjectExpression") {
|
||||
type += " property";
|
||||
}
|
||||
break;
|
||||
case "RestElement":
|
||||
type = "rest";
|
||||
if (node.parent.type === "ObjectPattern") {
|
||||
type += " property";
|
||||
}
|
||||
break;
|
||||
case "ExperimentalSpreadProperty":
|
||||
type = "spread property";
|
||||
break;
|
||||
case "ExperimentalRestProperty":
|
||||
type = "rest property";
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (alwaysSpace && !hasWhitespace) {
|
||||
context.report({
|
||||
node,
|
||||
loc: operator.loc,
|
||||
messageId: "expectedWhitespace",
|
||||
data: {
|
||||
type,
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.replaceTextRange(
|
||||
[operator.range[1], nextToken.range[0]],
|
||||
" ",
|
||||
);
|
||||
},
|
||||
});
|
||||
} else if (!alwaysSpace && hasWhitespace) {
|
||||
context.report({
|
||||
node,
|
||||
loc: {
|
||||
start: operator.loc.end,
|
||||
end: nextToken.loc.start,
|
||||
},
|
||||
messageId: "unexpectedWhitespace",
|
||||
data: {
|
||||
type,
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.removeRange([
|
||||
operator.range[1],
|
||||
nextToken.range[0],
|
||||
]);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Public
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
return {
|
||||
SpreadElement: checkWhiteSpace,
|
||||
RestElement: checkWhiteSpace,
|
||||
ExperimentalSpreadProperty: checkWhiteSpace,
|
||||
ExperimentalRestProperty: checkWhiteSpace,
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
function tsRewriteRelativeImportExtensions(t, e) {
|
||||
return "string" == typeof t && /^\.\.?\//.test(t) ? t.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+)?)\.([cm]?)ts$/i, function (t, s, r, n, o) {
|
||||
return s ? e ? ".jsx" : ".js" : !r || n && o ? r + n + "." + o.toLowerCase() + "js" : t;
|
||||
}) : t;
|
||||
}
|
||||
export { tsRewriteRelativeImportExtensions as default };
|
||||
@@ -0,0 +1 @@
|
||||
export { _ as default } from "../esm/_await_value.js";
|
||||
@@ -0,0 +1,389 @@
|
||||
export declare enum SyntaxKind {
|
||||
Unknown = 0,
|
||||
EndOfFile = 1,
|
||||
SingleLineCommentTrivia = 2,
|
||||
MultiLineCommentTrivia = 3,
|
||||
NewLineTrivia = 4,
|
||||
WhitespaceTrivia = 5,
|
||||
ConflictMarkerTrivia = 6,
|
||||
NonTextFileMarkerTrivia = 7,
|
||||
NumericLiteral = 8,
|
||||
BigIntLiteral = 9,
|
||||
StringLiteral = 10,
|
||||
JsxText = 11,
|
||||
JsxTextAllWhiteSpaces = 12,
|
||||
RegularExpressionLiteral = 13,
|
||||
NoSubstitutionTemplateLiteral = 14,
|
||||
TemplateHead = 15,
|
||||
TemplateMiddle = 16,
|
||||
TemplateTail = 17,
|
||||
OpenBraceToken = 18,
|
||||
CloseBraceToken = 19,
|
||||
OpenParenToken = 20,
|
||||
CloseParenToken = 21,
|
||||
OpenBracketToken = 22,
|
||||
CloseBracketToken = 23,
|
||||
DotToken = 24,
|
||||
DotDotDotToken = 25,
|
||||
SemicolonToken = 26,
|
||||
CommaToken = 27,
|
||||
QuestionDotToken = 28,
|
||||
LessThanToken = 29,
|
||||
LessThanSlashToken = 30,
|
||||
GreaterThanToken = 31,
|
||||
LessThanEqualsToken = 32,
|
||||
GreaterThanEqualsToken = 33,
|
||||
EqualsEqualsToken = 34,
|
||||
ExclamationEqualsToken = 35,
|
||||
EqualsEqualsEqualsToken = 36,
|
||||
ExclamationEqualsEqualsToken = 37,
|
||||
EqualsGreaterThanToken = 38,
|
||||
PlusToken = 39,
|
||||
MinusToken = 40,
|
||||
AsteriskToken = 41,
|
||||
AsteriskAsteriskToken = 42,
|
||||
SlashToken = 43,
|
||||
PercentToken = 44,
|
||||
PlusPlusToken = 45,
|
||||
MinusMinusToken = 46,
|
||||
LessThanLessThanToken = 47,
|
||||
GreaterThanGreaterThanToken = 48,
|
||||
GreaterThanGreaterThanGreaterThanToken = 49,
|
||||
AmpersandToken = 50,
|
||||
BarToken = 51,
|
||||
CaretToken = 52,
|
||||
ExclamationToken = 53,
|
||||
TildeToken = 54,
|
||||
AmpersandAmpersandToken = 55,
|
||||
BarBarToken = 56,
|
||||
QuestionToken = 57,
|
||||
ColonToken = 58,
|
||||
AtToken = 59,
|
||||
QuestionQuestionToken = 60,
|
||||
BacktickToken = 61,
|
||||
HashToken = 62,
|
||||
EqualsToken = 63,
|
||||
PlusEqualsToken = 64,
|
||||
MinusEqualsToken = 65,
|
||||
AsteriskEqualsToken = 66,
|
||||
AsteriskAsteriskEqualsToken = 67,
|
||||
SlashEqualsToken = 68,
|
||||
PercentEqualsToken = 69,
|
||||
LessThanLessThanEqualsToken = 70,
|
||||
GreaterThanGreaterThanEqualsToken = 71,
|
||||
GreaterThanGreaterThanGreaterThanEqualsToken = 72,
|
||||
AmpersandEqualsToken = 73,
|
||||
BarEqualsToken = 74,
|
||||
BarBarEqualsToken = 75,
|
||||
AmpersandAmpersandEqualsToken = 76,
|
||||
QuestionQuestionEqualsToken = 77,
|
||||
CaretEqualsToken = 78,
|
||||
Identifier = 79,
|
||||
PrivateIdentifier = 80,
|
||||
JSDocCommentTextToken = 81,
|
||||
BreakKeyword = 82,
|
||||
CaseKeyword = 83,
|
||||
CatchKeyword = 84,
|
||||
ClassKeyword = 85,
|
||||
ConstKeyword = 86,
|
||||
ContinueKeyword = 87,
|
||||
DebuggerKeyword = 88,
|
||||
DefaultKeyword = 89,
|
||||
DeleteKeyword = 90,
|
||||
DoKeyword = 91,
|
||||
ElseKeyword = 92,
|
||||
EnumKeyword = 93,
|
||||
ExportKeyword = 94,
|
||||
ExtendsKeyword = 95,
|
||||
FalseKeyword = 96,
|
||||
FinallyKeyword = 97,
|
||||
ForKeyword = 98,
|
||||
FunctionKeyword = 99,
|
||||
IfKeyword = 100,
|
||||
ImportKeyword = 101,
|
||||
InKeyword = 102,
|
||||
InstanceOfKeyword = 103,
|
||||
NewKeyword = 104,
|
||||
NullKeyword = 105,
|
||||
ReturnKeyword = 106,
|
||||
SuperKeyword = 107,
|
||||
SwitchKeyword = 108,
|
||||
ThisKeyword = 109,
|
||||
ThrowKeyword = 110,
|
||||
TrueKeyword = 111,
|
||||
TryKeyword = 112,
|
||||
TypeOfKeyword = 113,
|
||||
VarKeyword = 114,
|
||||
VoidKeyword = 115,
|
||||
WhileKeyword = 116,
|
||||
WithKeyword = 117,
|
||||
ImplementsKeyword = 118,
|
||||
InterfaceKeyword = 119,
|
||||
LetKeyword = 120,
|
||||
PackageKeyword = 121,
|
||||
PrivateKeyword = 122,
|
||||
ProtectedKeyword = 123,
|
||||
PublicKeyword = 124,
|
||||
StaticKeyword = 125,
|
||||
YieldKeyword = 126,
|
||||
AbstractKeyword = 127,
|
||||
AccessorKeyword = 128,
|
||||
AsKeyword = 129,
|
||||
AssertsKeyword = 130,
|
||||
AssertKeyword = 131,
|
||||
AnyKeyword = 132,
|
||||
AsyncKeyword = 133,
|
||||
AwaitKeyword = 134,
|
||||
BooleanKeyword = 135,
|
||||
ConstructorKeyword = 136,
|
||||
DeclareKeyword = 137,
|
||||
GetKeyword = 138,
|
||||
ImmediateKeyword = 139,
|
||||
InferKeyword = 140,
|
||||
IntrinsicKeyword = 141,
|
||||
IsKeyword = 142,
|
||||
KeyOfKeyword = 143,
|
||||
ModuleKeyword = 144,
|
||||
NamespaceKeyword = 145,
|
||||
NeverKeyword = 146,
|
||||
OutKeyword = 147,
|
||||
ReadonlyKeyword = 148,
|
||||
RequireKeyword = 149,
|
||||
NumberKeyword = 150,
|
||||
ObjectKeyword = 151,
|
||||
SatisfiesKeyword = 152,
|
||||
SetKeyword = 153,
|
||||
StringKeyword = 154,
|
||||
SymbolKeyword = 155,
|
||||
TypeKeyword = 156,
|
||||
UndefinedKeyword = 157,
|
||||
UniqueKeyword = 158,
|
||||
UnknownKeyword = 159,
|
||||
UsingKeyword = 160,
|
||||
FromKeyword = 161,
|
||||
GlobalKeyword = 162,
|
||||
BigIntKeyword = 163,
|
||||
OverrideKeyword = 164,
|
||||
OfKeyword = 165,
|
||||
DeferKeyword = 166,
|
||||
QualifiedName = 167,
|
||||
ComputedPropertyName = 168,
|
||||
TypeParameter = 169,
|
||||
Parameter = 170,
|
||||
Decorator = 171,
|
||||
PropertySignature = 172,
|
||||
PropertyDeclaration = 173,
|
||||
MethodSignature = 174,
|
||||
MethodDeclaration = 175,
|
||||
ClassStaticBlockDeclaration = 176,
|
||||
Constructor = 177,
|
||||
GetAccessor = 178,
|
||||
SetAccessor = 179,
|
||||
CallSignature = 180,
|
||||
ConstructSignature = 181,
|
||||
IndexSignature = 182,
|
||||
TypePredicate = 183,
|
||||
TypeReference = 184,
|
||||
FunctionType = 185,
|
||||
ConstructorType = 186,
|
||||
TypeQuery = 187,
|
||||
TypeLiteral = 188,
|
||||
ArrayType = 189,
|
||||
TupleType = 190,
|
||||
OptionalType = 191,
|
||||
RestType = 192,
|
||||
UnionType = 193,
|
||||
IntersectionType = 194,
|
||||
ConditionalType = 195,
|
||||
InferType = 196,
|
||||
ParenthesizedType = 197,
|
||||
ThisType = 198,
|
||||
TypeOperator = 199,
|
||||
IndexedAccessType = 200,
|
||||
MappedType = 201,
|
||||
LiteralType = 202,
|
||||
NamedTupleMember = 203,
|
||||
TemplateLiteralType = 204,
|
||||
TemplateLiteralTypeSpan = 205,
|
||||
ImportType = 206,
|
||||
ObjectBindingPattern = 207,
|
||||
ArrayBindingPattern = 208,
|
||||
BindingElement = 209,
|
||||
ArrayLiteralExpression = 210,
|
||||
ObjectLiteralExpression = 211,
|
||||
PropertyAccessExpression = 212,
|
||||
ElementAccessExpression = 213,
|
||||
CallExpression = 214,
|
||||
NewExpression = 215,
|
||||
TaggedTemplateExpression = 216,
|
||||
TypeAssertionExpression = 217,
|
||||
ParenthesizedExpression = 218,
|
||||
FunctionExpression = 219,
|
||||
ArrowFunction = 220,
|
||||
DeleteExpression = 221,
|
||||
TypeOfExpression = 222,
|
||||
VoidExpression = 223,
|
||||
AwaitExpression = 224,
|
||||
PrefixUnaryExpression = 225,
|
||||
PostfixUnaryExpression = 226,
|
||||
BinaryExpression = 227,
|
||||
ConditionalExpression = 228,
|
||||
TemplateExpression = 229,
|
||||
YieldExpression = 230,
|
||||
SpreadElement = 231,
|
||||
ClassExpression = 232,
|
||||
OmittedExpression = 233,
|
||||
ExpressionWithTypeArguments = 234,
|
||||
AsExpression = 235,
|
||||
NonNullExpression = 236,
|
||||
MetaProperty = 237,
|
||||
SyntheticExpression = 238,
|
||||
SatisfiesExpression = 239,
|
||||
TemplateSpan = 240,
|
||||
SemicolonClassElement = 241,
|
||||
Block = 242,
|
||||
EmptyStatement = 243,
|
||||
VariableStatement = 244,
|
||||
ExpressionStatement = 245,
|
||||
IfStatement = 246,
|
||||
DoStatement = 247,
|
||||
WhileStatement = 248,
|
||||
ForStatement = 249,
|
||||
ForInStatement = 250,
|
||||
ForOfStatement = 251,
|
||||
ContinueStatement = 252,
|
||||
BreakStatement = 253,
|
||||
ReturnStatement = 254,
|
||||
WithStatement = 255,
|
||||
SwitchStatement = 256,
|
||||
LabeledStatement = 257,
|
||||
ThrowStatement = 258,
|
||||
TryStatement = 259,
|
||||
DebuggerStatement = 260,
|
||||
VariableDeclaration = 261,
|
||||
VariableDeclarationList = 262,
|
||||
FunctionDeclaration = 263,
|
||||
ClassDeclaration = 264,
|
||||
InterfaceDeclaration = 265,
|
||||
TypeAliasDeclaration = 266,
|
||||
EnumDeclaration = 267,
|
||||
ModuleDeclaration = 268,
|
||||
ModuleBlock = 269,
|
||||
CaseBlock = 270,
|
||||
NamespaceExportDeclaration = 271,
|
||||
ImportEqualsDeclaration = 272,
|
||||
ImportDeclaration = 273,
|
||||
ImportClause = 274,
|
||||
NamespaceImport = 275,
|
||||
NamedImports = 276,
|
||||
ImportSpecifier = 277,
|
||||
ExportAssignment = 278,
|
||||
ExportDeclaration = 279,
|
||||
NamedExports = 280,
|
||||
NamespaceExport = 281,
|
||||
ExportSpecifier = 282,
|
||||
MissingDeclaration = 283,
|
||||
ExternalModuleReference = 284,
|
||||
JsxElement = 285,
|
||||
JsxSelfClosingElement = 286,
|
||||
JsxOpeningElement = 287,
|
||||
JsxClosingElement = 288,
|
||||
JsxFragment = 289,
|
||||
JsxOpeningFragment = 290,
|
||||
JsxClosingFragment = 291,
|
||||
JsxAttribute = 292,
|
||||
JsxAttributes = 293,
|
||||
JsxSpreadAttribute = 294,
|
||||
JsxExpression = 295,
|
||||
JsxNamespacedName = 296,
|
||||
CaseClause = 297,
|
||||
DefaultClause = 298,
|
||||
HeritageClause = 299,
|
||||
CatchClause = 300,
|
||||
ImportAttributes = 301,
|
||||
ImportAttribute = 302,
|
||||
PropertyAssignment = 303,
|
||||
ShorthandPropertyAssignment = 304,
|
||||
SpreadAssignment = 305,
|
||||
EnumMember = 306,
|
||||
SourceFile = 307,
|
||||
JSDocTypeExpression = 308,
|
||||
JSDocNameReference = 309,
|
||||
JSDocAllType = 310,
|
||||
JSDocNullableType = 311,
|
||||
JSDocNonNullableType = 312,
|
||||
JSDocOptionalType = 313,
|
||||
JSDocVariadicType = 314,
|
||||
JSDoc = 315,
|
||||
JSDocText = 316,
|
||||
JSDocTypeLiteral = 317,
|
||||
JSDocSignature = 318,
|
||||
JSDocLink = 319,
|
||||
JSDocLinkCode = 320,
|
||||
JSDocLinkPlain = 321,
|
||||
JSDocUnknownTag = 322,
|
||||
JSDocAugmentsTag = 323,
|
||||
JSDocImplementsTag = 324,
|
||||
JSDocDeprecatedTag = 325,
|
||||
JSDocPublicTag = 326,
|
||||
JSDocPrivateTag = 327,
|
||||
JSDocProtectedTag = 328,
|
||||
JSDocReadonlyTag = 329,
|
||||
JSDocOverrideTag = 330,
|
||||
JSDocCallbackTag = 331,
|
||||
JSDocOverloadTag = 332,
|
||||
JSDocParameterTag = 333,
|
||||
JSDocReturnTag = 334,
|
||||
JSDocThisTag = 335,
|
||||
JSDocTypeTag = 336,
|
||||
JSDocTemplateTag = 337,
|
||||
JSDocTypedefTag = 338,
|
||||
JSDocSeeTag = 339,
|
||||
JSDocPropertyTag = 340,
|
||||
JSDocThrowsTag = 341,
|
||||
JSDocSatisfiesTag = 342,
|
||||
JSDocImportTag = 343,
|
||||
SyntaxList = 344,
|
||||
JSTypeAliasDeclaration = 345,
|
||||
JSImportDeclaration = 346,
|
||||
NotEmittedStatement = 347,
|
||||
PartiallyEmittedExpression = 348,
|
||||
SyntheticReferenceExpression = 349,
|
||||
NotEmittedTypeElement = 350,
|
||||
Count = 351,
|
||||
FirstAssignment = 63,
|
||||
LastAssignment = 78,
|
||||
FirstCompoundAssignment = 64,
|
||||
LastCompoundAssignment = 78,
|
||||
FirstReservedWord = 82,
|
||||
LastReservedWord = 117,
|
||||
FirstKeyword = 82,
|
||||
LastKeyword = 166,
|
||||
FirstFutureReservedWord = 118,
|
||||
LastFutureReservedWord = 126,
|
||||
FirstTypeNode = 183,
|
||||
LastTypeNode = 206,
|
||||
FirstPunctuation = 18,
|
||||
LastPunctuation = 78,
|
||||
FirstToken = 0,
|
||||
LastToken = 166,
|
||||
FirstLiteralToken = 8,
|
||||
LastLiteralToken = 14,
|
||||
FirstTemplateToken = 14,
|
||||
LastTemplateToken = 17,
|
||||
FirstBinaryOperator = 29,
|
||||
LastBinaryOperator = 78,
|
||||
FirstStatement = 244,
|
||||
LastStatement = 260,
|
||||
FirstNode = 167,
|
||||
FirstJSDocNode = 308,
|
||||
LastJSDocNode = 343,
|
||||
FirstJSDocTagNode = 322,
|
||||
LastJSDocTagNode = 343,
|
||||
FirstContextualKeyword = 127,
|
||||
LastContextualKeyword = 166,
|
||||
LastUnaryOperator = 54,
|
||||
FirstTriviaToken = 2,
|
||||
LastTriviaToken = 6
|
||||
}
|
||||
//# sourceMappingURL=syntaxKind.enum.d.ts.map
|
||||
Reference in New Issue
Block a user