@forge/lint 3.1.3-next.1 → 3.1.3-next.4

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,27 @@
1
1
  # @forge/lint
2
2
 
3
+ ## 3.1.3-next.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 7fe19b40: More resilient linting against handler exports
8
+
9
+ ## 3.1.3-next.3
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [4285fc36]
14
+ - @forge/manifest@3.9.0-next.2
15
+ - @forge/cli-shared@2.6.0-next.3
16
+
17
+ ## 3.1.3-next.2
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [b447be27]
22
+ - @forge/manifest@3.9.0-next.1
23
+ - @forge/cli-shared@2.6.0-next.2
24
+
3
25
  ## 3.1.3-next.1
4
26
 
5
27
  ### Patch Changes
@@ -3,5 +3,12 @@ import { NodeVisitor } from '../../node-visitor-interface';
3
3
  import { ExportedMethod } from '../exported-method-interface';
4
4
  export declare class ExportedFunctionNodeVisitor implements NodeVisitor<ExportedMethod> {
5
5
  visit(node: TSESTree.Node, _parent: TSESTree.Node | undefined, callback: (exportedMethod: ExportedMethod) => void): void;
6
+ private visitSpecifiedNamedExports;
7
+ private visitInlineNamedExport;
8
+ private visitObjectAssignmentExpression;
9
+ private visitMemberExpression;
10
+ private tryAddObjectExpressionPropertiesExportedMethods;
11
+ private createExportedMethod;
12
+ private isExports;
6
13
  }
7
14
  //# sourceMappingURL=exported-function-node-visitor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"exported-function-node-visitor.d.ts","sourceRoot":"","sources":["../../../../../src/lint/linters/handler-linter/visitors/exported-function-node-visitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAkB,MAAM,sCAAsC,CAAC;AAEhF,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,qBAAa,2BAA4B,YAAW,WAAW,CAAC,cAAc,CAAC;IACtE,KAAK,CACV,IAAI,EAAE,QAAQ,CAAC,IAAI,EACnB,OAAO,EAAE,QAAQ,CAAC,IAAI,GAAG,SAAS,EAClC,QAAQ,EAAE,CAAC,cAAc,EAAE,cAAc,KAAK,IAAI,GACjD,IAAI;CA4IR"}
