update
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
# dequal [](https://github.com/lukeed/dequal/actions)
|
||||
|
||||
> A tiny (304B to 489B) utility to check for deep equality
|
||||
|
||||
This module supports comparison of all types, including `Function`, `RegExp`, `Date`, `Set`, `Map`, `TypedArray`s, `DataView`, `null`, `undefined`, and `NaN` values. Complex values (eg, Objects, Arrays, Sets, Maps, etc) are traversed recursively.
|
||||
|
||||
> **Important:**
|
||||
> * key order **within Objects** does not matter
|
||||
> * value order **within Arrays** _does_ matter
|
||||
> * values **within Sets and Maps** use value equality
|
||||
> * keys **within Maps** use value equality
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save dequal
|
||||
```
|
||||
|
||||
## Modes
|
||||
|
||||
There are two "versions" of `dequal` available:
|
||||
|
||||
#### `dequal`
|
||||
> **Size (gzip):** 489 bytes<br>
|
||||
> **Availability:** [CommonJS](https://unpkg.com/dequal/dist/index.js), [ES Module](https://unpkg.com/dequal/dist/index.mjs), [UMD](https://unpkg.com/dequal/dist/index.min.js)
|
||||
|
||||
#### `dequal/lite`
|
||||
> **Size (gzip):** 304 bytes<br>
|
||||
> **Availability:** [CommonJS](https://unpkg.com/dequal/lite/index.js), [ES Module](https://unpkg.com/dequal/lite/index.mjs)
|
||||
|
||||
| | IE9+ | Number | String | Date | RegExp | Object | Array | Class | Set | Map | ArrayBuffer | [TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#TypedArray_objects) | [DataView](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView) |
|
||||
|-|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
|
||||
| `dequal` | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| `dequal/lite` | :+1: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :x: | :x: | :x: |
|
||||
|
||||
> <sup>**Note:** Table scrolls horizontally!</sup>
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import { dequal } from 'dequal';
|
||||
|
||||
dequal(1, 1); //=> true
|
||||
dequal({}, {}); //=> true
|
||||
dequal('foo', 'foo'); //=> true
|
||||
dequal([1, 2, 3], [1, 2, 3]); //=> true
|
||||
dequal(dequal, dequal); //=> true
|
||||
dequal(/foo/, /foo/); //=> true
|
||||
dequal(null, null); //=> true
|
||||
dequal(NaN, NaN); //=> true
|
||||
dequal([], []); //=> true
|
||||
dequal(
|
||||
[{ a:1 }, [{ b:{ c:[1] } }]],
|
||||
[{ a:1 }, [{ b:{ c:[1] } }]]
|
||||
); //=> true
|
||||
|
||||
dequal(1, '1'); //=> false
|
||||
dequal(null, undefined); //=> false
|
||||
dequal({ a:1, b:[2,3] }, { a:1, b:[2,5] }); //=> false
|
||||
dequal(/foo/i, /bar/g); //=> false
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### dequal(foo, bar)
|
||||
Returns: `Boolean`
|
||||
|
||||
Both `foo` and `bar` can be of any type.<br>
|
||||
A `Boolean` is returned indicating if the two were deeply equal.
|
||||
|
||||
|
||||
## Benchmarks
|
||||
|
||||
> Running Node v10.13.0
|
||||
|
||||
The benchmarks can be found in the [`/bench`](/bench) directory. They are separated into two categories:
|
||||
|
||||
* `basic` – compares an object comprised of `String`, `Number`, `Date`, `Array`, and `Object` values.
|
||||
* `complex` – like `basic`, but adds `RegExp`, `Map`, `Set`, and `Uint8Array` values.
|
||||
|
||||
> **Note:** Only candidates that pass validation step(s) are listed. <br>For example, `fast-deep-equal/es6` handles `Set` and `Map` values, but uses _referential equality_ while those listed use _value equality_.
|
||||
|
||||
```
|
||||
Load times:
|
||||
assert 0.109ms
|
||||
util 0.006ms
|
||||
fast-deep-equal 0.479ms
|
||||
lodash/isequal 22.826ms
|
||||
nano-equal 0.417ms
|
||||
dequal 0.396ms
|
||||
dequal/lite 0.264ms
|
||||
|
||||
Benchmark :: basic
|
||||
assert.deepStrictEqual x 325,262 ops/sec ±0.57% (94 runs sampled)
|
||||
util.isDeepStrictEqual x 318,812 ops/sec ±0.87% (94 runs sampled)
|
||||
fast-deep-equal x 1,332,393 ops/sec ±0.36% (93 runs sampled)
|
||||
lodash.isEqual x 269,129 ops/sec ±0.59% (95 runs sampled)
|
||||
nano-equal x 1,122,053 ops/sec ±0.36% (96 runs sampled)
|
||||
dequal/lite x 1,700,972 ops/sec ±0.31% (94 runs sampled)
|
||||
dequal x 1,698,972 ops/sec ±0.63% (97 runs sampled)
|
||||
|
||||
Benchmark :: complex
|
||||
assert.deepStrictEqual x 124,518 ops/sec ±0.64% (96 runs sampled)
|
||||
util.isDeepStrictEqual x 125,113 ops/sec ±0.24% (96 runs sampled)
|
||||
lodash.isEqual x 58,677 ops/sec ±0.49% (96 runs sampled)
|
||||
dequal x 345,386 ops/sec ±0.27% (96 runs sampled)
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Luke Edwards](https://lukeed.com)
|
||||
@@ -0,0 +1,124 @@
|
||||
/**
|
||||
* @fileoverview Rule to disallow calls to the `Object` constructor without an argument
|
||||
* @author Francesco Trotta
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const {
|
||||
getVariableByName,
|
||||
isArrowToken,
|
||||
isStartOfExpressionStatement,
|
||||
needsPrecedingSemicolon,
|
||||
} = require("./utils/ast-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description:
|
||||
"Disallow calls to the `Object` constructor without an argument",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/no-object-constructor",
|
||||
},
|
||||
|
||||
hasSuggestions: true,
|
||||
|
||||
schema: [],
|
||||
|
||||
messages: {
|
||||
preferLiteral: "The object literal notation {} is preferable.",
|
||||
useLiteral: "Replace with '{{replacement}}'.",
|
||||
useLiteralAfterSemicolon:
|
||||
"Replace with '{{replacement}}', add preceding semicolon.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Determines whether or not an object literal that replaces a specified node needs to be enclosed in parentheses.
|
||||
* @param {ASTNode} node The node to be replaced.
|
||||
* @returns {boolean} Whether or not parentheses around the object literal are required.
|
||||
*/
|
||||
function needsParentheses(node) {
|
||||
if (isStartOfExpressionStatement(node)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const prevToken = sourceCode.getTokenBefore(node);
|
||||
|
||||
if (prevToken && isArrowToken(prevToken)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports on nodes where the `Object` constructor is called without arguments.
|
||||
* @param {ASTNode} node The node to evaluate.
|
||||
* @returns {void}
|
||||
*/
|
||||
function check(node) {
|
||||
if (
|
||||
node.callee.type !== "Identifier" ||
|
||||
node.callee.name !== "Object" ||
|
||||
node.arguments.length
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const variable = getVariableByName(
|
||||
sourceCode.getScope(node),
|
||||
"Object",
|
||||
);
|
||||
|
||||
if (variable && variable.identifiers.length === 0) {
|
||||
let replacement;
|
||||
let fixText;
|
||||
let messageId = "useLiteral";
|
||||
|
||||
if (needsParentheses(node)) {
|
||||
replacement = "({})";
|
||||
if (needsPrecedingSemicolon(sourceCode, node)) {
|
||||
fixText = ";({})";
|
||||
messageId = "useLiteralAfterSemicolon";
|
||||
} else {
|
||||
fixText = "({})";
|
||||
}
|
||||
} else {
|
||||
replacement = fixText = "{}";
|
||||
}
|
||||
|
||||
context.report({
|
||||
node,
|
||||
messageId: "preferLiteral",
|
||||
suggest: [
|
||||
{
|
||||
messageId,
|
||||
data: { replacement },
|
||||
fix: fixer => fixer.replaceText(node, fixText),
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
CallExpression: check,
|
||||
NewExpression: check,
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"4":"K D E mC","132":"F A B"},B:{"4":"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 9 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","8":"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 qC rC"},D:{"4":"0 1 2 3 4 5 6 7 8 9 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 BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC","8":"J"},E:{"4":"PB K D E F A B C L M G 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","8":"J sC SC"},F:{"4":"0 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 p q r s t u v w x y z","8":"F B C 4C 5C 6C 7C FC kC 8C GC"},G:{"4":"E 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","8":"SC 9C lC"},H:{"8":"WD"},I:{"4":"LC J I aD lC bD cD","8":"XD YD ZD"},J:{"4":"A","8":"D"},K:{"4":"H","8":"A B C FC kC GC"},L:{"4":"I"},M:{"1":"EC"},N:{"132":"A B"},O:{"4":"HC"},P:{"4":"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:{"4":"oD"},R:{"4":"pD"},S:{"1":"qD rD"}},B:1,C:"Ruby annotation",D:true};
|
||||
@@ -0,0 +1,86 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`allEvents > should contain all events 1`] = `
|
||||
Set {
|
||||
"onAbort",
|
||||
"onAnimationEnd",
|
||||
"onAnimationIteration",
|
||||
"onAnimationStart",
|
||||
"onBlur",
|
||||
"onCanPlay",
|
||||
"onCanPlayThrough",
|
||||
"onChange",
|
||||
"onClick",
|
||||
"onCompositionEnd",
|
||||
"onCompositionStart",
|
||||
"onCompositionUpdate",
|
||||
"onContextMenu",
|
||||
"onCopy",
|
||||
"onCut",
|
||||
"onDoubleClick",
|
||||
"onDrag",
|
||||
"onDragEnd",
|
||||
"onDragEnter",
|
||||
"onDragExit",
|
||||
"onDragLeave",
|
||||
"onDragOver",
|
||||
"onDragStart",
|
||||
"onDrop",
|
||||
"onDurationChange",
|
||||
"onEmptied",
|
||||
"onEncrypted",
|
||||
"onEnded",
|
||||
"onError",
|
||||
"onFocus",
|
||||
"onGotPointerCapture",
|
||||
"onInput",
|
||||
"onInvalid",
|
||||
"onKeyDown",
|
||||
"onKeyPress",
|
||||
"onKeyUp",
|
||||
"onLoad",
|
||||
"onLoadStart",
|
||||
"onLoadedData",
|
||||
"onLoadedMetadata",
|
||||
"onLostPointerCapture",
|
||||
"onMouseDown",
|
||||
"onMouseEnter",
|
||||
"onMouseLeave",
|
||||
"onMouseMove",
|
||||
"onMouseOut",
|
||||
"onMouseOver",
|
||||
"onMouseUp",
|
||||
"onPaste",
|
||||
"onPause",
|
||||
"onPlay",
|
||||
"onPlaying",
|
||||
"onPointerCancel",
|
||||
"onPointerDown",
|
||||
"onPointerEnter",
|
||||
"onPointerLeave",
|
||||
"onPointerMove",
|
||||
"onPointerOut",
|
||||
"onPointerOver",
|
||||
"onPointerUp",
|
||||
"onProgress",
|
||||
"onRateChange",
|
||||
"onReset",
|
||||
"onScroll",
|
||||
"onSeeked",
|
||||
"onSeeking",
|
||||
"onSelect",
|
||||
"onStalled",
|
||||
"onSubmit",
|
||||
"onSuspend",
|
||||
"onTimeUpdate",
|
||||
"onToggle",
|
||||
"onTouchCancel",
|
||||
"onTouchEnd",
|
||||
"onTouchMove",
|
||||
"onTouchStart",
|
||||
"onTransitionEnd",
|
||||
"onVolumeChange",
|
||||
"onWaiting",
|
||||
"onWheel",
|
||||
}
|
||||
`;
|
||||
@@ -0,0 +1,8 @@
|
||||
import { StructuralSharingOption, ValidateSelected } from './structuralSharing.cjs';
|
||||
import { AnyRouter, RegisteredRouter, ResolveUseLoaderDeps, StrictOrFrom, UseLoaderDepsResult } from '@tanstack/router-core';
|
||||
export interface UseLoaderDepsBaseOptions<TRouter extends AnyRouter, TFrom, TSelected, TStructuralSharing> {
|
||||
select?: (deps: ResolveUseLoaderDeps<TRouter, TFrom>) => ValidateSelected<TRouter, TSelected, TStructuralSharing>;
|
||||
}
|
||||
export type UseLoaderDepsOptions<TRouter extends AnyRouter, TFrom extends string | undefined, TSelected, TStructuralSharing> = StrictOrFrom<TRouter, TFrom> & UseLoaderDepsBaseOptions<TRouter, TFrom, TSelected, TStructuralSharing> & StructuralSharingOption<TRouter, TSelected, TStructuralSharing>;
|
||||
export type UseLoaderDepsRoute<out TId> = <TRouter extends AnyRouter = RegisteredRouter, TSelected = unknown, TStructuralSharing extends boolean = boolean>(opts?: UseLoaderDepsBaseOptions<TRouter, TId, TSelected, TStructuralSharing> & StructuralSharingOption<TRouter, TSelected, false>) => UseLoaderDepsResult<TRouter, TId, TSelected>;
|
||||
export declare function useLoaderDeps<TRouter extends AnyRouter = RegisteredRouter, const TFrom extends string | undefined = undefined, TSelected = unknown, TStructuralSharing extends boolean = boolean>(opts: UseLoaderDepsOptions<TRouter, TFrom, TSelected, TStructuralSharing>): UseLoaderDepsResult<TRouter, TFrom, TSelected>;
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Removes everything after the last "/", but leaves the slash.
|
||||
*/
|
||||
export default function stripFilename(path: string | undefined | null): string;
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @fileoverview Helpers for severity values (e.g. normalizing different types).
|
||||
* @author Bryan Mishkin
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Convert severity value of different types to a string.
|
||||
* @param {string|number} severity severity value
|
||||
* @throws error if severity is invalid
|
||||
* @returns {string} severity string
|
||||
*/
|
||||
function normalizeSeverityToString(severity) {
|
||||
if ([2, "2", "error"].includes(severity)) {
|
||||
return "error";
|
||||
}
|
||||
if ([1, "1", "warn"].includes(severity)) {
|
||||
return "warn";
|
||||
}
|
||||
if ([0, "0", "off"].includes(severity)) {
|
||||
return "off";
|
||||
}
|
||||
throw new Error(`Invalid severity value: ${severity}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert severity value of different types to a number.
|
||||
* @param {string|number} severity severity value
|
||||
* @throws error if severity is invalid
|
||||
* @returns {number} severity number
|
||||
*/
|
||||
function normalizeSeverityToNumber(severity) {
|
||||
if ([2, "2", "error"].includes(severity)) {
|
||||
return 2;
|
||||
}
|
||||
if ([1, "1", "warn"].includes(severity)) {
|
||||
return 1;
|
||||
}
|
||||
if ([0, "0", "off"].includes(severity)) {
|
||||
return 0;
|
||||
}
|
||||
throw new Error(`Invalid severity value: ${severity}`);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
normalizeSeverityToString,
|
||||
normalizeSeverityToNumber,
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_cloneNode","require","cloneDeep","node","cloneNode"],"sources":["../../src/clone/cloneDeep.ts"],"sourcesContent":["import cloneNode from \"./cloneNode.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Create a deep clone of a `node` and all of it's child nodes\n * including only properties belonging to the node.\n * @deprecated Use t.cloneNode instead.\n */\nexport default function cloneDeep<T extends t.Node>(node: T): T {\n return cloneNode(node);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAQe,SAASC,SAASA,CAAmBC,IAAO,EAAK;EAC9D,OAAO,IAAAC,kBAAS,EAACD,IAAI,CAAC;AACxB","ignoreList":[]}
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* @fileoverview exports for browsers
|
||||
* @author 唯然<weiran.zsd@outlook.com>
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const { Linter } = require("./linter/linter");
|
||||
|
||||
module.exports = { Linter };
|
||||
@@ -0,0 +1,48 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = getAssignmentIdentifiers;
|
||||
function getAssignmentIdentifiers(node) {
|
||||
const search = [].concat(node);
|
||||
const ids = Object.create(null);
|
||||
while (search.length) {
|
||||
const id = search.pop();
|
||||
if (!id) continue;
|
||||
switch (id.type) {
|
||||
case "ArrayPattern":
|
||||
search.push(...id.elements);
|
||||
break;
|
||||
case "AssignmentExpression":
|
||||
case "AssignmentPattern":
|
||||
case "ForInStatement":
|
||||
case "ForOfStatement":
|
||||
search.push(id.left);
|
||||
break;
|
||||
case "ObjectPattern":
|
||||
search.push(...id.properties);
|
||||
break;
|
||||
case "ObjectProperty":
|
||||
search.push(id.value);
|
||||
break;
|
||||
case "RestElement":
|
||||
case "UpdateExpression":
|
||||
search.push(id.argument);
|
||||
break;
|
||||
case "UnaryExpression":
|
||||
if (id.operator === "delete") {
|
||||
search.push(id.argument);
|
||||
}
|
||||
break;
|
||||
case "Identifier":
|
||||
ids[id.name] = id;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=getAssignmentIdentifiers.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_temporalUndefined"],"sources":["../../src/helpers/temporalUndefined.ts"],"sourcesContent":["/* @minVersion 7.0.0-beta.0 */\n\n// This function isn't mean to be called, but to be used as a reference.\n// We can't use a normal object because it isn't hoisted.\nexport default function _temporalUndefined(this: never): void {}\n"],"mappings":";;;;;;AAIe,SAASA,kBAAkBA,CAAA,EAAoB,CAAC","ignoreList":[]}
|
||||
@@ -0,0 +1,45 @@
|
||||
import { GenMapping } from '@jridgewell/gen-mapping';
|
||||
import type { TraceMap } from '@jridgewell/trace-mapping';
|
||||
export declare type SourceMapSegmentObject = {
|
||||
column: number;
|
||||
line: number;
|
||||
name: string;
|
||||
source: string;
|
||||
content: string | null;
|
||||
ignore: boolean;
|
||||
};
|
||||
export declare type OriginalSource = {
|
||||
map: null;
|
||||
sources: Sources[];
|
||||
source: string;
|
||||
content: string | null;
|
||||
ignore: boolean;
|
||||
};
|
||||
export declare type MapSource = {
|
||||
map: TraceMap;
|
||||
sources: Sources[];
|
||||
source: string;
|
||||
content: null;
|
||||
ignore: false;
|
||||
};
|
||||
export declare type Sources = OriginalSource | MapSource;
|
||||
/**
|
||||
* MapSource represents a single sourcemap, with the ability to trace mappings into its child nodes
|
||||
* (which may themselves be SourceMapTrees).
|
||||
*/
|
||||
export declare function MapSource(map: TraceMap, sources: Sources[]): MapSource;
|
||||
/**
|
||||
* A "leaf" node in the sourcemap tree, representing an original, unmodified source file. Recursive
|
||||
* segment tracing ends at the `OriginalSource`.
|
||||
*/
|
||||
export declare function OriginalSource(source: string, content: string | null, ignore: boolean): OriginalSource;
|
||||
/**
|
||||
* traceMappings is only called on the root level SourceMapTree, and begins the process of
|
||||
* resolving each mapping in terms of the original source files.
|
||||
*/
|
||||
export declare function traceMappings(tree: MapSource): GenMapping;
|
||||
/**
|
||||
* originalPositionFor is only called on children SourceMapTrees. It recurses down into its own
|
||||
* child SourceMapTrees, until we find the original source map.
|
||||
*/
|
||||
export declare function originalPositionFor(source: Sources, line: number, column: number, name: string): SourceMapSegmentObject | null;
|
||||
@@ -0,0 +1,158 @@
|
||||
/**
|
||||
* @fileoverview Rule to enforce spacing around colons of switch statements.
|
||||
* @author Toru Nagashima
|
||||
* @deprecated in ESLint v8.53.0
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const astUtils = require("./utils/ast-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// 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: "switch-colon-spacing",
|
||||
url: "https://eslint.style/rules/js/switch-colon-spacing",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
type: "layout",
|
||||
|
||||
docs: {
|
||||
description: "Enforce spacing around colons of switch statements",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/switch-colon-spacing",
|
||||
},
|
||||
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
before: { type: "boolean", default: false },
|
||||
after: { type: "boolean", default: true },
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
fixable: "whitespace",
|
||||
messages: {
|
||||
expectedBefore: "Expected space(s) before this colon.",
|
||||
expectedAfter: "Expected space(s) after this colon.",
|
||||
unexpectedBefore: "Unexpected space(s) before this colon.",
|
||||
unexpectedAfter: "Unexpected space(s) after this colon.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const options = context.options[0] || {};
|
||||
const beforeSpacing = options.before === true; // false by default
|
||||
const afterSpacing = options.after !== false; // true by default
|
||||
|
||||
/**
|
||||
* Check whether the spacing between the given 2 tokens is valid or not.
|
||||
* @param {Token} left The left token to check.
|
||||
* @param {Token} right The right token to check.
|
||||
* @param {boolean} expected The expected spacing to check. `true` if there should be a space.
|
||||
* @returns {boolean} `true` if the spacing between the tokens is valid.
|
||||
*/
|
||||
function isValidSpacing(left, right, expected) {
|
||||
return (
|
||||
astUtils.isClosingBraceToken(right) ||
|
||||
!astUtils.isTokenOnSameLine(left, right) ||
|
||||
sourceCode.isSpaceBetweenTokens(left, right) === expected
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether comments exist between the given 2 tokens.
|
||||
* @param {Token} left The left token to check.
|
||||
* @param {Token} right The right token to check.
|
||||
* @returns {boolean} `true` if comments exist between the given 2 tokens.
|
||||
*/
|
||||
function commentsExistBetween(left, right) {
|
||||
return (
|
||||
sourceCode.getFirstTokenBetween(left, right, {
|
||||
includeComments: true,
|
||||
filter: astUtils.isCommentToken,
|
||||
}) !== null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix the spacing between the given 2 tokens.
|
||||
* @param {RuleFixer} fixer The fixer to fix.
|
||||
* @param {Token} left The left token of fix range.
|
||||
* @param {Token} right The right token of fix range.
|
||||
* @param {boolean} spacing The spacing style. `true` if there should be a space.
|
||||
* @returns {Fix|null} The fix object.
|
||||
*/
|
||||
function fix(fixer, left, right, spacing) {
|
||||
if (commentsExistBetween(left, right)) {
|
||||
return null;
|
||||
}
|
||||
if (spacing) {
|
||||
return fixer.insertTextAfter(left, " ");
|
||||
}
|
||||
return fixer.removeRange([left.range[1], right.range[0]]);
|
||||
}
|
||||
|
||||
return {
|
||||
SwitchCase(node) {
|
||||
const colonToken = astUtils.getSwitchCaseColonToken(
|
||||
node,
|
||||
sourceCode,
|
||||
);
|
||||
const beforeToken = sourceCode.getTokenBefore(colonToken);
|
||||
const afterToken = sourceCode.getTokenAfter(colonToken);
|
||||
|
||||
if (!isValidSpacing(beforeToken, colonToken, beforeSpacing)) {
|
||||
context.report({
|
||||
node,
|
||||
loc: colonToken.loc,
|
||||
messageId: beforeSpacing
|
||||
? "expectedBefore"
|
||||
: "unexpectedBefore",
|
||||
fix: fixer =>
|
||||
fix(fixer, beforeToken, colonToken, beforeSpacing),
|
||||
});
|
||||
}
|
||||
if (!isValidSpacing(colonToken, afterToken, afterSpacing)) {
|
||||
context.report({
|
||||
node,
|
||||
loc: colonToken.loc,
|
||||
messageId: afterSpacing
|
||||
? "expectedAfter"
|
||||
: "unexpectedAfter",
|
||||
fix: fixer =>
|
||||
fix(fixer, colonToken, afterToken, afterSpacing),
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,138 @@
|
||||
/**
|
||||
* @fileoverview Validates newlines before and after dots
|
||||
* @author Greg Cochard
|
||||
* @deprecated in ESLint v8.53.0
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const astUtils = require("./utils/ast-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// 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: "dot-location",
|
||||
url: "https://eslint.style/rules/js/dot-location",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
type: "layout",
|
||||
|
||||
docs: {
|
||||
description: "Enforce consistent newlines before and after dots",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/dot-location",
|
||||
},
|
||||
|
||||
schema: [
|
||||
{
|
||||
enum: ["object", "property"],
|
||||
},
|
||||
],
|
||||
|
||||
fixable: "code",
|
||||
|
||||
messages: {
|
||||
expectedDotAfterObject:
|
||||
"Expected dot to be on same line as object.",
|
||||
expectedDotBeforeProperty:
|
||||
"Expected dot to be on same line as property.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const config = context.options[0];
|
||||
|
||||
// default to onObject if no preference is passed
|
||||
const onObject = config === "object" || !config;
|
||||
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Reports if the dot between object and property is on the correct location.
|
||||
* @param {ASTNode} node The `MemberExpression` node.
|
||||
* @returns {void}
|
||||
*/
|
||||
function checkDotLocation(node) {
|
||||
const property = node.property;
|
||||
const dotToken = sourceCode.getTokenBefore(property);
|
||||
|
||||
if (onObject) {
|
||||
// `obj` expression can be parenthesized, but those paren tokens are not a part of the `obj` node.
|
||||
const tokenBeforeDot = sourceCode.getTokenBefore(dotToken);
|
||||
|
||||
if (!astUtils.isTokenOnSameLine(tokenBeforeDot, dotToken)) {
|
||||
context.report({
|
||||
node,
|
||||
loc: dotToken.loc,
|
||||
messageId: "expectedDotAfterObject",
|
||||
*fix(fixer) {
|
||||
if (
|
||||
dotToken.value.startsWith(".") &&
|
||||
astUtils.isDecimalIntegerNumericToken(
|
||||
tokenBeforeDot,
|
||||
)
|
||||
) {
|
||||
yield fixer.insertTextAfter(
|
||||
tokenBeforeDot,
|
||||
` ${dotToken.value}`,
|
||||
);
|
||||
} else {
|
||||
yield fixer.insertTextAfter(
|
||||
tokenBeforeDot,
|
||||
dotToken.value,
|
||||
);
|
||||
}
|
||||
yield fixer.remove(dotToken);
|
||||
},
|
||||
});
|
||||
}
|
||||
} else if (!astUtils.isTokenOnSameLine(dotToken, property)) {
|
||||
context.report({
|
||||
node,
|
||||
loc: dotToken.loc,
|
||||
messageId: "expectedDotBeforeProperty",
|
||||
*fix(fixer) {
|
||||
yield fixer.remove(dotToken);
|
||||
yield fixer.insertTextBefore(property, dotToken.value);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the spacing of the dot within a member expression.
|
||||
* @param {ASTNode} node The node to check.
|
||||
* @returns {void}
|
||||
*/
|
||||
function checkNode(node) {
|
||||
if (!node.computed) {
|
||||
checkDotLocation(node);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
MemberExpression: checkNode,
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,69 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports._assertUnremoved = _assertUnremoved;
|
||||
exports._callRemovalHooks = _callRemovalHooks;
|
||||
exports._markRemoved = _markRemoved;
|
||||
exports._remove = _remove;
|
||||
exports._removeFromScope = _removeFromScope;
|
||||
exports.remove = remove;
|
||||
var _removalHooks = require("./lib/removal-hooks.js");
|
||||
var _cache = require("../cache.js");
|
||||
var _replacement = require("./replacement.js");
|
||||
var _index = require("./index.js");
|
||||
var _t = require("@babel/types");
|
||||
var _modification = require("./modification.js");
|
||||
var _context = require("./context.js");
|
||||
const {
|
||||
getBindingIdentifiers
|
||||
} = _t;
|
||||
function remove() {
|
||||
var _this$opts;
|
||||
_assertUnremoved.call(this);
|
||||
_context.resync.call(this);
|
||||
if (_callRemovalHooks.call(this)) {
|
||||
_markRemoved.call(this);
|
||||
return;
|
||||
}
|
||||
if (!((_this$opts = this.opts) != null && _this$opts.noScope)) {
|
||||
_removeFromScope.call(this);
|
||||
}
|
||||
this.shareCommentsWithSiblings();
|
||||
_remove.call(this);
|
||||
_markRemoved.call(this);
|
||||
}
|
||||
function _removeFromScope() {
|
||||
const bindings = getBindingIdentifiers(this.node, false, false, true);
|
||||
Object.keys(bindings).forEach(name => this.scope.removeBinding(name));
|
||||
}
|
||||
function _callRemovalHooks() {
|
||||
if (this.parentPath) {
|
||||
for (const fn of _removalHooks.hooks) {
|
||||
if (fn(this, this.parentPath)) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
function _remove() {
|
||||
if (Array.isArray(this.container)) {
|
||||
this.container.splice(this.key, 1);
|
||||
_modification.updateSiblingKeys.call(this, this.key, -1);
|
||||
} else {
|
||||
_replacement._replaceWith.call(this, null);
|
||||
}
|
||||
}
|
||||
function _markRemoved() {
|
||||
this._traverseFlags |= _index.SHOULD_SKIP | _index.REMOVED;
|
||||
if (this.parent) {
|
||||
(0, _cache.getCachedPaths)(this.hub, this.parent).delete(this.node);
|
||||
}
|
||||
this.node = null;
|
||||
}
|
||||
function _assertUnremoved() {
|
||||
if (this.removed) {
|
||||
throw this.buildCodeFrameError("NodePath has been removed so is read-only.");
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=removal.js.map
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = function () {
|
||||
throw new Error('Readable.from is not available in the browser')
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getEnv = getEnv;
|
||||
function getEnv(defaultValue = "development") {
|
||||
return process.env.BABEL_ENV || process.env.NODE_ENV || defaultValue;
|
||||
}
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=environment.js.map
|
||||
@@ -0,0 +1 @@
|
||||
tidelift: "npm/fast-json-stable-stringify"
|
||||
Reference in New Issue
Block a user