@forge/lint 5.2.4-next.0 → 5.3.0-next.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @forge/lint
2
2
 
3
+ ## 5.3.0-next.1
4
+
5
+ ### Minor Changes
6
+
7
+ - 8cf085b: Improve linting to check for invokeRemote compute classification
8
+
3
9
  ## 5.2.4-next.0
4
10
 
5
11
  ### Patch Changes
@@ -5,6 +5,8 @@ export declare class InvokeRemoteVerifier extends BaseLintIssueVerifier implemen
5
5
  protected getLintClass(): LintClass;
6
6
  process(input: InvokeRemoteVerifierInput): Promise<LintResultRule[]>;
7
7
  private isValidCall;
8
+ private getRemoteForCall;
8
9
  private isRemoteKeyValid;
10
+ private hasComputeOperation;
9
11
  }
10
12
  //# sourceMappingURL=invoke-remote-verifier.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"invoke-remote-verifier.d.ts","sourceRoot":"","sources":["../../../../../src/lint/linters/remote-linter/verifiers/invoke-remote-verifier.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEtE,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACpF,OAAO,EAIL,yBAAyB,EAC1B,MAAM,4BAA4B,CAAC;AAEpC,qBAAa,oBACX,SAAQ,qBACR,YAAW,iBAAiB,CAAC,yBAAyB,CAAC;IAEvD,SAAS,CAAC,YAAY,IAAI,SAAS;IAItB,OAAO,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAgBjF,OAAO,CAAC,WAAW;IAYnB,OAAO,CAAC,gBAAgB;CASzB"}
