@forge/lint 5.0.2-next.1 → 5.0.2

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/out/lint/abstract-linter.js +0 -1
  3. package/out/lint/base-linter.js +3 -5
  4. package/out/lint/lint.js +1 -1
  5. package/out/lint/linter-interface.js +2 -4
  6. package/out/lint/linters/dynamic-properties-linter/dynamic-properties-permissions-linter.js +0 -1
  7. package/out/lint/linters/dynamic-properties-linter/verifiers/abstract-dynamic-properties-verifier.js +3 -2
  8. package/out/lint/linters/dynamic-properties-linter/verifiers/dynamic-properties-icon-verifier.js +2 -2
  9. package/out/lint/linters/dynamic-properties-linter/visitors/abstract-icon-visitor.js +22 -19
  10. package/out/lint/linters/dynamic-properties-linter/visitors/confluence-icon-visitor.js +8 -5
  11. package/out/lint/linters/dynamic-properties-linter/visitors/jira-icon-visitor.js +31 -28
  12. package/out/lint/linters/handler-linter/handler-linter.js +6 -9
  13. package/out/lint/linters/handler-linter/verifiers/handlers-verifier.js +2 -1
  14. package/out/lint/linters/handler-linter/visitors/exported-function-node-visitor.js +14 -15
  15. package/out/lint/linters/manifest-linter/abstract-manifest-linter.js +5 -5
  16. package/out/lint/linters/manifest-linter/deprecated-csp-permissions-manifest-linter.js +2 -1
  17. package/out/lint/linters/manifest-linter/permissions-manifest-linter.js +2 -1
  18. package/out/lint/linters/manifest-linter/remote-compute-manifest-linter.js +2 -1
  19. package/out/lint/linters/permission-linter/permission-linter.js +22 -43
  20. package/out/lint/linters/permission-linter/verifiers/content-property-verifier.js +2 -1
  21. package/out/lint/linters/permission-linter/verifiers/external-fetch-verifier.js +4 -4
  22. package/out/lint/linters/permission-linter/verifiers/image-url-verifier.js +2 -2
  23. package/out/lint/linters/permission-linter/verifiers/product-verifier.js +12 -15
  24. package/out/lint/linters/permission-linter/verifiers/storage-api-verifier.js +4 -9
  25. package/out/lint/linters/permission-linter/verifiers/ui-hook-verifier.js +2 -1
  26. package/out/lint/linters/permission-linter/visitors/external-fetch-call-visitor.js +13 -11
  27. package/out/lint/linters/permission-linter/visitors/image-url-visitor.js +2 -2
  28. package/out/lint/linters/permission-linter/visitors/product-node-visitor.js +3 -3
  29. package/out/lint/linters/permission-linter/visitors/storage-api-node-visitor.js +1 -4
  30. package/out/lint/linters/permission-linter/visitors/ui-hook-node-visitor.js +1 -5
  31. package/out/lint/linters/verifier-interface.js +0 -2
  32. package/out/parse/parser.js +2 -10
  33. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @forge/lint
2
2
 
3
+ ## 5.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [d72f638]
8
+ - Updated dependencies [9eee9ac]
9
+ - Updated dependencies [937db7a]
10
+ - @forge/manifest@7.2.0
11
+ - @forge/cli-shared@4.0.1
12
+
13
+ ## 5.0.2-next.2
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [937db7a]
18
+ - @forge/cli-shared@4.0.1-next.2
19
+ - @forge/manifest@7.2.0-next.2
20
+
3
21
  ## 5.0.2-next.1
4
22
 
5
23
  ### Patch Changes
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AbstractLinter = void 0;
4
4
  const cli_shared_1 = require("@forge/cli-shared");
5
5
  class AbstractLinter {
6
- logger;
7
6
  constructor(logger) {
8
7
  this.logger = logger;
9
8
  }
@@ -4,15 +4,13 @@ const cli_shared_1 = require("@forge/cli-shared");
4
4
  const linter_interface_1 = require("./linter-interface");
5
5
  const abstract_linter_1 = require("./abstract-linter");
6
6
  class BaseLinter extends abstract_linter_1.AbstractLinter {
7
- environment;
8
- logger;
9
- nodeVisitors = [];
10
- matches = new Map();
11
- verifiers = {};
12
7
  constructor(environment, logger) {
13
8
  super(logger);
14
9
  this.environment = environment;
15
10
  this.logger = logger;
11
+ this.nodeVisitors = [];
12
+ this.matches = new Map();
13
+ this.verifiers = {};
16
14
  }
17
15
  getFixer() {
18
16
  return undefined;
package/out/lint/lint.js CHANGED
@@ -103,7 +103,7 @@ const lint = async (filesToLint, manifest, environment, logger, parseFunction =
103
103
  }
104
104
  }
105
105
  return { ast: null, filepath: '' };
106
- }))).filter((result) => !!result?.ast);
106
+ }))).filter((result) => !!(result === null || result === void 0 ? void 0 : result.ast));
107
107
  await Promise.all(linters.map((linter) => linter.bootstrap()));
108
108
  const results = await Promise.all(linters.map((linter) => linter.batchExecute(lintInputs))).then(cli_shared_1.flat);
109
109
  return results.map((result) => {
@@ -7,13 +7,11 @@ var LintClass;
7
7
  LintClass["Warning"] = "warning";
8
8
  })(LintClass = exports.LintClass || (exports.LintClass = {}));
