npm package diff
Package: @forge/lint
Versions: 5.2.4-next.0-experimental-10722bc - 5.3.3-next.13
File: package/out/lint/linters/remote-linter/verifiers/invoke-remote-verifier.js
Index: package/out/lint/linters/remote-linter/verifiers/invoke-remote-verifier.js
===================================================================
--- package/out/lint/linters/remote-linter/verifiers/invoke-remote-verifier.js
+++ package/out/lint/linters/remote-linter/verifiers/invoke-remote-verifier.js
@@ -10,17 +10,21 @@
getLintClass() {
return linter_interface_1.LintClass.Error;
}
async process(input) {
- return input.invokeRemoteCalls
- .filter((call) => this.isValidCall(call, input.imports))
+ const validCalls = input.invokeRemoteCalls.filter((call) => this.isValidCall(call, input.imports));
+ const missingRemotes = validCalls
.filter((call) => !this.isRemoteKeyValid(call))
- .map((call) => ({
+ .map((call) => ({ call, message: text_1.messages.verifiers.invokeRemoteKey }));
+ const missingComputeOperation = validCalls
+ .filter((call) => this.isRemoteKeyValid(call) && !this.hasComputeOperation(call))
+ .map((call) => ({ call, message: text_1.messages.verifiers.invokeRemoteCompute }));
+ return [...missingRemotes, ...missingComputeOperation].map(({ call, message }) => ({
class: this.getLintClass(),
column: call.column,
line: call.line,
- message: text_1.messages.verifiers.invokeRemoteKey.message(call.remoteKey),
- reference: text_1.messages.verifiers.invokeRemoteKey.reference
+ message: message.message(call.remoteKey),
+ reference: message.reference
}));
}
isValidCall(call, imports) {
if (call.type === invoke_remote_interface_1.InvokeRemoteTypes.DIRECT_CALL) {
@@ -28,13 +32,17 @@
}
return imports.some((imp) => (imp.type === typescript_estree_1.AST_NODE_TYPES.ImportDefaultSpecifier || imp.type === typescript_estree_1.AST_NODE_TYPES.ImportNamespaceSpecifier) &&
call.objectName === imp.alias);
}
+ getRemoteForCall(call) {
+ return this.manifest.remotes?.find((remote) => remote.key === call.remoteKey);
+ }
isRemoteKeyValid(call) {
- const remotes = this.manifest.remotes;
- if (!remotes) {
- return false;
- }
- return remotes.some((remote) => remote.key === call.remoteKey);
+ const remote = this.getRemoteForCall(call);
+ return typeof remote !== 'undefined';
}
+ hasComputeOperation(call) {
+ const remote = this.getRemoteForCall(call);
+ return remote?.operations?.includes('compute') ?? false;
+ }
}
exports.InvokeRemoteVerifier = InvokeRemoteVerifier;