1
+ {"version":3,"file":"invoke-remote-verifier.d.ts","sourceRoot":"","sources":["../../../../../src/lint/linters/remote-linter/verifiers/invoke-remote-verifier.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEtE,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACpF,OAAO,EAIL,yBAAyB,EAC1B,MAAM,4BAA4B,CAAC;AAEpC,qBAAa,oBACX,SAAQ,qBACR,YAAW,iBAAiB,CAAC,yBAAyB,CAAC;IAEvD,SAAS,CAAC,YAAY,IAAI,SAAS;IAItB,OAAO,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAuBjF,OAAO,CAAC,WAAW;IAcnB,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,mBAAmB;CAK5B"}
@@ -11,15 +11,19 @@ class InvokeRemoteVerifier extends verifier_interface_1.BaseLintIssueVerifier {
11
11
  return linter_interface_1.LintClass.Error;
12
12
  }
13
13
  async process(input) {
14
- return input.invokeRemoteCalls
15
- .filter((call) => this.isValidCall(call, input.imports))
14
+ const validCalls = input.invokeRemoteCalls.filter((call) => this.isValidCall(call, input.imports));
15
+ const missingRemotes = validCalls
16
16
  .filter((call) => !this.isRemoteKeyValid(call))
17
- .map((call) => ({
17
+ .map((call) => ({ call, message: text_1.messages.verifiers.invokeRemoteKey }));
18
+ const missingComputeOperation = validCalls
19
+ .filter((call) => this.isRemoteKeyValid(call) && !this.hasComputeOperation(call))
20
+ .map((call) => ({ call, message: text_1.messages.verifiers.invokeRemoteCompute }));
21
+ return [...missingRemotes, ...missingComputeOperation].map(({ call, message }) => ({
18
22
  class: this.getLintClass(),
19
23
  column: call.column,
20
24
  line: call.line,
21
- message: text_1.messages.verifiers.invokeRemoteKey.message(call.remoteKey),
22
- reference: text_1.messages.verifiers.invokeRemoteKey.reference
25
+ message: message.message(call.remoteKey),
26
+ reference: message.reference
23
27
  }));
24
28
  }
25
29
  isValidCall(call, imports) {
@@ -29,12 +33,16 @@ class InvokeRemoteVerifier extends verifier_interface_1.BaseLintIssueVerifier {
29
33
  return imports.some((imp) => (imp.type === typescript_estree_1.AST_NODE_TYPES.ImportDefaultSpecifier || imp.type === typescript_estree_1.AST_NODE_TYPES.ImportNamespaceSpecifier) &&
30
34
  call.objectName === imp.alias);
31
35
  }
36
+ getRemoteForCall(call) {
37
+ return this.manifest.remotes?.find((remote) => remote.key === call.remoteKey);
38
+ }
32
39
  isRemoteKeyValid(call) {
33
- const remotes = this.manifest.remotes;
34
- if (!remotes) {
35
- return false;
36
- }
37
- return remotes.some((remote) => remote.key === call.remoteKey);
40
+ const remote = this.getRemoteForCall(call);
41
+ return typeof remote !== 'undefined';
42
+ }
43
+ hasComputeOperation(call) {
44
+ const remote = this.getRemoteForCall(call);
45
+ return remote?.operations?.includes('compute') ?? false;
38
46
  }
39
47
  }
40
48
  exports.InvokeRemoteVerifier = InvokeRemoteVerifier;
@@ -21,6 +21,10 @@ export declare const messages: {
21
21
  message: (remoteKey: string) => string;
22
22
  reference: string;
23
23
  };
24
+ invokeRemoteCompute: {
25
+ message: (remoteKey: string) => string;
26
+ reference: string;
27
+ };
24
28
  handler: {
25
29
  message: (method: string, key: string) => string;
26
30
  reference: string;
@@ -1 +1 @@
1
- {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/lint/text/messages.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ;;;+BAGI,MAAM,UAAU,MAAM,SAAS,MAAM,KAAG,MAAM;;;;2BAKlD,MAAM;;;;2BAKN,MAAM;2BAER,MAAM;;;;2BAKJ,MAAM;;;;iCAKA,MAAM;;;;8BAKT,MAAM,OAAO,MAAM;;;;+BAKlB,MAAM,UAAU,MAAM,QAAQ,MAAM,GAAG,SAAS,SAAS,MAAM;;;;6BAKjE,MAAM;;;;+BAIJ,MAAM,QAAQ,MAAM,SAAS,MAAM;;;;CAK3D,CAAC"}
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/lint/text/messages.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ;;;+BAGI,MAAM,UAAU,MAAM,SAAS,MAAM,KAAG,MAAM;;;;2BAKlD,MAAM;;;;2BAKN,MAAM;2BAER,MAAM;;;;2BAKJ,MAAM;;;;iCAKA,MAAM;;;;iCAKN,MAAM;;;;8BAKT,MAAM,OAAO,MAAM;;;;+BAKlB,MAAM,UAAU,MAAM,QAAQ,MAAM,GAAG,SAAS,SAAS,MAAM;;;;6BAKjE,MAAM;;;;+BAIJ,MAAM,QAAQ,MAAM,SAAS,MAAM;;;;CAK3D,CAAC"}
@@ -24,6 +24,10 @@ exports.messages = {
24
24
  message: (remoteKey) => `The remote key "${remoteKey}" does not exist in the "remotes" section of your app's manifest.yml file`,
25
25
  reference: 'missing-remote-key'
26
26
  },
27
+ invokeRemoteCompute: {
28
+ message: (remoteKey) => `The remote key "${remoteKey}" does not have a compute operation defined in the "remotes" section of your app's manifest.yml file`,
29
+ reference: 'missing-remote-compute'
30
+ },
27
31
  handler: {
28
32
  message: (method, key) => `Cannot find exported function "${method}", which is required by module "${key}" handler defined in your app's manifest.yml file`,
29
33
  reference: 'valid-module-required'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/lint",
3
- "version": "5.2.4-next.0",
3
+ "version": "5.3.0-next.1",
4
4
  "description": "Linting for forge apps",
5
5
  "main": "out/index.js",
6
6
  "license": "UNLICENSED",