9
9
  class LintResult {
10
- file;
11
- fixer;
12
- errors = [];
13
- warnings = [];
14
10
  constructor(file, fixer) {
15
11
  this.file = file;
16
12
  this.fixer = fixer;
13
+ this.errors = [];
14
+ this.warnings = [];
17
15
  }
18
16
  add(rule) {
19
17
  switch (rule.class) {
@@ -9,7 +9,6 @@ const confluence_icon_visitor_1 = require("./visitors/confluence-icon-visitor");
9
9
  const permission_linter_1 = require("../permission-linter/permission-linter");
10
10
  const jira_icon_visitor_1 = require("./visitors/jira-icon-visitor");
11
11
  class DynamicPropertiesPermissionsLinter extends base_linter_1.default {
12
- manifest;
13
12
  constructor(environment, manifest, logger) {
14
13
  super(environment, logger);
15
14
  this.manifest = manifest;
@@ -3,16 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AbstractDynamicPropertiesVerifier = void 0;
4
4
  const verifier_interface_1 = require("../../verifier-interface");
5
5
  class AbstractDynamicPropertiesVerifier extends verifier_interface_1.BaseLintIssueVerifier {
6
- shouldRunCheck = false;
7
6
  constructor(environment, manifest) {
8
7
  super(environment, manifest);
8
+ this.shouldRunCheck = false;
9
9
  Object.keys(this.manifest.modules || {}).forEach((moduleType) => {
10
+ var _a, _b;
10
11
  switch (moduleType) {
11
12
  case 'confluence:contentBylineItem':
12
13
  case 'jira:issueGlance':
13
14
  case 'jira:issueContext':
14
15
  this.shouldRunCheck =
15
- this.manifest.modules?.[moduleType]?.find((module) => module.dynamicProperties?.function) !==
16
+ ((_b = (_a = this.manifest.modules) === null || _a === void 0 ? void 0 : _a[moduleType]) === null || _b === void 0 ? void 0 : _b.find((module) => { var _a; return (_a = module.dynamicProperties) === null || _a === void 0 ? void 0 : _a.function; })) !==
16
17
  undefined;
17
18
  break;
18
19
  }
@@ -7,10 +7,10 @@ const utils_1 = require("../../utils");
7
7
  const text_1 = require("../../../text");
8
8
  const abstract_dynamic_properties_verifier_1 = require("./abstract-dynamic-properties-verifier");
9
9
  class DynamicPropertiesIconVerifier extends abstract_dynamic_properties_verifier_1.AbstractDynamicPropertiesVerifier {
10
- egressFilteringService;
11
10
  constructor(environment, manifest) {
11
+ var _a, _b, _c, _d;
12
12
  super(environment, manifest);
13
- const allowList = this.manifest?.permissions?.external?.images ?? [];
13
+ const allowList = (_d = (_c = (_b = (_a = this.manifest) === null || _a === void 0 ? void 0 : _a.permissions) === null || _b === void 0 ? void 0 : _b.external) === null || _c === void 0 ? void 0 : _c.images) !== null && _d !== void 0 ? _d : [];
14
14
  const collectedUrls = allowList.filter((item) => typeof item === 'string');
15
15
  this.egressFilteringService = new egress_1.EgressFilteringService(collectedUrls);
16
16
  }
@@ -3,36 +3,39 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AbstractIconVisitor = void 0;
4
4
  const typescript_estree_1 = require("@typescript-eslint/typescript-estree");
5
5
  class AbstractIconVisitor {
6
+ constructor() {
7
+ this.isBundledUri = (iconUri) => iconUri.startsWith('resource:') || iconUri.startsWith('data:image');
8
+ this.handleIconNode = (iconNode, callback) => {
9
+ if ((iconNode === null || iconNode === void 0 ? void 0 : iconNode.type) === typescript_estree_1.AST_NODE_TYPES.Literal && typeof (iconNode === null || iconNode === void 0 ? void 0 : iconNode.value) === 'string') {
10
+ if (iconNode.value.trim() !== '' && !this.isBundledUri(iconNode.value.trim())) {
11
+ const iconUrl = this.transformArgsToIconUrl(iconNode);
12
+ callback(iconUrl);
13
+ }
14
+ }
15
+ };
16
+ this.transformArgsToIconUrl = (iconNode) => ({
17
+ type: 'DYNAMIC_PROPERTIES_ICON',
18
+ url: iconNode.value,
19
+ line: iconNode.loc.start.line,
20
+ column: iconNode.loc.start.column
21
+ });
22
+ }
6
23
  visit(node, parent, callback) {
24
+ var _a, _b;
7
25
  switch (node.type) {
8
26
  case typescript_estree_1.AST_NODE_TYPES.ArrowFunctionExpression:
9
- if (node.body?.type === typescript_estree_1.AST_NODE_TYPES.ObjectExpression) {
27
+ if (((_a = node.body) === null || _a === void 0 ? void 0 : _a.type) === typescript_estree_1.AST_NODE_TYPES.ObjectExpression) {
10
28
  const iconDefinitionNode = this.getIconDefinitionNode(node.body);
11
- this.handleIconNode(iconDefinitionNode?.value, callback);
29
+ this.handleIconNode(iconDefinitionNode === null || iconDefinitionNode === void 0 ? void 0 : iconDefinitionNode.value, callback);
12
30
  }
13
31
  break;
14
32
  case typescript_estree_1.AST_NODE_TYPES.ReturnStatement:
15
- if (node.argument?.type === typescript_estree_1.AST_NODE_TYPES.ObjectExpression) {
33
+ if (((_b = node.argument) === null || _b === void 0 ? void 0 : _b.type) === typescript_estree_1.AST_NODE_TYPES.ObjectExpression) {
16
34
  const iconDefinitionNode = this.getIconDefinitionNode(node.argument);
17
- this.handleIconNode(iconDefinitionNode?.value, callback);
35
+ this.handleIconNode(iconDefinitionNode === null || iconDefinitionNode === void 0 ? void 0 : iconDefinitionNode.value, callback);
18
36
  }
19
37
  break;
20
38
  }
21
39
  }
22
- isBundledUri = (iconUri) => iconUri.startsWith('resource:') || iconUri.startsWith('data:image');
23
- handleIconNode = (iconNode, callback) => {
24
- if (iconNode?.type === typescript_estree_1.AST_NODE_TYPES.Literal && typeof iconNode?.value === 'string') {
25
- if (iconNode.value.trim() !== '' && !this.isBundledUri(iconNode.value.trim())) {
26
- const iconUrl = this.transformArgsToIconUrl(iconNode);
27
- callback(iconUrl);
28
- }
29
- }
30
- };
31
- transformArgsToIconUrl = (iconNode) => ({
32
- type: 'DYNAMIC_PROPERTIES_ICON',
33
- url: iconNode.value,
34
- line: iconNode.loc.start.line,
35
- column: iconNode.loc.start.column
36
- });
37
40
  }
38
41
  exports.AbstractIconVisitor = AbstractIconVisitor;
@@ -4,13 +4,16 @@ exports.ConfluenceIconVisitor = void 0;
4
4
  const typescript_estree_1 = require("@typescript-eslint/typescript-estree");
5
5
  const abstract_icon_visitor_1 = require("./abstract-icon-visitor");
6
6
  class ConfluenceIconVisitor extends abstract_icon_visitor_1.AbstractIconVisitor {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.isIconPropertyDefinition = (node) => {
10
+ return (node.type === typescript_estree_1.AST_NODE_TYPES.Property &&
11
+ ((node.key.type === typescript_estree_1.AST_NODE_TYPES.Identifier && node.key.name === 'icon') ||
12
+ (node.key.type === typescript_estree_1.AST_NODE_TYPES.Literal && node.key.value === 'icon')));
13
+ };
14
+ }
7
15
  getIconDefinitionNode(node) {
8
16
  return node.properties.find(this.isIconPropertyDefinition);
9
17
  }
10
- isIconPropertyDefinition = (node) => {
11
- return (node.type === typescript_estree_1.AST_NODE_TYPES.Property &&
12
- ((node.key.type === typescript_estree_1.AST_NODE_TYPES.Identifier && node.key.name === 'icon') ||
13
- (node.key.type === typescript_estree_1.AST_NODE_TYPES.Literal && node.key.value === 'icon')));
14
- };
15
18
  }
16
19
  exports.ConfluenceIconVisitor = ConfluenceIconVisitor;
@@ -4,37 +4,40 @@ exports.JiraIconVisitor = void 0;
4
4
  const typescript_estree_1 = require("@typescript-eslint/typescript-estree");
5
5
  const abstract_icon_visitor_1 = require("./abstract-icon-visitor");
6
6
  class JiraIconVisitor extends abstract_icon_visitor_1.AbstractIconVisitor {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.isStatusPropertyDefinition = (node) => {
10
+ return (node.type === typescript_estree_1.AST_NODE_TYPES.Property &&
11
+ ((node.key.type === typescript_estree_1.AST_NODE_TYPES.Literal && node.key.value === 'status') ||
12
+ (node.key.type === typescript_estree_1.AST_NODE_TYPES.Identifier && node.key.name === 'status')) &&
13
+ node.value.type === typescript_estree_1.AST_NODE_TYPES.ObjectExpression &&
14
+ node.value.properties.find((prop) => {
15
+ return (prop.type === typescript_estree_1.AST_NODE_TYPES.Property &&
16
+ ((prop.key.type === typescript_estree_1.AST_NODE_TYPES.Literal && prop.key.value === 'type') ||
17
+ (prop.key.type === typescript_estree_1.AST_NODE_TYPES.Identifier && prop.key.name === 'type')) &&
18
+ ((prop.value.type === typescript_estree_1.AST_NODE_TYPES.Literal && prop.value.value === 'icon') ||
19
+ (prop.value.type === typescript_estree_1.AST_NODE_TYPES.Identifier && prop.value.name === 'icon')));
20
+ }) !== undefined);
21
+ };
22
+ this.extractIconDefinition = (node) => {
23
+ if (!node) {
24
+ return undefined;
25
+ }
26
+ const valueDefinitionNode = node === null || node === void 0 ? void 0 : node.value.properties.find((prop) => {
27
+ return (prop.type === typescript_estree_1.AST_NODE_TYPES.Property &&
28
+ ((prop.key.type === typescript_estree_1.AST_NODE_TYPES.Literal && prop.key.value === 'value') ||
29
+ (prop.key.type === typescript_estree_1.AST_NODE_TYPES.Identifier && prop.key.name === 'value')));
30
+ });
31
+ return valueDefinitionNode.value.properties.find((prop) => {
32
+ return (prop.type === typescript_estree_1.AST_NODE_TYPES.Property &&
33
+ ((prop.key.type === typescript_estree_1.AST_NODE_TYPES.Literal && prop.key.value === 'url') ||
34
+ (prop.key.type === typescript_estree_1.AST_NODE_TYPES.Identifier && prop.key.name === 'url')));
35
+ });
36
+ };
37
+ }
7
38
  getIconDefinitionNode(node) {
8
39
  const statusPropertyNode = node.properties.find(this.isStatusPropertyDefinition);
9
40
  return this.extractIconDefinition(statusPropertyNode);
10
41
  }
11
- isStatusPropertyDefinition = (node) => {
12
- return (node.type === typescript_estree_1.AST_NODE_TYPES.Property &&
13
- ((node.key.type === typescript_estree_1.AST_NODE_TYPES.Literal && node.key.value === 'status') ||
14
- (node.key.type === typescript_estree_1.AST_NODE_TYPES.Identifier && node.key.name === 'status')) &&
15
- node.value.type === typescript_estree_1.AST_NODE_TYPES.ObjectExpression &&
16
- node.value.properties.find((prop) => {
17
- return (prop.type === typescript_estree_1.AST_NODE_TYPES.Property &&
18
- ((prop.key.type === typescript_estree_1.AST_NODE_TYPES.Literal && prop.key.value === 'type') ||
19
- (prop.key.type === typescript_estree_1.AST_NODE_TYPES.Identifier && prop.key.name === 'type')) &&
20
- ((prop.value.type === typescript_estree_1.AST_NODE_TYPES.Literal && prop.value.value === 'icon') ||
21
- (prop.value.type === typescript_estree_1.AST_NODE_TYPES.Identifier && prop.value.name === 'icon')));
22
- }) !== undefined);
23
- };
24
- extractIconDefinition = (node) => {
25
- if (!node) {
26
- return undefined;
27
- }
28
- const valueDefinitionNode = node?.value.properties.find((prop) => {
29
- return (prop.type === typescript_estree_1.AST_NODE_TYPES.Property &&
30
- ((prop.key.type === typescript_estree_1.AST_NODE_TYPES.Literal && prop.key.value === 'value') ||
31
- (prop.key.type === typescript_estree_1.AST_NODE_TYPES.Identifier && prop.key.name === 'value')));
32
- });
33
- return valueDefinitionNode.value.properties.find((prop) => {
34
- return (prop.type === typescript_estree_1.AST_NODE_TYPES.Property &&
35
- ((prop.key.type === typescript_estree_1.AST_NODE_TYPES.Literal && prop.key.value === 'url') ||
36
- (prop.key.type === typescript_estree_1.AST_NODE_TYPES.Identifier && prop.key.name === 'url')));
37
- });
38
- };
39
42
  }
40
43
  exports.JiraIconVisitor = JiraIconVisitor;
@@ -7,10 +7,10 @@ const base_linter_1 = tslib_1.__importDefault(require("../../base-linter"));
7
7
  const handlers_verifier_1 = require("./verifiers/handlers-verifier");
8
8
  const visitors_1 = require("./visitors");
9
9
  class HandlerLinter extends base_linter_1.default {
10
- manifest;
11
10
  constructor(environment, manifest, logger) {
12
11
  super(environment, logger);
13
12
  this.manifest = manifest;
13
+ this.getHandlerFileRegex = (fileName) => new RegExp(`^src(\/|\\\\)${fileName}\.[tj](s|sx)$`);
14
14
  }
15
15
  async bootstrap() {
16
16
  this.nodeVisitors = [new visitors_1.ExportedFunctionNodeVisitor()];
@@ -19,23 +19,20 @@ class HandlerLinter extends base_linter_1.default {
19
19
  functionHandlers: new handlers_verifier_1.HandlersVerifier(humanReadableEnvironment, this.manifest)
20
20
  };
21
21
  }
22
- getHandlerFileRegex = (fileName) => new RegExp(`^src(\/|\\\\)${fileName}\.[tj](s|sx)$`);
23
22
  getFunctionHandlers(manifest) {
24
- return manifest.modules?.function
25
- ?.filter((funcs) => funcs.handler && funcs.handler.split('.').length === 2)
26
- ?.map((funcs) => {
23
+ var _a, _b, _c;
24
+ return (_c = (_b = (_a = manifest.modules) === null || _a === void 0 ? void 0 : _a.function) === null || _b === void 0 ? void 0 : _b.filter((funcs) => funcs.handler && funcs.handler.split('.').length === 2)) === null || _c === void 0 ? void 0 : _c.map((funcs) => {
27
25
  const [file, method] = funcs.handler.split('.');
28
26
  return {
29
27
  file,
30
28
  method,
31
29
  key: funcs.key
32
30
  };
33
- })
34
- .filter((handler) => handler.method && handler.file);
31
+ }).filter((handler) => handler.method && handler.file);
35
32
  }
36
33
  setupMatchesMap(filepath) {
37
34
  const handlers = this.getFunctionHandlers(this.manifest);
38
- const filteredHandlers = handlers?.filter((handler) => this.getHandlerFileRegex(handler.file).test(filepath));
35
+ const filteredHandlers = handlers === null || handlers === void 0 ? void 0 : handlers.filter((handler) => this.getHandlerFileRegex(handler.file).test(filepath));
39
36
  this.matches.set(filepath, {
40
37
  functionHandlers: {
41
38
  expectedMethods: filteredHandlers || [],
@@ -45,7 +42,7 @@ class HandlerLinter extends base_linter_1.default {
45
42
  }
46
43
  filterLintInput(inputs) {
47
44
  const handlers = this.getFunctionHandlers(this.manifest);
48
- return inputs.filter((input) => handlers?.find((handler) => this.getHandlerFileRegex(handler.file).test(input.filepath)));
45
+ return inputs.filter((input) => handlers === null || handlers === void 0 ? void 0 : handlers.find((handler) => this.getHandlerFileRegex(handler.file).test(input.filepath)));
49
46
  }
50
47
  addLintCriteriaMatch(exportedMethod, filepath) {
51
48
  const criteriaMatches = this.matches.get(filepath);
@@ -9,7 +9,8 @@ class HandlersVerifier extends verifier_interface_1.BaseLintIssueVerifier {
9
9
  return linter_interface_1.LintClass.Warning;
10
10
  }
11
11
  async process(input) {
12
- if (!this.manifest?.modules?.function) {
12
+ var _a, _b;
13
+ if (!((_b = (_a = this.manifest) === null || _a === void 0 ? void 0 : _a.modules) === null || _b === void 0 ? void 0 : _b.function)) {
13
14
  return [];
14
15
  }
15
16
  const missingMethods = input.expectedMethods.filter((func) => !input.exportedMethods.find((exportedMethod) => exportedMethod.method === func.method));
@@ -23,20 +23,21 @@ class ExportedFunctionNodeVisitor {
23
23
  }
24
24
  visitSpecifiedNamedExports(node, specifier, callback) {
25
25
  if (specifier.type === typescript_estree_1.AST_NODE_TYPES.ExportSpecifier && specifier.local.type === typescript_estree_1.AST_NODE_TYPES.Identifier) {
26
- callback(this.createExportedMethod(specifier.exported.name, { ...node.loc.start }));
26
+ callback(this.createExportedMethod(specifier.exported.name, Object.assign({}, node.loc.start)));
27
27
  }
28
28
  }
29
29
  visitInlineNamedExport(node, callback) {
30
- if (node.declaration?.type === typescript_estree_1.AST_NODE_TYPES.VariableDeclaration) {
30
+ var _a, _b, _c, _d;
31
+ if (((_a = node.declaration) === null || _a === void 0 ? void 0 : _a.type) === typescript_estree_1.AST_NODE_TYPES.VariableDeclaration) {
31
32
  node.declaration.declarations.forEach((declarator) => {
32
33
  if (declarator.id && declarator.id.type === typescript_estree_1.AST_NODE_TYPES.Identifier) {
33
- callback(this.createExportedMethod(declarator.id.name, { ...declarator.id.loc.start }));
34
+ callback(this.createExportedMethod(declarator.id.name, Object.assign({}, declarator.id.loc.start)));
34
35
  }
35
36
  });
36
37
  }
37
- else if (node.declaration?.type === typescript_estree_1.AST_NODE_TYPES.FunctionDeclaration) {
38
- if (node.declaration?.id && node.declaration?.id.type === typescript_estree_1.AST_NODE_TYPES.Identifier) {
39
- callback(this.createExportedMethod(node.declaration.id.name, { ...node.declaration.id.loc.start }));
38
+ else if (((_b = node.declaration) === null || _b === void 0 ? void 0 : _b.type) === typescript_estree_1.AST_NODE_TYPES.FunctionDeclaration) {
39
+ if (((_c = node.declaration) === null || _c === void 0 ? void 0 : _c.id) && ((_d = node.declaration) === null || _d === void 0 ? void 0 : _d.id.type) === typescript_estree_1.AST_NODE_TYPES.Identifier) {
40
+ callback(this.createExportedMethod(node.declaration.id.name, Object.assign({}, node.declaration.id.loc.start)));
40
41
  }
41
42
  }
42
43
  }
@@ -47,23 +48,21 @@ class ExportedFunctionNodeVisitor {
47
48
  }
48
49
  visitMemberExpression(node, callback) {
49
50
  if (node.property.type === typescript_estree_1.AST_NODE_TYPES.Identifier && this.isExports(node.object)) {
50
- callback(this.createExportedMethod(node.property.name, { ...node.property.loc.start }));
51
+ callback(this.createExportedMethod(node.property.name, Object.assign({}, node.property.loc.start)));
51
52
  }
52
53
  }
53
54
  tryAddObjectExpressionPropertiesExportedMethods(node, callback) {
54
- if (node.right?.type === typescript_estree_1.AST_NODE_TYPES.ObjectExpression) {
55
- node.right.properties?.forEach((property) => {
55
+ var _a, _b;
56
+ if (((_a = node.right) === null || _a === void 0 ? void 0 : _a.type) === typescript_estree_1.AST_NODE_TYPES.ObjectExpression) {
57
+ (_b = node.right.properties) === null || _b === void 0 ? void 0 : _b.forEach((property) => {
56
58
  if (property.key.type === typescript_estree_1.AST_NODE_TYPES.Identifier) {
57
- callback(this.createExportedMethod(property.key.name, { ...property.key.loc.start }));
59
+ callback(this.createExportedMethod(property.key.name, Object.assign({}, property.key.loc.start)));
58
60
  }
59
61
  });
60
62
  }
61
63
  }
62
64
  createExportedMethod(method, location) {
63
- return {
64
- method,
65
- ...location
66
- };
65
+ return Object.assign({ method }, location);
67
66
  }
68
67
  isExports(node) {
69
68
  return ((node.type === typescript_estree_1.AST_NODE_TYPES.MemberExpression &&
@@ -71,7 +70,7 @@ class ExportedFunctionNodeVisitor {
71
70
  node.object.name === 'module' &&
72
71
  node.property.type === typescript_estree_1.AST_NODE_TYPES.Identifier &&
73
72
  node.property.name === 'exports') ||
74
- (node?.type === typescript_estree_1.AST_NODE_TYPES.Identifier && node?.name === 'exports'));
73
+ ((node === null || node === void 0 ? void 0 : node.type) === typescript_estree_1.AST_NODE_TYPES.Identifier && (node === null || node === void 0 ? void 0 : node.name) === 'exports'));
75
74
  }
76
75
  }
77
76
  exports.ExportedFunctionNodeVisitor = ExportedFunctionNodeVisitor;
@@ -5,15 +5,14 @@ const manifest_1 = require("@forge/manifest");
5
5
  const linter_interface_1 = require("../../linter-interface");
6
6
  const abstract_linter_1 = require("../../abstract-linter");
7
7
  class AbstractManifestLinter extends abstract_linter_1.AbstractLinter {
8
- type;
9
- processor;
10
8
  constructor(type, logger) {
11
9
  super(logger);
12
10
  this.type = type;
13
11
  }
14
12
  mapManifestResponse(results, fixer) {
13
+ var _a;
15
14
  const manifestLintResults = new linter_interface_1.LintResult(manifest_1.MANIFEST_FILE, fixer);
16
- manifestLintResults.batchAdd(...(this.getResultsForFixer(results).map(({ level, message, line, column, reference, metadata }) => {
15
+ manifestLintResults.batchAdd(...((_a = this.getResultsForFixer(results).map(({ level, message, line, column, reference, metadata }) => {
17
16
  return {
18
17
  class: level,
19
18
  message,
@@ -22,7 +21,7 @@ class AbstractManifestLinter extends abstract_linter_1.AbstractLinter {
22
21
  column,
23
22
  metadata
24
23
  };
25
- }) ?? []).sort((a, b) => a.line - b.line));
24
+ })) !== null && _a !== void 0 ? _a : []).sort((a, b) => a.line - b.line));
26
25
  return manifestLintResults;
27
26
  }
28
27
  getProcessor() {
@@ -43,7 +42,8 @@ class AbstractManifestLinter extends abstract_linter_1.AbstractLinter {
43
42
  return undefined;
44
43
  }
45
44
  getResultsForFixer(results) {
46
- return results.errors?.filter((error) => !error.metadata) || [];
45
+ var _a;
46
+ return ((_a = results.errors) === null || _a === void 0 ? void 0 : _a.filter((error) => !error.metadata)) || [];
47
47
  }
48
48
  }
49
49
  exports.AbstractManifestLinter = AbstractManifestLinter;
@@ -12,7 +12,8 @@ class DeprecatedCspPermissionsManifestLinter extends abstract_manifest_linter_1.
12
12
  return permission_linter_1.fixMissingPermissions;
13
13
  }
14
14
  getResultsForFixer(results) {
15
- return results.errors?.filter((error) => error.metadata?.missingContentStylePermission) || [];
15
+ var _a;
16
+ return ((_a = results.errors) === null || _a === void 0 ? void 0 : _a.filter((error) => { var _a; return (_a = error.metadata) === null || _a === void 0 ? void 0 : _a.missingContentStylePermission; })) || [];
16
17
  }
17
18
  }
18
19
  exports.DeprecatedCspPermissionsManifestLinter = DeprecatedCspPermissionsManifestLinter;
@@ -12,7 +12,8 @@ class PermissionsManifestLinter extends abstract_manifest_linter_1.AbstractManif
12
12
  return permission_linter_1.fixMissingPermissions;
13
13
  }
14
14
  getResultsForFixer(results) {
15
- return results.errors?.filter((error) => error.metadata?.missingPermission) || [];
15
+ var _a;
16
+ return ((_a = results.errors) === null || _a === void 0 ? void 0 : _a.filter((error) => { var _a; return (_a = error.metadata) === null || _a === void 0 ? void 0 : _a.missingPermission; })) || [];
16
17
  }
17
18
  }
18
19
  exports.PermissionsManifestLinter = PermissionsManifestLinter;
@@ -12,7 +12,8 @@ class RemoteComputeManifestLinter extends abstract_manifest_linter_1.AbstractMan
12
12
  return permission_linter_1.fixMissingPermissions;
13
13
  }
14
14
  getResultsForFixer(results) {
15
- return results.errors?.filter((error) => error.metadata?.missingPermission) || [];
15
+ var _a;
16
+ return ((_a = results.errors) === null || _a === void 0 ? void 0 : _a.filter((error) => { var _a; return (_a = error.metadata) === null || _a === void 0 ? void 0 : _a.missingPermission; })) || [];
16
17
  }
17
18
  }
18
19
  exports.RemoteComputeManifestLinter = RemoteComputeManifestLinter;
@@ -32,70 +32,47 @@ const findMissingPermissions = (errors, warnings, permissionsType, state) => {
32
32
  };
33
33
  exports.findMissingPermissions = findMissingPermissions;
34
34
  const fixMissingPermissions = async (errors, warnings, state) => {
35
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
35
36
  const missingScopes = (0, exports.findMissingPermissions)(errors, warnings, 'missingPermission', state);
36
37
  const missingExternalFetchBackend = (0, exports.findMissingPermissions)(errors, warnings, 'missingExternalFetchPermission', state);
37
38
  const missingContentStyle = (0, exports.findMissingPermissions)(errors, warnings, 'missingContentStylePermission', state);
38
39
  const missingExternalImage = (0, exports.findMissingPermissions)(errors, warnings, 'missingExternalImagesPermission', state);
39
- const currentPermissions = (await state.configFile.readConfig())?.permissions ?? {};
40
- const currentRemotes = (await state.configFile.readConfig())?.remotes ?? [];
41
- const currentScopes = currentPermissions?.scopes ?? [];
40
+ const currentPermissions = (_b = (_a = (await state.configFile.readConfig())) === null || _a === void 0 ? void 0 : _a.permissions) !== null && _b !== void 0 ? _b : {};
41
+ const currentRemotes = (_d = (_c = (await state.configFile.readConfig())) === null || _c === void 0 ? void 0 : _c.remotes) !== null && _d !== void 0 ? _d : [];
42
+ const currentScopes = (_e = currentPermissions === null || currentPermissions === void 0 ? void 0 : currentPermissions.scopes) !== null && _e !== void 0 ? _e : [];
42
43
  currentScopes.forEach((e) => missingScopes.add(e));
43
- const currentExternalFetchBackend = currentPermissions?.external?.fetch?.backend ?? [];
44
+ const currentExternalFetchBackend = (_h = (_g = (_f = currentPermissions === null || currentPermissions === void 0 ? void 0 : currentPermissions.external) === null || _f === void 0 ? void 0 : _f.fetch) === null || _g === void 0 ? void 0 : _g.backend) !== null && _h !== void 0 ? _h : [];
44
45
  currentExternalFetchBackend
45
46
  .map((item) => {
47
+ var _a;
46
48
  if (typeof item === 'string')
47
49
  return item;
48
- return currentRemotes.find((remote) => remote.key == item.remote)?.baseUrl;
50
+ return (_a = currentRemotes.find((remote) => remote.key == item.remote)) === null || _a === void 0 ? void 0 : _a.baseUrl;
49
51
  })
50
52
  .filter((item) => typeof item === 'string')
51
53
  .forEach((e) => missingExternalFetchBackend.add(e));
52
54
  const arrayMissingExternalFetchBackend = [...missingExternalFetchBackend];
53
- const currentContentStyles = currentPermissions?.content?.styles ?? [];
55
+ const currentContentStyles = (_k = (_j = currentPermissions === null || currentPermissions === void 0 ? void 0 : currentPermissions.content) === null || _j === void 0 ? void 0 : _j.styles) !== null && _k !== void 0 ? _k : [];
54
56
  currentContentStyles.forEach((e) => missingContentStyle.add(e));
55
57
  const arrayMissingContentStyles = [...missingContentStyle];
56
- const currentExternalImages = currentPermissions?.external?.images ?? [];
58
+ const currentExternalImages = (_m = (_l = currentPermissions === null || currentPermissions === void 0 ? void 0 : currentPermissions.external) === null || _l === void 0 ? void 0 : _l.images) !== null && _m !== void 0 ? _m : [];
57
59
  currentExternalImages.forEach((e) => missingExternalImage.add(e));
58
60
  const arrayMissingExternalImages = [...missingExternalImage];
59
- const config = {
60
- ...currentPermissions,
61
- scopes: [...missingScopes]
62
- };
61
+ const config = Object.assign(Object.assign({}, currentPermissions), { scopes: [...missingScopes] });
63
62
  if (arrayMissingExternalFetchBackend.length > 0) {
64
- config.external = {
65
- ...config.external,
66
- fetch: {
67
- ...config.external?.fetch,
68
- backend: arrayMissingExternalFetchBackend
69
- }
70
- };
63
+ config.external = Object.assign(Object.assign({}, config.external), { fetch: Object.assign(Object.assign({}, (_o = config.external) === null || _o === void 0 ? void 0 : _o.fetch), { backend: arrayMissingExternalFetchBackend }) });
71
64
  }
72
65
  if (arrayMissingExternalImages.length > 0) {
73
- config.external = {
74
- ...config.external,
75
- images: arrayMissingExternalImages
76
- };
66
+ config.external = Object.assign(Object.assign({}, config.external), { images: arrayMissingExternalImages });
77
67
  }
78
68
  if (arrayMissingContentStyles.length > 0) {
79
- config.content = {
80
- ...config.content,
81
- styles: arrayMissingContentStyles
82
- };
69
+ config.content = Object.assign(Object.assign({}, config.content), { styles: arrayMissingContentStyles });
83
70
  }
84
71
  await state.configFile.writeToConfigFile('permissions', config);
85
72
  return state;
86
73
  };
87
74
  exports.fixMissingPermissions = fixMissingPermissions;
88
75
  class PermissionLinter extends base_linter_1.default {
89
- manifest;
90
- static JIRA_CACHE_KEY = 'permissions-jira-cache-key';
91
- static JSM_CACHE_KEY = 'permissions-jsm-cache-key';
92
- static JSW_CACHE_KEY = 'permissions-jsw-cache-key';
93
- static CONFLUENCE_CACHE_KEY = 'permissions-confluence-cache-key';
94
- static BITBUCKET_CACHE_KEY = 'permissions-bitbucket-cache-key';
95
- jira;
96
- confluence;
97
- bitbucket;
98
- cache;
99
76
  constructor(environment, manifest, logger) {
100
77
  super(environment, logger);
101
78
  this.manifest = manifest;
@@ -133,11 +110,7 @@ class PermissionLinter extends base_linter_1.default {
133
110
  ];
134
111
  }
135
112
  const [jiraSwagger, jsmSwagger, jswSwagger, confluenceSwagger, bitbucketSwagger] = await Promise.all(swaggerFiles);
136
- this.jira = this.processPaths({
137
- ...jiraSwagger.paths,
138
- ...jsmSwagger.paths,
139
- ...jswSwagger.paths
140
- });
113
+ this.jira = this.processPaths(Object.assign(Object.assign(Object.assign({}, jiraSwagger.paths), jsmSwagger.paths), jswSwagger.paths));
141
114
  this.confluence = this.processPaths(confluenceSwagger.paths);
142
115
  this.bitbucket = this.processPaths(bitbucketSwagger.paths);
143
116
  this.nodeVisitors = [
@@ -201,11 +174,12 @@ class PermissionLinter extends base_linter_1.default {
201
174
  }
202
175
  }
203
176
  async getProductPaths(cacheKey, url) {
204
- const cached = this.cache?.get(cacheKey);
177
+ var _a, _b;
178
+ const cached = (_a = this.cache) === null || _a === void 0 ? void 0 : _a.get(cacheKey);
205
179
  if (!cached) {
206
180
  const response = await (0, node_fetch_1.default)(url);
207
181
  const jsonBody = await response.json();
208
- void this.cache?.set(cacheKey, jsonBody, 12 * ONE_HOUR_MS);
182
+ void ((_b = this.cache) === null || _b === void 0 ? void 0 : _b.set(cacheKey, jsonBody, 12 * ONE_HOUR_MS));
209
183
  return jsonBody;
210
184
  }
211
185
  return cached;
@@ -224,3 +198,8 @@ class PermissionLinter extends base_linter_1.default {
224
198
  }
225
199
  }
226
200
  exports.PermissionLinter = PermissionLinter;
201
+ PermissionLinter.JIRA_CACHE_KEY = 'permissions-jira-cache-key';
202
+ PermissionLinter.JSM_CACHE_KEY = 'permissions-jsm-cache-key';
203
+ PermissionLinter.JSW_CACHE_KEY = 'permissions-jsw-cache-key';
204
+ PermissionLinter.CONFLUENCE_CACHE_KEY = 'permissions-confluence-cache-key';
205
+ PermissionLinter.BITBUCKET_CACHE_KEY = 'permissions-bitbucket-cache-key';
@@ -88,7 +88,8 @@ class ContentPropertyVerifier extends verifier_interface_1.BaseLintIssueVerifier
88
88
  return lintErrors;
89
89
  }
90
90
  getMissingScopes({ context, method }) {
91
- const existingScopes = this.manifest?.permissions?.scopes;
91
+ var _a, _b;
92
+ const existingScopes = (_b = (_a = this.manifest) === null || _a === void 0 ? void 0 : _a.permissions) === null || _b === void 0 ? void 0 : _b.scopes;
92
93
  return (0, manifest_1.getMissingScopes)(existingScopes, exports.CONTENT_PROPERTY_PERMISSIONS_MAP[context][method]);
93
94
  }
94
95
  }
@@ -7,14 +7,14 @@ const verifier_interface_1 = require("../../verifier-interface");
7
7
  const text_1 = require("../../../text");
8
8
  const utils_1 = require("../../utils");
9
9
  class ExternalFetchVerifier extends verifier_interface_1.BaseLintIssueVerifier {
10
- egressFilteringService;
11
10
  constructor(environment, manifest) {
11
+ var _a, _b, _c, _d, _e, _f, _g;
12
12
  super(environment, manifest);
13
- const allowList = this.manifest?.permissions?.external?.fetch?.backend ?? [];
14
- const remoteList = this.manifest?.remotes ?? [];
13
+ const allowList = (_e = (_d = (_c = (_b = (_a = this.manifest) === null || _a === void 0 ? void 0 : _a.permissions) === null || _b === void 0 ? void 0 : _b.external) === null || _c === void 0 ? void 0 : _c.fetch) === null || _d === void 0 ? void 0 : _d.backend) !== null && _e !== void 0 ? _e : [];
14
+ const remoteList = (_g = (_f = this.manifest) === null || _f === void 0 ? void 0 : _f.remotes) !== null && _g !== void 0 ? _g : [];
15
15
  const collectedUrls = allowList.filter((item) => typeof item === 'string');
16
16
  const collectedRemotes = allowList
17
- .map((item) => typeof item !== 'string' && remoteList.find((remoteItem) => remoteItem.key === item.remote)?.baseUrl)
17
+ .map((item) => { var _a; return typeof item !== 'string' && ((_a = remoteList.find((remoteItem) => remoteItem.key === item.remote)) === null || _a === void 0 ? void 0 : _a.baseUrl); })
18
18
  .filter((x) => typeof x === 'string');
19
19
  this.egressFilteringService = new egress_1.EgressFilteringService(collectedUrls.concat(collectedRemotes));
20
20
  }
@@ -7,10 +7,10 @@ const verifier_interface_1 = require("../../verifier-interface");
7
7
  const text_1 = require("../../../text");
8
8
  const utils_1 = require("../../utils");
9
9
  class ImageUrlVerifier extends verifier_interface_1.BaseLintIssueVerifier {
10
- egressFilteringService;
11
10
  constructor(environment, manifest) {
11
+ var _a, _b, _c, _d;
12
12
  super(environment, manifest);
13
- const allowList = this.manifest?.permissions?.external?.images ?? [];
13
+ const allowList = (_d = (_c = (_b = (_a = this.manifest) === null || _a === void 0 ? void 0 : _a.permissions) === null || _b === void 0 ? void 0 : _b.external) === null || _c === void 0 ? void 0 : _c.images) !== null && _d !== void 0 ? _d : [];
14
14
  const collectedUrls = allowList.filter((item) => typeof item === 'string');
15
15
  this.egressFilteringService = new egress_1.EgressFilteringService(collectedUrls);
16
16
  }
@@ -9,8 +9,6 @@ const manifest_1 = require("@forge/manifest");
9
9
  const text_1 = require("../../../text");
10
10
  const array_prototype_flatmap_1 = tslib_1.__importDefault(require("array.prototype.flatmap"));
11
11
  class ProductVerifier extends verifier_interface_1.BaseLintIssueVerifier {
12
- pathMap;
13
- product;
14
12
  constructor(environment, manifest, pathMap, product) {
15
13
  super(environment, manifest);
16
14
  this.pathMap = pathMap;
@@ -20,6 +18,7 @@ class ProductVerifier extends verifier_interface_1.BaseLintIssueVerifier {
20
18
  return linter_interface_1.LintClass.Error;
21
19
  }
22
20
  async process(apiCalls) {
21
+ var _a;
23
22
  const rules = [];
24
23
  const lintCriteriaMatches = new Set();
25
24
  for (const apiCall of apiCalls) {
@@ -29,14 +28,14 @@ class ProductVerifier extends verifier_interface_1.BaseLintIssueVerifier {
29
28
  }
30
29
  }
31
30
  for (const apiCall of lintCriteriaMatches) {
32
- if (!apiCall?.regex) {
31
+ if (!(apiCall === null || apiCall === void 0 ? void 0 : apiCall.regex)) {
33
32
  continue;
34
33
  }
35
34
  const missingScopes = await this.getMissingPermissionScopes(apiCall);
36
35
  for (const permission of missingScopes) {
37
36
  rules.push({
38
37
  class: this.getLintClass(),
39
- message: text_1.messages.verifiers.product.message((0, cli_shared_1.capitalise)(this.product), apiCall.method.toUpperCase(), this.pathMap.get(apiCall.regex)?.originalPath, permission),
38
+ message: text_1.messages.verifiers.product.message((0, cli_shared_1.capitalise)(this.product), apiCall.method.toUpperCase(), (_a = this.pathMap.get(apiCall.regex)) === null || _a === void 0 ? void 0 : _a.originalPath, permission),
40
39
  reference: text_1.messages.verifiers.product.reference,
41
40
  line: apiCall.line,
42
41
  column: apiCall.column,
@@ -52,36 +51,34 @@ class ProductVerifier extends verifier_interface_1.BaseLintIssueVerifier {
52
51
  const pathWithoutQuery = apiCall.path.replace(/\?.+$/, '');
53
52
  for (const regex of this.pathMap.keys()) {
54
53
  if (regex.test(pathWithoutQuery)) {
55
- return {
56
- ...apiCall,
57
- regex,
58
- path: pathWithoutQuery,
59
- method: apiCall.method.toLowerCase()
60
- };
54
+ return Object.assign(Object.assign({}, apiCall), { regex, path: pathWithoutQuery, method: apiCall.method.toLowerCase() });
61
55
  }
62
56
  }
63
57
  }
64
58
  getMissingPermissionScopes(apiCall) {
59
+ var _a, _b;
65
60
  const current = this.getRequiredScopes(apiCall);
66
61
  const beta = this.getBetaScopes(apiCall);
67
- return (0, manifest_1.getMissingScopes)(this.manifest?.permissions?.scopes, { current, beta });
62
+ return (0, manifest_1.getMissingScopes)((_b = (_a = this.manifest) === null || _a === void 0 ? void 0 : _a.permissions) === null || _b === void 0 ? void 0 : _b.scopes, { current, beta });
68
63
  }
69
64
  getRequiredScopes({ regex, method }) {
65
+ var _a, _b, _c, _d;
70
66
  if (!regex)
71
67
  return [];
72
- const oAuth2Scopes = this.pathMap.get(regex)?.methods[method]?.['x-atlassian-oauth2-scopes'];
68
+ const oAuth2Scopes = (_b = (_a = this.pathMap.get(regex)) === null || _a === void 0 ? void 0 : _a.methods[method]) === null || _b === void 0 ? void 0 : _b['x-atlassian-oauth2-scopes'];
73
69
  if (oAuth2Scopes) {
74
70
  return (0, array_prototype_flatmap_1.default)(oAuth2Scopes.filter((scope) => scope.state === 'Current').map((scope) => scope.scopes), (x) => x);
75
71
  }
76
- const swaggerEntries = this.pathMap.get(regex)?.methods[method]?.security;
72
+ const swaggerEntries = (_d = (_c = this.pathMap.get(regex)) === null || _c === void 0 ? void 0 : _c.methods[method]) === null || _d === void 0 ? void 0 : _d.security;
77
73
  if (!swaggerEntries)
78
74
  return [];
79
- return swaggerEntries?.reduce((prev, curr) => [...prev, ...(curr['OAuth2'] || []), ...(curr['oAuthDefinitions'] || [])], []);
75
+ return swaggerEntries === null || swaggerEntries === void 0 ? void 0 : swaggerEntries.reduce((prev, curr) => [...prev, ...(curr['OAuth2'] || []), ...(curr['oAuthDefinitions'] || [])], []);
80
76
  }
81
77
  getBetaScopes({ regex, method }) {
78
+ var _a, _b;
82
79
  if (!regex)
83
80
  return [];
84
- const oAuth2Scopes = this.pathMap.get(regex)?.methods[method]?.['x-atlassian-oauth2-scopes'];
81
+ const oAuth2Scopes = (_b = (_a = this.pathMap.get(regex)) === null || _a === void 0 ? void 0 : _a.methods[method]) === null || _b === void 0 ? void 0 : _b['x-atlassian-oauth2-scopes'];
85
82
  if (!oAuth2Scopes)
86
83
  return [];
87
84
  return (0, array_prototype_flatmap_1.default)(oAuth2Scopes.filter((scope) => scope.state === 'Beta').map((scope) => scope.scopes), (x) => x);
@@ -10,18 +10,13 @@ class StorageAPIVerifier extends verifier_interface_1.BaseLintIssueVerifier {
10
10
  return linter_interface_1.LintClass.Error;
11
11
  }
12
12
  async process(apiCalls) {
13
- if (this.manifest.permissions?.scopes?.includes(STORAGE_PERMISSION)) {
13
+ var _a, _b;
14
+ if ((_b = (_a = this.manifest.permissions) === null || _a === void 0 ? void 0 : _a.scopes) === null || _b === void 0 ? void 0 : _b.includes(STORAGE_PERMISSION)) {
14
15
  return [];
15
16
  }
16
- return apiCalls.map((apiCall) => ({
17
- class: this.getLintClass(),
18
- message: text_1.messages.verifiers.storage.message(STORAGE_PERMISSION),
19
- reference: text_1.messages.verifiers.storage.reference,
20
- ...apiCall,
21
- metadata: {
17
+ return apiCalls.map((apiCall) => (Object.assign(Object.assign({ class: this.getLintClass(), message: text_1.messages.verifiers.storage.message(STORAGE_PERMISSION), reference: text_1.messages.verifiers.storage.reference }, apiCall), { metadata: {
22
18
  missingPermission: STORAGE_PERMISSION
23
- }
24
- }));
19
+ } })));
25
20
  }
26
21
  }
27
22
  exports.StorageAPIVerifier = StorageAPIVerifier;
@@ -24,12 +24,13 @@ class UIHookVerifier extends verifier_interface_1.BaseLintIssueVerifier {
24
24
  return linter_interface_1.LintClass.Error;
25
25
  }
26
26
  async process(apiCalls) {
27
+ var _a;
27
28
  const rules = [];
28
29
  for (const apiCall of apiCalls) {
29
30
  const requiredPermissions = FORGE_UI_HOOK_PERMISSIONS[apiCall.hookName];
30
31
  if (!requiredPermissions)
31
32
  return rules;
32
- const missingPermissions = await (0, manifest_1.getMissingScopes)(this.manifest.permissions?.scopes, requiredPermissions);
33
+ const missingPermissions = await (0, manifest_1.getMissingScopes)((_a = this.manifest.permissions) === null || _a === void 0 ? void 0 : _a.scopes, requiredPermissions);
33
34
  missingPermissions.forEach((perm) => rules.push(this.getHookRule(apiCall, perm)));
34
35
  }
35
36
  return rules;
@@ -5,12 +5,20 @@ const typescript_estree_1 = require("@typescript-eslint/typescript-estree");
5
5
  const url_1 = require("url");
6
6
  const api_call_interface_1 = require("../api-call-interface");
7
7
  class ExternalApiCallVisitor {
8
+ constructor() {
9
+ this.transformArgsToFetchCall = (endpointNode) => ({
10
+ type: api_call_interface_1.ApiCallTypes.EXTERNAL,
11
+ url: endpointNode.value,
12
+ line: endpointNode.loc.start.line,
13
+ column: endpointNode.loc.start.column
14
+ });
15
+ }
8
16
  visit(node, parent, callback) {
9
17
  switch (node.type) {
10
18
  case typescript_estree_1.AST_NODE_TYPES.CallExpression:
11
19
  if (node.callee.type === typescript_estree_1.AST_NODE_TYPES.Identifier && node.callee.name === 'fetch') {
12
20
  const [endpointNode] = node.arguments;
13
- if (endpointNode?.type === typescript_estree_1.AST_NODE_TYPES.Literal && typeof endpointNode?.value === 'string') {
21
+ if ((endpointNode === null || endpointNode === void 0 ? void 0 : endpointNode.type) === typescript_estree_1.AST_NODE_TYPES.Literal && typeof (endpointNode === null || endpointNode === void 0 ? void 0 : endpointNode.value) === 'string') {
14
22
  if (endpointNode.value.trim() !== '') {
15
23
  const fetchCall = this.transformArgsToFetchCall(endpointNode);
16
24
  callback(fetchCall);
@@ -21,7 +29,7 @@ class ExternalApiCallVisitor {
21
29
  case typescript_estree_1.AST_NODE_TYPES.MemberExpression:
22
30
  if (node.property.type === typescript_estree_1.AST_NODE_TYPES.Identifier &&
23
31
  node.property.name === 'fetch' &&
24
- parent?.type === typescript_estree_1.AST_NODE_TYPES.CallExpression) {
32
+ (parent === null || parent === void 0 ? void 0 : parent.type) === typescript_estree_1.AST_NODE_TYPES.CallExpression) {
25
33
  const [endpointNode] = parent.arguments;
26
34
  if (this.endpointCanBeChecked(endpointNode)) {
27
35
  const fetchCall = this.transformArgsToFetchCall(endpointNode);
@@ -37,21 +45,15 @@ class ExternalApiCallVisitor {
37
45
  thunk();
38
46
  return false;
39
47
  }
40
- catch {
48
+ catch (_a) {
41
49
  return true;
42
50
  }
43
51
  };
44
52
  const isPathOnlyUrl = (s) => throws(() => new url_1.URL(s)) && !throws(() => new url_1.URL(s, 'http://example'));
45
- return (endpointNode?.type === typescript_estree_1.AST_NODE_TYPES.Literal &&
46
- typeof endpointNode?.value === 'string' &&
53
+ return ((endpointNode === null || endpointNode === void 0 ? void 0 : endpointNode.type) === typescript_estree_1.AST_NODE_TYPES.Literal &&
54
+ typeof (endpointNode === null || endpointNode === void 0 ? void 0 : endpointNode.value) === 'string' &&
47
55
  endpointNode.value.trim() !== '' &&
48
56
  !isPathOnlyUrl(endpointNode.value));
49
57
  }
50
- transformArgsToFetchCall = (endpointNode) => ({
51
- type: api_call_interface_1.ApiCallTypes.EXTERNAL,
52
- url: endpointNode.value,
53
- line: endpointNode.loc.start.line,
54
- column: endpointNode.loc.start.column
55
- });
56
58
  }
57
59
  exports.ExternalApiCallVisitor = ExternalApiCallVisitor;
@@ -4,13 +4,12 @@ exports.ImageUrlVisitor = void 0;
4
4
  const typescript_estree_1 = require("@typescript-eslint/typescript-estree");
5
5
  const api_call_interface_1 = require("../api-call-interface");
6
6
  class ImageUrlVisitor {
7
- static ABSOLUTE_URL_REGEX = /^(?:[a-z+]+:)?\/\//i;
8
7
  visit(node, _parent, callback) {
9
8
  const imageUrlNode = this.getImageUrlNode(node);
10
9
  if (!imageUrlNode) {
11
10
  return undefined;
12
11
  }
13
- if (imageUrlNode?.type === typescript_estree_1.AST_NODE_TYPES.JSXAttribute) {
12
+ if ((imageUrlNode === null || imageUrlNode === void 0 ? void 0 : imageUrlNode.type) === typescript_estree_1.AST_NODE_TYPES.JSXAttribute) {
14
13
  const imageUrlAttribute = imageUrlNode.value;
15
14
  if (imageUrlAttribute &&
16
15
  imageUrlAttribute.type === typescript_estree_1.AST_NODE_TYPES.Literal &&
@@ -55,3 +54,4 @@ class ImageUrlVisitor {
55
54
  }
56
55
  }
57
56
  exports.ImageUrlVisitor = ImageUrlVisitor;
57
+ ImageUrlVisitor.ABSOLUTE_URL_REGEX = /^(?:[a-z+]+:)?\/\//i;
@@ -17,7 +17,7 @@ class ProductNodeVisitor {
17
17
  case typescript_estree_1.AST_NODE_TYPES.MemberExpression:
18
18
  if (node.property.type === typescript_estree_1.AST_NODE_TYPES.Identifier &&
19
19
  node.property.name.match(REQUEST_PRODUCT_REGEX) &&
20
- parent?.type === typescript_estree_1.AST_NODE_TYPES.CallExpression) {
20
+ (parent === null || parent === void 0 ? void 0 : parent.type) === typescript_estree_1.AST_NODE_TYPES.CallExpression) {
21
21
  const apiCallProblem = this.checkProductApiCallArgs(node.property.name, parent.arguments);
22
22
  apiCallProblem && callback(apiCallProblem);
23
23
  }
@@ -78,10 +78,10 @@ class ProductNodeVisitor {
78
78
  if (!endpointString) {
79
79
  return;
80
80
  }
81
- const methodProperty = optionsNode?.properties.find((property) => property.type === typescript_estree_1.AST_NODE_TYPES.Property &&
81
+ const methodProperty = optionsNode === null || optionsNode === void 0 ? void 0 : optionsNode.properties.find((property) => property.type === typescript_estree_1.AST_NODE_TYPES.Property &&
82
82
  property.key.type === typescript_estree_1.AST_NODE_TYPES.Identifier &&
83
83
  property.key.name === 'method');
84
- const methodValue = methodProperty?.value.type === typescript_estree_1.AST_NODE_TYPES.Literal && typeof methodProperty.value.value === 'string'
84
+ const methodValue = (methodProperty === null || methodProperty === void 0 ? void 0 : methodProperty.value.type) === typescript_estree_1.AST_NODE_TYPES.Literal && typeof methodProperty.value.value === 'string'
85
85
  ? methodProperty.value.value
86
86
  : 'GET';
87
87
  return {
@@ -9,10 +9,7 @@ class StorageAPINodeVisitor {
9
9
  node.specifiers.forEach((specifier) => {
10
10
  if (specifier.type === 'ImportSpecifier' && specifier.local.type === 'Identifier') {
11
11
  if (specifier.loc && specifier.local.name === 'storage') {
12
- const storageApiCall = {
13
- type: api_call_interface_1.ApiCallTypes.STORAGE,
14
- ...specifier.loc.start
15
- };
12
+ const storageApiCall = Object.assign({ type: api_call_interface_1.ApiCallTypes.STORAGE }, specifier.loc.start);
16
13
  callback(storageApiCall);
17
14
  }
18
15
  }
@@ -8,11 +8,7 @@ class UIHookNodeVisitor {
8
8
  if (node.type === typescript_estree_1.AST_NODE_TYPES.ImportDeclaration) {
9
9
  node.specifiers.forEach((specifier) => {
10
10
  if (specifier.loc && specifier.local.name.match(/^use(Space|Content|Issue)Property/)) {
11
- const hookApiCall = {
12
- type: api_call_interface_1.ApiCallTypes.HOOK,
13
- hookName: specifier.local.name,
14
- ...specifier.loc.start
15
- };
11
+ const hookApiCall = Object.assign({ type: api_call_interface_1.ApiCallTypes.HOOK, hookName: specifier.local.name }, specifier.loc.start);
16
12
  callback(hookApiCall);
17
13
  }
18
14
  });
@@ -4,8 +4,6 @@ exports.BaseLintIssueVerifier = void 0;
4
4
  const linter_interface_1 = require("../linter-interface");
5
5
  const cli_shared_1 = require("@forge/cli-shared");
6
6
  class BaseLintIssueVerifier {
7
- environment;
8
- manifest;
9
7
  constructor(environment, manifest) {
10
8
  this.environment = environment;
11
9
  this.manifest = manifest;
@@ -10,20 +10,12 @@ const createParseOptions = (absoluteFilePath, fileSystemReader) => {
10
10
  const tsconfigOptions = fileSystemReader.fileExists(TSCONFIG_PATH)
11
11
  ? { tsconfigRootDir: process.cwd(), project: TSCONFIG_PATH }
12
12
  : {};
13
- return {
14
- errorOnTypeScriptSyntacticAndSemanticIssues: true,
15
- loc: true,
16
- filePath: absoluteFilePath,
17
- ...tsconfigOptions
18
- };
13
+ return Object.assign({ errorOnTypeScriptSyntacticAndSemanticIssues: true, loc: true, filePath: absoluteFilePath }, tsconfigOptions);
19
14
  };
20
15
  exports.createParseOptions = createParseOptions;
21
16
  const tsParser = async (code, filepath, parseOptions) => {
22
17
  const absoluteFilePath = path_1.default.resolve(process.cwd(), filepath);
23
- const parseResult = (0, typescript_estree_1.parseAndGenerateServices)(code, {
24
- ...(0, exports.createParseOptions)(absoluteFilePath, new cli_shared_1.FileSystemReader()),
25
- ...parseOptions
26
- });
18
+ const parseResult = (0, typescript_estree_1.parseAndGenerateServices)(code, Object.assign(Object.assign({}, (0, exports.createParseOptions)(absoluteFilePath, new cli_shared_1.FileSystemReader())), parseOptions));
27
19
  return {
28
20
  parsed: parseResult.ast,
29
21
  traverse: (options) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/lint",
3
- "version": "5.0.2-next.1",
3
+ "version": "5.0.2",
4
4
  "description": "Linting for forge apps",
5
5
  "main": "out/index.js",
6
6
  "license": "UNLICENSED",
@@ -17,9 +17,9 @@
17
17
  "@types/node-fetch": "^2.6.11"
18
18
  },
19
19
  "dependencies": {
20
- "@forge/cli-shared": "4.0.1-next.1",
20
+ "@forge/cli-shared": "4.0.1",
21
21
  "@forge/egress": "1.2.13",
22
- "@forge/manifest": "7.2.0-next.1",
22
+ "@forge/manifest": "7.2.0",
23
23
  "@typescript-eslint/typescript-estree": "^5.62.0",
24
24
  "array.prototype.flatmap": "^1.3.2",
25
25
  "atlassian-openapi": "^1.0.18",