update
This commit is contained in:
@@ -0,0 +1,237 @@
|
||||
/**
|
||||
* @fileoverview Rule to require grouped accessor pairs in object literals and classes
|
||||
* @author Milos Djermanovic
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const astUtils = require("./utils/ast-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Typedefs
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Property name if it can be computed statically, otherwise the list of the tokens of the key node.
|
||||
* @typedef {string|Token[]} Key
|
||||
*/
|
||||
|
||||
/**
|
||||
* Accessor nodes with the same key.
|
||||
* @typedef {Object} AccessorData
|
||||
* @property {Key} key Accessor's key
|
||||
* @property {ASTNode[]} getters List of getter nodes.
|
||||
* @property {ASTNode[]} setters List of setter nodes.
|
||||
*/
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Checks whether or not the given lists represent the equal tokens in the same order.
|
||||
* Tokens are compared by their properties, not by instance.
|
||||
* @param {Token[]} left First list of tokens.
|
||||
* @param {Token[]} right Second list of tokens.
|
||||
* @returns {boolean} `true` if the lists have same tokens.
|
||||
*/
|
||||
function areEqualTokenLists(left, right) {
|
||||
if (left.length !== right.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let i = 0; i < left.length; i++) {
|
||||
const leftToken = left[i],
|
||||
rightToken = right[i];
|
||||
|
||||
if (
|
||||
leftToken.type !== rightToken.type ||
|
||||
leftToken.value !== rightToken.value
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether or not the given keys are equal.
|
||||
* @param {Key} left First key.
|
||||
* @param {Key} right Second key.
|
||||
* @returns {boolean} `true` if the keys are equal.
|
||||
*/
|
||||
function areEqualKeys(left, right) {
|
||||
if (typeof left === "string" && typeof right === "string") {
|
||||
// Statically computed names.
|
||||
return left === right;
|
||||
}
|
||||
if (Array.isArray(left) && Array.isArray(right)) {
|
||||
// Token lists.
|
||||
return areEqualTokenLists(left, right);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether or not a given node is of an accessor kind ('get' or 'set').
|
||||
* @param {ASTNode} node A node to check.
|
||||
* @returns {boolean} `true` if the node is of an accessor kind.
|
||||
*/
|
||||
function isAccessorKind(node) {
|
||||
return node.kind === "get" || node.kind === "set";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
defaultOptions: ["anyOrder"],
|
||||
|
||||
docs: {
|
||||
description:
|
||||
"Require grouped accessor pairs in object literals and classes",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/grouped-accessor-pairs",
|
||||
},
|
||||
|
||||
schema: [
|
||||
{
|
||||
enum: ["anyOrder", "getBeforeSet", "setBeforeGet"],
|
||||
},
|
||||
],
|
||||
|
||||
messages: {
|
||||
notGrouped:
|
||||
"Accessor pair {{ formerName }} and {{ latterName }} should be grouped.",
|
||||
invalidOrder:
|
||||
"Expected {{ latterName }} to be before {{ formerName }}.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const [order] = context.options;
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Reports the given accessor pair.
|
||||
* @param {string} messageId messageId to report.
|
||||
* @param {ASTNode} formerNode getter/setter node that is defined before `latterNode`.
|
||||
* @param {ASTNode} latterNode getter/setter node that is defined after `formerNode`.
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
function report(messageId, formerNode, latterNode) {
|
||||
context.report({
|
||||
node: latterNode,
|
||||
messageId,
|
||||
loc: astUtils.getFunctionHeadLoc(latterNode.value, sourceCode),
|
||||
data: {
|
||||
formerName: astUtils.getFunctionNameWithKind(
|
||||
formerNode.value,
|
||||
),
|
||||
latterName: astUtils.getFunctionNameWithKind(
|
||||
latterNode.value,
|
||||
),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks accessor pairs in the given list of nodes.
|
||||
* @param {ASTNode[]} nodes The list to check.
|
||||
* @param {Function} shouldCheck – Predicate that returns `true` if the node should be checked.
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
function checkList(nodes, shouldCheck) {
|
||||
const accessors = [];
|
||||
let found = false;
|
||||
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
const node = nodes[i];
|
||||
|
||||
if (shouldCheck(node) && isAccessorKind(node)) {
|
||||
// Creates a new `AccessorData` object for the given getter or setter node.
|
||||
const name = astUtils.getStaticPropertyName(node);
|
||||
const key =
|
||||
name !== null ? name : sourceCode.getTokens(node.key);
|
||||
|
||||
// Merges the given `AccessorData` object into the given accessors list.
|
||||
for (let j = 0; j < accessors.length; j++) {
|
||||
const accessor = accessors[j];
|
||||
|
||||
if (areEqualKeys(accessor.key, key)) {
|
||||
accessor.getters.push(
|
||||
...(node.kind === "get" ? [node] : []),
|
||||
);
|
||||
accessor.setters.push(
|
||||
...(node.kind === "set" ? [node] : []),
|
||||
);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
accessors.push({
|
||||
key,
|
||||
getters: node.kind === "get" ? [node] : [],
|
||||
setters: node.kind === "set" ? [node] : [],
|
||||
});
|
||||
}
|
||||
found = false;
|
||||
}
|
||||
}
|
||||
|
||||
for (const { getters, setters } of accessors) {
|
||||
// Don't report accessor properties that have duplicate getters or setters.
|
||||
if (getters.length === 1 && setters.length === 1) {
|
||||
const [getter] = getters,
|
||||
[setter] = setters,
|
||||
getterIndex = nodes.indexOf(getter),
|
||||
setterIndex = nodes.indexOf(setter),
|
||||
formerNode =
|
||||
getterIndex < setterIndex ? getter : setter,
|
||||
latterNode =
|
||||
getterIndex < setterIndex ? setter : getter;
|
||||
|
||||
if (Math.abs(getterIndex - setterIndex) > 1) {
|
||||
report("notGrouped", formerNode, latterNode);
|
||||
} else if (
|
||||
(order === "getBeforeSet" &&
|
||||
getterIndex > setterIndex) ||
|
||||
(order === "setBeforeGet" && getterIndex < setterIndex)
|
||||
) {
|
||||
report("invalidOrder", formerNode, latterNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
ObjectExpression(node) {
|
||||
checkList(node.properties, n => n.type === "Property");
|
||||
},
|
||||
ClassBody(node) {
|
||||
checkList(
|
||||
node.body,
|
||||
n => n.type === "MethodDefinition" && !n.static,
|
||||
);
|
||||
checkList(
|
||||
node.body,
|
||||
n => n.type === "MethodDefinition" && n.static,
|
||||
);
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_arrayWithHoles","require","_iterableToArray","_unsupportedIterableToArray","_nonIterableRest","_toArray","arr","arrayWithHoles","iterableToArray","unsupportedIterableToArray","nonIterableRest"],"sources":["../../src/helpers/toArray.ts"],"sourcesContent":["/* @minVersion 7.0.0-beta.0 */\n\nimport arrayWithHoles from \"./arrayWithHoles.ts\";\nimport iterableToArray from \"./iterableToArray.ts\";\nimport unsupportedIterableToArray from \"./unsupportedIterableToArray.ts\";\n// @ts-expect-error nonIterableRest is still being converted to TS.\nimport nonIterableRest from \"./nonIterableRest.ts\";\n\nexport default function _toArray<T>(arr: any): T[] {\n return (\n arrayWithHoles<T>(arr) ||\n iterableToArray<T>(arr) ||\n unsupportedIterableToArray<T>(arr) ||\n nonIterableRest()\n );\n}\n"],"mappings":";;;;;;AAEA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,2BAAA,GAAAF,OAAA;AAEA,IAAAG,gBAAA,GAAAH,OAAA;AAEe,SAASI,QAAQA,CAAIC,GAAQ,EAAO;EACjD,OACE,IAAAC,uBAAc,EAAID,GAAG,CAAC,IACtB,IAAAE,wBAAe,EAAIF,GAAG,CAAC,IACvB,IAAAG,mCAA0B,EAAIH,GAAG,CAAC,IAClC,IAAAI,wBAAe,EAAC,CAAC;AAErB","ignoreList":[]}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { SCHEMES } from "./uri";
|
||||
import http from "./schemes/http";
|
||||
SCHEMES[http.scheme] = http;
|
||||
import https from "./schemes/https";
|
||||
SCHEMES[https.scheme] = https;
|
||||
import ws from "./schemes/ws";
|
||||
SCHEMES[ws.scheme] = ws;
|
||||
import wss from "./schemes/wss";
|
||||
SCHEMES[wss.scheme] = wss;
|
||||
import mailto from "./schemes/mailto";
|
||||
SCHEMES[mailto.scheme] = mailto;
|
||||
import urn from "./schemes/urn";
|
||||
SCHEMES[urn.scheme] = urn;
|
||||
import uuid from "./schemes/urn-uuid";
|
||||
SCHEMES[uuid.scheme] = uuid;
|
||||
export * from "./uri";
|
||||
//# sourceMappingURL=index.js.map
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"1":"A B","2":"K D E F mC"},B:{"1":"0 9 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 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"},C:{"1":"0 1 2 3 4 5 6 7 8 9 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 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 qC rC"},D:{"1":"0 1 2 3 4 5 6 7 8 9 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 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","2":"J PB K D"},E:{"1":"K D E F A B C L M G uC vC wC TC FC GC 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","2":"J PB sC SC tC"},F:{"1":"0 1 2 3 4 5 6 7 8 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 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 FC kC 8C GC","2":"F 4C 5C 6C 7C"},G:{"1":"E DD ED FD GD HD ID JD KD LD MD 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","2":"SC 9C lC AD BD","132":"CD"},H:{"1":"WD"},I:{"1":"I bD cD","2":"LC J XD YD ZD aD lC"},J:{"1":"D A"},K:{"1":"B C H FC kC GC","2":"A"},L:{"1":"I"},M:{"1":"EC"},N:{"1":"A B"},O:{"1":"HC"},P:{"1":"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":"qD rD"}},B:1,C:"progress element",D:true};
|
||||
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"name": "turbo-stream",
|
||||
"version": "2.4.0",
|
||||
"description": "A streaming data transport format that aims to support built-in features such as Promises, Dates, RegExps, Maps, Sets and more.",
|
||||
"files": [
|
||||
"dist",
|
||||
"README.md"
|
||||
],
|
||||
"main": "dist/turbo-stream.js",
|
||||
"types": "dist/turbo-stream.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/turbo-stream.d.ts",
|
||||
"import": "./dist/turbo-stream.mjs",
|
||||
"require": "./dist/turbo-stream.js",
|
||||
"default": "./dist/turbo-stream.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "pnpm build:esm && pnpm build:cjs && cp ./dist/turbo-stream.mjs ./viewer/scripts/turbo-stream.js",
|
||||
"build:cjs": "tsc --outDir dist --project tsconfig.lib.json",
|
||||
"build:esm": "esbuild --bundle --platform=node --target=node16 --format=esm --outfile=dist/turbo-stream.mjs src/turbo-stream.ts",
|
||||
"test": "node --no-warnings --loader tsm --enable-source-maps --test-reporter tap --test src/*.spec.ts",
|
||||
"test-typecheck": "tsc --noEmit --project tsconfig.spec.json",
|
||||
"prepublish": "attw $(npm pack) --ignore-rules false-cjs"
|
||||
},
|
||||
"keywords": [
|
||||
"devalue",
|
||||
"turbo",
|
||||
"stream",
|
||||
"enhanced",
|
||||
"json"
|
||||
],
|
||||
"author": "Jacob Ebey <jacob.ebey@live.com>",
|
||||
"license": "ISC",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jacob-ebey/turbo-stream.git"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"devDependencies": {
|
||||
"@arethetypeswrong/cli": "^0.12.2",
|
||||
"@types/node": "^20.8.7",
|
||||
"esbuild": "^0.19.5",
|
||||
"expect": "^29.7.0",
|
||||
"tsm": "^2.3.0",
|
||||
"typescript": "^5.2.2"
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* @fileoverview ESLint Parser
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
/* eslint class-methods-use-this: off -- Anticipate future constructor arguments. */
|
||||
|
||||
"use strict";
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Types
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** @typedef {import("../linter/vfile.js").VFile} VFile */
|
||||
/** @typedef {import("@eslint/core").Language} Language */
|
||||
/** @typedef {import("@eslint/core").LanguageOptions} LanguageOptions */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Exports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The parser for ESLint.
|
||||
*/
|
||||
class ParserService {
|
||||
/**
|
||||
* Parses the given file synchronously.
|
||||
* @param {VFile} file The file to parse.
|
||||
* @param {{language:Language,languageOptions:LanguageOptions}} config The configuration to use.
|
||||
* @returns {Object} An object with the parsed source code or errors.
|
||||
* @throws {Error} If the parser returns a promise.
|
||||
*/
|
||||
parseSync(file, config) {
|
||||
const { language, languageOptions } = config;
|
||||
const result = language.parse(file, { languageOptions });
|
||||
|
||||
if (typeof result.then === "function") {
|
||||
throw new Error("Unsupported: Language parser returned a promise.");
|
||||
}
|
||||
|
||||
if (result.ok) {
|
||||
return {
|
||||
ok: true,
|
||||
sourceCode: language.createSourceCode(file, result, {
|
||||
languageOptions,
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
// if we made it to here there was an error
|
||||
return {
|
||||
ok: false,
|
||||
errors: result.errors.map(error => ({
|
||||
ruleId: null,
|
||||
nodeType: null,
|
||||
fatal: true,
|
||||
severity: 2,
|
||||
message: `Parsing error: ${error.message}`,
|
||||
line: error.line,
|
||||
column: error.column,
|
||||
})),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { ParserService };
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"K D E F A B mC"},B:{"1":"G N O P","33":"C L M","129":"BB CB DB EB FB GB HB IB JB KB LB MB NB OB I","161":"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"},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":"1 2 3 4 5 6 7 8 nC LC 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 qC rC"},D:{"129":"BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC","161":"0 1 2 3 4 5 6 7 8 9 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 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:{"2":"sC","129":"HC 0C IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C","388":"PB K D E F A B C L M G tC uC vC wC TC FC GC xC yC zC UC VC","420":"J SC"},F:{"2":"F B C 4C 5C 6C 7C FC kC 8C GC","129":"0 p q r s t u v w x y z","161":"1 2 3 4 5 6 7 8 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 a b c d e f g h i j k l m n o"},G:{"129":"HC TD IC WC XC YC ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC","388":"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"},H:{"2":"WD"},I:{"16":"LC XD YD ZD","129":"I","161":"J aD lC bD cD"},J:{"161":"D A"},K:{"16":"A B C FC kC GC","129":"H"},L:{"129":"I"},M:{"1":"EC"},N:{"2":"A B"},O:{"161":"HC"},P:{"1":"6 7 8","161":"1 2 3 4 5 J dD eD fD gD hD TC iD jD kD lD mD IC JC KC nD"},Q:{"161":"oD"},R:{"161":"pD"},S:{"1":"qD rD"}},B:7,C:"Background-clip: text",D:true};
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,468 @@
|
||||
/**
|
||||
* @fileoverview A rule to disallow the type conversions with shorter notations.
|
||||
* @author Toru Nagashima
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const astUtils = require("./utils/ast-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const INDEX_OF_PATTERN = /^(?:i|lastI)ndexOf$/u;
|
||||
const ALLOWABLE_OPERATORS = ["~", "!!", "+", "- -", "-", "*"];
|
||||
|
||||
/**
|
||||
* Checks whether or not a node is a double logical negating.
|
||||
* @param {ASTNode} node An UnaryExpression node to check.
|
||||
* @returns {boolean} Whether or not the node is a double logical negating.
|
||||
*/
|
||||
function isDoubleLogicalNegating(node) {
|
||||
return (
|
||||
node.operator === "!" &&
|
||||
node.argument.type === "UnaryExpression" &&
|
||||
node.argument.operator === "!"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether or not a node is a binary negating of `.indexOf()` method calling.
|
||||
* @param {ASTNode} node An UnaryExpression node to check.
|
||||
* @returns {boolean} Whether or not the node is a binary negating of `.indexOf()` method calling.
|
||||
*/
|
||||
function isBinaryNegatingOfIndexOf(node) {
|
||||
if (node.operator !== "~") {
|
||||
return false;
|
||||
}
|
||||
const callNode = astUtils.skipChainExpression(node.argument);
|
||||
|
||||
return (
|
||||
callNode.type === "CallExpression" &&
|
||||
astUtils.isSpecificMemberAccess(callNode.callee, null, INDEX_OF_PATTERN)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether or not a node is a multiplying by one.
|
||||
* @param {BinaryExpression} node A BinaryExpression node to check.
|
||||
* @returns {boolean} Whether or not the node is a multiplying by one.
|
||||
*/
|
||||
function isMultiplyByOne(node) {
|
||||
return (
|
||||
node.operator === "*" &&
|
||||
((node.left.type === "Literal" && node.left.value === 1) ||
|
||||
(node.right.type === "Literal" && node.right.value === 1))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given node logically represents multiplication by a fraction of `1`.
|
||||
* For example, `a * 1` in `a * 1 / b` is technically multiplication by `1`, but the
|
||||
* whole expression can be logically interpreted as `a * (1 / b)` rather than `(a * 1) / b`.
|
||||
* @param {BinaryExpression} node A BinaryExpression node to check.
|
||||
* @param {SourceCode} sourceCode The source code object.
|
||||
* @returns {boolean} Whether or not the node is a multiplying by a fraction of `1`.
|
||||
*/
|
||||
function isMultiplyByFractionOfOne(node, sourceCode) {
|
||||
return (
|
||||
node.type === "BinaryExpression" &&
|
||||
node.operator === "*" &&
|
||||
node.right.type === "Literal" &&
|
||||
node.right.value === 1 &&
|
||||
node.parent.type === "BinaryExpression" &&
|
||||
node.parent.operator === "/" &&
|
||||
node.parent.left === node &&
|
||||
!astUtils.isParenthesised(sourceCode, node)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the result of a node is numeric or not
|
||||
* @param {ASTNode} node The node to test
|
||||
* @returns {boolean} true if the node is a number literal or a `Number()`, `parseInt` or `parseFloat` call
|
||||
*/
|
||||
function isNumeric(node) {
|
||||
return (
|
||||
(node.type === "Literal" && typeof node.value === "number") ||
|
||||
(node.type === "CallExpression" &&
|
||||
(node.callee.name === "Number" ||
|
||||
node.callee.name === "parseInt" ||
|
||||
node.callee.name === "parseFloat"))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first non-numeric operand in a BinaryExpression. Designed to be
|
||||
* used from bottom to up since it walks up the BinaryExpression trees using
|
||||
* node.parent to find the result.
|
||||
* @param {BinaryExpression} node The BinaryExpression node to be walked up on
|
||||
* @returns {ASTNode|null} The first non-numeric item in the BinaryExpression tree or null
|
||||
*/
|
||||
function getNonNumericOperand(node) {
|
||||
const left = node.left,
|
||||
right = node.right;
|
||||
|
||||
if (right.type !== "BinaryExpression" && !isNumeric(right)) {
|
||||
return right;
|
||||
}
|
||||
|
||||
if (left.type !== "BinaryExpression" && !isNumeric(left)) {
|
||||
return left;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether an expression evaluates to a string.
|
||||
* @param {ASTNode} node node that represents the expression to check.
|
||||
* @returns {boolean} Whether or not the expression evaluates to a string.
|
||||
*/
|
||||
function isStringType(node) {
|
||||
return (
|
||||
astUtils.isStringLiteral(node) ||
|
||||
(node.type === "CallExpression" &&
|
||||
node.callee.type === "Identifier" &&
|
||||
node.callee.name === "String")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a node is an empty string literal or not.
|
||||
* @param {ASTNode} node The node to check.
|
||||
* @returns {boolean} Whether or not the passed in node is an
|
||||
* empty string literal or not.
|
||||
*/
|
||||
function isEmptyString(node) {
|
||||
return (
|
||||
astUtils.isStringLiteral(node) &&
|
||||
(node.value === "" ||
|
||||
(node.type === "TemplateLiteral" &&
|
||||
node.quasis.length === 1 &&
|
||||
node.quasis[0].value.cooked === ""))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether or not a node is a concatenating with an empty string.
|
||||
* @param {ASTNode} node A BinaryExpression node to check.
|
||||
* @returns {boolean} Whether or not the node is a concatenating with an empty string.
|
||||
*/
|
||||
function isConcatWithEmptyString(node) {
|
||||
return (
|
||||
node.operator === "+" &&
|
||||
((isEmptyString(node.left) && !isStringType(node.right)) ||
|
||||
(isEmptyString(node.right) && !isStringType(node.left)))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether or not a node is appended with an empty string.
|
||||
* @param {ASTNode} node An AssignmentExpression node to check.
|
||||
* @returns {boolean} Whether or not the node is appended with an empty string.
|
||||
*/
|
||||
function isAppendEmptyString(node) {
|
||||
return node.operator === "+=" && isEmptyString(node.right);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the operand that is not an empty string from a flagged BinaryExpression.
|
||||
* @param {ASTNode} node The flagged BinaryExpression node to check.
|
||||
* @returns {ASTNode} The operand that is not an empty string from a flagged BinaryExpression.
|
||||
*/
|
||||
function getNonEmptyOperand(node) {
|
||||
return isEmptyString(node.left) ? node.right : node.left;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
hasSuggestions: true,
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description: "Disallow shorthand type conversions",
|
||||
recommended: false,
|
||||
frozen: true,
|
||||
url: "https://eslint.org/docs/latest/rules/no-implicit-coercion",
|
||||
},
|
||||
|
||||
fixable: "code",
|
||||
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
boolean: {
|
||||
type: "boolean",
|
||||
},
|
||||
number: {
|
||||
type: "boolean",
|
||||
},
|
||||
string: {
|
||||
type: "boolean",
|
||||
},
|
||||
disallowTemplateShorthand: {
|
||||
type: "boolean",
|
||||
},
|
||||
allow: {
|
||||
type: "array",
|
||||
items: {
|
||||
enum: ALLOWABLE_OPERATORS,
|
||||
},
|
||||
uniqueItems: true,
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
|
||||
defaultOptions: [
|
||||
{
|
||||
allow: [],
|
||||
boolean: true,
|
||||
disallowTemplateShorthand: false,
|
||||
number: true,
|
||||
string: true,
|
||||
},
|
||||
],
|
||||
|
||||
messages: {
|
||||
implicitCoercion:
|
||||
"Unexpected implicit coercion encountered. Use `{{recommendation}}` instead.",
|
||||
useRecommendation: "Use `{{recommendation}}` instead.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const [options] = context.options;
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Reports an error and autofixes the node
|
||||
* @param {ASTNode} node An ast node to report the error on.
|
||||
* @param {string} recommendation The recommended code for the issue
|
||||
* @param {bool} shouldSuggest Whether this report should offer a suggestion
|
||||
* @param {bool} shouldFix Whether this report should fix the node
|
||||
* @returns {void}
|
||||
*/
|
||||
function report(node, recommendation, shouldSuggest, shouldFix) {
|
||||
/**
|
||||
* Fix function
|
||||
* @param {RuleFixer} fixer The fixer to fix.
|
||||
* @returns {Fix} The fix object.
|
||||
*/
|
||||
function fix(fixer) {
|
||||
const tokenBefore = sourceCode.getTokenBefore(node);
|
||||
|
||||
if (
|
||||
tokenBefore?.range[1] === node.range[0] &&
|
||||
!astUtils.canTokensBeAdjacent(tokenBefore, recommendation)
|
||||
) {
|
||||
return fixer.replaceText(node, ` ${recommendation}`);
|
||||
}
|
||||
|
||||
return fixer.replaceText(node, recommendation);
|
||||
}
|
||||
|
||||
context.report({
|
||||
node,
|
||||
messageId: "implicitCoercion",
|
||||
data: { recommendation },
|
||||
fix(fixer) {
|
||||
if (!shouldFix) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return fix(fixer);
|
||||
},
|
||||
suggest: [
|
||||
{
|
||||
messageId: "useRecommendation",
|
||||
data: { recommendation },
|
||||
fix(fixer) {
|
||||
if (shouldFix || !shouldSuggest) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return fix(fixer);
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
UnaryExpression(node) {
|
||||
let operatorAllowed;
|
||||
|
||||
// !!foo
|
||||
operatorAllowed = options.allow.includes("!!");
|
||||
if (
|
||||
!operatorAllowed &&
|
||||
options.boolean &&
|
||||
isDoubleLogicalNegating(node)
|
||||
) {
|
||||
const recommendation = `Boolean(${sourceCode.getText(node.argument.argument)})`;
|
||||
const variable = astUtils.getVariableByName(
|
||||
sourceCode.getScope(node),
|
||||
"Boolean",
|
||||
);
|
||||
const booleanExists = variable?.identifiers.length === 0;
|
||||
|
||||
report(node, recommendation, true, booleanExists);
|
||||
}
|
||||
|
||||
// ~foo.indexOf(bar)
|
||||
operatorAllowed = options.allow.includes("~");
|
||||
if (
|
||||
!operatorAllowed &&
|
||||
options.boolean &&
|
||||
isBinaryNegatingOfIndexOf(node)
|
||||
) {
|
||||
// `foo?.indexOf(bar) !== -1` will be true (== found) if the `foo` is nullish. So use `>= 0` in that case.
|
||||
const comparison =
|
||||
node.argument.type === "ChainExpression"
|
||||
? ">= 0"
|
||||
: "!== -1";
|
||||
const recommendation = `${sourceCode.getText(node.argument)} ${comparison}`;
|
||||
|
||||
report(node, recommendation, false, false);
|
||||
}
|
||||
|
||||
// +foo
|
||||
operatorAllowed = options.allow.includes("+");
|
||||
if (
|
||||
!operatorAllowed &&
|
||||
options.number &&
|
||||
node.operator === "+" &&
|
||||
!isNumeric(node.argument)
|
||||
) {
|
||||
const recommendation = `Number(${sourceCode.getText(node.argument)})`;
|
||||
|
||||
report(node, recommendation, true, false);
|
||||
}
|
||||
|
||||
// -(-foo)
|
||||
operatorAllowed = options.allow.includes("- -");
|
||||
if (
|
||||
!operatorAllowed &&
|
||||
options.number &&
|
||||
node.operator === "-" &&
|
||||
node.argument.type === "UnaryExpression" &&
|
||||
node.argument.operator === "-" &&
|
||||
!isNumeric(node.argument.argument)
|
||||
) {
|
||||
const recommendation = `Number(${sourceCode.getText(node.argument.argument)})`;
|
||||
|
||||
report(node, recommendation, true, false);
|
||||
}
|
||||
},
|
||||
|
||||
// Use `:exit` to prevent double reporting
|
||||
"BinaryExpression:exit"(node) {
|
||||
let operatorAllowed;
|
||||
|
||||
// 1 * foo
|
||||
operatorAllowed = options.allow.includes("*");
|
||||
const nonNumericOperand =
|
||||
!operatorAllowed &&
|
||||
options.number &&
|
||||
isMultiplyByOne(node) &&
|
||||
!isMultiplyByFractionOfOne(node, sourceCode) &&
|
||||
getNonNumericOperand(node);
|
||||
|
||||
if (nonNumericOperand) {
|
||||
const recommendation = `Number(${sourceCode.getText(nonNumericOperand)})`;
|
||||
|
||||
report(node, recommendation, true, false);
|
||||
}
|
||||
|
||||
// foo - 0
|
||||
operatorAllowed = options.allow.includes("-");
|
||||
if (
|
||||
!operatorAllowed &&
|
||||
options.number &&
|
||||
node.operator === "-" &&
|
||||
node.right.type === "Literal" &&
|
||||
node.right.value === 0 &&
|
||||
!isNumeric(node.left)
|
||||
) {
|
||||
const recommendation = `Number(${sourceCode.getText(node.left)})`;
|
||||
|
||||
report(node, recommendation, true, false);
|
||||
}
|
||||
|
||||
// "" + foo
|
||||
operatorAllowed = options.allow.includes("+");
|
||||
if (
|
||||
!operatorAllowed &&
|
||||
options.string &&
|
||||
isConcatWithEmptyString(node)
|
||||
) {
|
||||
const recommendation = `String(${sourceCode.getText(getNonEmptyOperand(node))})`;
|
||||
|
||||
report(node, recommendation, true, false);
|
||||
}
|
||||
},
|
||||
|
||||
AssignmentExpression(node) {
|
||||
// foo += ""
|
||||
const operatorAllowed = options.allow.includes("+");
|
||||
|
||||
if (
|
||||
!operatorAllowed &&
|
||||
options.string &&
|
||||
isAppendEmptyString(node)
|
||||
) {
|
||||
const code = sourceCode.getText(getNonEmptyOperand(node));
|
||||
const recommendation = `${code} = String(${code})`;
|
||||
|
||||
report(node, recommendation, true, false);
|
||||
}
|
||||
},
|
||||
|
||||
TemplateLiteral(node) {
|
||||
if (!options.disallowTemplateShorthand) {
|
||||
return;
|
||||
}
|
||||
|
||||
// tag`${foo}`
|
||||
if (node.parent.type === "TaggedTemplateExpression") {
|
||||
return;
|
||||
}
|
||||
|
||||
// `` or `${foo}${bar}`
|
||||
if (node.expressions.length !== 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// `prefix${foo}`
|
||||
if (node.quasis[0].value.cooked !== "") {
|
||||
return;
|
||||
}
|
||||
|
||||
// `${foo}postfix`
|
||||
if (node.quasis[1].value.cooked !== "") {
|
||||
return;
|
||||
}
|
||||
|
||||
// if the expression is already a string, then this isn't a coercion
|
||||
if (isStringType(node.expressions[0])) {
|
||||
return;
|
||||
}
|
||||
|
||||
const code = sourceCode.getText(node.expressions[0]);
|
||||
const recommendation = `String(${code})`;
|
||||
|
||||
report(node, recommendation, true, false);
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,174 @@
|
||||
import type {
|
||||
PDFDataRangeTransport,
|
||||
PDFDocumentProxy,
|
||||
PDFPageProxy,
|
||||
PasswordResponses,
|
||||
} from 'pdfjs-dist';
|
||||
import type {
|
||||
TypedArray,
|
||||
DocumentInitParameters,
|
||||
RefProxy,
|
||||
StructTreeNode,
|
||||
TextContent,
|
||||
TextItem,
|
||||
} from 'pdfjs-dist/types/src/display/api.js';
|
||||
import type { AnnotationLayerParameters } from 'pdfjs-dist/types/src/display/annotation_layer.js';
|
||||
import type LinkService from '../LinkService.js';
|
||||
|
||||
type NullableObject<T extends object> = { [P in keyof T]: T[P] | null };
|
||||
|
||||
type KeyOfUnion<T> = T extends unknown ? keyof T : never;
|
||||
|
||||
/* Primitive types */
|
||||
export type Annotations = AnnotationLayerParameters['annotations'];
|
||||
|
||||
export type ClassName = string | null | undefined | (string | null | undefined)[];
|
||||
|
||||
export type ResolvedDest = (RefProxy | number)[];
|
||||
|
||||
export type Dest = Promise<ResolvedDest> | ResolvedDest | string | null;
|
||||
|
||||
export type ExternalLinkRel = string;
|
||||
|
||||
export type ExternalLinkTarget = '_self' | '_blank' | '_parent' | '_top';
|
||||
|
||||
export type ImageResourcesPath = string;
|
||||
|
||||
export type OnError = (error: Error) => void;
|
||||
|
||||
export type OnItemClickArgs = {
|
||||
dest?: Dest;
|
||||
pageIndex: number;
|
||||
pageNumber: number;
|
||||
};
|
||||
|
||||
export type OnLoadProgressArgs = {
|
||||
loaded: number;
|
||||
total: number;
|
||||
};
|
||||
|
||||
export type RegisterPage = (pageIndex: number, ref: HTMLDivElement) => void;
|
||||
|
||||
export type RenderMode = 'canvas' | 'custom' | 'none';
|
||||
|
||||
export type ScrollPageIntoViewArgs = {
|
||||
dest?: ResolvedDest;
|
||||
pageIndex?: number;
|
||||
pageNumber: number;
|
||||
};
|
||||
|
||||
type BinaryData = TypedArray | ArrayBuffer | number[] | string;
|
||||
|
||||
export type Source =
|
||||
| { data: BinaryData | undefined }
|
||||
| { range: PDFDataRangeTransport }
|
||||
| { url: string };
|
||||
|
||||
export type UnregisterPage = (pageIndex: number) => void;
|
||||
|
||||
/* Complex types */
|
||||
export type CustomRenderer = React.FunctionComponent | React.ComponentClass;
|
||||
|
||||
export type CustomTextRenderer = (
|
||||
props: { pageIndex: number; pageNumber: number; itemIndex: number } & TextItem,
|
||||
) => string;
|
||||
|
||||
export type DocumentCallback = PDFDocumentProxy;
|
||||
|
||||
export type File = string | ArrayBuffer | Blob | Source | null;
|
||||
|
||||
export type PageCallback = PDFPageProxy & {
|
||||
width: number;
|
||||
height: number;
|
||||
originalWidth: number;
|
||||
originalHeight: number;
|
||||
};
|
||||
|
||||
export type NodeOrRenderer = React.ReactNode | (() => React.ReactNode);
|
||||
|
||||
export type OnDocumentLoadError = OnError;
|
||||
|
||||
export type OnDocumentLoadProgress = (args: OnLoadProgressArgs) => void;
|
||||
|
||||
export type OnDocumentLoadSuccess = (document: DocumentCallback) => void;
|
||||
|
||||
export type OnGetAnnotationsError = OnError;
|
||||
|
||||
export type OnGetAnnotationsSuccess = (annotations: Annotations) => void;
|
||||
|
||||
export type OnGetStructTreeError = OnError;
|
||||
|
||||
export type OnGetStructTreeSuccess = (tree: StructTreeNode) => void;
|
||||
|
||||
export type OnGetTextError = OnError;
|
||||
|
||||
export type OnGetTextSuccess = (textContent: TextContent) => void;
|
||||
|
||||
export type OnPageLoadError = OnError;
|
||||
|
||||
export type OnPageLoadSuccess = (page: PageCallback) => void;
|
||||
|
||||
export type OnPasswordCallback = (password: string | null) => void;
|
||||
|
||||
export type OnRenderAnnotationLayerError = (error: unknown) => void;
|
||||
|
||||
export type OnRenderAnnotationLayerSuccess = () => void;
|
||||
|
||||
export type OnRenderError = OnError;
|
||||
|
||||
export type OnRenderSuccess = (page: PageCallback) => void;
|
||||
|
||||
export type OnRenderTextLayerError = OnError;
|
||||
|
||||
export type OnRenderTextLayerSuccess = () => void;
|
||||
|
||||
export type PasswordResponse = (typeof PasswordResponses)[keyof typeof PasswordResponses];
|
||||
|
||||
export type Options = NullableObject<Omit<DocumentInitParameters, KeyOfUnion<Source>>>;
|
||||
|
||||
/* Context types */
|
||||
export type DocumentContextType = {
|
||||
imageResourcesPath?: ImageResourcesPath;
|
||||
linkService: LinkService;
|
||||
onItemClick?: (args: OnItemClickArgs) => void;
|
||||
pdf?: PDFDocumentProxy | false;
|
||||
registerPage: RegisterPage;
|
||||
renderMode?: RenderMode;
|
||||
rotate?: number | null;
|
||||
unregisterPage: UnregisterPage;
|
||||
} | null;
|
||||
|
||||
export type PageContextType = {
|
||||
_className?: string;
|
||||
canvasBackground?: string;
|
||||
customTextRenderer?: CustomTextRenderer;
|
||||
devicePixelRatio?: number;
|
||||
onGetAnnotationsError?: OnGetAnnotationsError;
|
||||
onGetAnnotationsSuccess?: OnGetAnnotationsSuccess;
|
||||
onGetStructTreeError?: OnGetStructTreeError;
|
||||
onGetStructTreeSuccess?: OnGetStructTreeSuccess;
|
||||
onGetTextError?: OnGetTextError;
|
||||
onGetTextSuccess?: OnGetTextSuccess;
|
||||
onRenderAnnotationLayerError?: OnRenderAnnotationLayerError;
|
||||
onRenderAnnotationLayerSuccess?: OnRenderAnnotationLayerSuccess;
|
||||
onRenderError?: OnRenderError;
|
||||
onRenderSuccess?: OnRenderSuccess;
|
||||
onRenderTextLayerError?: OnRenderTextLayerError;
|
||||
onRenderTextLayerSuccess?: OnRenderTextLayerSuccess;
|
||||
page: PDFPageProxy | false | undefined;
|
||||
pageIndex: number;
|
||||
pageNumber: number;
|
||||
renderForms: boolean;
|
||||
renderTextLayer: boolean;
|
||||
rotate: number;
|
||||
scale: number;
|
||||
} | null;
|
||||
|
||||
export type OutlineContextType = {
|
||||
onItemClick?: (args: OnItemClickArgs) => void;
|
||||
} | null;
|
||||
|
||||
export type StructTreeNodeWithExtraAttributes = StructTreeNode & {
|
||||
alt?: string;
|
||||
lang?: string;
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"K D E F mC","164":"A B"},B:{"66":"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","164":"C L M G N O P"},C:{"2":"0 1 2 3 4 5 6 7 8 9 nC LC 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 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 qC rC"},D:{"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","66":"0 9 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 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"},E:{"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 ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C"},F:{"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 4C 5C 6C 7C FC kC 8C GC","66":"0 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 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"},G:{"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 ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC"},H:{"292":"WD"},I:{"2":"LC J I XD YD ZD aD lC bD cD"},J:{"2":"D A"},K:{"2":"A H","292":"B C FC kC GC"},L:{"2":"I"},M:{"2":"EC"},N:{"164":"A B"},O:{"2":"HC"},P:{"2":"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:{"66":"oD"},R:{"2":"pD"},S:{"2":"qD rD"}},B:5,C:"CSS Device Adaptation",D:true};
|
||||
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* @fileoverview Rule to flag comparison where left part is the same as the right
|
||||
* part.
|
||||
* @author Ilya Volodin
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "problem",
|
||||
|
||||
docs: {
|
||||
description:
|
||||
"Disallow comparisons where both sides are exactly the same",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/no-self-compare",
|
||||
},
|
||||
|
||||
schema: [],
|
||||
|
||||
messages: {
|
||||
comparingToSelf: "Comparing to itself is potentially pointless.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Determines whether two nodes are composed of the same tokens.
|
||||
* @param {ASTNode} nodeA The first node
|
||||
* @param {ASTNode} nodeB The second node
|
||||
* @returns {boolean} true if the nodes have identical token representations
|
||||
*/
|
||||
function hasSameTokens(nodeA, nodeB) {
|
||||
const tokensA = sourceCode.getTokens(nodeA);
|
||||
const tokensB = sourceCode.getTokens(nodeB);
|
||||
|
||||
return (
|
||||
tokensA.length === tokensB.length &&
|
||||
tokensA.every(
|
||||
(token, index) =>
|
||||
token.type === tokensB[index].type &&
|
||||
token.value === tokensB[index].value,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
BinaryExpression(node) {
|
||||
const operators = new Set([
|
||||
"===",
|
||||
"==",
|
||||
"!==",
|
||||
"!=",
|
||||
">",
|
||||
"<",
|
||||
">=",
|
||||
"<=",
|
||||
]);
|
||||
|
||||
if (
|
||||
operators.has(node.operator) &&
|
||||
hasSameTokens(node.left, node.right)
|
||||
) {
|
||||
context.report({ node, messageId: "comparingToSelf" });
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,231 @@
|
||||
// This is used for classifying characters according to the definition of tokens
|
||||
// in the CSS standards, but could be extended for any other future uses
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace CharData {
|
||||
static constexpr uint8_t Whitespace = 0x1;
|
||||
static constexpr uint8_t Newline = 0x2;
|
||||
static constexpr uint8_t Hex = 0x4;
|
||||
static constexpr uint8_t Nmstart = 0x8;
|
||||
static constexpr uint8_t Nmchar = 0x10;
|
||||
static constexpr uint8_t Sign = 0x20;
|
||||
static constexpr uint8_t Digit = 0x40;
|
||||
static constexpr uint8_t NumStart = 0x80;
|
||||
};
|
||||
|
||||
using namespace CharData;
|
||||
|
||||
constexpr const uint8_t charData[256] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, // 0-8
|
||||
Whitespace, // 9 (HT)
|
||||
Whitespace | Newline, // 10 (LF)
|
||||
0, // 11 (VT)
|
||||
Whitespace | Newline, // 12 (FF)
|
||||
Whitespace | Newline, // 13 (CR)
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 14-31
|
||||
Whitespace, // 32 (Space)
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 33-42
|
||||
Sign | NumStart, // 43 (+)
|
||||
0, // 44
|
||||
Nmchar | Sign | NumStart, // 45 (-)
|
||||
0, 0, // 46-47
|
||||
Nmchar | Digit | NumStart | Hex, // 48 (0)
|
||||
Nmchar | Digit | NumStart | Hex, // 49 (1)
|
||||
Nmchar | Digit | NumStart | Hex, // 50 (2)
|
||||
Nmchar | Digit | NumStart | Hex, // 51 (3)
|
||||
Nmchar | Digit | NumStart | Hex, // 52 (4)
|
||||
Nmchar | Digit | NumStart | Hex, // 53 (5)
|
||||
Nmchar | Digit | NumStart | Hex, // 54 (6)
|
||||
Nmchar | Digit | NumStart | Hex, // 55 (7)
|
||||
Nmchar | Digit | NumStart | Hex, // 56 (8)
|
||||
Nmchar | Digit | NumStart | Hex, // 57 (9)
|
||||
0, 0, 0, 0, 0, 0, 0, // 58-64
|
||||
Nmstart | Nmchar | Hex, // 65 (A)
|
||||
Nmstart | Nmchar | Hex, // 66 (B)
|
||||
Nmstart | Nmchar | Hex, // 67 (C)
|
||||
Nmstart | Nmchar | Hex, // 68 (D)
|
||||
Nmstart | Nmchar | Hex, // 69 (E)
|
||||
Nmstart | Nmchar | Hex, // 70 (F)
|
||||
Nmstart | Nmchar, // 71 (G)
|
||||
Nmstart | Nmchar, // 72 (H)
|
||||
Nmstart | Nmchar, // 73 (I)
|
||||
Nmstart | Nmchar, // 74 (J)
|
||||
Nmstart | Nmchar, // 75 (K)
|
||||
Nmstart | Nmchar, // 76 (L)
|
||||
Nmstart | Nmchar, // 77 (M)
|
||||
Nmstart | Nmchar, // 78 (N)
|
||||
Nmstart | Nmchar, // 79 (O)
|
||||
Nmstart | Nmchar, // 80 (P)
|
||||
Nmstart | Nmchar, // 81 (Q)
|
||||
Nmstart | Nmchar, // 82 (R)
|
||||
Nmstart | Nmchar, // 83 (S)
|
||||
Nmstart | Nmchar, // 84 (T)
|
||||
Nmstart | Nmchar, // 85 (U)
|
||||
Nmstart | Nmchar, // 86 (V)
|
||||
Nmstart | Nmchar, // 87 (W)
|
||||
Nmstart | Nmchar, // 88 (X)
|
||||
Nmstart | Nmchar, // 89 (Y)
|
||||
Nmstart | Nmchar, // 90 (Z)
|
||||
0, // 91
|
||||
Nmstart, // 92 (\)
|
||||
0, 0, // 93-94
|
||||
Nmstart | Nmchar, // 95 (_)
|
||||
0, // 96
|
||||
Nmstart | Nmchar | Hex, // 97 (a)
|
||||
Nmstart | Nmchar | Hex, // 98 (b)
|
||||
Nmstart | Nmchar | Hex, // 99 (c)
|
||||
Nmstart | Nmchar | Hex, // 100 (d)
|
||||
Nmstart | Nmchar | Hex, // 101 (e)
|
||||
Nmstart | Nmchar | Hex, // 102 (f)
|
||||
Nmstart | Nmchar, // 103 (g)
|
||||
Nmstart | Nmchar, // 104 (h)
|
||||
Nmstart | Nmchar, // 105 (i)
|
||||
Nmstart | Nmchar, // 106 (j)
|
||||
Nmstart | Nmchar, // 107 (k)
|
||||
Nmstart | Nmchar, // 108 (l)
|
||||
Nmstart | Nmchar, // 109 (m)
|
||||
Nmstart | Nmchar, // 110 (n)
|
||||
Nmstart | Nmchar, // 111 (o)
|
||||
Nmstart | Nmchar, // 112 (p)
|
||||
Nmstart | Nmchar, // 113 (q)
|
||||
Nmstart | Nmchar, // 114 (r)
|
||||
Nmstart | Nmchar, // 115 (s)
|
||||
Nmstart | Nmchar, // 116 (t)
|
||||
Nmstart | Nmchar, // 117 (u)
|
||||
Nmstart | Nmchar, // 118 (v)
|
||||
Nmstart | Nmchar, // 119 (w)
|
||||
Nmstart | Nmchar, // 120 (x)
|
||||
Nmstart | Nmchar, // 121 (y)
|
||||
Nmstart | Nmchar, // 122 (z)
|
||||
0, 0, 0, 0, 0, // 123-127
|
||||
// Non-ASCII
|
||||
Nmstart | Nmchar, // 128
|
||||
Nmstart | Nmchar, // 129
|
||||
Nmstart | Nmchar, // 130
|
||||
Nmstart | Nmchar, // 131
|
||||
Nmstart | Nmchar, // 132
|
||||
Nmstart | Nmchar, // 133
|
||||
Nmstart | Nmchar, // 134
|
||||
Nmstart | Nmchar, // 135
|
||||
Nmstart | Nmchar, // 136
|
||||
Nmstart | Nmchar, // 137
|
||||
Nmstart | Nmchar, // 138
|
||||
Nmstart | Nmchar, // 139
|
||||
Nmstart | Nmchar, // 140
|
||||
Nmstart | Nmchar, // 141
|
||||
Nmstart | Nmchar, // 142
|
||||
Nmstart | Nmchar, // 143
|
||||
Nmstart | Nmchar, // 144
|
||||
Nmstart | Nmchar, // 145
|
||||
Nmstart | Nmchar, // 146
|
||||
Nmstart | Nmchar, // 147
|
||||
Nmstart | Nmchar, // 148
|
||||
Nmstart | Nmchar, // 149
|
||||
Nmstart | Nmchar, // 150
|
||||
Nmstart | Nmchar, // 151
|
||||
Nmstart | Nmchar, // 152
|
||||
Nmstart | Nmchar, // 153
|
||||
Nmstart | Nmchar, // 154
|
||||
Nmstart | Nmchar, // 155
|
||||
Nmstart | Nmchar, // 156
|
||||
Nmstart | Nmchar, // 157
|
||||
Nmstart | Nmchar, // 158
|
||||
Nmstart | Nmchar, // 159
|
||||
Nmstart | Nmchar, // 160
|
||||
Nmstart | Nmchar, // 161
|
||||
Nmstart | Nmchar, // 162
|
||||
Nmstart | Nmchar, // 163
|
||||
Nmstart | Nmchar, // 164
|
||||
Nmstart | Nmchar, // 165
|
||||
Nmstart | Nmchar, // 166
|
||||
Nmstart | Nmchar, // 167
|
||||
Nmstart | Nmchar, // 168
|
||||
Nmstart | Nmchar, // 169
|
||||
Nmstart | Nmchar, // 170
|
||||
Nmstart | Nmchar, // 171
|
||||
Nmstart | Nmchar, // 172
|
||||
Nmstart | Nmchar, // 173
|
||||
Nmstart | Nmchar, // 174
|
||||
Nmstart | Nmchar, // 175
|
||||
Nmstart | Nmchar, // 176
|
||||
Nmstart | Nmchar, // 177
|
||||
Nmstart | Nmchar, // 178
|
||||
Nmstart | Nmchar, // 179
|
||||
Nmstart | Nmchar, // 180
|
||||
Nmstart | Nmchar, // 181
|
||||
Nmstart | Nmchar, // 182
|
||||
Nmstart | Nmchar, // 183
|
||||
Nmstart | Nmchar, // 184
|
||||
Nmstart | Nmchar, // 185
|
||||
Nmstart | Nmchar, // 186
|
||||
Nmstart | Nmchar, // 187
|
||||
Nmstart | Nmchar, // 188
|
||||
Nmstart | Nmchar, // 189
|
||||
Nmstart | Nmchar, // 190
|
||||
Nmstart | Nmchar, // 191
|
||||
Nmstart | Nmchar, // 192
|
||||
Nmstart | Nmchar, // 193
|
||||
Nmstart | Nmchar, // 194
|
||||
Nmstart | Nmchar, // 195
|
||||
Nmstart | Nmchar, // 196
|
||||
Nmstart | Nmchar, // 197
|
||||
Nmstart | Nmchar, // 198
|
||||
Nmstart | Nmchar, // 199
|
||||
Nmstart | Nmchar, // 200
|
||||
Nmstart | Nmchar, // 201
|
||||
Nmstart | Nmchar, // 202
|
||||
Nmstart | Nmchar, // 203
|
||||
Nmstart | Nmchar, // 204
|
||||
Nmstart | Nmchar, // 205
|
||||
Nmstart | Nmchar, // 206
|
||||
Nmstart | Nmchar, // 207
|
||||
Nmstart | Nmchar, // 208
|
||||
Nmstart | Nmchar, // 209
|
||||
Nmstart | Nmchar, // 210
|
||||
Nmstart | Nmchar, // 211
|
||||
Nmstart | Nmchar, // 212
|
||||
Nmstart | Nmchar, // 213
|
||||
Nmstart | Nmchar, // 214
|
||||
Nmstart | Nmchar, // 215
|
||||
Nmstart | Nmchar, // 216
|
||||
Nmstart | Nmchar, // 217
|
||||
Nmstart | Nmchar, // 218
|
||||
Nmstart | Nmchar, // 219
|
||||
Nmstart | Nmchar, // 220
|
||||
Nmstart | Nmchar, // 221
|
||||
Nmstart | Nmchar, // 222
|
||||
Nmstart | Nmchar, // 223
|
||||
Nmstart | Nmchar, // 224
|
||||
Nmstart | Nmchar, // 225
|
||||
Nmstart | Nmchar, // 226
|
||||
Nmstart | Nmchar, // 227
|
||||
Nmstart | Nmchar, // 228
|
||||
Nmstart | Nmchar, // 229
|
||||
Nmstart | Nmchar, // 230
|
||||
Nmstart | Nmchar, // 231
|
||||
Nmstart | Nmchar, // 232
|
||||
Nmstart | Nmchar, // 233
|
||||
Nmstart | Nmchar, // 234
|
||||
Nmstart | Nmchar, // 235
|
||||
Nmstart | Nmchar, // 236
|
||||
Nmstart | Nmchar, // 237
|
||||
Nmstart | Nmchar, // 238
|
||||
Nmstart | Nmchar, // 239
|
||||
Nmstart | Nmchar, // 240
|
||||
Nmstart | Nmchar, // 241
|
||||
Nmstart | Nmchar, // 242
|
||||
Nmstart | Nmchar, // 243
|
||||
Nmstart | Nmchar, // 244
|
||||
Nmstart | Nmchar, // 245
|
||||
Nmstart | Nmchar, // 246
|
||||
Nmstart | Nmchar, // 247
|
||||
Nmstart | Nmchar, // 248
|
||||
Nmstart | Nmchar, // 249
|
||||
Nmstart | Nmchar, // 250
|
||||
Nmstart | Nmchar, // 251
|
||||
Nmstart | Nmchar, // 252
|
||||
Nmstart | Nmchar, // 253
|
||||
Nmstart | Nmchar, // 254
|
||||
Nmstart | Nmchar // 255
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
import { Parser } from "../index.js";
|
||||
|
||||
export declare const parsers: {
|
||||
css: Parser;
|
||||
less: Parser;
|
||||
scss: Parser;
|
||||
};
|
||||
@@ -0,0 +1,234 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.DEFAULT_EXTENSIONS = void 0;
|
||||
Object.defineProperty(exports, "File", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _file.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "buildExternalHelpers", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _buildExternalHelpers.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "createConfigItem", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _index2.createConfigItem;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "createConfigItemAsync", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _index2.createConfigItemAsync;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "createConfigItemSync", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _index2.createConfigItemSync;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "getEnv", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _environment.getEnv;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "loadOptions", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _index2.loadOptions;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "loadOptionsAsync", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _index2.loadOptionsAsync;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "loadOptionsSync", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _index2.loadOptionsSync;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "loadPartialConfig", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _index2.loadPartialConfig;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "loadPartialConfigAsync", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _index2.loadPartialConfigAsync;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "loadPartialConfigSync", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _index2.loadPartialConfigSync;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "parse", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _parse.parse;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "parseAsync", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _parse.parseAsync;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "parseSync", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _parse.parseSync;
|
||||
}
|
||||
});
|
||||
exports.resolvePreset = exports.resolvePlugin = void 0;
|
||||
Object.defineProperty((0, exports), "template", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _template().default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty((0, exports), "tokTypes", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _parser().tokTypes;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "transform", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _transform.transform;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "transformAsync", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _transform.transformAsync;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "transformFile", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _transformFile.transformFile;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "transformFileAsync", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _transformFile.transformFileAsync;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "transformFileSync", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _transformFile.transformFileSync;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "transformFromAst", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _transformAst.transformFromAst;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "transformFromAstAsync", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _transformAst.transformFromAstAsync;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "transformFromAstSync", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _transformAst.transformFromAstSync;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "transformSync", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _transform.transformSync;
|
||||
}
|
||||
});
|
||||
Object.defineProperty((0, exports), "traverse", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _traverse().default;
|
||||
}
|
||||
});
|
||||
exports.version = exports.types = void 0;
|
||||
var _file = require("./transformation/file/file.js");
|
||||
var _buildExternalHelpers = require("./tools/build-external-helpers.js");
|
||||
var resolvers = require("./config/files/index.js");
|
||||
var _environment = require("./config/helpers/environment.js");
|
||||
function _types() {
|
||||
const data = require("@babel/types");
|
||||
_types = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
Object.defineProperty((0, exports), "types", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _types();
|
||||
}
|
||||
});
|
||||
function _parser() {
|
||||
const data = require("@babel/parser");
|
||||
_parser = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _traverse() {
|
||||
const data = require("@babel/traverse");
|
||||
_traverse = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _template() {
|
||||
const data = require("@babel/template");
|
||||
_template = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var _index2 = require("./config/index.js");
|
||||
var _transform = require("./transform.js");
|
||||
var _transformFile = require("./transform-file.js");
|
||||
var _transformAst = require("./transform-ast.js");
|
||||
var _parse = require("./parse.js");
|
||||
;
|
||||
const version = exports.version = "7.26.10";
|
||||
const resolvePlugin = (name, dirname) => resolvers.resolvePlugin(name, dirname, false).filepath;
|
||||
exports.resolvePlugin = resolvePlugin;
|
||||
const resolvePreset = (name, dirname) => resolvers.resolvePreset(name, dirname, false).filepath;
|
||||
exports.resolvePreset = resolvePreset;
|
||||
const DEFAULT_EXTENSIONS = exports.DEFAULT_EXTENSIONS = Object.freeze([".js", ".jsx", ".es6", ".es", ".mjs", ".cjs"]);
|
||||
;
|
||||
{
|
||||
exports.OptionManager = class OptionManager {
|
||||
init(opts) {
|
||||
return (0, _index2.loadOptionsSync)(opts);
|
||||
}
|
||||
};
|
||||
exports.Plugin = function Plugin(alias) {
|
||||
throw new Error(`The (${alias}) Babel 5 plugin is being run with an unsupported Babel version.`);
|
||||
};
|
||||
}
|
||||
0 && (exports.types = exports.traverse = exports.tokTypes = exports.template = 0);
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,5 @@
|
||||
import { AllLoaderData, RouteById } from './routeInfo.cjs';
|
||||
import { AnyRouter } from './router.cjs';
|
||||
import { Expand } from './utils.cjs';
|
||||
export type ResolveUseLoaderData<TRouter extends AnyRouter, TFrom, TStrict extends boolean> = TStrict extends false ? AllLoaderData<TRouter['routeTree']> : Expand<RouteById<TRouter['routeTree'], TFrom>['types']['loaderData']>;
|
||||
export type UseLoaderDataResult<TRouter extends AnyRouter, TFrom, TStrict extends boolean, TSelected> = unknown extends TSelected ? ResolveUseLoaderData<TRouter, TFrom, TStrict> : TSelected;
|
||||
@@ -0,0 +1,6 @@
|
||||
var concatMap = require('../');
|
||||
var xs = [ 1, 2, 3, 4, 5, 6 ];
|
||||
var ys = concatMap(xs, function (x) {
|
||||
return x % 2 ? [ x - 0.1, x, x + 0.1 ] : [];
|
||||
});
|
||||
console.dir(ys);
|
||||
@@ -0,0 +1,9 @@
|
||||
export type Callback = (
|
||||
directory: string,
|
||||
files: string[],
|
||||
) => string | false | void;
|
||||
|
||||
export default function (
|
||||
directory: string,
|
||||
callback: Callback,
|
||||
): string | void;
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","_interopRequireWildcard","obj","__esModule","default","cache","has","get","newObj","__proto__","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set"],"sources":["../../src/helpers/interopRequireWildcard.ts"],"sourcesContent":["/* @minVersion 7.14.0 */\n\nfunction _getRequireWildcardCache(nodeInterop: boolean) {\n if (typeof WeakMap !== \"function\") return null;\n\n var cacheBabelInterop = new WeakMap();\n var cacheNodeInterop = new WeakMap();\n // @ts-expect-error assign to function\n return (_getRequireWildcardCache = function (nodeInterop: boolean) {\n return nodeInterop ? cacheNodeInterop : cacheBabelInterop;\n })(nodeInterop);\n}\n\nexport default function _interopRequireWildcard(\n obj: any,\n nodeInterop: boolean,\n) {\n if (!nodeInterop && obj && obj.__esModule) {\n return obj;\n }\n\n if (obj === null || (typeof obj !== \"object\" && typeof obj !== \"function\")) {\n return { default: obj };\n }\n\n var cache = _getRequireWildcardCache(nodeInterop);\n if (cache && cache.has(obj)) {\n return cache.get(obj);\n }\n\n var newObj: { [key: string]: any } = { __proto__: null };\n var hasPropertyDescriptor =\n // @ts-expect-error check if Object.defineProperty is available\n (Object.defineProperty && Object.getOwnPropertyDescriptor) as\n | typeof Object.getOwnPropertyDescriptor\n | undefined;\n for (var key in obj) {\n if (key !== \"default\" && Object.prototype.hasOwnProperty.call(obj, key)) {\n var desc = hasPropertyDescriptor\n ? Object.getOwnPropertyDescriptor(obj, key)\n : null;\n if (desc && (desc.get || desc.set)) {\n Object.defineProperty(newObj, key, desc);\n } else {\n newObj[key] = obj[key];\n }\n }\n }\n newObj.default = obj;\n if (cache) {\n cache.set(obj, newObj);\n }\n return newObj;\n}\n"],"mappings":";;;;;;AAEA,SAASA,wBAAwBA,CAACC,WAAoB,EAAE;EACtD,IAAI,OAAOC,OAAO,KAAK,UAAU,EAAE,OAAO,IAAI;EAE9C,IAAIC,iBAAiB,GAAG,IAAID,OAAO,CAAC,CAAC;EACrC,IAAIE,gBAAgB,GAAG,IAAIF,OAAO,CAAC,CAAC;EAEpC,OAAO,CAACF,wBAAwB,GAAG,SAAAA,CAAUC,WAAoB,EAAE;IACjE,OAAOA,WAAW,GAAGG,gBAAgB,GAAGD,iBAAiB;EAC3D,CAAC,EAAEF,WAAW,CAAC;AACjB;AAEe,SAASI,uBAAuBA,CAC7CC,GAAQ,EACRL,WAAoB,EACpB;EACA,IAAI,CAACA,WAAW,IAAIK,GAAG,IAAIA,GAAG,CAACC,UAAU,EAAE;IACzC,OAAOD,GAAG;EACZ;EAEA,IAAIA,GAAG,KAAK,IAAI,IAAK,OAAOA,GAAG,KAAK,QAAQ,IAAI,OAAOA,GAAG,KAAK,UAAW,EAAE;IAC1E,OAAO;MAAEE,OAAO,EAAEF;IAAI,CAAC;EACzB;EAEA,IAAIG,KAAK,GAAGT,wBAAwB,CAACC,WAAW,CAAC;EACjD,IAAIQ,KAAK,IAAIA,KAAK,CAACC,GAAG,CAACJ,GAAG,CAAC,EAAE;IAC3B,OAAOG,KAAK,CAACE,GAAG,CAACL,GAAG,CAAC;EACvB;EAEA,IAAIM,MAA8B,GAAG;IAAEC,SAAS,EAAE;EAAK,CAAC;EACxD,IAAIC,qBAAqB,GAEtBC,MAAM,CAACC,cAAc,IAAID,MAAM,CAACE,wBAEpB;EACf,KAAK,IAAIC,GAAG,IAAIZ,GAAG,EAAE;IACnB,IAAIY,GAAG,KAAK,SAAS,IAAIH,MAAM,CAACI,SAAS,CAACC,cAAc,CAACC,IAAI,CAACf,GAAG,EAAEY,GAAG,CAAC,EAAE;MACvE,IAAII,IAAI,GAAGR,qBAAqB,GAC5BC,MAAM,CAACE,wBAAwB,CAACX,GAAG,EAAEY,GAAG,CAAC,GACzC,IAAI;MACR,IAAII,IAAI,KAAKA,IAAI,CAACX,GAAG,IAAIW,IAAI,CAACC,GAAG,CAAC,EAAE;QAClCR,MAAM,CAACC,cAAc,CAACJ,MAAM,EAAEM,GAAG,EAAEI,IAAI,CAAC;MAC1C,CAAC,MAAM;QACLV,MAAM,CAACM,GAAG,CAAC,GAAGZ,GAAG,CAACY,GAAG,CAAC;MACxB;IACF;EACF;EACAN,MAAM,CAACJ,OAAO,GAAGF,GAAG;EACpB,IAAIG,KAAK,EAAE;IACTA,KAAK,CAACc,GAAG,CAACjB,GAAG,EAAEM,MAAM,CAAC;EACxB;EACA,OAAOA,MAAM;AACf","ignoreList":[]}
|
||||
Reference in New Issue
Block a user