update
This commit is contained in:
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"awaited.js","sources":["../../src/awaited.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { TSR_DEFERRED_PROMISE, defer } from '@tanstack/router-core'\nimport type { DeferredPromise } from '@tanstack/router-core'\n\nexport type AwaitOptions<T> = {\n promise: Promise<T>\n}\n\nexport function useAwaited<T>({\n promise: _promise,\n}: AwaitOptions<T>): [T, DeferredPromise<T>] {\n const promise = defer(_promise)\n\n if (promise[TSR_DEFERRED_PROMISE].status === 'pending') {\n throw promise\n }\n\n if (promise[TSR_DEFERRED_PROMISE].status === 'error') {\n throw promise[TSR_DEFERRED_PROMISE].error\n }\n\n return [promise[TSR_DEFERRED_PROMISE].data, promise]\n}\n\nexport function Await<T>(\n props: AwaitOptions<T> & {\n fallback?: React.ReactNode\n children: (result: T) => React.ReactNode\n },\n) {\n const inner = <AwaitInner {...props} />\n if (props.fallback) {\n return <React.Suspense fallback={props.fallback}>{inner}</React.Suspense>\n }\n return inner\n}\n\nfunction AwaitInner<T>(\n props: AwaitOptions<T> & {\n fallback?: React.ReactNode\n children: (result: T) => React.ReactNode\n },\n): React.JSX.Element {\n const [data] = useAwaited(props)\n\n return props.children(data) as React.JSX.Element\n}\n"],"names":[],"mappings":";;;AASO,SAAS,WAAc;AAAA,EAC5B,SAAS;AACX,GAA6C;AACrC,QAAA,UAAU,MAAM,QAAQ;AAE9B,MAAI,QAAQ,oBAAoB,EAAE,WAAW,WAAW;AAChD,UAAA;AAAA,EAAA;AAGR,MAAI,QAAQ,oBAAoB,EAAE,WAAW,SAAS;AAC9C,UAAA,QAAQ,oBAAoB,EAAE;AAAA,EAAA;AAGtC,SAAO,CAAC,QAAQ,oBAAoB,EAAE,MAAM,OAAO;AACrD;AAEO,SAAS,MACd,OAIA;AACA,QAAM,QAAQ,oBAAC,YAAY,EAAA,GAAG,MAAO,CAAA;AACrC,MAAI,MAAM,UAAU;AAClB,+BAAQ,MAAM,UAAN,EAAe,UAAU,MAAM,UAAW,UAAM,OAAA;AAAA,EAAA;AAEnD,SAAA;AACT;AAEA,SAAS,WACP,OAImB;AACnB,QAAM,CAAC,IAAI,IAAI,WAAW,KAAK;AAExB,SAAA,MAAM,SAAS,IAAI;AAC5B;"}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_async","require","once","fn","result","resultP","promiseReferenced","waitFor","isAsync","ok","value","error","resolve","reject","Promise","res","rej"],"sources":["../../src/gensync-utils/functional.ts"],"sourcesContent":["import type { Handler } from \"gensync\";\n\nimport { isAsync, waitFor } from \"./async.ts\";\n\nexport function once<R>(fn: () => Handler<R>): () => Handler<R> {\n let result: { ok: true; value: R } | { ok: false; value: unknown };\n let resultP: Promise<R>;\n let promiseReferenced = false;\n return function* () {\n if (!result) {\n if (resultP) {\n promiseReferenced = true;\n return yield* waitFor(resultP);\n }\n\n if (!(yield* isAsync())) {\n try {\n result = { ok: true, value: yield* fn() };\n } catch (error) {\n result = { ok: false, value: error };\n }\n } else {\n let resolve: (result: R) => void, reject: (error: unknown) => void;\n resultP = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n\n try {\n result = { ok: true, value: yield* fn() };\n // Avoid keeping the promise around\n // now that we have the result.\n resultP = null;\n // We only resolve/reject the promise if it has been actually\n // referenced. If there are no listeners we can forget about it.\n // In the reject case, this avoid uncatchable unhandledRejection\n // events.\n if (promiseReferenced) resolve(result.value);\n } catch (error) {\n result = { ok: false, value: error };\n resultP = null;\n if (promiseReferenced) reject(error);\n }\n }\n }\n\n if (result.ok) return result.value;\n else throw result.value;\n };\n}\n"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AAEO,SAASC,IAAIA,CAAIC,EAAoB,EAAoB;EAC9D,IAAIC,MAA8D;EAClE,IAAIC,OAAmB;EACvB,IAAIC,iBAAiB,GAAG,KAAK;EAC7B,OAAO,aAAa;IAClB,IAAI,CAACF,MAAM,EAAE;MACX,IAAIC,OAAO,EAAE;QACXC,iBAAiB,GAAG,IAAI;QACxB,OAAO,OAAO,IAAAC,cAAO,EAACF,OAAO,CAAC;MAChC;MAEA,IAAI,EAAE,OAAO,IAAAG,cAAO,EAAC,CAAC,CAAC,EAAE;QACvB,IAAI;UACFJ,MAAM,GAAG;YAAEK,EAAE,EAAE,IAAI;YAAEC,KAAK,EAAE,OAAOP,EAAE,CAAC;UAAE,CAAC;QAC3C,CAAC,CAAC,OAAOQ,KAAK,EAAE;UACdP,MAAM,GAAG;YAAEK,EAAE,EAAE,KAAK;YAAEC,KAAK,EAAEC;UAAM,CAAC;QACtC;MACF,CAAC,MAAM;QACL,IAAIC,OAA4B,EAAEC,MAAgC;QAClER,OAAO,GAAG,IAAIS,OAAO,CAAC,CAACC,GAAG,EAAEC,GAAG,KAAK;UAClCJ,OAAO,GAAGG,GAAG;UACbF,MAAM,GAAGG,GAAG;QACd,CAAC,CAAC;QAEF,IAAI;UACFZ,MAAM,GAAG;YAAEK,EAAE,EAAE,IAAI;YAAEC,KAAK,EAAE,OAAOP,EAAE,CAAC;UAAE,CAAC;UAGzCE,OAAO,GAAG,IAAI;UAKd,IAAIC,iBAAiB,EAAEM,OAAO,CAACR,MAAM,CAACM,KAAK,CAAC;QAC9C,CAAC,CAAC,OAAOC,KAAK,EAAE;UACdP,MAAM,GAAG;YAAEK,EAAE,EAAE,KAAK;YAAEC,KAAK,EAAEC;UAAM,CAAC;UACpCN,OAAO,GAAG,IAAI;UACd,IAAIC,iBAAiB,EAAEO,MAAM,CAACF,KAAK,CAAC;QACtC;MACF;IACF;IAEA,IAAIP,MAAM,CAACK,EAAE,EAAE,OAAOL,MAAM,CAACM,KAAK,CAAC,KAC9B,MAAMN,MAAM,CAACM,KAAK;EACzB,CAAC;AACH;AAAC","ignoreList":[]}
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Alexander Reardon
|
||||
|
||||
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 @@
|
||||
module.exports={A:{A:{"2":"K D E mC","2561":"A B","2692":"F"},B:{"1":"0 9 Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I","2561":"C L M G N O P"},C:{"1":"0 9 mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC","16":"nC","1537":"1 2 3 4 5 6 7 8 J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB rC","1796":"LC qC"},D:{"1":"0 9 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC","16":"J PB K D E F A B C L M","1025":"YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B","1537":"1 2 3 4 5 6 7 8 G N O P QB RB SB TB UB VB WB XB"},E:{"1":"M G xC yC zC UC VC HC 0C IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C","16":"J PB K sC SC","1025":"D E F A B C uC vC wC TC FC","1537":"tC","4097":"L GC"},F:{"1":"0 pB qB rB sB tB uB vB wB xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z GC","16":"F B C 4C 5C 6C 7C FC kC","260":"8C","1025":"3 4 5 6 7 8 RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB","1537":"1 2 G N O P QB"},G:{"1":"ND OD PD QD RD SD UC VC HC TD IC WC XC YC ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC","16":"SC 9C lC","1025":"E DD ED FD GD HD ID JD KD","1537":"AD BD CD","4097":"LD MD"},H:{"2":"WD"},I:{"16":"XD YD","1025":"I cD","1537":"LC J ZD aD lC bD"},J:{"1025":"A","1537":"D"},K:{"1":"A B C H FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"2561":"A B"},O:{"1":"HC"},P:{"1025":"1 2 3 4 5 6 7 8 J dD eD fD gD hD TC iD jD kD lD mD IC JC KC nD"},Q:{"1":"oD"},R:{"1":"pD"},S:{"1":"rD","1537":"qD"}},B:1,C:"input event",D:true};
|
||||
Binary file not shown.
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @fileoverview Universal module importer
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Imports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
import { createRequire } from "module";
|
||||
import { fileURLToPath } from "url";
|
||||
import { dirname } from "path";
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
const require = createRequire(__dirname + "/");
|
||||
const { ModuleImporter } = require("./module-importer.cjs");
|
||||
|
||||
export { ModuleImporter };
|
||||
@@ -0,0 +1,11 @@
|
||||
export { P as PluginUtils } from './resolve-config-QUZ9b-Gn.mjs';
|
||||
import { a as PluginFn, C as Config, b as PluginWithConfig, c as PluginWithOptions } from './types-B254mqw1.mjs';
|
||||
export { d as PluginAPI, P as PluginsConfig, T as ThemeConfig } from './types-B254mqw1.mjs';
|
||||
import './colors.mjs';
|
||||
|
||||
declare function createPlugin(handler: PluginFn, config?: Partial<Config>): PluginWithConfig;
|
||||
declare namespace createPlugin {
|
||||
var withOptions: <T>(pluginFunction: (options?: T) => PluginFn, configFunction?: (options?: T) => Partial<Config>) => PluginWithOptions<T>;
|
||||
}
|
||||
|
||||
export { Config, PluginFn as PluginCreator, createPlugin as default };
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_getBindingIdentifiers","require","isBinding","node","parent","grandparent","type","keys","getBindingIdentifiers","i","length","key","val","Array","isArray","includes"],"sources":["../../src/validators/isBinding.ts"],"sourcesContent":["import getBindingIdentifiers from \"../retrievers/getBindingIdentifiers.ts\";\nimport type * as t from \"../index.ts\";\n/**\n * Check if the input `node` is a binding identifier.\n */\nexport default function isBinding(\n node: t.Node,\n parent: t.Node,\n grandparent?: t.Node,\n): boolean {\n if (\n grandparent &&\n node.type === \"Identifier\" &&\n parent.type === \"ObjectProperty\" &&\n grandparent.type === \"ObjectExpression\"\n ) {\n // We need to special-case this, because getBindingIdentifiers\n // has an ObjectProperty->value entry for destructuring patterns.\n return false;\n }\n\n const keys = getBindingIdentifiers.keys[parent.type];\n if (keys) {\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const val =\n // @ts-expect-error key must present in parent\n parent[key];\n if (Array.isArray(val)) {\n if (val.includes(node)) return true;\n } else {\n if (val === node) return true;\n }\n }\n }\n\n return false;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AAKe,SAASC,SAASA,CAC/BC,IAAY,EACZC,MAAc,EACdC,WAAoB,EACX;EACT,IACEA,WAAW,IACXF,IAAI,CAACG,IAAI,KAAK,YAAY,IAC1BF,MAAM,CAACE,IAAI,KAAK,gBAAgB,IAChCD,WAAW,CAACC,IAAI,KAAK,kBAAkB,EACvC;IAGA,OAAO,KAAK;EACd;EAEA,MAAMC,IAAI,GAAGC,8BAAqB,CAACD,IAAI,CAACH,MAAM,CAACE,IAAI,CAAC;EACpD,IAAIC,IAAI,EAAE;IACR,KAAK,IAAIE,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,IAAI,CAACG,MAAM,EAAED,CAAC,EAAE,EAAE;MACpC,MAAME,GAAG,GAAGJ,IAAI,CAACE,CAAC,CAAC;MACnB,MAAMG,GAAG,GAEPR,MAAM,CAACO,GAAG,CAAC;MACb,IAAIE,KAAK,CAACC,OAAO,CAACF,GAAG,CAAC,EAAE;QACtB,IAAIA,GAAG,CAACG,QAAQ,CAACZ,IAAI,CAAC,EAAE,OAAO,IAAI;MACrC,CAAC,MAAM;QACL,IAAIS,GAAG,KAAKT,IAAI,EAAE,OAAO,IAAI;MAC/B;IACF;EACF;EAEA,OAAO,KAAK;AACd","ignoreList":[]}
|
||||
@@ -0,0 +1,16 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = cloneDeepWithoutLoc;
|
||||
var _cloneNode = require("./cloneNode.js");
|
||||
function cloneDeepWithoutLoc(node) {
|
||||
return (0, _cloneNode.default)(node, true, true);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=cloneDeepWithoutLoc.js.map
|
||||
@@ -0,0 +1,206 @@
|
||||
exports.parse = exports.decode = decode
|
||||
|
||||
exports.stringify = exports.encode = encode
|
||||
|
||||
exports.safe = safe
|
||||
exports.unsafe = unsafe
|
||||
|
||||
var eol = typeof process !== 'undefined' &&
|
||||
process.platform === 'win32' ? '\r\n' : '\n'
|
||||
|
||||
function encode (obj, opt) {
|
||||
var children = []
|
||||
var out = ''
|
||||
|
||||
if (typeof opt === 'string') {
|
||||
opt = {
|
||||
section: opt,
|
||||
whitespace: false,
|
||||
}
|
||||
} else {
|
||||
opt = opt || {}
|
||||
opt.whitespace = opt.whitespace === true
|
||||
}
|
||||
|
||||
var separator = opt.whitespace ? ' = ' : '='
|
||||
|
||||
Object.keys(obj).forEach(function (k, _, __) {
|
||||
var val = obj[k]
|
||||
if (val && Array.isArray(val)) {
|
||||
val.forEach(function (item) {
|
||||
out += safe(k + '[]') + separator + safe(item) + '\n'
|
||||
})
|
||||
} else if (val && typeof val === 'object')
|
||||
children.push(k)
|
||||
else
|
||||
out += safe(k) + separator + safe(val) + eol
|
||||
})
|
||||
|
||||
if (opt.section && out.length)
|
||||
out = '[' + safe(opt.section) + ']' + eol + out
|
||||
|
||||
children.forEach(function (k, _, __) {
|
||||
var nk = dotSplit(k).join('\\.')
|
||||
var section = (opt.section ? opt.section + '.' : '') + nk
|
||||
var child = encode(obj[k], {
|
||||
section: section,
|
||||
whitespace: opt.whitespace,
|
||||
})
|
||||
if (out.length && child.length)
|
||||
out += eol
|
||||
|
||||
out += child
|
||||
})
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
function dotSplit (str) {
|
||||
return str.replace(/\1/g, '\u0002LITERAL\\1LITERAL\u0002')
|
||||
.replace(/\\\./g, '\u0001')
|
||||
.split(/\./).map(function (part) {
|
||||
return part.replace(/\1/g, '\\.')
|
||||
.replace(/\2LITERAL\\1LITERAL\2/g, '\u0001')
|
||||
})
|
||||
}
|
||||
|
||||
function decode (str) {
|
||||
var out = {}
|
||||
var p = out
|
||||
var section = null
|
||||
// section |key = value
|
||||
var re = /^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i
|
||||
var lines = str.split(/[\r\n]+/g)
|
||||
|
||||
lines.forEach(function (line, _, __) {
|
||||
if (!line || line.match(/^\s*[;#]/))
|
||||
return
|
||||
var match = line.match(re)
|
||||
if (!match)
|
||||
return
|
||||
if (match[1] !== undefined) {
|
||||
section = unsafe(match[1])
|
||||
if (section === '__proto__') {
|
||||
// not allowed
|
||||
// keep parsing the section, but don't attach it.
|
||||
p = {}
|
||||
return
|
||||
}
|
||||
p = out[section] = out[section] || {}
|
||||
return
|
||||
}
|
||||
var key = unsafe(match[2])
|
||||
if (key === '__proto__')
|
||||
return
|
||||
var value = match[3] ? unsafe(match[4]) : true
|
||||
switch (value) {
|
||||
case 'true':
|
||||
case 'false':
|
||||
case 'null': value = JSON.parse(value)
|
||||
}
|
||||
|
||||
// Convert keys with '[]' suffix to an array
|
||||
if (key.length > 2 && key.slice(-2) === '[]') {
|
||||
key = key.substring(0, key.length - 2)
|
||||
if (key === '__proto__')
|
||||
return
|
||||
if (!p[key])
|
||||
p[key] = []
|
||||
else if (!Array.isArray(p[key]))
|
||||
p[key] = [p[key]]
|
||||
}
|
||||
|
||||
// safeguard against resetting a previously defined
|
||||
// array by accidentally forgetting the brackets
|
||||
if (Array.isArray(p[key]))
|
||||
p[key].push(value)
|
||||
else
|
||||
p[key] = value
|
||||
})
|
||||
|
||||
// {a:{y:1},"a.b":{x:2}} --> {a:{y:1,b:{x:2}}}
|
||||
// use a filter to return the keys that have to be deleted.
|
||||
Object.keys(out).filter(function (k, _, __) {
|
||||
if (!out[k] ||
|
||||
typeof out[k] !== 'object' ||
|
||||
Array.isArray(out[k]))
|
||||
return false
|
||||
|
||||
// see if the parent section is also an object.
|
||||
// if so, add it to that, and mark this one for deletion
|
||||
var parts = dotSplit(k)
|
||||
var p = out
|
||||
var l = parts.pop()
|
||||
var nl = l.replace(/\\\./g, '.')
|
||||
parts.forEach(function (part, _, __) {
|
||||
if (part === '__proto__')
|
||||
return
|
||||
if (!p[part] || typeof p[part] !== 'object')
|
||||
p[part] = {}
|
||||
p = p[part]
|
||||
})
|
||||
if (p === out && nl === l)
|
||||
return false
|
||||
|
||||
p[nl] = out[k]
|
||||
return true
|
||||
}).forEach(function (del, _, __) {
|
||||
delete out[del]
|
||||
})
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
function isQuoted (val) {
|
||||
return (val.charAt(0) === '"' && val.slice(-1) === '"') ||
|
||||
(val.charAt(0) === "'" && val.slice(-1) === "'")
|
||||
}
|
||||
|
||||
function safe (val) {
|
||||
return (typeof val !== 'string' ||
|
||||
val.match(/[=\r\n]/) ||
|
||||
val.match(/^\[/) ||
|
||||
(val.length > 1 &&
|
||||
isQuoted(val)) ||
|
||||
val !== val.trim())
|
||||
? JSON.stringify(val)
|
||||
: val.replace(/;/g, '\\;').replace(/#/g, '\\#')
|
||||
}
|
||||
|
||||
function unsafe (val, doUnesc) {
|
||||
val = (val || '').trim()
|
||||
if (isQuoted(val)) {
|
||||
// remove the single quotes before calling JSON.parse
|
||||
if (val.charAt(0) === "'")
|
||||
val = val.substr(1, val.length - 2)
|
||||
|
||||
try {
|
||||
val = JSON.parse(val)
|
||||
} catch (_) {}
|
||||
} else {
|
||||
// walk the val to find the first not-escaped ; character
|
||||
var esc = false
|
||||
var unesc = ''
|
||||
for (var i = 0, l = val.length; i < l; i++) {
|
||||
var c = val.charAt(i)
|
||||
if (esc) {
|
||||
if ('\\;#'.indexOf(c) !== -1)
|
||||
unesc += c
|
||||
else
|
||||
unesc += '\\' + c
|
||||
|
||||
esc = false
|
||||
} else if (';#'.indexOf(c) !== -1)
|
||||
break
|
||||
else if (c === '\\')
|
||||
esc = true
|
||||
else
|
||||
unesc += c
|
||||
}
|
||||
if (esc)
|
||||
unesc += '\\'
|
||||
|
||||
return unesc.trim()
|
||||
}
|
||||
return val
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"K D E F A B mC"},B:{"1":"BB CB DB EB FB GB HB IB JB KB LB MB NB OB I","2":"C L M G N O P Q H R S T U V W X Y Z a b c d e f g h i j k l m n","194":"0 9 o p q r s t u v w x y z AB"},C:{"1":"0 9 mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC","2":"nC LC J PB K D E F A B C L M G N qC rC","33":"1 2 3 4 5 6 7 8 O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB"},D:{"1":"BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC","2":"1 2 3 4 5 6 7 8 J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R S T U V W X Y Z","194":"0 9 a b c d e f g h i j k l m n o p q r s t u v w x y z AB"},E:{"1":"ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C","2":"J PB K D E F A B C L M G sC SC tC uC vC wC TC FC GC xC yC zC UC VC HC 0C IC WC XC YC"},F:{"1":"0 p q r s t u v w x y z","2":"1 2 3 4 5 6 7 8 F B C G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z 4C 5C 6C 7C FC kC 8C GC","194":"a b c d e f g h i j k l m n o"},G:{"1":"ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC","2":"E SC 9C lC AD BD CD DD ED FD GD HD ID JD KD LD MD ND OD PD QD RD SD UC VC HC TD IC WC XC YC"},H:{"2":"WD"},I:{"1":"I","2":"LC J XD YD ZD aD lC bD cD"},J:{"2":"D A"},K:{"1":"H","2":"A B C FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"2":"A B"},O:{"2":"HC"},P:{"1":"6 7 8","2":"1 2 3 4 5 J dD eD fD gD hD TC iD jD kD lD mD IC JC KC nD"},Q:{"2":"oD"},R:{"2":"pD"},S:{"1":"rD","33":"qD"}},B:5,C:":dir() CSS pseudo-class",D:true};
|
||||
@@ -0,0 +1,81 @@
|
||||
'use strict';
|
||||
module.exports = function generate_contains(it, $keyword, $ruleType) {
|
||||
var out = ' ';
|
||||
var $lvl = it.level;
|
||||
var $dataLvl = it.dataLevel;
|
||||
var $schema = it.schema[$keyword];
|
||||
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
||||
var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
|
||||
var $breakOnError = !it.opts.allErrors;
|
||||
var $data = 'data' + ($dataLvl || '');
|
||||
var $valid = 'valid' + $lvl;
|
||||
var $errs = 'errs__' + $lvl;
|
||||
var $it = it.util.copy(it);
|
||||
var $closingBraces = '';
|
||||
$it.level++;
|
||||
var $nextValid = 'valid' + $it.level;
|
||||
var $idx = 'i' + $lvl,
|
||||
$dataNxt = $it.dataLevel = it.dataLevel + 1,
|
||||
$nextData = 'data' + $dataNxt,
|
||||
$currentBaseId = it.baseId,
|
||||
$nonEmptySchema = (it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all));
|
||||
out += 'var ' + ($errs) + ' = errors;var ' + ($valid) + ';';
|
||||
if ($nonEmptySchema) {
|
||||
var $wasComposite = it.compositeRule;
|
||||
it.compositeRule = $it.compositeRule = true;
|
||||
$it.schema = $schema;
|
||||
$it.schemaPath = $schemaPath;
|
||||
$it.errSchemaPath = $errSchemaPath;
|
||||
out += ' var ' + ($nextValid) + ' = false; for (var ' + ($idx) + ' = 0; ' + ($idx) + ' < ' + ($data) + '.length; ' + ($idx) + '++) { ';
|
||||
$it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
|
||||
var $passData = $data + '[' + $idx + ']';
|
||||
$it.dataPathArr[$dataNxt] = $idx;
|
||||
var $code = it.validate($it);
|
||||
$it.baseId = $currentBaseId;
|
||||
if (it.util.varOccurences($code, $nextData) < 2) {
|
||||
out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
|
||||
} else {
|
||||
out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
|
||||
}
|
||||
out += ' if (' + ($nextValid) + ') break; } ';
|
||||
it.compositeRule = $it.compositeRule = $wasComposite;
|
||||
out += ' ' + ($closingBraces) + ' if (!' + ($nextValid) + ') {';
|
||||
} else {
|
||||
out += ' if (' + ($data) + '.length == 0) {';
|
||||
}
|
||||
var $$outStack = $$outStack || [];
|
||||
$$outStack.push(out);
|
||||
out = ''; /* istanbul ignore else */
|
||||
if (it.createErrors !== false) {
|
||||
out += ' { keyword: \'' + ('contains') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
|
||||
if (it.opts.messages !== false) {
|
||||
out += ' , message: \'should contain a valid item\' ';
|
||||
}
|
||||
if (it.opts.verbose) {
|
||||
out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
|
||||
}
|
||||
out += ' } ';
|
||||
} else {
|
||||
out += ' {} ';
|
||||
}
|
||||
var __err = out;
|
||||
out = $$outStack.pop();
|
||||
if (!it.compositeRule && $breakOnError) {
|
||||
/* istanbul ignore if */
|
||||
if (it.async) {
|
||||
out += ' throw new ValidationError([' + (__err) + ']); ';
|
||||
} else {
|
||||
out += ' validate.errors = [' + (__err) + ']; return false; ';
|
||||
}
|
||||
} else {
|
||||
out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
|
||||
}
|
||||
out += ' } else { ';
|
||||
if ($nonEmptySchema) {
|
||||
out += ' errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } ';
|
||||
}
|
||||
if (it.opts.allErrors) {
|
||||
out += ' } ';
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
const compare = require('./compare')
|
||||
const lt = (a, b, loose) => compare(a, b, loose) < 0
|
||||
module.exports = lt
|
||||
@@ -0,0 +1,368 @@
|
||||
export { default as invariant } from 'tiny-invariant'
|
||||
export { default as warning } from 'tiny-warning'
|
||||
|
||||
export {
|
||||
defer,
|
||||
TSR_DEFERRED_PROMISE,
|
||||
isMatch,
|
||||
joinPaths,
|
||||
cleanPath,
|
||||
trimPathLeft,
|
||||
trimPathRight,
|
||||
trimPath,
|
||||
resolvePath,
|
||||
parsePathname,
|
||||
interpolatePath,
|
||||
matchPathname,
|
||||
removeBasepath,
|
||||
matchByPath,
|
||||
encode,
|
||||
decode,
|
||||
rootRouteId,
|
||||
defaultSerializeError,
|
||||
defaultParseSearch,
|
||||
defaultStringifySearch,
|
||||
parseSearchWith,
|
||||
stringifySearchWith,
|
||||
escapeJSON, // SSR
|
||||
pick,
|
||||
functionalUpdate,
|
||||
replaceEqualDeep,
|
||||
isPlainObject,
|
||||
isPlainArray,
|
||||
deepEqual,
|
||||
shallow,
|
||||
createControlledPromise,
|
||||
retainSearchParams,
|
||||
stripSearchParams,
|
||||
} from '@tanstack/router-core'
|
||||
|
||||
export type {
|
||||
AnyRoute,
|
||||
StartSerializer,
|
||||
Serializable,
|
||||
SerializerParse,
|
||||
SerializerParseBy,
|
||||
SerializerStringify,
|
||||
SerializerStringifyBy,
|
||||
DeferredPromiseState,
|
||||
DeferredPromise,
|
||||
ParsedLocation,
|
||||
ParsePathParams,
|
||||
RemoveTrailingSlashes,
|
||||
RemoveLeadingSlashes,
|
||||
ActiveOptions,
|
||||
Segment,
|
||||
ResolveRelativePath,
|
||||
RootRouteId,
|
||||
AnyPathParams,
|
||||
ResolveParams,
|
||||
SearchSchemaInput,
|
||||
AnyContext,
|
||||
RouteContext,
|
||||
PreloadableObj,
|
||||
RoutePathOptions,
|
||||
StaticDataRouteOption,
|
||||
RoutePathOptionsIntersection,
|
||||
UpdatableStaticRouteOption,
|
||||
MetaDescriptor,
|
||||
RouteLinkEntry,
|
||||
ParseParamsFn,
|
||||
SearchFilter,
|
||||
ResolveId,
|
||||
InferFullSearchSchema,
|
||||
InferFullSearchSchemaInput,
|
||||
ErrorRouteProps,
|
||||
ErrorComponentProps,
|
||||
NotFoundRouteProps,
|
||||
TrimPath,
|
||||
TrimPathLeft,
|
||||
TrimPathRight,
|
||||
ParseSplatParams,
|
||||
SplatParams,
|
||||
StringifyParamsFn,
|
||||
ParamsOptions,
|
||||
InferAllParams,
|
||||
InferAllContext,
|
||||
LooseReturnType,
|
||||
LooseAsyncReturnType,
|
||||
ContextReturnType,
|
||||
ContextAsyncReturnType,
|
||||
ResolveLoaderData,
|
||||
ResolveRouteContext,
|
||||
SearchSerializer,
|
||||
SearchParser,
|
||||
TrailingSlashOption,
|
||||
ExtractedEntry,
|
||||
ExtractedStream,
|
||||
ExtractedPromise,
|
||||
StreamState,
|
||||
Manifest,
|
||||
RouterManagedTag,
|
||||
ControlledPromise,
|
||||
Constrain,
|
||||
Expand,
|
||||
MergeAll,
|
||||
Assign,
|
||||
IntersectAssign,
|
||||
ResolveValidatorInput,
|
||||
ResolveValidatorOutput,
|
||||
Register,
|
||||
AnyValidator,
|
||||
DefaultValidator,
|
||||
ValidatorFn,
|
||||
AnySchema,
|
||||
AnyValidatorAdapter,
|
||||
AnyValidatorFn,
|
||||
AnyValidatorObj,
|
||||
ResolveValidatorInputFn,
|
||||
ResolveValidatorOutputFn,
|
||||
ResolveSearchValidatorInput,
|
||||
ResolveSearchValidatorInputFn,
|
||||
Validator,
|
||||
ValidatorAdapter,
|
||||
ValidatorObj,
|
||||
FileRoutesByPath,
|
||||
RouteById,
|
||||
RootRouteOptions,
|
||||
SerializerExtensions,
|
||||
} from '@tanstack/router-core'
|
||||
|
||||
export type * from './serializer'
|
||||
|
||||
export {
|
||||
createHistory,
|
||||
createBrowserHistory,
|
||||
createHashHistory,
|
||||
createMemoryHistory,
|
||||
} from '@tanstack/history'
|
||||
|
||||
export type {
|
||||
BlockerFn,
|
||||
HistoryLocation,
|
||||
RouterHistory,
|
||||
ParsedPath,
|
||||
HistoryState,
|
||||
} from '@tanstack/history'
|
||||
|
||||
export { useAwaited, Await } from './awaited'
|
||||
export type { AwaitOptions } from './awaited'
|
||||
|
||||
export { CatchBoundary, ErrorComponent } from './CatchBoundary'
|
||||
|
||||
export {
|
||||
FileRoute,
|
||||
createFileRoute,
|
||||
FileRouteLoader,
|
||||
LazyRoute,
|
||||
createLazyRoute,
|
||||
createLazyFileRoute,
|
||||
} from './fileRoute'
|
||||
|
||||
export * from './history'
|
||||
|
||||
export { lazyRouteComponent } from './lazyRouteComponent'
|
||||
|
||||
export { useLinkProps, createLink, Link, linkOptions } from './link'
|
||||
export type {
|
||||
InferDescendantToPaths,
|
||||
RelativeToPath,
|
||||
RelativeToParentPath,
|
||||
RelativeToCurrentPath,
|
||||
AbsoluteToPath,
|
||||
RelativeToPathAutoComplete,
|
||||
NavigateOptions,
|
||||
ToOptions,
|
||||
ToMaskOptions,
|
||||
ToSubOptions,
|
||||
ResolveRoute,
|
||||
SearchParamOptions,
|
||||
PathParamOptions,
|
||||
ToPathOption,
|
||||
LinkOptions,
|
||||
MakeOptionalPathParams,
|
||||
FileRouteTypes,
|
||||
RouteContextParameter,
|
||||
BeforeLoadContextParameter,
|
||||
ResolveAllContext,
|
||||
ResolveAllParamsFromParent,
|
||||
ResolveFullSearchSchema,
|
||||
ResolveFullSearchSchemaInput,
|
||||
RouteIds,
|
||||
NavigateFn,
|
||||
BuildLocationFn,
|
||||
FullSearchSchemaOption,
|
||||
MakeRemountDepsOptionsUnion,
|
||||
RemountDepsOptions,
|
||||
ResolveFullPath,
|
||||
AnyRouteWithContext,
|
||||
AnyRouterWithContext,
|
||||
CommitLocationOptions,
|
||||
MatchLocation,
|
||||
UseNavigateResult,
|
||||
AnyRedirect,
|
||||
Redirect,
|
||||
ResolvedRedirect,
|
||||
MakeRouteMatch,
|
||||
MakeRouteMatchUnion,
|
||||
RouteMatch,
|
||||
AnyRouteMatch,
|
||||
RouteContextFn,
|
||||
RouteContextOptions,
|
||||
BeforeLoadFn,
|
||||
BeforeLoadContextOptions,
|
||||
ContextOptions,
|
||||
RouteOptions,
|
||||
FileBaseRouteOptions,
|
||||
BaseRouteOptions,
|
||||
UpdatableRouteOptions,
|
||||
RouteLoaderFn,
|
||||
LoaderFnContext,
|
||||
LazyRouteOptions,
|
||||
AnyRouter,
|
||||
RegisteredRouter,
|
||||
RouterContextOptions,
|
||||
ControllablePromise,
|
||||
InjectedHtmlEntry,
|
||||
RouterOptions,
|
||||
RouterErrorSerializer,
|
||||
RouterState,
|
||||
ListenerFn,
|
||||
BuildNextOptions,
|
||||
RouterConstructorOptions,
|
||||
RouterEvents,
|
||||
RouterEvent,
|
||||
RouterListener,
|
||||
RouteConstraints,
|
||||
RouteMask,
|
||||
MatchRouteOptions,
|
||||
} from '@tanstack/router-core'
|
||||
export type {
|
||||
UseLinkPropsOptions,
|
||||
ActiveLinkOptions,
|
||||
LinkProps,
|
||||
LinkComponent,
|
||||
LinkComponentProps,
|
||||
CreateLinkProps,
|
||||
} from './link'
|
||||
|
||||
export {
|
||||
Matches,
|
||||
useMatchRoute,
|
||||
MatchRoute,
|
||||
useMatches,
|
||||
useParentMatches,
|
||||
useChildMatches,
|
||||
} from './Matches'
|
||||
|
||||
export type { UseMatchRouteOptions, MakeMatchRouteOptions } from './Matches'
|
||||
|
||||
export { matchContext } from './matchContext'
|
||||
export { Match, Outlet } from './Match'
|
||||
|
||||
export { useMatch } from './useMatch'
|
||||
export { useLoaderDeps } from './useLoaderDeps'
|
||||
export { useLoaderData } from './useLoaderData'
|
||||
|
||||
export { redirect, isRedirect } from '@tanstack/router-core'
|
||||
|
||||
export {
|
||||
RouteApi,
|
||||
getRouteApi,
|
||||
Route,
|
||||
createRoute,
|
||||
RootRoute,
|
||||
rootRouteWithContext,
|
||||
createRootRoute,
|
||||
createRootRouteWithContext,
|
||||
createRouteMask,
|
||||
NotFoundRoute,
|
||||
} from './route'
|
||||
export type {
|
||||
AnyRootRoute,
|
||||
ReactNode,
|
||||
SyncRouteComponent,
|
||||
AsyncRouteComponent,
|
||||
RouteComponent,
|
||||
ErrorRouteComponent,
|
||||
NotFoundRouteComponent,
|
||||
} from './route'
|
||||
|
||||
export { createRouter, Router } from './router'
|
||||
|
||||
export {
|
||||
componentTypes,
|
||||
lazyFn,
|
||||
SearchParamError,
|
||||
PathParamError,
|
||||
getInitialRouterState,
|
||||
} from '@tanstack/router-core'
|
||||
|
||||
export { RouterProvider, RouterContextProvider } from './RouterProvider'
|
||||
export type { RouterProps } from './RouterProvider'
|
||||
|
||||
export {
|
||||
useElementScrollRestoration,
|
||||
ScrollRestoration,
|
||||
} from './ScrollRestoration'
|
||||
|
||||
export type { UseBlockerOpts, ShouldBlockFn } from './useBlocker'
|
||||
export { useBlocker, Block } from './useBlocker'
|
||||
|
||||
export { useNavigate, Navigate } from './useNavigate'
|
||||
|
||||
export { useParams } from './useParams'
|
||||
export { useSearch } from './useSearch'
|
||||
|
||||
export {
|
||||
getRouterContext, // SSR
|
||||
} from './routerContext'
|
||||
|
||||
export { useRouteContext } from './useRouteContext'
|
||||
export { useRouter } from './useRouter'
|
||||
export { useRouterState } from './useRouterState'
|
||||
export { useLocation } from './useLocation'
|
||||
export { useCanGoBack } from './useCanGoBack'
|
||||
|
||||
export {
|
||||
useLayoutEffect, // SSR
|
||||
useStableCallback,
|
||||
} from './utils'
|
||||
|
||||
export { CatchNotFound, DefaultGlobalNotFound } from './not-found'
|
||||
export { notFound, isNotFound } from '@tanstack/router-core'
|
||||
export type { NotFoundError } from '@tanstack/router-core'
|
||||
|
||||
export type {
|
||||
ValidateLinkOptions,
|
||||
InferStructuralSharing,
|
||||
ValidateUseSearchOptions,
|
||||
ValidateUseParamsOptions,
|
||||
ValidateLinkOptionsArray,
|
||||
} from './typePrimitives'
|
||||
|
||||
export type {
|
||||
ValidateFromPath,
|
||||
ValidateToPath,
|
||||
ValidateSearch,
|
||||
ValidateParams,
|
||||
InferFrom,
|
||||
InferTo,
|
||||
InferMaskTo,
|
||||
InferMaskFrom,
|
||||
ValidateNavigateOptions,
|
||||
ValidateNavigateOptionsArray,
|
||||
ValidateRedirectOptions,
|
||||
ValidateRedirectOptionsArray,
|
||||
ValidateId,
|
||||
InferStrict,
|
||||
InferShouldThrow,
|
||||
InferSelected,
|
||||
ValidateUseSearchResult,
|
||||
ValidateUseParamsResult,
|
||||
} from '@tanstack/router-core'
|
||||
|
||||
export { ScriptOnce } from './ScriptOnce'
|
||||
export { Asset } from './Asset'
|
||||
export { HeadContent } from './HeadContent'
|
||||
export { Scripts } from './Scripts'
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "shebang-regex",
|
||||
"version": "3.0.0",
|
||||
"description": "Regular expression for matching a shebang line",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/shebang-regex",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"regex",
|
||||
"regexp",
|
||||
"shebang",
|
||||
"match",
|
||||
"test",
|
||||
"line"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { Parser } from "../index.js";
|
||||
|
||||
export declare const parsers: {
|
||||
graphql: Parser;
|
||||
};
|
||||
@@ -0,0 +1,153 @@
|
||||
/**
|
||||
* @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('../shared/types').Rule} */
|
||||
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: "10.0.0",
|
||||
replacedBy: [
|
||||
{
|
||||
message:
|
||||
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
||||
url: "https://eslint.style/guide/migration",
|
||||
plugin: {
|
||||
name: "@stylistic/eslint-plugin-js",
|
||||
url: "https://eslint.style/packages/js",
|
||||
},
|
||||
rule: {
|
||||
name: "rest-spread-spacing",
|
||||
url: "https://eslint.style/rules/js/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.isSpaceBetweenTokens(
|
||||
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,
|
||||
};
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user