1
+ {"version":3,"file":"exported-function-node-visitor.d.ts","sourceRoot":"","sources":["../../../../../src/lint/linters/handler-linter/visitors/exported-function-node-visitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAkB,MAAM,sCAAsC,CAAC;AAEhF,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,qBAAa,2BAA4B,YAAW,WAAW,CAAC,cAAc,CAAC;IACtE,KAAK,CACV,IAAI,EAAE,QAAQ,CAAC,IAAI,EACnB,OAAO,EAAE,QAAQ,CAAC,IAAI,GAAG,SAAS,EAClC,QAAQ,EAAE,CAAC,cAAc,EAAE,cAAc,KAAK,IAAI,GACjD,IAAI;IAuCP,OAAO,CAAC,0BAA0B;IAelC,OAAO,CAAC,sBAAsB;IAkC9B,OAAO,CAAC,+BAA+B;IAkBvC,OAAO,CAAC,qBAAqB;IAS7B,OAAO,CAAC,+CAA+C;IAavD,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,SAAS;CAUlB"}
@@ -4,78 +4,73 @@ exports.ExportedFunctionNodeVisitor = void 0;
4
4
  const typescript_estree_1 = require("@typescript-eslint/typescript-estree");
5
5
  class ExportedFunctionNodeVisitor {
6
6
  visit(node, _parent, callback) {
7
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
8
7
  if (node.type === typescript_estree_1.AST_NODE_TYPES.MemberExpression &&
9
8
  node.object &&
10
- (node === null || node === void 0 ? void 0 : node.property.type) === typescript_estree_1.AST_NODE_TYPES.Identifier) {
11
- if (node.object.type === typescript_estree_1.AST_NODE_TYPES.MemberExpression) {
12
- if (((_a = node.object) === null || _a === void 0 ? void 0 : _a.object.type) === typescript_estree_1.AST_NODE_TYPES.Identifier && ((_b = node.object) === null || _b === void 0 ? void 0 : _b.object.name) === 'module') {
13
- if (((_c = node.object) === null || _c === void 0 ? void 0 : _c.property.type) === typescript_estree_1.AST_NODE_TYPES.Identifier && ((_d = node.object) === null || _d === void 0 ? void 0 : _d.property.name) === 'exports') {
14
- const exportedMethod = Object.assign({ method: node.property.name }, node.property.loc.start);
15
- return callback(exportedMethod);
16
- }
17
- }
18
- }
19
- if (node.object.type === typescript_estree_1.AST_NODE_TYPES.Identifier && node.object.name === 'exports') {
20
- if (node.property.type === typescript_estree_1.AST_NODE_TYPES.Identifier) {
21
- const exportedMethod = Object.assign({ method: node.property.name }, node.property.loc.start);
22
- return callback(exportedMethod);
23
- }
24
- }
9
+ node.property.type === typescript_estree_1.AST_NODE_TYPES.Identifier) {
10
+ this.visitMemberExpression(node, callback);
25
11
  }
26
12
  if (node.type === typescript_estree_1.AST_NODE_TYPES.AssignmentExpression && node.operator === '=') {
27
- if (((_e = node.left) === null || _e === void 0 ? void 0 : _e.type) === typescript_estree_1.AST_NODE_TYPES.MemberExpression && ((_f = node.left) === null || _f === void 0 ? void 0 : _f.object) && ((_g = node.left) === null || _g === void 0 ? void 0 : _g.property)) {
28
- if (((_h = node.left) === null || _h === void 0 ? void 0 : _h.object.type) === typescript_estree_1.AST_NODE_TYPES.Identifier && ((_j = node.left) === null || _j === void 0 ? void 0 : _j.object.name) === 'module') {
29
- if (((_k = node.left) === null || _k === void 0 ? void 0 : _k.property.type) === typescript_estree_1.AST_NODE_TYPES.Identifier && ((_l = node.left) === null || _l === void 0 ? void 0 : _l.property.name) === 'exports') {
30
- ((_m = node.right) === null || _m === void 0 ? void 0 : _m.properties).forEach((property) => {
31
- if (property.key.type === typescript_estree_1.AST_NODE_TYPES.Identifier) {
32
- const exportedMethod = Object.assign({ method: property.key.name }, property.key.loc.start);
33
- return callback(exportedMethod);
34
- }
35
- });
36
- }
37
- }
38
- }
39
- if (((_o = node.left) === null || _o === void 0 ? void 0 : _o.type) === typescript_estree_1.AST_NODE_TYPES.Identifier && ((_p = node.left) === null || _p === void 0 ? void 0 : _p.name) === 'exports') {
40
- ((_q = node.right) === null || _q === void 0 ? void 0 : _q.properties).forEach((property) => {
41
- if (property.key.type === typescript_estree_1.AST_NODE_TYPES.Identifier) {
42
- const exportedMethod = Object.assign({ method: property.key.name }, property.key.loc.start);
43
- return callback(exportedMethod);
44
- }
45
- });
46
- }
13
+ this.visitObjectAssignmentExpression(node, callback);
47
14
  }
48
15
  if (node.type === typescript_estree_1.AST_NODE_TYPES.ExportNamedDeclaration) {
49
16
  if (node.declaration) {
50
- if (((_r = node.declaration) === null || _r === void 0 ? void 0 : _r.type) === typescript_estree_1.AST_NODE_TYPES.VariableDeclaration) {
51
- node.declaration.declarations.forEach((declarator) => {
52
- if (declarator.id && declarator.id.type === typescript_estree_1.AST_NODE_TYPES.Identifier) {
53
- const exportedMethod = Object.assign({ method: declarator.id.name }, declarator.id.loc.start);
54
- return callback(exportedMethod);
55
- }
56
- });
57
- }
58
- else if (((_s = node.declaration) === null || _s === void 0 ? void 0 : _s.type) === typescript_estree_1.AST_NODE_TYPES.FunctionDeclaration) {
59
- if (((_t = node.declaration) === null || _t === void 0 ? void 0 : _t.id) && ((_u = node.declaration) === null || _u === void 0 ? void 0 : _u.id.type) === typescript_estree_1.AST_NODE_TYPES.Identifier) {
60
- const exportedMethod = Object.assign({ method: node.declaration.id.name }, node.declaration.id.loc.start);
61
- return callback(exportedMethod);
62
- }
63
- }
17
+ this.visitInlineNamedExport(node, callback);
64
18
  }
65
19
  else {
66
- node.specifiers.forEach((specifier) => {
67
- if (specifier.type === typescript_estree_1.AST_NODE_TYPES.ExportSpecifier &&
68
- specifier.exported.type === typescript_estree_1.AST_NODE_TYPES.Identifier) {
69
- const exportedMethod = Object.assign({ method: specifier.exported.name }, node.loc.start);
70
- return callback(exportedMethod);
71
- }
72
- if (specifier.type === typescript_estree_1.AST_NODE_TYPES.ExportSpecifier && specifier.local.type === typescript_estree_1.AST_NODE_TYPES.Identifier) {
73
- const exportedMethod = Object.assign({ method: specifier.local.name }, node.loc.start);
74
- return callback(exportedMethod);
75
- }
76
- });
20
+ node.specifiers.forEach((specifier) => this.visitSpecifiedNamedExports(node, specifier, callback));
77
21
  }
78
22
  }
79
23
  }
24
+ visitSpecifiedNamedExports(node, specifier, callback) {
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, Object.assign({}, node.loc.start)));
27
+ }
28
+ }
29
+ visitInlineNamedExport(node, callback) {
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) {
32
+ node.declaration.declarations.forEach((declarator) => {
33
+ if (declarator.id && declarator.id.type === typescript_estree_1.AST_NODE_TYPES.Identifier) {
34
+ callback(this.createExportedMethod(declarator.id.name, Object.assign({}, declarator.id.loc.start)));
35
+ }
36
+ });
37
+ }
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)));
41
+ }
42
+ }
43
+ }
44
+ visitObjectAssignmentExpression(node, callback) {
45
+ if (this.isExports(node.left)) {
46
+ this.tryAddObjectExpressionPropertiesExportedMethods(node, callback);
47
+ }
48
+ }
49
+ visitMemberExpression(node, callback) {
50
+ if (node.property.type === typescript_estree_1.AST_NODE_TYPES.Identifier && this.isExports(node.object)) {
51
+ callback(this.createExportedMethod(node.property.name, Object.assign({}, node.property.loc.start)));
52
+ }
53
+ }
54
+ tryAddObjectExpressionPropertiesExportedMethods(node, callback) {
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) => {
58
+ if (property.key.type === typescript_estree_1.AST_NODE_TYPES.Identifier) {
59
+ callback(this.createExportedMethod(property.key.name, Object.assign({}, property.key.loc.start)));
60
+ }
61
+ });
62
+ }
63
+ }
64
+ createExportedMethod(method, location) {
65
+ return Object.assign({ method }, location);
66
+ }
67
+ isExports(node) {
68
+ return ((node.type === typescript_estree_1.AST_NODE_TYPES.MemberExpression &&
69
+ node.object.type === typescript_estree_1.AST_NODE_TYPES.Identifier &&
70
+ node.object.name === 'module' &&
71
+ node.property.type === typescript_estree_1.AST_NODE_TYPES.Identifier &&
72
+ node.property.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'));
74
+ }
80
75
  }
81
76
  exports.ExportedFunctionNodeVisitor = ExportedFunctionNodeVisitor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/lint",
3
- "version": "3.1.3-next.1",
3
+ "version": "3.1.3-next.4",
4
4
  "description": "Linting for forge apps",
5
5
  "main": "out/index.js",
6
6
  "license": "UNLICENSED",
@@ -15,9 +15,9 @@
15
15
  "@types/node-fetch": "^2.5.7"
16
16
  },
17
17
  "dependencies": {
18
- "@forge/cli-shared": "2.6.0-next.1",
18
+ "@forge/cli-shared": "2.6.0-next.3",
19
19
  "@forge/csp": "1.11.0",
20
- "@forge/manifest": "3.8.2-next.0",
20
+ "@forge/manifest": "3.9.0-next.2",
21
21
  "@typescript-eslint/typescript-estree": "^3.5.0",
22
22
  "cross-spawn": "^7.0.1",
23
23
  "node-fetch": "2.6.1",