pasika 0.10.77 → 0.10.78
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/dist/eslint/pasika/index.js +18 -17
- package/package.json +1 -1
|
@@ -6153,11 +6153,8 @@ function directPropertyBinding(context, declarator) {
|
|
|
6153
6153
|
function canGroupSource(source) {
|
|
6154
6154
|
return source.type === "Identifier" || source.type === "ThisExpression";
|
|
6155
6155
|
}
|
|
6156
|
-
function
|
|
6157
|
-
|
|
6158
|
-
if (source.type !== "MemberExpression") return false;
|
|
6159
|
-
if (source.computed || source.optional || source.property.type !== "Identifier") return false;
|
|
6160
|
-
return isStableObjectSource(source.object);
|
|
6156
|
+
function isGroupedUsageSource(source) {
|
|
6157
|
+
return source.type === "Identifier" || source.type === "ThisExpression";
|
|
6161
6158
|
}
|
|
6162
6159
|
function rootIdentifierName(node) {
|
|
6163
6160
|
if (node.type === "Identifier") return node.name;
|
|
@@ -6231,7 +6228,7 @@ function memberIsDirectVariableInitializer(context, member) {
|
|
|
6231
6228
|
function recordMemberUsage(context, scope, ownershipResolver, member) {
|
|
6232
6229
|
if (!scope || member.computed || member.optional || member.property.type !== "Identifier") return;
|
|
6233
6230
|
if (!memberCanBeDestructured(context, ownershipResolver, member)) return;
|
|
6234
|
-
if (!
|
|
6231
|
+
if (!isGroupedUsageSource(member.object) || !memberIsRead(context, member)) return;
|
|
6235
6232
|
const sourceText = context.sourceCode.getText(member.object);
|
|
6236
6233
|
const usage = objectUsage(scope, sourceText);
|
|
6237
6234
|
const propertyName5 = member.property.name;
|
|
@@ -6243,10 +6240,11 @@ function recordMemberUsage(context, scope, ownershipResolver, member) {
|
|
|
6243
6240
|
function recordDestructuringUsage(context, scope, declaration) {
|
|
6244
6241
|
if (!scope) return;
|
|
6245
6242
|
for (const declarator of declaration.declarations) {
|
|
6246
|
-
if (declarator.id.type !== "ObjectPattern" || !declarator.init || !
|
|
6243
|
+
if (declarator.id.type !== "ObjectPattern" || !declarator.init || !isGroupedUsageSource(declarator.init)) continue;
|
|
6247
6244
|
if (rootIdentifierName(declarator.init) === "locales") continue;
|
|
6248
6245
|
const sourceText = context.sourceCode.getText(declarator.init);
|
|
6249
6246
|
const usage = objectUsage(scope, sourceText);
|
|
6247
|
+
if (usage.directMembers.length > 0) continue;
|
|
6250
6248
|
const propertyNames = /* @__PURE__ */ new Set();
|
|
6251
6249
|
for (const property of declarator.id.properties) {
|
|
6252
6250
|
if (property.type !== "Property" || property.computed || property.key.type !== "Identifier") continue;
|
|
@@ -6404,6 +6402,9 @@ var preferObjectDestructuringRule = {
|
|
|
6404
6402
|
const enterUsageScope = (node) => {
|
|
6405
6403
|
usageScopes.push({ node, objects: /* @__PURE__ */ new Map() });
|
|
6406
6404
|
};
|
|
6405
|
+
const enterUsageBarrier = () => {
|
|
6406
|
+
usageScopes.push(void 0);
|
|
6407
|
+
};
|
|
6407
6408
|
const exitUsageScope = () => {
|
|
6408
6409
|
const scope = usageScopes.pop();
|
|
6409
6410
|
if (!scope) return;
|
|
@@ -6412,17 +6413,17 @@ var preferObjectDestructuringRule = {
|
|
|
6412
6413
|
const firstDirectUsage = usage.directMembers[0];
|
|
6413
6414
|
if (!firstDirectUsage) continue;
|
|
6414
6415
|
const { member: firstDirectMember } = firstDirectUsage;
|
|
6416
|
+
const propertyNames = [...usage.propertyNames];
|
|
6417
|
+
const missingPropertyNames = propertyNames.filter(
|
|
6418
|
+
(propertyName5) => !usage.destructuring?.propertyNames.has(propertyName5)
|
|
6419
|
+
);
|
|
6420
|
+
if (missingPropertyNames.some((propertyName5) => hasBinding(context, firstDirectMember, propertyName5))) {
|
|
6421
|
+
continue;
|
|
6422
|
+
}
|
|
6415
6423
|
context.report({
|
|
6416
6424
|
node: firstDirectMember,
|
|
6417
6425
|
message: scopeUsageMessage(sourceText, usage.propertyNames),
|
|
6418
6426
|
fix(fixer) {
|
|
6419
|
-
const propertyNames = [...usage.propertyNames];
|
|
6420
|
-
const missingPropertyNames = propertyNames.filter(
|
|
6421
|
-
(propertyName5) => !usage.destructuring?.propertyNames.has(propertyName5)
|
|
6422
|
-
);
|
|
6423
|
-
if (missingPropertyNames.some((propertyName5) => hasBinding(context, firstDirectMember, propertyName5))) {
|
|
6424
|
-
return null;
|
|
6425
|
-
}
|
|
6426
6427
|
const memberFixes = usage.directMembers.map(
|
|
6427
6428
|
({ member, propertyName: propertyName5 }) => fixer.replaceText(member, propertyName5)
|
|
6428
6429
|
);
|
|
@@ -6452,11 +6453,11 @@ ${indentation}`;
|
|
|
6452
6453
|
"Program:exit": exitUsageScope,
|
|
6453
6454
|
BlockStatement: enterUsageScope,
|
|
6454
6455
|
"BlockStatement:exit": exitUsageScope,
|
|
6455
|
-
FunctionDeclaration:
|
|
6456
|
+
FunctionDeclaration: enterUsageBarrier,
|
|
6456
6457
|
"FunctionDeclaration:exit": exitUsageScope,
|
|
6457
|
-
FunctionExpression:
|
|
6458
|
+
FunctionExpression: enterUsageBarrier,
|
|
6458
6459
|
"FunctionExpression:exit": exitUsageScope,
|
|
6459
|
-
ArrowFunctionExpression:
|
|
6460
|
+
ArrowFunctionExpression: enterUsageBarrier,
|
|
6460
6461
|
"ArrowFunctionExpression:exit": exitUsageScope,
|
|
6461
6462
|
MemberExpression(node) {
|
|
6462
6463
|
recordMemberUsage(context, currentUsageScope(), ownershipResolver, node);
|