@taiga-ui/eslint-plugin-experience-next 0.523.0 → 0.525.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.esm.js +782 -673
- package/package.json +1 -1
- package/rules/utils/ast/ancestors.d.ts +2 -0
- package/rules/utils/ast/ast-expressions.d.ts +1 -0
- package/rules/utils/ast/ast-walk.d.ts +2 -0
- package/rules/utils/ast/class-members.d.ts +1 -1
- package/rules/utils/ast/condition-expressions.d.ts +6 -0
- package/rules/utils/ast/indexed-access-narrowing.d.ts +2 -0
- package/rules/utils/ast/member-expressions.d.ts +4 -0
- package/rules/utils/ast/mutation-targets.d.ts +2 -0
- package/rules/utils/ast/spacing.d.ts +1 -0
- package/rules/utils/typescript/built-in-at.d.ts +2 -0
- package/rules/utils/typescript/compiler-options.d.ts +2 -0
- package/rules/utils/typescript/types.d.ts +6 -0
package/index.esm.js
CHANGED
|
@@ -1496,6 +1496,9 @@ var recommended = defineConfig([
|
|
|
1496
1496
|
'String.prototype.at',
|
|
1497
1497
|
'Touch',
|
|
1498
1498
|
'TouchEvent',
|
|
1499
|
+
'MIDIMessageEvent',
|
|
1500
|
+
'Notification',
|
|
1501
|
+
'Permissions',
|
|
1499
1502
|
'document.fullscreenElement',
|
|
1500
1503
|
],
|
|
1501
1504
|
},
|
|
@@ -14543,6 +14546,645 @@ Object.defineProperty(NoInfer, "__esModule", { value: true });
|
|
|
14543
14546
|
exports.TSUtils = __importStar(tsUtils);
|
|
14544
14547
|
} (dist$4));
|
|
14545
14548
|
|
|
14549
|
+
function isFunctionExpressionLike(node) {
|
|
14550
|
+
return (node?.type === dist$4.AST_NODE_TYPES.ArrowFunctionExpression ||
|
|
14551
|
+
node?.type === dist$4.AST_NODE_TYPES.FunctionExpression);
|
|
14552
|
+
}
|
|
14553
|
+
function isFunctionLike(node) {
|
|
14554
|
+
return (node.type === dist$4.AST_NODE_TYPES.ArrowFunctionExpression ||
|
|
14555
|
+
node.type === dist$4.AST_NODE_TYPES.FunctionDeclaration ||
|
|
14556
|
+
node.type === dist$4.AST_NODE_TYPES.FunctionExpression);
|
|
14557
|
+
}
|
|
14558
|
+
function getOrderedChildren(node) {
|
|
14559
|
+
if (isFunctionLike(node)) {
|
|
14560
|
+
const children = [
|
|
14561
|
+
...node.params,
|
|
14562
|
+
node.body,
|
|
14563
|
+
];
|
|
14564
|
+
return children.filter((child) => child != null);
|
|
14565
|
+
}
|
|
14566
|
+
if (node.type === dist$4.AST_NODE_TYPES.BlockStatement ||
|
|
14567
|
+
node.type === dist$4.AST_NODE_TYPES.Program) {
|
|
14568
|
+
return node.body;
|
|
14569
|
+
}
|
|
14570
|
+
if (node.type === dist$4.AST_NODE_TYPES.IfStatement) {
|
|
14571
|
+
return node.alternate
|
|
14572
|
+
? [node.test, node.consequent, node.alternate]
|
|
14573
|
+
: [node.test, node.consequent];
|
|
14574
|
+
}
|
|
14575
|
+
if (node.type === dist$4.AST_NODE_TYPES.ConditionalExpression) {
|
|
14576
|
+
return [node.test, node.consequent, node.alternate];
|
|
14577
|
+
}
|
|
14578
|
+
if (node.type === dist$4.AST_NODE_TYPES.WhileStatement) {
|
|
14579
|
+
return [node.test, node.body];
|
|
14580
|
+
}
|
|
14581
|
+
if (node.type === dist$4.AST_NODE_TYPES.DoWhileStatement) {
|
|
14582
|
+
return [node.body, node.test];
|
|
14583
|
+
}
|
|
14584
|
+
if (node.type === dist$4.AST_NODE_TYPES.ForStatement) {
|
|
14585
|
+
const children = [
|
|
14586
|
+
node.init && 'type' in node.init ? node.init : null,
|
|
14587
|
+
node.test,
|
|
14588
|
+
node.update,
|
|
14589
|
+
node.body,
|
|
14590
|
+
];
|
|
14591
|
+
return children.filter((child) => child != null);
|
|
14592
|
+
}
|
|
14593
|
+
if (node.type === dist$4.AST_NODE_TYPES.ForInStatement ||
|
|
14594
|
+
node.type === dist$4.AST_NODE_TYPES.ForOfStatement) {
|
|
14595
|
+
return [node.left, node.right, node.body];
|
|
14596
|
+
}
|
|
14597
|
+
const children = [];
|
|
14598
|
+
for (const key of Object.keys(node)) {
|
|
14599
|
+
if (key === 'parent') {
|
|
14600
|
+
continue;
|
|
14601
|
+
}
|
|
14602
|
+
const child = node[key];
|
|
14603
|
+
if (Array.isArray(child)) {
|
|
14604
|
+
for (const item of child) {
|
|
14605
|
+
if (item && typeof item === 'object' && 'type' in item) {
|
|
14606
|
+
children.push(item);
|
|
14607
|
+
}
|
|
14608
|
+
}
|
|
14609
|
+
}
|
|
14610
|
+
else if (child && typeof child === 'object' && 'type' in child) {
|
|
14611
|
+
children.push(child);
|
|
14612
|
+
}
|
|
14613
|
+
}
|
|
14614
|
+
return children;
|
|
14615
|
+
}
|
|
14616
|
+
/**
|
|
14617
|
+
* Walks the synchronous portion of a reactive scope.
|
|
14618
|
+
*
|
|
14619
|
+
* - Stops descending into nested function boundaries, since they run in their
|
|
14620
|
+
* own call context and should not be treated as reads/writes of the current
|
|
14621
|
+
* reactive scope.
|
|
14622
|
+
* - Traverses the argument of `await`, because it is evaluated synchronously,
|
|
14623
|
+
* then stops visiting subsequent sibling nodes in the current execution path.
|
|
14624
|
+
*/
|
|
14625
|
+
function walkSynchronousAst(root, visitor) {
|
|
14626
|
+
traverse(root, true);
|
|
14627
|
+
function traverse(node, isRoot = false) {
|
|
14628
|
+
if (visitor(node) === false || (!isRoot && isFunctionLike(node))) {
|
|
14629
|
+
return false;
|
|
14630
|
+
}
|
|
14631
|
+
if (node.type === dist$4.AST_NODE_TYPES.AwaitExpression) {
|
|
14632
|
+
return traverse(node.argument, false) || true;
|
|
14633
|
+
}
|
|
14634
|
+
for (const child of getOrderedChildren(node)) {
|
|
14635
|
+
if (traverse(child, false)) {
|
|
14636
|
+
return true;
|
|
14637
|
+
}
|
|
14638
|
+
}
|
|
14639
|
+
return false;
|
|
14640
|
+
}
|
|
14641
|
+
}
|
|
14642
|
+
/**
|
|
14643
|
+
* Walks nodes that run after an async boundary inside a reactive callback.
|
|
14644
|
+
*
|
|
14645
|
+
* The traversal is intentionally conservative:
|
|
14646
|
+
* - it never descends into nested function boundaries
|
|
14647
|
+
* - it propagates async state through straight-line code
|
|
14648
|
+
* - it does not propagate branch-local `await` from optional control-flow
|
|
14649
|
+
* bodies into later siblings, which avoids noisy false positives
|
|
14650
|
+
*/
|
|
14651
|
+
function walkAfterAsyncBoundaryAst(root, visitor) {
|
|
14652
|
+
traverse(root, true, false);
|
|
14653
|
+
function traverse(node, isRoot = false, afterBoundary = false) {
|
|
14654
|
+
if (afterBoundary) {
|
|
14655
|
+
visitor(node);
|
|
14656
|
+
}
|
|
14657
|
+
if (!isRoot && isFunctionLike(node)) {
|
|
14658
|
+
return false;
|
|
14659
|
+
}
|
|
14660
|
+
if (node.type === dist$4.AST_NODE_TYPES.AwaitExpression) {
|
|
14661
|
+
traverse(node.argument, false, afterBoundary);
|
|
14662
|
+
return true;
|
|
14663
|
+
}
|
|
14664
|
+
if (node.type === dist$4.AST_NODE_TYPES.BlockStatement ||
|
|
14665
|
+
node.type === dist$4.AST_NODE_TYPES.Program) {
|
|
14666
|
+
let crossed = afterBoundary;
|
|
14667
|
+
for (const child of node.body) {
|
|
14668
|
+
const childCrossed = traverse(child, false, crossed);
|
|
14669
|
+
crossed = crossed || childCrossed;
|
|
14670
|
+
}
|
|
14671
|
+
return crossed && !afterBoundary;
|
|
14672
|
+
}
|
|
14673
|
+
if (node.type === dist$4.AST_NODE_TYPES.IfStatement) {
|
|
14674
|
+
const crossedInTest = traverse(node.test, false, afterBoundary);
|
|
14675
|
+
const branchAfterBoundary = afterBoundary || crossedInTest;
|
|
14676
|
+
traverse(node.consequent, false, branchAfterBoundary);
|
|
14677
|
+
if (node.alternate) {
|
|
14678
|
+
traverse(node.alternate, false, branchAfterBoundary);
|
|
14679
|
+
}
|
|
14680
|
+
return crossedInTest && !afterBoundary;
|
|
14681
|
+
}
|
|
14682
|
+
let crossed = afterBoundary;
|
|
14683
|
+
for (const child of getOrderedChildren(node)) {
|
|
14684
|
+
const childCrossed = traverse(child, false, crossed);
|
|
14685
|
+
crossed = crossed || childCrossed;
|
|
14686
|
+
}
|
|
14687
|
+
return crossed && !afterBoundary;
|
|
14688
|
+
}
|
|
14689
|
+
}
|
|
14690
|
+
/**
|
|
14691
|
+
* Shallow AST walker. Visits `root` and every descendant, skipping the
|
|
14692
|
+
* synthetic `parent` back-pointer to avoid cycles.
|
|
14693
|
+
*
|
|
14694
|
+
* If the visitor returns `false` for a node, that node's children are NOT
|
|
14695
|
+
* visited (prune / stop-descend). Any other return value (including `void`)
|
|
14696
|
+
* continues the walk.
|
|
14697
|
+
*/
|
|
14698
|
+
function walkAst(root, visitor) {
|
|
14699
|
+
if (visitor(root) === false) {
|
|
14700
|
+
return;
|
|
14701
|
+
}
|
|
14702
|
+
for (const key of Object.keys(root)) {
|
|
14703
|
+
if (key === 'parent') {
|
|
14704
|
+
continue;
|
|
14705
|
+
}
|
|
14706
|
+
const child = root[key];
|
|
14707
|
+
if (Array.isArray(child)) {
|
|
14708
|
+
for (const item of child) {
|
|
14709
|
+
if (item && typeof item === 'object' && 'type' in item) {
|
|
14710
|
+
walkAst(item, visitor);
|
|
14711
|
+
}
|
|
14712
|
+
}
|
|
14713
|
+
}
|
|
14714
|
+
else if (child && typeof child === 'object' && 'type' in child) {
|
|
14715
|
+
walkAst(child, visitor);
|
|
14716
|
+
}
|
|
14717
|
+
}
|
|
14718
|
+
}
|
|
14719
|
+
|
|
14720
|
+
function isAstNode(value) {
|
|
14721
|
+
if (!value || typeof value !== 'object' || !('type' in value)) {
|
|
14722
|
+
return false;
|
|
14723
|
+
}
|
|
14724
|
+
const { type } = value;
|
|
14725
|
+
return typeof type === 'string';
|
|
14726
|
+
}
|
|
14727
|
+
function getParentNode(node) {
|
|
14728
|
+
const maybeNode = node;
|
|
14729
|
+
if (!maybeNode || typeof maybeNode !== 'object' || !('parent' in maybeNode)) {
|
|
14730
|
+
return null;
|
|
14731
|
+
}
|
|
14732
|
+
const { parent } = maybeNode;
|
|
14733
|
+
return isAstNode(parent) ? parent : null;
|
|
14734
|
+
}
|
|
14735
|
+
function findAncestor(node, predicate) {
|
|
14736
|
+
for (let current = node?.parent; current; current = current.parent) {
|
|
14737
|
+
if (predicate(current)) {
|
|
14738
|
+
return current;
|
|
14739
|
+
}
|
|
14740
|
+
}
|
|
14741
|
+
return null;
|
|
14742
|
+
}
|
|
14743
|
+
function findSelfOrAncestor(node, predicate) {
|
|
14744
|
+
for (let current = node; current; current = current.parent) {
|
|
14745
|
+
if (predicate(current)) {
|
|
14746
|
+
return current;
|
|
14747
|
+
}
|
|
14748
|
+
}
|
|
14749
|
+
return null;
|
|
14750
|
+
}
|
|
14751
|
+
function hasAncestor(node, predicate) {
|
|
14752
|
+
for (let current = node?.parent; current; current = current.parent) {
|
|
14753
|
+
if (predicate(current)) {
|
|
14754
|
+
return true;
|
|
14755
|
+
}
|
|
14756
|
+
}
|
|
14757
|
+
return false;
|
|
14758
|
+
}
|
|
14759
|
+
function isNodeInside(node, ancestor) {
|
|
14760
|
+
for (let current = node; current; current = current.parent) {
|
|
14761
|
+
if (current === ancestor) {
|
|
14762
|
+
return true;
|
|
14763
|
+
}
|
|
14764
|
+
}
|
|
14765
|
+
return false;
|
|
14766
|
+
}
|
|
14767
|
+
function isNodeInsideAny(node, ancestors) {
|
|
14768
|
+
return ancestors.some((ancestor) => isNodeInside(node, ancestor));
|
|
14769
|
+
}
|
|
14770
|
+
function isClassLike(node) {
|
|
14771
|
+
return (node.type === dist$4.AST_NODE_TYPES.ClassDeclaration ||
|
|
14772
|
+
node.type === dist$4.AST_NODE_TYPES.ClassExpression);
|
|
14773
|
+
}
|
|
14774
|
+
function isClassMember(node) {
|
|
14775
|
+
return (node.type === dist$4.AST_NODE_TYPES.MethodDefinition ||
|
|
14776
|
+
node.type === dist$4.AST_NODE_TYPES.PropertyDefinition);
|
|
14777
|
+
}
|
|
14778
|
+
function getEnclosingFunction(node) {
|
|
14779
|
+
return findAncestor(node, isFunctionLike);
|
|
14780
|
+
}
|
|
14781
|
+
function getEnclosingClass(node) {
|
|
14782
|
+
return findSelfOrAncestor(node, isClassLike);
|
|
14783
|
+
}
|
|
14784
|
+
function getEnclosingClassMember(node) {
|
|
14785
|
+
return findAncestor(node, isClassMember);
|
|
14786
|
+
}
|
|
14787
|
+
function getScopeRoot(node) {
|
|
14788
|
+
return (findAncestor(node, (ancestor) => ancestor.type === dist$4.AST_NODE_TYPES.Program || isFunctionLike(ancestor)) ?? node);
|
|
14789
|
+
}
|
|
14790
|
+
|
|
14791
|
+
function getParenthesizedInner(node) {
|
|
14792
|
+
const maybeNode = node;
|
|
14793
|
+
return maybeNode.type === 'ParenthesizedExpression'
|
|
14794
|
+
? (maybeNode.expression ?? null)
|
|
14795
|
+
: null;
|
|
14796
|
+
}
|
|
14797
|
+
function unwrapParenthesized(node) {
|
|
14798
|
+
let current = node;
|
|
14799
|
+
let inner = getParenthesizedInner(current);
|
|
14800
|
+
while (inner) {
|
|
14801
|
+
current = inner;
|
|
14802
|
+
inner = getParenthesizedInner(current);
|
|
14803
|
+
}
|
|
14804
|
+
return current;
|
|
14805
|
+
}
|
|
14806
|
+
|
|
14807
|
+
/**
|
|
14808
|
+
* Strips expression wrapper nodes that do not affect the underlying expression:
|
|
14809
|
+
* parentheses, `as` casts, `satisfies`, non-null assertions (`!`), type
|
|
14810
|
+
* assertions (`<T>expr`), and optional-chain wrappers. Iterates until no more
|
|
14811
|
+
* wrappers are found.
|
|
14812
|
+
*/
|
|
14813
|
+
function unwrapExpression(expression) {
|
|
14814
|
+
let current = expression;
|
|
14815
|
+
let didUnwrap = true;
|
|
14816
|
+
while (didUnwrap) {
|
|
14817
|
+
didUnwrap = false;
|
|
14818
|
+
const parenthesized = getParenthesizedExpression(current);
|
|
14819
|
+
if (parenthesized) {
|
|
14820
|
+
current = parenthesized;
|
|
14821
|
+
didUnwrap = true;
|
|
14822
|
+
continue;
|
|
14823
|
+
}
|
|
14824
|
+
switch (current.type) {
|
|
14825
|
+
case dist$4.AST_NODE_TYPES.ChainExpression:
|
|
14826
|
+
current = current.expression;
|
|
14827
|
+
didUnwrap = true;
|
|
14828
|
+
break;
|
|
14829
|
+
case dist$4.AST_NODE_TYPES.TSAsExpression:
|
|
14830
|
+
current = current.expression;
|
|
14831
|
+
didUnwrap = true;
|
|
14832
|
+
break;
|
|
14833
|
+
case dist$4.AST_NODE_TYPES.TSNonNullExpression:
|
|
14834
|
+
current = current.expression;
|
|
14835
|
+
didUnwrap = true;
|
|
14836
|
+
break;
|
|
14837
|
+
case dist$4.AST_NODE_TYPES.TSSatisfiesExpression:
|
|
14838
|
+
current = current.expression;
|
|
14839
|
+
didUnwrap = true;
|
|
14840
|
+
break;
|
|
14841
|
+
case dist$4.AST_NODE_TYPES.TSTypeAssertion:
|
|
14842
|
+
current = current.expression;
|
|
14843
|
+
didUnwrap = true;
|
|
14844
|
+
break;
|
|
14845
|
+
}
|
|
14846
|
+
}
|
|
14847
|
+
return current;
|
|
14848
|
+
}
|
|
14849
|
+
function hasNonNullAssertionParent(node) {
|
|
14850
|
+
let current = node;
|
|
14851
|
+
let parent = getParentNode(current);
|
|
14852
|
+
while (parent) {
|
|
14853
|
+
if (parent.type === dist$4.AST_NODE_TYPES.TSNonNullExpression &&
|
|
14854
|
+
parent.expression === current) {
|
|
14855
|
+
return true;
|
|
14856
|
+
}
|
|
14857
|
+
if (getParenthesizedInner(parent) !== current) {
|
|
14858
|
+
return false;
|
|
14859
|
+
}
|
|
14860
|
+
current = parent;
|
|
14861
|
+
parent = getParentNode(current);
|
|
14862
|
+
}
|
|
14863
|
+
return false;
|
|
14864
|
+
}
|
|
14865
|
+
function isExpressionLike(value) {
|
|
14866
|
+
return (typeof value === 'object' &&
|
|
14867
|
+
value !== null &&
|
|
14868
|
+
'type' in value &&
|
|
14869
|
+
typeof value.type === 'string');
|
|
14870
|
+
}
|
|
14871
|
+
function getParenthesizedExpression(expression) {
|
|
14872
|
+
const maybeExpression = expression;
|
|
14873
|
+
return maybeExpression.type === 'ParenthesizedExpression' &&
|
|
14874
|
+
isExpressionLike(maybeExpression.expression)
|
|
14875
|
+
? maybeExpression.expression
|
|
14876
|
+
: null;
|
|
14877
|
+
}
|
|
14878
|
+
|
|
14879
|
+
const EQUALITY_OPERATORS = new Set(['!=', '!==', '==', '===']);
|
|
14880
|
+
function getChainExpressionRoot(node) {
|
|
14881
|
+
const parent = getParentNode(node);
|
|
14882
|
+
return parent?.type === dist$4.AST_NODE_TYPES.ChainExpression ? parent : node;
|
|
14883
|
+
}
|
|
14884
|
+
function isLogicalFallbackLeftOperand(node) {
|
|
14885
|
+
const expression = getChainExpressionRoot(node);
|
|
14886
|
+
const parent = getParentNode(expression);
|
|
14887
|
+
return (parent?.type === dist$4.AST_NODE_TYPES.LogicalExpression &&
|
|
14888
|
+
(parent.operator === '??' || parent.operator === '||') &&
|
|
14889
|
+
parent.left === expression);
|
|
14890
|
+
}
|
|
14891
|
+
function getContainingIfStatementForTestExpression(node) {
|
|
14892
|
+
let current = getChainExpressionRoot(node);
|
|
14893
|
+
let parent = getParentNode(current);
|
|
14894
|
+
while (parent?.type === dist$4.AST_NODE_TYPES.LogicalExpression) {
|
|
14895
|
+
current = parent;
|
|
14896
|
+
parent = getParentNode(parent);
|
|
14897
|
+
}
|
|
14898
|
+
if (parent?.type === dist$4.AST_NODE_TYPES.UnaryExpression && parent.operator === '!') {
|
|
14899
|
+
current = parent;
|
|
14900
|
+
parent = getParentNode(parent);
|
|
14901
|
+
}
|
|
14902
|
+
return parent?.type === dist$4.AST_NODE_TYPES.IfStatement && parent.test === current
|
|
14903
|
+
? parent
|
|
14904
|
+
: null;
|
|
14905
|
+
}
|
|
14906
|
+
function isConditionTestExpression(node) {
|
|
14907
|
+
let current = getChainExpressionRoot(node);
|
|
14908
|
+
let parent = getParentNode(current);
|
|
14909
|
+
if (!parent) {
|
|
14910
|
+
return false;
|
|
14911
|
+
}
|
|
14912
|
+
while (parent?.type === dist$4.AST_NODE_TYPES.LogicalExpression) {
|
|
14913
|
+
current = parent;
|
|
14914
|
+
parent = getParentNode(parent);
|
|
14915
|
+
}
|
|
14916
|
+
if (!parent) {
|
|
14917
|
+
return false;
|
|
14918
|
+
}
|
|
14919
|
+
if (parent.type === dist$4.AST_NODE_TYPES.UnaryExpression && parent.operator === '!') {
|
|
14920
|
+
current = parent;
|
|
14921
|
+
parent = getParentNode(parent);
|
|
14922
|
+
}
|
|
14923
|
+
return parent
|
|
14924
|
+
? (parent.type === dist$4.AST_NODE_TYPES.IfStatement && parent.test === current) ||
|
|
14925
|
+
(parent.type === dist$4.AST_NODE_TYPES.ConditionalExpression &&
|
|
14926
|
+
parent.test === current) ||
|
|
14927
|
+
(parent.type === dist$4.AST_NODE_TYPES.WhileStatement &&
|
|
14928
|
+
parent.test === current) ||
|
|
14929
|
+
(parent.type === dist$4.AST_NODE_TYPES.DoWhileStatement &&
|
|
14930
|
+
parent.test === current) ||
|
|
14931
|
+
(parent.type === dist$4.AST_NODE_TYPES.ForStatement && parent.test === current)
|
|
14932
|
+
: false;
|
|
14933
|
+
}
|
|
14934
|
+
function isEqualityComparisonOperand(node) {
|
|
14935
|
+
const expression = getChainExpressionRoot(node);
|
|
14936
|
+
const parent = getParentNode(expression);
|
|
14937
|
+
return (parent?.type === dist$4.AST_NODE_TYPES.BinaryExpression &&
|
|
14938
|
+
EQUALITY_OPERATORS.has(parent.operator));
|
|
14939
|
+
}
|
|
14940
|
+
|
|
14941
|
+
function getSafeBracketIndexText(sourceCode, node) {
|
|
14942
|
+
if (!node.computed || node.property.type !== dist$4.AST_NODE_TYPES.Literal) {
|
|
14943
|
+
return null;
|
|
14944
|
+
}
|
|
14945
|
+
const { value } = node.property;
|
|
14946
|
+
if (typeof value !== 'number') {
|
|
14947
|
+
return null;
|
|
14948
|
+
}
|
|
14949
|
+
const hasSameAtIndexSemantics = Number.isInteger(value) && value >= 0;
|
|
14950
|
+
return hasSameAtIndexSemantics ? sourceCode.getText(node.property) : null;
|
|
14951
|
+
}
|
|
14952
|
+
function getMemberAccessStart(sourceCode, node) {
|
|
14953
|
+
const tokenBeforeProperty = sourceCode.getTokenBefore(node.property);
|
|
14954
|
+
if (!tokenBeforeProperty) {
|
|
14955
|
+
return null;
|
|
14956
|
+
}
|
|
14957
|
+
if (!node.computed) {
|
|
14958
|
+
return tokenBeforeProperty.range[0];
|
|
14959
|
+
}
|
|
14960
|
+
if (tokenBeforeProperty.value !== '[') {
|
|
14961
|
+
return null;
|
|
14962
|
+
}
|
|
14963
|
+
const tokenBeforeBracket = sourceCode.getTokenBefore(tokenBeforeProperty);
|
|
14964
|
+
const hasOptionalBracketAccess = node.optional && tokenBeforeBracket?.value === '?.';
|
|
14965
|
+
return hasOptionalBracketAccess
|
|
14966
|
+
? tokenBeforeBracket.range[0]
|
|
14967
|
+
: tokenBeforeProperty.range[0];
|
|
14968
|
+
}
|
|
14969
|
+
function isSameIndexedAccess(sourceCode, left, right) {
|
|
14970
|
+
const leftIndexText = getSafeBracketIndexText(sourceCode, left);
|
|
14971
|
+
const rightIndexText = getSafeBracketIndexText(sourceCode, right);
|
|
14972
|
+
return (leftIndexText !== null &&
|
|
14973
|
+
leftIndexText === rightIndexText &&
|
|
14974
|
+
sourceCode.getText(left.object) === sourceCode.getText(right.object));
|
|
14975
|
+
}
|
|
14976
|
+
|
|
14977
|
+
function unwrapMutationTarget(node) {
|
|
14978
|
+
let current = node;
|
|
14979
|
+
while (current.type === dist$4.AST_NODE_TYPES.TSAsExpression ||
|
|
14980
|
+
current.type === dist$4.AST_NODE_TYPES.TSNonNullExpression ||
|
|
14981
|
+
current.type === dist$4.AST_NODE_TYPES.TSTypeAssertion) {
|
|
14982
|
+
current = current.expression;
|
|
14983
|
+
}
|
|
14984
|
+
return current;
|
|
14985
|
+
}
|
|
14986
|
+
function collectMutationTargets(node) {
|
|
14987
|
+
const current = unwrapMutationTarget(node);
|
|
14988
|
+
switch (current.type) {
|
|
14989
|
+
case dist$4.AST_NODE_TYPES.ArrayPattern:
|
|
14990
|
+
return current.elements.flatMap((element) => element ? collectMutationTargets(element) : []);
|
|
14991
|
+
case dist$4.AST_NODE_TYPES.AssignmentPattern:
|
|
14992
|
+
return collectMutationTargets(current.left);
|
|
14993
|
+
case dist$4.AST_NODE_TYPES.Identifier:
|
|
14994
|
+
return [current];
|
|
14995
|
+
case dist$4.AST_NODE_TYPES.MemberExpression:
|
|
14996
|
+
return [current];
|
|
14997
|
+
case dist$4.AST_NODE_TYPES.ObjectPattern:
|
|
14998
|
+
return current.properties.flatMap((property) => property.type === dist$4.AST_NODE_TYPES.RestElement
|
|
14999
|
+
? collectMutationTargets(property.argument)
|
|
15000
|
+
: collectMutationTargets(property.value));
|
|
15001
|
+
case dist$4.AST_NODE_TYPES.RestElement:
|
|
15002
|
+
return collectMutationTargets(current.argument);
|
|
15003
|
+
default:
|
|
15004
|
+
return [];
|
|
15005
|
+
}
|
|
15006
|
+
}
|
|
15007
|
+
function getMutationExpressionTarget(node) {
|
|
15008
|
+
if (node.type === dist$4.AST_NODE_TYPES.AssignmentExpression ||
|
|
15009
|
+
node.type === dist$4.AST_NODE_TYPES.UpdateExpression) {
|
|
15010
|
+
return node.type === dist$4.AST_NODE_TYPES.AssignmentExpression
|
|
15011
|
+
? node.left
|
|
15012
|
+
: node.argument;
|
|
15013
|
+
}
|
|
15014
|
+
return node.type === dist$4.AST_NODE_TYPES.UnaryExpression && node.operator === 'delete'
|
|
15015
|
+
? node.argument
|
|
15016
|
+
: null;
|
|
15017
|
+
}
|
|
15018
|
+
function isMutationTarget(node) {
|
|
15019
|
+
const { parent } = node;
|
|
15020
|
+
if (!parent) {
|
|
15021
|
+
return false;
|
|
15022
|
+
}
|
|
15023
|
+
const isForLoopTarget = parent.type === dist$4.AST_NODE_TYPES.ForInStatement ||
|
|
15024
|
+
parent.type === dist$4.AST_NODE_TYPES.ForOfStatement;
|
|
15025
|
+
return isForLoopTarget
|
|
15026
|
+
? parent.left === node
|
|
15027
|
+
: getMutationExpressionTarget(parent) === node;
|
|
15028
|
+
}
|
|
15029
|
+
|
|
15030
|
+
function hasSameIndexedAssignmentTarget(sourceCode, root, target) {
|
|
15031
|
+
let found = false;
|
|
15032
|
+
walkAst(root, (node) => {
|
|
15033
|
+
const shouldStopWalking = found || (node !== root && isFunctionExpressionLike(node));
|
|
15034
|
+
if (shouldStopWalking) {
|
|
15035
|
+
return false;
|
|
15036
|
+
}
|
|
15037
|
+
const isGuardedAssignmentTarget = node.type === dist$4.AST_NODE_TYPES.MemberExpression &&
|
|
15038
|
+
isMutationTarget(node) &&
|
|
15039
|
+
isSameIndexedAccess(sourceCode, node, target);
|
|
15040
|
+
if (!isGuardedAssignmentTarget) {
|
|
15041
|
+
return;
|
|
15042
|
+
}
|
|
15043
|
+
found = true;
|
|
15044
|
+
return false;
|
|
15045
|
+
});
|
|
15046
|
+
return found;
|
|
15047
|
+
}
|
|
15048
|
+
function isIndexedAccessGuardingSameIndexAssignment(sourceCode, node) {
|
|
15049
|
+
const ifStatement = getContainingIfStatementForTestExpression(node);
|
|
15050
|
+
return ifStatement
|
|
15051
|
+
? hasSameIndexedAssignmentTarget(sourceCode, ifStatement.consequent, node)
|
|
15052
|
+
: false;
|
|
15053
|
+
}
|
|
15054
|
+
|
|
15055
|
+
function isStringLiteral$1(node) {
|
|
15056
|
+
return node?.type === dist$4.AST_NODE_TYPES.Literal && typeof node.value === 'string';
|
|
15057
|
+
}
|
|
15058
|
+
function isStaticTemplateLiteral(node) {
|
|
15059
|
+
return (node?.type === dist$4.AST_NODE_TYPES.TemplateLiteral &&
|
|
15060
|
+
node.expressions.length === 0 &&
|
|
15061
|
+
node.quasis.length === 1);
|
|
15062
|
+
}
|
|
15063
|
+
function getStaticStringValue(node) {
|
|
15064
|
+
if (isStringLiteral$1(node)) {
|
|
15065
|
+
return node.value;
|
|
15066
|
+
}
|
|
15067
|
+
return isStaticTemplateLiteral(node)
|
|
15068
|
+
? (node.quasis[0]?.value.cooked ?? node.quasis[0]?.value.raw ?? '')
|
|
15069
|
+
: null;
|
|
15070
|
+
}
|
|
15071
|
+
function isEmptyStaticString(node) {
|
|
15072
|
+
return getStaticStringValue(node) === '';
|
|
15073
|
+
}
|
|
15074
|
+
|
|
15075
|
+
function getStaticPropertyName(key) {
|
|
15076
|
+
if (key.type === dist$4.AST_NODE_TYPES.Identifier) {
|
|
15077
|
+
return key.name;
|
|
15078
|
+
}
|
|
15079
|
+
return key.type === dist$4.AST_NODE_TYPES.Literal &&
|
|
15080
|
+
(typeof key.value === 'string' || typeof key.value === 'number')
|
|
15081
|
+
? String(key.value)
|
|
15082
|
+
: getStaticStringValue(key);
|
|
15083
|
+
}
|
|
15084
|
+
function getObjectPropertyName(node) {
|
|
15085
|
+
return node.computed ? null : getStaticPropertyName(node.key);
|
|
15086
|
+
}
|
|
15087
|
+
function getMemberExpressionPropertyName(node) {
|
|
15088
|
+
if (!node.computed && node.property.type === dist$4.AST_NODE_TYPES.Identifier) {
|
|
15089
|
+
return node.property.name;
|
|
15090
|
+
}
|
|
15091
|
+
return node.computed ? getStaticStringValue(node.property) : null;
|
|
15092
|
+
}
|
|
15093
|
+
function getClassMemberName(member) {
|
|
15094
|
+
return member.key.type === dist$4.AST_NODE_TYPES.PrivateIdentifier
|
|
15095
|
+
? null
|
|
15096
|
+
: getStaticPropertyName(member.key);
|
|
15097
|
+
}
|
|
15098
|
+
|
|
15099
|
+
function isSingleLineNode(node) {
|
|
15100
|
+
return node.loc.start.line === node.loc.end.line;
|
|
15101
|
+
}
|
|
15102
|
+
function hasCommentLikeText(text) {
|
|
15103
|
+
return text.includes('//') || text.includes('/*');
|
|
15104
|
+
}
|
|
15105
|
+
function hasBlankLine(text) {
|
|
15106
|
+
let lineBreaks = 0;
|
|
15107
|
+
for (let index = 0; index < text.length; index++) {
|
|
15108
|
+
const char = text[index];
|
|
15109
|
+
if (char === '\n') {
|
|
15110
|
+
lineBreaks++;
|
|
15111
|
+
}
|
|
15112
|
+
else if (char === '\r') {
|
|
15113
|
+
lineBreaks++;
|
|
15114
|
+
if (text[index + 1] === '\n') {
|
|
15115
|
+
index++;
|
|
15116
|
+
}
|
|
15117
|
+
}
|
|
15118
|
+
if (lineBreaks > 1) {
|
|
15119
|
+
return true;
|
|
15120
|
+
}
|
|
15121
|
+
}
|
|
15122
|
+
return false;
|
|
15123
|
+
}
|
|
15124
|
+
function getLineBreak(text) {
|
|
15125
|
+
if (text.includes('\r\n')) {
|
|
15126
|
+
return '\r\n';
|
|
15127
|
+
}
|
|
15128
|
+
return text.includes('\r') ? '\r' : '\n';
|
|
15129
|
+
}
|
|
15130
|
+
function getLeadingIndentation(text) {
|
|
15131
|
+
let index = 0;
|
|
15132
|
+
while (index < text.length && (text[index] === ' ' || text[index] === '\t')) {
|
|
15133
|
+
index++;
|
|
15134
|
+
}
|
|
15135
|
+
return text.slice(0, index);
|
|
15136
|
+
}
|
|
15137
|
+
function getLineStartOffset(text, offset) {
|
|
15138
|
+
return text.lastIndexOf('\n', offset - 1) + 1;
|
|
15139
|
+
}
|
|
15140
|
+
function getIndentAtOffset(text, offset) {
|
|
15141
|
+
const lineStart = getLineStartOffset(text, offset);
|
|
15142
|
+
const indent = text.slice(lineStart, offset);
|
|
15143
|
+
return indent.trim() === '' ? indent : '';
|
|
15144
|
+
}
|
|
15145
|
+
function getSpacingReplacement(sourceCode, betweenText, nextLine, blankLineCount) {
|
|
15146
|
+
const indentation = getLeadingIndentation(sourceCode.lines[nextLine - 1] ?? '');
|
|
15147
|
+
return `${getLineBreak(betweenText).repeat(blankLineCount + 1)}${indentation}`;
|
|
15148
|
+
}
|
|
15149
|
+
|
|
15150
|
+
const RULE_DOCS_BASE_URL = 'https://github.com/taiga-family/toolkit/tree/main/projects/eslint-plugin-experience-next/docs';
|
|
15151
|
+
const ruleCreator = dist$4.ESLintUtils.RuleCreator((name) => `${RULE_DOCS_BASE_URL}/${name}.md`);
|
|
15152
|
+
function createRule(options) {
|
|
15153
|
+
if ('rule' in options) {
|
|
15154
|
+
const { name, rule } = options;
|
|
15155
|
+
const meta = rule.meta ?? {};
|
|
15156
|
+
const docs = meta.docs ?? {};
|
|
15157
|
+
return ruleCreator({
|
|
15158
|
+
create: (context) => rule.create(context),
|
|
15159
|
+
meta: {
|
|
15160
|
+
...meta,
|
|
15161
|
+
docs: {
|
|
15162
|
+
...docs,
|
|
15163
|
+
description: typeof docs.description === 'string' ? docs.description : name,
|
|
15164
|
+
},
|
|
15165
|
+
},
|
|
15166
|
+
name,
|
|
15167
|
+
});
|
|
15168
|
+
}
|
|
15169
|
+
return ruleCreator(options);
|
|
15170
|
+
}
|
|
15171
|
+
|
|
15172
|
+
function getResolvedVariable(sourceCode, node) {
|
|
15173
|
+
const scope = sourceCode.getScope(node);
|
|
15174
|
+
const reference = scope.references.find((item) => item.identifier === node);
|
|
15175
|
+
return reference?.resolved ?? null;
|
|
15176
|
+
}
|
|
15177
|
+
function hasVariableInScope(sourceCode, node, name) {
|
|
15178
|
+
let scope = sourceCode.getScope(node);
|
|
15179
|
+
while (scope) {
|
|
15180
|
+
if (scope.variables.some((variable) => variable.name === name)) {
|
|
15181
|
+
return true;
|
|
15182
|
+
}
|
|
15183
|
+
scope = scope.upper;
|
|
15184
|
+
}
|
|
15185
|
+
return false;
|
|
15186
|
+
}
|
|
15187
|
+
|
|
14546
15188
|
function commonjsRequire(path) {
|
|
14547
15189
|
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
14548
15190
|
}
|
|
@@ -215187,331 +215829,34 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
|
|
|
215187
215829
|
var typescriptExports = typescript.exports;
|
|
215188
215830
|
var ts = /*@__PURE__*/getDefaultExportFromCjs(typescriptExports);
|
|
215189
215831
|
|
|
215190
|
-
|
|
215191
|
-
|
|
215192
|
-
|
|
215193
|
-
node.type === dist$4.AST_NODE_TYPES.FunctionExpression);
|
|
215194
|
-
}
|
|
215195
|
-
function getOrderedChildren(node) {
|
|
215196
|
-
if (isFunctionLike(node)) {
|
|
215197
|
-
const children = [
|
|
215198
|
-
...node.params,
|
|
215199
|
-
node.body,
|
|
215200
|
-
];
|
|
215201
|
-
return children.filter((child) => child != null);
|
|
215202
|
-
}
|
|
215203
|
-
if (node.type === dist$4.AST_NODE_TYPES.BlockStatement ||
|
|
215204
|
-
node.type === dist$4.AST_NODE_TYPES.Program) {
|
|
215205
|
-
return node.body;
|
|
215206
|
-
}
|
|
215207
|
-
if (node.type === dist$4.AST_NODE_TYPES.IfStatement) {
|
|
215208
|
-
return node.alternate
|
|
215209
|
-
? [node.test, node.consequent, node.alternate]
|
|
215210
|
-
: [node.test, node.consequent];
|
|
215211
|
-
}
|
|
215212
|
-
if (node.type === dist$4.AST_NODE_TYPES.ConditionalExpression) {
|
|
215213
|
-
return [node.test, node.consequent, node.alternate];
|
|
215214
|
-
}
|
|
215215
|
-
if (node.type === dist$4.AST_NODE_TYPES.WhileStatement) {
|
|
215216
|
-
return [node.test, node.body];
|
|
215217
|
-
}
|
|
215218
|
-
if (node.type === dist$4.AST_NODE_TYPES.DoWhileStatement) {
|
|
215219
|
-
return [node.body, node.test];
|
|
215220
|
-
}
|
|
215221
|
-
if (node.type === dist$4.AST_NODE_TYPES.ForStatement) {
|
|
215222
|
-
const children = [
|
|
215223
|
-
node.init && 'type' in node.init ? node.init : null,
|
|
215224
|
-
node.test,
|
|
215225
|
-
node.update,
|
|
215226
|
-
node.body,
|
|
215227
|
-
];
|
|
215228
|
-
return children.filter((child) => child != null);
|
|
215229
|
-
}
|
|
215230
|
-
if (node.type === dist$4.AST_NODE_TYPES.ForInStatement ||
|
|
215231
|
-
node.type === dist$4.AST_NODE_TYPES.ForOfStatement) {
|
|
215232
|
-
return [node.left, node.right, node.body];
|
|
215233
|
-
}
|
|
215234
|
-
const children = [];
|
|
215235
|
-
for (const key of Object.keys(node)) {
|
|
215236
|
-
if (key === 'parent') {
|
|
215237
|
-
continue;
|
|
215238
|
-
}
|
|
215239
|
-
const child = node[key];
|
|
215240
|
-
if (Array.isArray(child)) {
|
|
215241
|
-
for (const item of child) {
|
|
215242
|
-
if (item && typeof item === 'object' && 'type' in item) {
|
|
215243
|
-
children.push(item);
|
|
215244
|
-
}
|
|
215245
|
-
}
|
|
215246
|
-
}
|
|
215247
|
-
else if (child && typeof child === 'object' && 'type' in child) {
|
|
215248
|
-
children.push(child);
|
|
215249
|
-
}
|
|
215250
|
-
}
|
|
215251
|
-
return children;
|
|
215252
|
-
}
|
|
215253
|
-
/**
|
|
215254
|
-
* Walks the synchronous portion of a reactive scope.
|
|
215255
|
-
*
|
|
215256
|
-
* - Stops descending into nested function boundaries, since they run in their
|
|
215257
|
-
* own call context and should not be treated as reads/writes of the current
|
|
215258
|
-
* reactive scope.
|
|
215259
|
-
* - Traverses the argument of `await`, because it is evaluated synchronously,
|
|
215260
|
-
* then stops visiting subsequent sibling nodes in the current execution path.
|
|
215261
|
-
*/
|
|
215262
|
-
function walkSynchronousAst(root, visitor) {
|
|
215263
|
-
traverse(root, true);
|
|
215264
|
-
function traverse(node, isRoot = false) {
|
|
215265
|
-
if (visitor(node) === false || (!isRoot && isFunctionLike(node))) {
|
|
215266
|
-
return false;
|
|
215267
|
-
}
|
|
215268
|
-
if (node.type === dist$4.AST_NODE_TYPES.AwaitExpression) {
|
|
215269
|
-
return traverse(node.argument, false) || true;
|
|
215270
|
-
}
|
|
215271
|
-
for (const child of getOrderedChildren(node)) {
|
|
215272
|
-
if (traverse(child, false)) {
|
|
215273
|
-
return true;
|
|
215274
|
-
}
|
|
215275
|
-
}
|
|
215276
|
-
return false;
|
|
215277
|
-
}
|
|
215278
|
-
}
|
|
215279
|
-
/**
|
|
215280
|
-
* Walks nodes that run after an async boundary inside a reactive callback.
|
|
215281
|
-
*
|
|
215282
|
-
* The traversal is intentionally conservative:
|
|
215283
|
-
* - it never descends into nested function boundaries
|
|
215284
|
-
* - it propagates async state through straight-line code
|
|
215285
|
-
* - it does not propagate branch-local `await` from optional control-flow
|
|
215286
|
-
* bodies into later siblings, which avoids noisy false positives
|
|
215287
|
-
*/
|
|
215288
|
-
function walkAfterAsyncBoundaryAst(root, visitor) {
|
|
215289
|
-
traverse(root, true, false);
|
|
215290
|
-
function traverse(node, isRoot = false, afterBoundary = false) {
|
|
215291
|
-
if (afterBoundary) {
|
|
215292
|
-
visitor(node);
|
|
215293
|
-
}
|
|
215294
|
-
if (!isRoot && isFunctionLike(node)) {
|
|
215295
|
-
return false;
|
|
215296
|
-
}
|
|
215297
|
-
if (node.type === dist$4.AST_NODE_TYPES.AwaitExpression) {
|
|
215298
|
-
traverse(node.argument, false, afterBoundary);
|
|
215299
|
-
return true;
|
|
215300
|
-
}
|
|
215301
|
-
if (node.type === dist$4.AST_NODE_TYPES.BlockStatement ||
|
|
215302
|
-
node.type === dist$4.AST_NODE_TYPES.Program) {
|
|
215303
|
-
let crossed = afterBoundary;
|
|
215304
|
-
for (const child of node.body) {
|
|
215305
|
-
const childCrossed = traverse(child, false, crossed);
|
|
215306
|
-
crossed = crossed || childCrossed;
|
|
215307
|
-
}
|
|
215308
|
-
return crossed && !afterBoundary;
|
|
215309
|
-
}
|
|
215310
|
-
if (node.type === dist$4.AST_NODE_TYPES.IfStatement) {
|
|
215311
|
-
const crossedInTest = traverse(node.test, false, afterBoundary);
|
|
215312
|
-
const branchAfterBoundary = afterBoundary || crossedInTest;
|
|
215313
|
-
traverse(node.consequent, false, branchAfterBoundary);
|
|
215314
|
-
if (node.alternate) {
|
|
215315
|
-
traverse(node.alternate, false, branchAfterBoundary);
|
|
215316
|
-
}
|
|
215317
|
-
return crossedInTest && !afterBoundary;
|
|
215318
|
-
}
|
|
215319
|
-
let crossed = afterBoundary;
|
|
215320
|
-
for (const child of getOrderedChildren(node)) {
|
|
215321
|
-
const childCrossed = traverse(child, false, crossed);
|
|
215322
|
-
crossed = crossed || childCrossed;
|
|
215323
|
-
}
|
|
215324
|
-
return crossed && !afterBoundary;
|
|
215325
|
-
}
|
|
215326
|
-
}
|
|
215327
|
-
/**
|
|
215328
|
-
* Shallow AST walker. Visits `root` and every descendant, skipping the
|
|
215329
|
-
* synthetic `parent` back-pointer to avoid cycles.
|
|
215330
|
-
*
|
|
215331
|
-
* If the visitor returns `false` for a node, that node's children are NOT
|
|
215332
|
-
* visited (prune / stop-descend). Any other return value (including `void`)
|
|
215333
|
-
* continues the walk.
|
|
215334
|
-
*/
|
|
215335
|
-
function walkAst(root, visitor) {
|
|
215336
|
-
if (visitor(root) === false) {
|
|
215337
|
-
return;
|
|
215338
|
-
}
|
|
215339
|
-
for (const key of Object.keys(root)) {
|
|
215340
|
-
if (key === 'parent') {
|
|
215341
|
-
continue;
|
|
215342
|
-
}
|
|
215343
|
-
const child = root[key];
|
|
215344
|
-
if (Array.isArray(child)) {
|
|
215345
|
-
for (const item of child) {
|
|
215346
|
-
if (item && typeof item === 'object' && 'type' in item) {
|
|
215347
|
-
walkAst(item, visitor);
|
|
215348
|
-
}
|
|
215349
|
-
}
|
|
215350
|
-
}
|
|
215351
|
-
else if (child && typeof child === 'object' && 'type' in child) {
|
|
215352
|
-
walkAst(child, visitor);
|
|
215353
|
-
}
|
|
215354
|
-
}
|
|
215355
|
-
}
|
|
215356
|
-
|
|
215357
|
-
function getParenthesizedInner(node) {
|
|
215358
|
-
const maybeNode = node;
|
|
215359
|
-
return maybeNode.type === 'ParenthesizedExpression'
|
|
215360
|
-
? (maybeNode.expression ?? null)
|
|
215361
|
-
: null;
|
|
215362
|
-
}
|
|
215363
|
-
function unwrapParenthesized(node) {
|
|
215364
|
-
let current = node;
|
|
215365
|
-
let inner = getParenthesizedInner(current);
|
|
215366
|
-
while (inner) {
|
|
215367
|
-
current = inner;
|
|
215368
|
-
inner = getParenthesizedInner(current);
|
|
215369
|
-
}
|
|
215370
|
-
return current;
|
|
215371
|
-
}
|
|
215372
|
-
|
|
215373
|
-
function isStringLiteral$1(node) {
|
|
215374
|
-
return node?.type === dist$4.AST_NODE_TYPES.Literal && typeof node.value === 'string';
|
|
215375
|
-
}
|
|
215376
|
-
function isStaticTemplateLiteral(node) {
|
|
215377
|
-
return (node?.type === dist$4.AST_NODE_TYPES.TemplateLiteral &&
|
|
215378
|
-
node.expressions.length === 0 &&
|
|
215379
|
-
node.quasis.length === 1);
|
|
215380
|
-
}
|
|
215381
|
-
function getStaticStringValue(node) {
|
|
215382
|
-
if (isStringLiteral$1(node)) {
|
|
215383
|
-
return node.value;
|
|
215384
|
-
}
|
|
215385
|
-
return isStaticTemplateLiteral(node)
|
|
215386
|
-
? (node.quasis[0]?.value.cooked ?? node.quasis[0]?.value.raw ?? '')
|
|
215387
|
-
: null;
|
|
215388
|
-
}
|
|
215389
|
-
function isEmptyStaticString(node) {
|
|
215390
|
-
return getStaticStringValue(node) === '';
|
|
215391
|
-
}
|
|
215392
|
-
|
|
215393
|
-
function getStaticPropertyName(key) {
|
|
215394
|
-
if (key.type === dist$4.AST_NODE_TYPES.Identifier) {
|
|
215395
|
-
return key.name;
|
|
215396
|
-
}
|
|
215397
|
-
return key.type === dist$4.AST_NODE_TYPES.Literal &&
|
|
215398
|
-
(typeof key.value === 'string' || typeof key.value === 'number')
|
|
215399
|
-
? String(key.value)
|
|
215400
|
-
: getStaticStringValue(key);
|
|
215401
|
-
}
|
|
215402
|
-
function getObjectPropertyName(node) {
|
|
215403
|
-
return node.computed ? null : getStaticPropertyName(node.key);
|
|
215404
|
-
}
|
|
215405
|
-
function getMemberExpressionPropertyName(node) {
|
|
215406
|
-
if (!node.computed && node.property.type === dist$4.AST_NODE_TYPES.Identifier) {
|
|
215407
|
-
return node.property.name;
|
|
215408
|
-
}
|
|
215409
|
-
return node.computed ? getStaticStringValue(node.property) : null;
|
|
215410
|
-
}
|
|
215411
|
-
function getClassMemberName(member) {
|
|
215412
|
-
return member.key.type === dist$4.AST_NODE_TYPES.PrivateIdentifier
|
|
215413
|
-
? null
|
|
215414
|
-
: getStaticPropertyName(member.key);
|
|
215415
|
-
}
|
|
215416
|
-
|
|
215417
|
-
function isSingleLineNode(node) {
|
|
215418
|
-
return node.loc.start.line === node.loc.end.line;
|
|
215419
|
-
}
|
|
215420
|
-
function hasCommentLikeText(text) {
|
|
215421
|
-
return text.includes('//') || text.includes('/*');
|
|
215422
|
-
}
|
|
215423
|
-
function hasBlankLine(text) {
|
|
215424
|
-
let lineBreaks = 0;
|
|
215425
|
-
for (let index = 0; index < text.length; index++) {
|
|
215426
|
-
const char = text[index];
|
|
215427
|
-
if (char === '\n') {
|
|
215428
|
-
lineBreaks++;
|
|
215429
|
-
}
|
|
215430
|
-
else if (char === '\r') {
|
|
215431
|
-
lineBreaks++;
|
|
215432
|
-
if (text[index + 1] === '\n') {
|
|
215433
|
-
index++;
|
|
215434
|
-
}
|
|
215435
|
-
}
|
|
215436
|
-
if (lineBreaks > 1) {
|
|
215437
|
-
return true;
|
|
215438
|
-
}
|
|
215439
|
-
}
|
|
215440
|
-
return false;
|
|
215441
|
-
}
|
|
215442
|
-
function getLineBreak(text) {
|
|
215443
|
-
if (text.includes('\r\n')) {
|
|
215444
|
-
return '\r\n';
|
|
215445
|
-
}
|
|
215446
|
-
return text.includes('\r') ? '\r' : '\n';
|
|
215832
|
+
const NULLISH_TYPE_FLAGS = typescriptExports.TypeFlags.Null | typescriptExports.TypeFlags.Undefined | typescriptExports.TypeFlags.Void;
|
|
215833
|
+
function isAnyOrUnknownType(type) {
|
|
215834
|
+
return (type.flags & (typescriptExports.TypeFlags.Any | typescriptExports.TypeFlags.Unknown)) !== 0;
|
|
215447
215835
|
}
|
|
215448
|
-
function
|
|
215449
|
-
|
|
215450
|
-
while (index < text.length && (text[index] === ' ' || text[index] === '\t')) {
|
|
215451
|
-
index++;
|
|
215452
|
-
}
|
|
215453
|
-
return text.slice(0, index);
|
|
215836
|
+
function isInterfaceType(type) {
|
|
215837
|
+
return 'getBaseTypes' in type && typeof type.getBaseTypes === 'function';
|
|
215454
215838
|
}
|
|
215455
|
-
function
|
|
215456
|
-
|
|
215457
|
-
const indent = text.slice(lineStart, offset);
|
|
215458
|
-
return indent.trim() === '' ? indent : '';
|
|
215839
|
+
function isNullishType(type) {
|
|
215840
|
+
return (type.flags & NULLISH_TYPE_FLAGS) !== 0;
|
|
215459
215841
|
}
|
|
215460
|
-
function
|
|
215461
|
-
|
|
215462
|
-
return `${getLineBreak(betweenText).repeat(blankLineCount + 1)}${indentation}`;
|
|
215842
|
+
function hasNullishType(type) {
|
|
215843
|
+
return type.isUnion() ? type.types.some(hasNullishType) : isNullishType(type);
|
|
215463
215844
|
}
|
|
215464
|
-
|
|
215465
|
-
const
|
|
215466
|
-
|
|
215467
|
-
|
|
215468
|
-
if ('rule' in options) {
|
|
215469
|
-
const { name, rule } = options;
|
|
215470
|
-
const meta = rule.meta ?? {};
|
|
215471
|
-
const docs = meta.docs ?? {};
|
|
215472
|
-
return ruleCreator({
|
|
215473
|
-
create: (context) => rule.create(context),
|
|
215474
|
-
meta: {
|
|
215475
|
-
...meta,
|
|
215476
|
-
docs: {
|
|
215477
|
-
...docs,
|
|
215478
|
-
description: typeof docs.description === 'string' ? docs.description : name,
|
|
215479
|
-
},
|
|
215480
|
-
},
|
|
215481
|
-
name,
|
|
215482
|
-
});
|
|
215845
|
+
function isKnownTupleType(typeChecker, type, visitedTypes = new Set()) {
|
|
215846
|
+
const shouldSkipReceiverType = isAnyOrUnknownType(type) || visitedTypes.has(type);
|
|
215847
|
+
if (shouldSkipReceiverType) {
|
|
215848
|
+
return false;
|
|
215483
215849
|
}
|
|
215484
|
-
|
|
215485
|
-
|
|
215486
|
-
|
|
215487
|
-
|
|
215488
|
-
|
|
215489
|
-
const reference = scope.references.find((item) => item.identifier === node);
|
|
215490
|
-
return reference?.resolved ?? null;
|
|
215491
|
-
}
|
|
215492
|
-
function hasVariableInScope(sourceCode, node, name) {
|
|
215493
|
-
let scope = sourceCode.getScope(node);
|
|
215494
|
-
while (scope) {
|
|
215495
|
-
if (scope.variables.some((variable) => variable.name === name)) {
|
|
215496
|
-
return true;
|
|
215497
|
-
}
|
|
215498
|
-
scope = scope.upper;
|
|
215850
|
+
visitedTypes.add(type);
|
|
215851
|
+
if (type.isUnion()) {
|
|
215852
|
+
const definedTypes = type.types.filter((item) => !isNullishType(item));
|
|
215853
|
+
return (definedTypes.length > 0 &&
|
|
215854
|
+
definedTypes.every((item) => isKnownTupleType(typeChecker, item, visitedTypes)));
|
|
215499
215855
|
}
|
|
215500
|
-
return
|
|
215501
|
-
|
|
215502
|
-
|
|
215503
|
-
|
|
215504
|
-
const parserServices = dist$4.ESLintUtils.getParserServices(context);
|
|
215505
|
-
const { sourceCode } = context;
|
|
215506
|
-
return {
|
|
215507
|
-
checker: parserServices.program.getTypeChecker(),
|
|
215508
|
-
esTreeNodeToTSNodeMap: parserServices.esTreeNodeToTSNodeMap,
|
|
215509
|
-
parserServices,
|
|
215510
|
-
program: sourceCode.ast,
|
|
215511
|
-
sourceCode,
|
|
215512
|
-
tsNodeToESTreeNodeMap: parserServices.tsNodeToESTreeNodeMap,
|
|
215513
|
-
tsProgram: parserServices.program,
|
|
215514
|
-
};
|
|
215856
|
+
return type.isIntersection()
|
|
215857
|
+
? type.types.some((item) => isKnownTupleType(typeChecker, item, visitedTypes))
|
|
215858
|
+
: typeChecker.isTupleType(type) ||
|
|
215859
|
+
typeChecker.isTupleType(typeChecker.getApparentType(type));
|
|
215515
215860
|
}
|
|
215516
215861
|
|
|
215517
215862
|
const BUILT_IN_AT_RECEIVER_NAMES = new Set([
|
|
@@ -215530,26 +215875,8 @@ const BUILT_IN_AT_RECEIVER_NAMES = new Set([
|
|
|
215530
215875
|
'Uint8Array',
|
|
215531
215876
|
'Uint8ClampedArray',
|
|
215532
215877
|
]);
|
|
215533
|
-
|
|
215534
|
-
|
|
215535
|
-
dist$4.AST_NODE_TYPES.ReturnStatement,
|
|
215536
|
-
dist$4.AST_NODE_TYPES.ThrowStatement,
|
|
215537
|
-
dist$4.AST_NODE_TYPES.VariableDeclaration,
|
|
215538
|
-
]);
|
|
215539
|
-
const NULLISH_TYPE_FLAGS = typescriptExports.TypeFlags.Null | typescriptExports.TypeFlags.Undefined | typescriptExports.TypeFlags.Void;
|
|
215540
|
-
const FALLBACK_SCRIPT_TARGET = typescriptExports.ScriptTarget.ES2021;
|
|
215541
|
-
function supportsAt(target) {
|
|
215542
|
-
return target >= typescriptExports.ScriptTarget.ES2022;
|
|
215543
|
-
}
|
|
215544
|
-
function isInterfaceType(type) {
|
|
215545
|
-
return 'getBaseTypes' in type && typeof type.getBaseTypes === 'function';
|
|
215546
|
-
}
|
|
215547
|
-
function isNullishType(type) {
|
|
215548
|
-
return (type.flags & NULLISH_TYPE_FLAGS) !== 0;
|
|
215549
|
-
}
|
|
215550
|
-
function hasKnownBuiltInAtReceiver(typeChecker, type, visitedTypes = new Set()) {
|
|
215551
|
-
const hasNoReliableType = (type.flags & (typescriptExports.TypeFlags.Any | typescriptExports.TypeFlags.Unknown)) !== 0;
|
|
215552
|
-
const shouldSkipReceiverType = hasNoReliableType || visitedTypes.has(type);
|
|
215878
|
+
function hasBuiltInAtReceiverType(typeChecker, type, visitedTypes = new Set()) {
|
|
215879
|
+
const shouldSkipReceiverType = isAnyOrUnknownType(type) || visitedTypes.has(type);
|
|
215553
215880
|
if (shouldSkipReceiverType) {
|
|
215554
215881
|
return false;
|
|
215555
215882
|
}
|
|
@@ -215557,10 +215884,10 @@ function hasKnownBuiltInAtReceiver(typeChecker, type, visitedTypes = new Set())
|
|
|
215557
215884
|
if (type.isUnion()) {
|
|
215558
215885
|
const definedTypes = type.types.filter((item) => !isNullishType(item));
|
|
215559
215886
|
return (definedTypes.length > 0 &&
|
|
215560
|
-
definedTypes.every((item) =>
|
|
215887
|
+
definedTypes.every((item) => hasBuiltInAtReceiverType(typeChecker, item, visitedTypes)));
|
|
215561
215888
|
}
|
|
215562
215889
|
if (type.isIntersection()) {
|
|
215563
|
-
return type.types.some((item) =>
|
|
215890
|
+
return type.types.some((item) => hasBuiltInAtReceiverType(typeChecker, item, visitedTypes));
|
|
215564
215891
|
}
|
|
215565
215892
|
const apparentType = typeChecker.getApparentType(type);
|
|
215566
215893
|
if (typeChecker.isArrayType(apparentType) || typeChecker.isTupleType(apparentType)) {
|
|
@@ -215572,9 +215899,60 @@ function hasKnownBuiltInAtReceiver(typeChecker, type, visitedTypes = new Set())
|
|
|
215572
215899
|
return true;
|
|
215573
215900
|
}
|
|
215574
215901
|
return isInterfaceType(apparentType)
|
|
215575
|
-
? (apparentType.getBaseTypes() ?? []).some((baseType) =>
|
|
215902
|
+
? (apparentType.getBaseTypes() ?? []).some((baseType) => hasBuiltInAtReceiverType(typeChecker, baseType, visitedTypes))
|
|
215576
215903
|
: false;
|
|
215577
215904
|
}
|
|
215905
|
+
|
|
215906
|
+
const FALLBACK_SCRIPT_TARGET = typescriptExports.ScriptTarget.ES2021;
|
|
215907
|
+
function normalizeLibName(name) {
|
|
215908
|
+
return name
|
|
215909
|
+
.toLowerCase()
|
|
215910
|
+
.replace(/^lib\./, '')
|
|
215911
|
+
.replace(/\.d\.ts$/, '');
|
|
215912
|
+
}
|
|
215913
|
+
function isFullEs2022OrLaterLib(name) {
|
|
215914
|
+
if (name === 'esnext' || name === 'esnext.full') {
|
|
215915
|
+
return true;
|
|
215916
|
+
}
|
|
215917
|
+
const match = /^es(?<year>\d{4})(?:\.full)?$/.exec(name);
|
|
215918
|
+
const year = match?.groups?.['year'];
|
|
215919
|
+
return year !== undefined && Number(year) >= 2022;
|
|
215920
|
+
}
|
|
215921
|
+
function hasBuiltInAtLib(libs) {
|
|
215922
|
+
if (!libs) {
|
|
215923
|
+
return true;
|
|
215924
|
+
}
|
|
215925
|
+
const normalizedLibs = libs.map(normalizeLibName);
|
|
215926
|
+
const hasFullAtLib = normalizedLibs.some(isFullEs2022OrLaterLib);
|
|
215927
|
+
const hasPartialAtLibs = normalizedLibs.includes('es2022.array') &&
|
|
215928
|
+
normalizedLibs.includes('es2022.string');
|
|
215929
|
+
return hasFullAtLib || hasPartialAtLibs;
|
|
215930
|
+
}
|
|
215931
|
+
function supportsBuiltInAt(compilerOptions) {
|
|
215932
|
+
const target = compilerOptions.target ?? FALLBACK_SCRIPT_TARGET;
|
|
215933
|
+
return target >= typescriptExports.ScriptTarget.ES2022 && hasBuiltInAtLib(compilerOptions.lib);
|
|
215934
|
+
}
|
|
215935
|
+
|
|
215936
|
+
function getTypeAwareRuleContext(context) {
|
|
215937
|
+
const parserServices = dist$4.ESLintUtils.getParserServices(context);
|
|
215938
|
+
const { sourceCode } = context;
|
|
215939
|
+
return {
|
|
215940
|
+
checker: parserServices.program.getTypeChecker(),
|
|
215941
|
+
esTreeNodeToTSNodeMap: parserServices.esTreeNodeToTSNodeMap,
|
|
215942
|
+
parserServices,
|
|
215943
|
+
program: sourceCode.ast,
|
|
215944
|
+
sourceCode,
|
|
215945
|
+
tsNodeToESTreeNodeMap: parserServices.tsNodeToESTreeNodeMap,
|
|
215946
|
+
tsProgram: parserServices.program,
|
|
215947
|
+
};
|
|
215948
|
+
}
|
|
215949
|
+
|
|
215950
|
+
const SUPPORTED_STATEMENT_TYPES = new Set([
|
|
215951
|
+
dist$4.AST_NODE_TYPES.ExpressionStatement,
|
|
215952
|
+
dist$4.AST_NODE_TYPES.ReturnStatement,
|
|
215953
|
+
dist$4.AST_NODE_TYPES.ThrowStatement,
|
|
215954
|
+
dist$4.AST_NODE_TYPES.VariableDeclaration,
|
|
215955
|
+
]);
|
|
215578
215956
|
function getAtCall(node) {
|
|
215579
215957
|
const { parent } = node;
|
|
215580
215958
|
const isSafeAtCall = parent.type === dist$4.AST_NODE_TYPES.CallExpression &&
|
|
@@ -215608,109 +215986,17 @@ function getAtIndex(sourceCode, call) {
|
|
|
215608
215986
|
? { text: sourceCode.getText(index), type: 'nonNegative' }
|
|
215609
215987
|
: null;
|
|
215610
215988
|
}
|
|
215611
|
-
function
|
|
215612
|
-
if (
|
|
215613
|
-
return
|
|
215989
|
+
function appendAtFallback(node, atCallText, indexedAccessTypeAlreadyIncludesUndefined) {
|
|
215990
|
+
if (indexedAccessTypeAlreadyIncludesUndefined) {
|
|
215991
|
+
return atCallText;
|
|
215614
215992
|
}
|
|
215615
|
-
const
|
|
215616
|
-
|
|
215617
|
-
|
|
215618
|
-
}
|
|
215619
|
-
const hasSameAtIndexSemantics = Number.isInteger(value) && value >= 0;
|
|
215620
|
-
return hasSameAtIndexSemantics ? sourceCode.getText(node.property) : null;
|
|
215621
|
-
}
|
|
215622
|
-
function getNodeParent(node) {
|
|
215623
|
-
const nodeWithParent = node;
|
|
215624
|
-
return nodeWithParent.parent ?? null;
|
|
215625
|
-
}
|
|
215626
|
-
function getReplacementExpression(node) {
|
|
215627
|
-
const parent = getNodeParent(node);
|
|
215628
|
-
return parent?.type === dist$4.AST_NODE_TYPES.ChainExpression ? parent : node;
|
|
215629
|
-
}
|
|
215630
|
-
function isLogicalFallbackOperand(node) {
|
|
215631
|
-
const expression = getReplacementExpression(node);
|
|
215632
|
-
const parent = getNodeParent(expression);
|
|
215633
|
-
return (parent?.type === dist$4.AST_NODE_TYPES.LogicalExpression &&
|
|
215634
|
-
(parent.operator === '??' || parent.operator === '||') &&
|
|
215635
|
-
parent.left === expression);
|
|
215636
|
-
}
|
|
215637
|
-
function isConditionExpression(node) {
|
|
215638
|
-
let current = getReplacementExpression(node);
|
|
215639
|
-
let parent = getNodeParent(current);
|
|
215640
|
-
if (!parent) {
|
|
215641
|
-
return false;
|
|
215642
|
-
}
|
|
215643
|
-
while (parent?.type === dist$4.AST_NODE_TYPES.LogicalExpression) {
|
|
215644
|
-
current = parent;
|
|
215645
|
-
parent = getNodeParent(parent);
|
|
215646
|
-
}
|
|
215647
|
-
if (!parent) {
|
|
215648
|
-
return false;
|
|
215649
|
-
}
|
|
215650
|
-
if (parent.type === dist$4.AST_NODE_TYPES.UnaryExpression && parent.operator === '!') {
|
|
215651
|
-
current = parent;
|
|
215652
|
-
parent = getNodeParent(parent);
|
|
215653
|
-
}
|
|
215654
|
-
return parent
|
|
215655
|
-
? (parent.type === dist$4.AST_NODE_TYPES.IfStatement && parent.test === current) ||
|
|
215656
|
-
(parent.type === dist$4.AST_NODE_TYPES.ConditionalExpression &&
|
|
215657
|
-
parent.test === current) ||
|
|
215658
|
-
(parent.type === dist$4.AST_NODE_TYPES.WhileStatement &&
|
|
215659
|
-
parent.test === current) ||
|
|
215660
|
-
(parent.type === dist$4.AST_NODE_TYPES.DoWhileStatement &&
|
|
215661
|
-
parent.test === current) ||
|
|
215662
|
-
(parent.type === dist$4.AST_NODE_TYPES.ForStatement && parent.test === current)
|
|
215663
|
-
: false;
|
|
215664
|
-
}
|
|
215665
|
-
function appendAtFallback(node, atCallText) {
|
|
215666
|
-
const canUseSurroundingFallback = isLogicalFallbackOperand(node) || isConditionExpression(node);
|
|
215993
|
+
const canUseSurroundingFallback = isLogicalFallbackLeftOperand(node) ||
|
|
215994
|
+
isConditionTestExpression(node) ||
|
|
215995
|
+
isEqualityComparisonOperand(node);
|
|
215667
215996
|
return node.optional || canUseSurroundingFallback || hasNonNullAssertionParent(node)
|
|
215668
215997
|
? atCallText
|
|
215669
215998
|
: `${atCallText}!`;
|
|
215670
215999
|
}
|
|
215671
|
-
function hasNonNullAssertionParent(node) {
|
|
215672
|
-
let current = node;
|
|
215673
|
-
let parent = getNodeParent(current);
|
|
215674
|
-
while (parent) {
|
|
215675
|
-
if (parent.type === dist$4.AST_NODE_TYPES.TSNonNullExpression &&
|
|
215676
|
-
parent.expression === current) {
|
|
215677
|
-
return true;
|
|
215678
|
-
}
|
|
215679
|
-
if (getParenthesizedInner(parent) !== current) {
|
|
215680
|
-
return false;
|
|
215681
|
-
}
|
|
215682
|
-
current = parent;
|
|
215683
|
-
parent = getNodeParent(current);
|
|
215684
|
-
}
|
|
215685
|
-
return false;
|
|
215686
|
-
}
|
|
215687
|
-
function isAssignmentTarget(node) {
|
|
215688
|
-
const { parent } = node;
|
|
215689
|
-
return ((parent.type === dist$4.AST_NODE_TYPES.AssignmentExpression && parent.left === node) ||
|
|
215690
|
-
(parent.type === dist$4.AST_NODE_TYPES.UpdateExpression && parent.argument === node) ||
|
|
215691
|
-
(parent.type === dist$4.AST_NODE_TYPES.UnaryExpression &&
|
|
215692
|
-
parent.operator === 'delete' &&
|
|
215693
|
-
parent.argument === node) ||
|
|
215694
|
-
(parent.type === dist$4.AST_NODE_TYPES.ForInStatement && parent.left === node) ||
|
|
215695
|
-
(parent.type === dist$4.AST_NODE_TYPES.ForOfStatement && parent.left === node));
|
|
215696
|
-
}
|
|
215697
|
-
function getMemberAccessStart(sourceCode, node) {
|
|
215698
|
-
const tokenBeforeProperty = sourceCode.getTokenBefore(node.property);
|
|
215699
|
-
if (!tokenBeforeProperty) {
|
|
215700
|
-
return null;
|
|
215701
|
-
}
|
|
215702
|
-
if (!node.computed) {
|
|
215703
|
-
return tokenBeforeProperty.range[0];
|
|
215704
|
-
}
|
|
215705
|
-
if (tokenBeforeProperty.value !== '[') {
|
|
215706
|
-
return null;
|
|
215707
|
-
}
|
|
215708
|
-
const tokenBeforeBracket = sourceCode.getTokenBefore(tokenBeforeProperty);
|
|
215709
|
-
const hasOptionalBracketAccess = node.optional && tokenBeforeBracket?.value === '?.';
|
|
215710
|
-
return hasOptionalBracketAccess
|
|
215711
|
-
? tokenBeforeBracket.range[0]
|
|
215712
|
-
: tokenBeforeProperty.range[0];
|
|
215713
|
-
}
|
|
215714
216000
|
function getAtCallText(sourceCode, node, indexText, useOptionalAccess) {
|
|
215715
216001
|
const accessStart = getMemberAccessStart(sourceCode, node);
|
|
215716
216002
|
if (accessStart === null) {
|
|
@@ -215731,15 +216017,6 @@ function isRepeatableReceiver(node) {
|
|
|
215731
216017
|
return false;
|
|
215732
216018
|
}
|
|
215733
216019
|
}
|
|
215734
|
-
function getLineIndent(text, start) {
|
|
215735
|
-
const lineStart = getLineStart$1(text, start);
|
|
215736
|
-
const linePrefix = text.slice(lineStart, start);
|
|
215737
|
-
const indent = /^\s*/.exec(linePrefix);
|
|
215738
|
-
return indent?.[0] ?? '';
|
|
215739
|
-
}
|
|
215740
|
-
function getLineStart$1(text, start) {
|
|
215741
|
-
return text.lastIndexOf('\n', start - 1) + 1;
|
|
215742
|
-
}
|
|
215743
216020
|
function capitalize(value) {
|
|
215744
216021
|
return value.length > 0 ? `${value[0]?.toUpperCase()}${value.slice(1)}` : value;
|
|
215745
216022
|
}
|
|
@@ -215827,7 +216104,7 @@ function isSupportedStatement(node) {
|
|
|
215827
216104
|
function getSupportedStatement(node) {
|
|
215828
216105
|
let current = node.parent;
|
|
215829
216106
|
while (current) {
|
|
215830
|
-
if (
|
|
216107
|
+
if (isFunctionExpressionLike(current)) {
|
|
215831
216108
|
return null;
|
|
215832
216109
|
}
|
|
215833
216110
|
const { parent } = current;
|
|
@@ -215859,7 +216136,7 @@ function isNonRepeatableLastAtCall(sourceCode, node) {
|
|
|
215859
216136
|
function hasMultipleNonRepeatableLastAtCalls(sourceCode, root) {
|
|
215860
216137
|
let count = 0;
|
|
215861
216138
|
walkAst(root, (node) => {
|
|
215862
|
-
if (node !== root &&
|
|
216139
|
+
if (node !== root && isFunctionExpressionLike(node)) {
|
|
215863
216140
|
return false;
|
|
215864
216141
|
}
|
|
215865
216142
|
if (isNonRepeatableLastAtCall(sourceCode, node)) {
|
|
@@ -215869,17 +216146,13 @@ function hasMultipleNonRepeatableLastAtCalls(sourceCode, root) {
|
|
|
215869
216146
|
});
|
|
215870
216147
|
return count > 1;
|
|
215871
216148
|
}
|
|
215872
|
-
function isFunctionExpressionBoundary(node) {
|
|
215873
|
-
return (node.type === dist$4.AST_NODE_TYPES.ArrowFunctionExpression ||
|
|
215874
|
-
node.type === dist$4.AST_NODE_TYPES.FunctionExpression);
|
|
215875
|
-
}
|
|
215876
216149
|
function getClassPropertyWithoutFunctionBoundary(node) {
|
|
215877
216150
|
let current = node.parent;
|
|
215878
216151
|
while (current) {
|
|
215879
216152
|
if (current.type === dist$4.AST_NODE_TYPES.PropertyDefinition) {
|
|
215880
216153
|
return current;
|
|
215881
216154
|
}
|
|
215882
|
-
if (
|
|
216155
|
+
if (isFunctionExpressionLike(current)) {
|
|
215883
216156
|
return null;
|
|
215884
216157
|
}
|
|
215885
216158
|
current = current.parent;
|
|
@@ -215887,9 +216160,24 @@ function getClassPropertyWithoutFunctionBoundary(node) {
|
|
|
215887
216160
|
return null;
|
|
215888
216161
|
}
|
|
215889
216162
|
function getClassPropertyPrefix(property) {
|
|
215890
|
-
|
|
216163
|
+
if (property.key.type === dist$4.AST_NODE_TYPES.PrivateIdentifier) {
|
|
216164
|
+
return property.static ? 'static ' : '';
|
|
216165
|
+
}
|
|
216166
|
+
const modifiers = [
|
|
216167
|
+
property.accessibility,
|
|
216168
|
+
property.static ? 'static' : null,
|
|
216169
|
+
'readonly',
|
|
216170
|
+
].filter((modifier) => Boolean(modifier));
|
|
215891
216171
|
return `${modifiers.join(' ')} `;
|
|
215892
216172
|
}
|
|
216173
|
+
function getClassPropertyDeclarationName(property, name) {
|
|
216174
|
+
return property.key.type === dist$4.AST_NODE_TYPES.PrivateIdentifier ? `#${name}` : name;
|
|
216175
|
+
}
|
|
216176
|
+
function getClassPropertyReceiver(property, name) {
|
|
216177
|
+
return property.key.type === dist$4.AST_NODE_TYPES.PrivateIdentifier
|
|
216178
|
+
? `this.#${name}`
|
|
216179
|
+
: `this.${name}`;
|
|
216180
|
+
}
|
|
215893
216181
|
function getLastIndexFix(fixer, sourceCode, node, call) {
|
|
215894
216182
|
if (node.optional) {
|
|
215895
216183
|
return null;
|
|
@@ -215905,8 +216193,8 @@ function getLastIndexFix(fixer, sourceCode, node, call) {
|
|
|
215905
216193
|
return null;
|
|
215906
216194
|
}
|
|
215907
216195
|
const temporaryName = getAvailableTemporaryName(sourceCode, call, preferredNames, null);
|
|
215908
|
-
const indent =
|
|
215909
|
-
const lineStart =
|
|
216196
|
+
const indent = getIndentAtOffset(sourceCode.text, statement.range[0]);
|
|
216197
|
+
const lineStart = getLineStartOffset(sourceCode.text, statement.range[0]);
|
|
215910
216198
|
const lineBreak = getLineBreak(sourceCode.text);
|
|
215911
216199
|
return [
|
|
215912
216200
|
fixer.insertTextBeforeRange([lineStart, lineStart], `${indent}const ${temporaryName} = ${objectText};${lineBreak}`),
|
|
@@ -215920,12 +216208,13 @@ function getLastIndexFix(fixer, sourceCode, node, call) {
|
|
|
215920
216208
|
return null;
|
|
215921
216209
|
}
|
|
215922
216210
|
const propertyName = getAvailableTemporaryName(sourceCode, call, preferredNames, classBody);
|
|
215923
|
-
const
|
|
215924
|
-
const
|
|
215925
|
-
const
|
|
216211
|
+
const declarationName = getClassPropertyDeclarationName(property, propertyName);
|
|
216212
|
+
const receiverText = getClassPropertyReceiver(property, propertyName);
|
|
216213
|
+
const indent = getIndentAtOffset(sourceCode.text, property.range[0]);
|
|
216214
|
+
const lineStart = getLineStartOffset(sourceCode.text, property.range[0]);
|
|
215926
216215
|
const lineBreak = getLineBreak(sourceCode.text);
|
|
215927
216216
|
return [
|
|
215928
|
-
fixer.insertTextBeforeRange([lineStart, lineStart], `${indent}${getClassPropertyPrefix(property)}${
|
|
216217
|
+
fixer.insertTextBeforeRange([lineStart, lineStart], `${indent}${getClassPropertyPrefix(property)}${declarationName} = ${objectText};${lineBreak}${lineBreak}`),
|
|
215929
216218
|
fixer.replaceText(call, `${receiverText}[${receiverText}.length - 1]`),
|
|
215930
216219
|
];
|
|
215931
216220
|
}
|
|
@@ -215934,21 +216223,29 @@ function getLastIndexFix(fixer, sourceCode, node, call) {
|
|
|
215934
216223
|
const rule$X = createRule({
|
|
215935
216224
|
create(context) {
|
|
215936
216225
|
const typeAwareContext = getTypeAwareRuleContext(context);
|
|
215937
|
-
const
|
|
215938
|
-
|
|
215939
|
-
const canUseAt = supportsAt(scriptTarget);
|
|
216226
|
+
const compilerOptions = typeAwareContext.tsProgram.getCompilerOptions();
|
|
216227
|
+
const canUseAt = supportsBuiltInAt(compilerOptions);
|
|
215940
216228
|
const { checker: typeChecker, esTreeNodeToTSNodeMap } = typeAwareContext;
|
|
215941
216229
|
const { sourceCode } = context;
|
|
215942
216230
|
return {
|
|
215943
216231
|
MemberExpression(node) {
|
|
215944
216232
|
if (canUseAt) {
|
|
215945
216233
|
const indexText = getSafeBracketIndexText(sourceCode, node);
|
|
215946
|
-
if (indexText === null ||
|
|
216234
|
+
if (indexText === null || isMutationTarget(node)) {
|
|
215947
216235
|
return;
|
|
215948
216236
|
}
|
|
215949
216237
|
const tsObjectNode = esTreeNodeToTSNodeMap.get(node.object);
|
|
216238
|
+
const tsIndexedAccessNode = esTreeNodeToTSNodeMap.get(node);
|
|
215950
216239
|
const objectType = typeChecker.getTypeAtLocation(tsObjectNode);
|
|
215951
|
-
|
|
216240
|
+
const indexedAccessType = typeChecker.getTypeAtLocation(tsIndexedAccessNode);
|
|
216241
|
+
const indexedAccessTypeAlreadyIncludesUndefined = compilerOptions.noUncheckedIndexedAccess === true &&
|
|
216242
|
+
hasNullishType(indexedAccessType);
|
|
216243
|
+
const shouldPreserveIndexedAccessNarrowing = indexedAccessTypeAlreadyIncludesUndefined &&
|
|
216244
|
+
isIndexedAccessGuardingSameIndexAssignment(sourceCode, node);
|
|
216245
|
+
const shouldSkipPreferAt = !hasBuiltInAtReceiverType(typeChecker, objectType) ||
|
|
216246
|
+
isKnownTupleType(typeChecker, objectType) ||
|
|
216247
|
+
shouldPreserveIndexedAccessNarrowing;
|
|
216248
|
+
if (shouldSkipPreferAt) {
|
|
215952
216249
|
return;
|
|
215953
216250
|
}
|
|
215954
216251
|
const useOptionalAccess = node.optional;
|
|
@@ -215957,7 +216254,7 @@ const rule$X = createRule({
|
|
|
215957
216254
|
const atCallText = getAtCallText(sourceCode, node, indexText, useOptionalAccess);
|
|
215958
216255
|
return atCallText === null
|
|
215959
216256
|
? null
|
|
215960
|
-
: fixer.replaceText(node, appendAtFallback(node, atCallText));
|
|
216257
|
+
: fixer.replaceText(node, appendAtFallback(node, atCallText, indexedAccessTypeAlreadyIncludesUndefined));
|
|
215961
216258
|
},
|
|
215962
216259
|
messageId: 'atCompatPreferAt',
|
|
215963
216260
|
node: node.property,
|
|
@@ -215969,7 +216266,7 @@ const rule$X = createRule({
|
|
|
215969
216266
|
}
|
|
215970
216267
|
const tsObjectNode = esTreeNodeToTSNodeMap.get(node.object);
|
|
215971
216268
|
const objectType = typeChecker.getTypeAtLocation(tsObjectNode);
|
|
215972
|
-
if (!
|
|
216269
|
+
if (!hasBuiltInAtReceiverType(typeChecker, objectType)) {
|
|
215973
216270
|
return;
|
|
215974
216271
|
}
|
|
215975
216272
|
context.report({
|
|
@@ -250500,8 +250797,7 @@ const AFTER_RENDER_EFFECT_PHASES = new Map([
|
|
|
250500
250797
|
['write', 'afterRenderEffect().write'],
|
|
250501
250798
|
]);
|
|
250502
250799
|
function isReactiveCallback(node) {
|
|
250503
|
-
return (node
|
|
250504
|
-
node?.type === dist$4.AST_NODE_TYPES.FunctionExpression);
|
|
250800
|
+
return isFunctionExpressionLike(node);
|
|
250505
250801
|
}
|
|
250506
250802
|
function getReactiveCallbackArgument(node) {
|
|
250507
250803
|
const [arg] = node.arguments;
|
|
@@ -250874,62 +251170,6 @@ const rule$H = createRule({
|
|
|
250874
251170
|
rule: config$3,
|
|
250875
251171
|
});
|
|
250876
251172
|
|
|
250877
|
-
function findAncestor(node, predicate) {
|
|
250878
|
-
for (let current = node?.parent; current; current = current.parent) {
|
|
250879
|
-
if (predicate(current)) {
|
|
250880
|
-
return current;
|
|
250881
|
-
}
|
|
250882
|
-
}
|
|
250883
|
-
return null;
|
|
250884
|
-
}
|
|
250885
|
-
function findSelfOrAncestor(node, predicate) {
|
|
250886
|
-
for (let current = node; current; current = current.parent) {
|
|
250887
|
-
if (predicate(current)) {
|
|
250888
|
-
return current;
|
|
250889
|
-
}
|
|
250890
|
-
}
|
|
250891
|
-
return null;
|
|
250892
|
-
}
|
|
250893
|
-
function hasAncestor(node, predicate) {
|
|
250894
|
-
for (let current = node?.parent; current; current = current.parent) {
|
|
250895
|
-
if (predicate(current)) {
|
|
250896
|
-
return true;
|
|
250897
|
-
}
|
|
250898
|
-
}
|
|
250899
|
-
return false;
|
|
250900
|
-
}
|
|
250901
|
-
function isNodeInside(node, ancestor) {
|
|
250902
|
-
for (let current = node; current; current = current.parent) {
|
|
250903
|
-
if (current === ancestor) {
|
|
250904
|
-
return true;
|
|
250905
|
-
}
|
|
250906
|
-
}
|
|
250907
|
-
return false;
|
|
250908
|
-
}
|
|
250909
|
-
function isNodeInsideAny(node, ancestors) {
|
|
250910
|
-
return ancestors.some((ancestor) => isNodeInside(node, ancestor));
|
|
250911
|
-
}
|
|
250912
|
-
function isClassLike(node) {
|
|
250913
|
-
return (node.type === dist$4.AST_NODE_TYPES.ClassDeclaration ||
|
|
250914
|
-
node.type === dist$4.AST_NODE_TYPES.ClassExpression);
|
|
250915
|
-
}
|
|
250916
|
-
function isClassMember(node) {
|
|
250917
|
-
return (node.type === dist$4.AST_NODE_TYPES.MethodDefinition ||
|
|
250918
|
-
node.type === dist$4.AST_NODE_TYPES.PropertyDefinition);
|
|
250919
|
-
}
|
|
250920
|
-
function getEnclosingFunction(node) {
|
|
250921
|
-
return findAncestor(node, isFunctionLike);
|
|
250922
|
-
}
|
|
250923
|
-
function getEnclosingClass(node) {
|
|
250924
|
-
return findSelfOrAncestor(node, isClassLike);
|
|
250925
|
-
}
|
|
250926
|
-
function getEnclosingClassMember(node) {
|
|
250927
|
-
return findAncestor(node, isClassMember);
|
|
250928
|
-
}
|
|
250929
|
-
function getScopeRoot(node) {
|
|
250930
|
-
return (findAncestor(node, (ancestor) => ancestor.type === dist$4.AST_NODE_TYPES.Program || isFunctionLike(ancestor)) ?? node);
|
|
250931
|
-
}
|
|
250932
|
-
|
|
250933
251173
|
const rule$G = createRule({
|
|
250934
251174
|
create(context) {
|
|
250935
251175
|
const checkImplicitPublic = (node) => {
|
|
@@ -252234,9 +252474,7 @@ const rule$w = createRule({
|
|
|
252234
252474
|
// only explicit return type declaration (satisfying
|
|
252235
252475
|
// @typescript-eslint/explicit-function-return-type via
|
|
252236
252476
|
// allowTypedFunctionExpressions). Removing it would break that rule.
|
|
252237
|
-
if ((value
|
|
252238
|
-
value.type === dist$4.AST_NODE_TYPES.FunctionExpression) &&
|
|
252239
|
-
!value.returnType) {
|
|
252477
|
+
if (isFunctionExpressionLike(value) && !value.returnType) {
|
|
252240
252478
|
return;
|
|
252241
252479
|
}
|
|
252242
252480
|
// If the annotation provides contextual typing that narrows an array
|
|
@@ -252247,7 +252485,7 @@ const rule$w = createRule({
|
|
|
252247
252485
|
const arrayExpressions = collectArrayExpressions(value);
|
|
252248
252486
|
for (const arrayExpression of arrayExpressions) {
|
|
252249
252487
|
const tsArrayNode = esTreeNodeToTSNodeMap.get(arrayExpression);
|
|
252250
|
-
if (
|
|
252488
|
+
if (isKnownTupleType(typeChecker, typeChecker.getTypeAtLocation(tsArrayNode))) {
|
|
252251
252489
|
return;
|
|
252252
252490
|
}
|
|
252253
252491
|
}
|
|
@@ -252311,13 +252549,7 @@ const rule$w = createRule({
|
|
|
252311
252549
|
function isNullableCallType(call, checker, nodeMap) {
|
|
252312
252550
|
try {
|
|
252313
252551
|
const tsNode = nodeMap.get(call);
|
|
252314
|
-
|
|
252315
|
-
return false;
|
|
252316
|
-
}
|
|
252317
|
-
const type = checker.getTypeAtLocation(tsNode);
|
|
252318
|
-
return type.flags & ts.TypeFlags.Union
|
|
252319
|
-
? type.types.some((t) => !!(t.flags & (ts.TypeFlags.Null | ts.TypeFlags.Undefined)))
|
|
252320
|
-
: false;
|
|
252552
|
+
return tsNode ? hasNullishType(checker.getTypeAtLocation(tsNode)) : false;
|
|
252321
252553
|
}
|
|
252322
252554
|
catch {
|
|
252323
252555
|
return false;
|
|
@@ -252372,40 +252604,22 @@ function findConciseArrowAncestor(node) {
|
|
|
252372
252604
|
}
|
|
252373
252605
|
function getArrowBodyIndent(arrowFn, sourceText) {
|
|
252374
252606
|
const arrowStart = arrowFn.range[0];
|
|
252375
|
-
const lineStart = sourceText
|
|
252607
|
+
const lineStart = getLineStartOffset(sourceText, arrowStart);
|
|
252376
252608
|
const textBeforeArrow = sourceText.slice(lineStart, arrowStart);
|
|
252377
252609
|
const outerIndent = /^(\s*)/.exec(textBeforeArrow)?.[1] ?? '';
|
|
252378
252610
|
return { innerIndent: `${outerIndent} `, outerIndent };
|
|
252379
252611
|
}
|
|
252380
252612
|
function getStatementIndent$1(statement, sourceText) {
|
|
252381
|
-
|
|
252382
|
-
const lineStart = sourceText.lastIndexOf('\n', start - 1) + 1;
|
|
252383
|
-
const before = sourceText.slice(lineStart, start);
|
|
252384
|
-
return /^\s*$/.test(before) ? before : '';
|
|
252385
|
-
}
|
|
252386
|
-
function isAstNode(value) {
|
|
252387
|
-
if (!value || typeof value !== 'object' || !('type' in value)) {
|
|
252388
|
-
return false;
|
|
252389
|
-
}
|
|
252390
|
-
const { type } = value;
|
|
252391
|
-
return typeof type === 'string';
|
|
252392
|
-
}
|
|
252393
|
-
function getParent(node) {
|
|
252394
|
-
const maybeNode = node;
|
|
252395
|
-
if (!maybeNode || typeof maybeNode !== 'object' || !('parent' in maybeNode)) {
|
|
252396
|
-
return null;
|
|
252397
|
-
}
|
|
252398
|
-
const { parent } = maybeNode;
|
|
252399
|
-
return isAstNode(parent) ? parent : null;
|
|
252613
|
+
return getIndentAtOffset(sourceText, statement.range[0]);
|
|
252400
252614
|
}
|
|
252401
252615
|
function isOptionalMemberReceiver(call) {
|
|
252402
252616
|
let current = call;
|
|
252403
|
-
let parent =
|
|
252617
|
+
let parent = getParentNode(current);
|
|
252404
252618
|
while (parent?.type === dist$4.AST_NODE_TYPES.TSAsExpression ||
|
|
252405
252619
|
parent?.type === dist$4.AST_NODE_TYPES.TSNonNullExpression ||
|
|
252406
252620
|
parent?.type === dist$4.AST_NODE_TYPES.TSTypeAssertion) {
|
|
252407
252621
|
current = parent;
|
|
252408
|
-
parent =
|
|
252622
|
+
parent = getParentNode(current);
|
|
252409
252623
|
}
|
|
252410
252624
|
return (parent?.type === dist$4.AST_NODE_TYPES.MemberExpression &&
|
|
252411
252625
|
parent.object === current &&
|
|
@@ -252513,93 +252727,6 @@ const rule$v = createRule({
|
|
|
252513
252727
|
name: 'no-repeated-signal-in-conditional',
|
|
252514
252728
|
});
|
|
252515
252729
|
|
|
252516
|
-
/**
|
|
252517
|
-
* Strips expression wrapper nodes that do not affect the underlying expression:
|
|
252518
|
-
* parentheses, `as` casts, `satisfies`, non-null assertions (`!`), type
|
|
252519
|
-
* assertions (`<T>expr`), and optional-chain wrappers. Iterates until no more
|
|
252520
|
-
* wrappers are found.
|
|
252521
|
-
*/
|
|
252522
|
-
function unwrapExpression(expression) {
|
|
252523
|
-
let current = expression;
|
|
252524
|
-
let didUnwrap = true;
|
|
252525
|
-
while (didUnwrap) {
|
|
252526
|
-
didUnwrap = false;
|
|
252527
|
-
const parenthesized = getParenthesizedExpression(current);
|
|
252528
|
-
if (parenthesized) {
|
|
252529
|
-
current = parenthesized;
|
|
252530
|
-
didUnwrap = true;
|
|
252531
|
-
continue;
|
|
252532
|
-
}
|
|
252533
|
-
switch (current.type) {
|
|
252534
|
-
case dist$4.AST_NODE_TYPES.ChainExpression:
|
|
252535
|
-
current = current.expression;
|
|
252536
|
-
didUnwrap = true;
|
|
252537
|
-
break;
|
|
252538
|
-
case dist$4.AST_NODE_TYPES.TSAsExpression:
|
|
252539
|
-
current = current.expression;
|
|
252540
|
-
didUnwrap = true;
|
|
252541
|
-
break;
|
|
252542
|
-
case dist$4.AST_NODE_TYPES.TSNonNullExpression:
|
|
252543
|
-
current = current.expression;
|
|
252544
|
-
didUnwrap = true;
|
|
252545
|
-
break;
|
|
252546
|
-
case dist$4.AST_NODE_TYPES.TSSatisfiesExpression:
|
|
252547
|
-
current = current.expression;
|
|
252548
|
-
didUnwrap = true;
|
|
252549
|
-
break;
|
|
252550
|
-
case dist$4.AST_NODE_TYPES.TSTypeAssertion:
|
|
252551
|
-
current = current.expression;
|
|
252552
|
-
didUnwrap = true;
|
|
252553
|
-
break;
|
|
252554
|
-
}
|
|
252555
|
-
}
|
|
252556
|
-
return current;
|
|
252557
|
-
}
|
|
252558
|
-
function isExpressionLike(value) {
|
|
252559
|
-
return (typeof value === 'object' &&
|
|
252560
|
-
value !== null &&
|
|
252561
|
-
'type' in value &&
|
|
252562
|
-
typeof value.type === 'string');
|
|
252563
|
-
}
|
|
252564
|
-
function getParenthesizedExpression(expression) {
|
|
252565
|
-
const maybeExpression = expression;
|
|
252566
|
-
return maybeExpression.type === 'ParenthesizedExpression' &&
|
|
252567
|
-
isExpressionLike(maybeExpression.expression)
|
|
252568
|
-
? maybeExpression.expression
|
|
252569
|
-
: null;
|
|
252570
|
-
}
|
|
252571
|
-
|
|
252572
|
-
function unwrapMutationTarget(node) {
|
|
252573
|
-
let current = node;
|
|
252574
|
-
while (current.type === dist$4.AST_NODE_TYPES.TSAsExpression ||
|
|
252575
|
-
current.type === dist$4.AST_NODE_TYPES.TSNonNullExpression ||
|
|
252576
|
-
current.type === dist$4.AST_NODE_TYPES.TSTypeAssertion) {
|
|
252577
|
-
current = current.expression;
|
|
252578
|
-
}
|
|
252579
|
-
return current;
|
|
252580
|
-
}
|
|
252581
|
-
function collectMutationTargets(node) {
|
|
252582
|
-
const current = unwrapMutationTarget(node);
|
|
252583
|
-
switch (current.type) {
|
|
252584
|
-
case dist$4.AST_NODE_TYPES.ArrayPattern:
|
|
252585
|
-
return current.elements.flatMap((element) => element ? collectMutationTargets(element) : []);
|
|
252586
|
-
case dist$4.AST_NODE_TYPES.AssignmentPattern:
|
|
252587
|
-
return collectMutationTargets(current.left);
|
|
252588
|
-
case dist$4.AST_NODE_TYPES.Identifier:
|
|
252589
|
-
return [current];
|
|
252590
|
-
case dist$4.AST_NODE_TYPES.MemberExpression:
|
|
252591
|
-
return [current];
|
|
252592
|
-
case dist$4.AST_NODE_TYPES.ObjectPattern:
|
|
252593
|
-
return current.properties.flatMap((property) => property.type === dist$4.AST_NODE_TYPES.RestElement
|
|
252594
|
-
? collectMutationTargets(property.argument)
|
|
252595
|
-
: collectMutationTargets(property.value));
|
|
252596
|
-
case dist$4.AST_NODE_TYPES.RestElement:
|
|
252597
|
-
return collectMutationTargets(current.argument);
|
|
252598
|
-
default:
|
|
252599
|
-
return [];
|
|
252600
|
-
}
|
|
252601
|
-
}
|
|
252602
|
-
|
|
252603
252730
|
function getSymbolAtNode(node, checker, esTreeNodeToTSNodeMap) {
|
|
252604
252731
|
const tsNode = esTreeNodeToTSNodeMap.get(node);
|
|
252605
252732
|
return tsNode ? (checker.getSymbolAtLocation(tsNode) ?? null) : null;
|
|
@@ -252787,19 +252914,9 @@ function functionHasObservableSideEffects(root, context, localScopes, visitedFun
|
|
|
252787
252914
|
return false;
|
|
252788
252915
|
}
|
|
252789
252916
|
}
|
|
252790
|
-
|
|
252791
|
-
|
|
252792
|
-
|
|
252793
|
-
return false;
|
|
252794
|
-
}
|
|
252795
|
-
if (node.type === dist$4.AST_NODE_TYPES.UpdateExpression &&
|
|
252796
|
-
hasObservableMutationTarget(node.argument, context, localScopes)) {
|
|
252797
|
-
hasSideEffect = true;
|
|
252798
|
-
return false;
|
|
252799
|
-
}
|
|
252800
|
-
if (node.type === dist$4.AST_NODE_TYPES.UnaryExpression &&
|
|
252801
|
-
node.operator === 'delete' &&
|
|
252802
|
-
hasObservableMutationTarget(node.argument, context, localScopes)) {
|
|
252917
|
+
const mutationTarget = getMutationExpressionTarget(node);
|
|
252918
|
+
if (mutationTarget &&
|
|
252919
|
+
hasObservableMutationTarget(mutationTarget, context, localScopes)) {
|
|
252803
252920
|
hasSideEffect = true;
|
|
252804
252921
|
return false;
|
|
252805
252922
|
}
|
|
@@ -252840,18 +252957,10 @@ function inspectComputedBody(root, context, localScopes, visitedFunctions, repor
|
|
|
252840
252957
|
return false;
|
|
252841
252958
|
}
|
|
252842
252959
|
}
|
|
252843
|
-
|
|
252844
|
-
|
|
252845
|
-
|
|
252846
|
-
|
|
252847
|
-
if (node.type === dist$4.AST_NODE_TYPES.UpdateExpression &&
|
|
252848
|
-
hasObservableMutationTarget(node.argument, context, localScopes)) {
|
|
252849
|
-
reportSideEffect(node.argument, context, report);
|
|
252850
|
-
}
|
|
252851
|
-
if (node.type === dist$4.AST_NODE_TYPES.UnaryExpression &&
|
|
252852
|
-
node.operator === 'delete' &&
|
|
252853
|
-
hasObservableMutationTarget(node.argument, context, localScopes)) {
|
|
252854
|
-
reportSideEffect(node.argument, context, report);
|
|
252960
|
+
const mutationTarget = getMutationExpressionTarget(node);
|
|
252961
|
+
if (mutationTarget &&
|
|
252962
|
+
hasObservableMutationTarget(mutationTarget, context, localScopes)) {
|
|
252963
|
+
reportSideEffect(mutationTarget, context, report);
|
|
252855
252964
|
}
|
|
252856
252965
|
return;
|
|
252857
252966
|
});
|