pasika 0.10.70 → 0.10.72
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 +21 -1
- package/package.json +1 -1
|
@@ -44,6 +44,11 @@ function importedContractMember(expression, propertyName4, imports) {
|
|
|
44
44
|
}
|
|
45
45
|
return expression.object.name;
|
|
46
46
|
}
|
|
47
|
+
function isImportedContractReference(expression, imports) {
|
|
48
|
+
if (expression.type === "Identifier") return imports.has(expression.name);
|
|
49
|
+
if (expression.type !== "MemberExpression" || expression.object.type !== "Identifier") return false;
|
|
50
|
+
return imports.has(expression.object.name);
|
|
51
|
+
}
|
|
47
52
|
function responseSchemaParserContract(callee, imports) {
|
|
48
53
|
if (callee.type === "Super" || callee.type !== "MemberExpression" || memberPropertyName(callee) !== "parse") {
|
|
49
54
|
return void 0;
|
|
@@ -136,7 +141,7 @@ var apiContractRule = {
|
|
|
136
141
|
const contractProperty = objectProperty(options, "contract");
|
|
137
142
|
if (contractProperty) {
|
|
138
143
|
const value = contractProperty.value;
|
|
139
|
-
if (!(value
|
|
144
|
+
if (!isImportedContractReference(value, imports)) {
|
|
140
145
|
context.report({ node: value, message: CLIENT_CONTRACT });
|
|
141
146
|
}
|
|
142
147
|
return;
|
|
@@ -374,6 +379,19 @@ function parseModule(file) {
|
|
|
374
379
|
if (!ts.isStringLiteral(specifierNode)) return;
|
|
375
380
|
imports.push({ specifier: specifierNode.text, names, line: lineOf(sourceFile, node) });
|
|
376
381
|
};
|
|
382
|
+
const namespaceMemberNames = (namespace) => {
|
|
383
|
+
const names = /* @__PURE__ */ new Set();
|
|
384
|
+
const visit = (node) => {
|
|
385
|
+
if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === namespace) {
|
|
386
|
+
names.add(node.name.text);
|
|
387
|
+
} else if (ts.isElementAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === namespace && ts.isStringLiteral(node.argumentExpression)) {
|
|
388
|
+
names.add(node.argumentExpression.text);
|
|
389
|
+
}
|
|
390
|
+
ts.forEachChild(node, visit);
|
|
391
|
+
};
|
|
392
|
+
visit(sourceFile);
|
|
393
|
+
return [...names];
|
|
394
|
+
};
|
|
377
395
|
for (const statement of sourceFile.statements) {
|
|
378
396
|
if (ts.isImportDeclaration(statement)) {
|
|
379
397
|
const names = [];
|
|
@@ -381,6 +399,8 @@ function parseModule(file) {
|
|
|
381
399
|
if (statement.importClause?.name) names.push(statement.importClause.name.text);
|
|
382
400
|
if (bindings && ts.isNamedImports(bindings)) {
|
|
383
401
|
for (const element of bindings.elements) names.push(element.propertyName?.text ?? element.name.text);
|
|
402
|
+
} else if (bindings && ts.isNamespaceImport(bindings)) {
|
|
403
|
+
names.push(...namespaceMemberNames(bindings.name.text));
|
|
384
404
|
}
|
|
385
405
|
addImport(statement.moduleSpecifier, names, statement);
|
|
386
406
|
continue;
|