@forge/lint 5.5.2-next.9 → 5.6.0-next.12

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,26 @@
1
1
  # @forge/lint
2
2
 
3
+ ## 5.6.0-next.12
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [8ca9a19]
8
+ - @forge/manifest@8.0.0-next.9
9
+ - @forge/cli-shared@6.3.0-next.11
10
+
11
+ ## 5.6.0-next.11
12
+
13
+ ### Minor Changes
14
+
15
+ - 3e59d28: Validate sql module during linting
16
+
17
+ ## 5.5.2-next.10
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [34bd8b6]
22
+ - @forge/cli-shared@6.3.0-next.10
23
+
3
24
  ## 5.5.2-next.9
4
25
 
5
26
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../src/lint/lint.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,IAAI,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,MAAM,IAAI,CAAC;AAIpB,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAkB,MAAM,oBAAoB,CAAC;AAWxG,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,iBAAiB,WAAY,UAAU,eAAe,UAAU,EAAE,4BAAuB,IA+CrG,CAAC;AAEF,eAAO,MAAM,YAAY,gBAAiB,UAAU,EAAE,KAAG,YAQxD,CAAC;AAEF,eAAO,MAAM,eAAe,aAChB,MAAM,UACR,eAAe,oBACN,OAAO,GAAG,QAAQ,CAAC,aAAa,KAChD,QAAQ,SAAS,CAOnB,CAAC;AAEF,eAAO,M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tB,QAAQ,UAAU,EAAE,CAGtB,CAAC"}
package/out/lint/lint.js CHANGED
@@ -16,6 +16,7 @@ const deprecated_csp_permissions_manifest_linter_1 = require("./linters/manifest
16
16
  const dynamic_properties_permissions_linter_1 = require("./linters/dynamic-properties-linter/dynamic-properties-permissions-linter");
17
17
  const remote_compute_manifest_linter_1 = require("./linters/manifest-linter/remote-compute-manifest-linter");
18
18
  const invoke_remote_linter_1 = require("./linters/remote-linter/invoke-remote-linter");
19
+ const storage_module_linter_1 = require("./linters/storage-module-linter/storage-module-linter");
19
20
  const reportLintResults = (logger, lintResults, showSummary = true) => {
20
21
  let numErrors = 0, numWarnings = 0;
21
22
  let noProblemsFound = true;
@@ -85,7 +86,8 @@ const lint = async (filesToLint, manifest, environment, logger, parseFunction =
85
86
  new full_manifest_linter_1.FullManifestLinter(logger),
86
87
  new handler_linter_1.HandlerLinter(environment, manifest, logger),
87
88
  new dynamic_properties_permissions_linter_1.DynamicPropertiesPermissionsLinter(environment, manifest, logger),
88
- new invoke_remote_linter_1.InvokeRemoteLinter(environment, manifest, logger)
89
+ new invoke_remote_linter_1.InvokeRemoteLinter(environment, manifest, logger),
90
+ new storage_module_linter_1.StorageModulesLinter(environment, manifest, logger)
89
91
  ]) => {
90
92
  const { include, exclude } = await (0, cli_shared_1.listTSConfigIncludeExclude)(new cli_shared_1.FileSystemReader());
91
93
  const tsInclude = new Set(include);
@@ -0,0 +1,10 @@
1
+ import { LintCriteriaMatch } from '../../linter-interface';
2
+ export declare enum ApiCallTypes {
3
+ 'SQL' = 0
4
+ }
5
+ export declare type ProductName = 'jira' | 'confluence' | 'bitbucket';
6
+ export interface SqlCall extends LintCriteriaMatch {
7
+ type: ApiCallTypes.SQL;
8
+ }
9
+ export declare type ApiCall = SqlCall;
10
+ //# sourceMappingURL=api-call-interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-call-interface.d.ts","sourceRoot":"","sources":["../../../../src/lint/linters/storage-module-linter/api-call-interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,oBAAY,YAAY;IACtB,KAAK,IAAA;CACN;AAED,oBAAY,WAAW,GAAG,MAAM,GAAG,YAAY,GAAG,WAAW,CAAC;AAE9D,MAAM,WAAW,OAAQ,SAAQ,iBAAiB;IAChD,IAAI,EAAE,YAAY,CAAC,GAAG,CAAC;CACxB;AAED,oBAAY,OAAO,GAAG,OAAO,CAAC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiCallTypes = void 0;
4
+ var ApiCallTypes;
5
+ (function (ApiCallTypes) {
6
+ ApiCallTypes[ApiCallTypes["SQL"] = 0] = "SQL";
7
+ })(ApiCallTypes = exports.ApiCallTypes || (exports.ApiCallTypes = {}));
@@ -0,0 +1,19 @@
1
+ import { ManifestSchema as Manifest } from '@forge/manifest';
2
+ import BaseLinter from '../../base-linter';
3
+ import { LintFixState, LintLogger, LintResultRule } from '../../linter-interface';
4
+ import { ApiCall, SqlCall } from './api-call-interface';
5
+ interface StorageModuleLintCriteriaMatches {
6
+ [key: string]: ApiCall[];
7
+ sql: SqlCall[];
8
+ }
9
+ export declare const fixMissingModules: (errors: LintResultRule[], warnings: LintResultRule[], state: LintFixState) => Promise<LintFixState>;
10
+ export declare class StorageModulesLinter extends BaseLinter<ApiCall, StorageModuleLintCriteriaMatches, ApiCall[]> {
11
+ private manifest;
12
+ constructor(environment: string, manifest: Manifest, logger: LintLogger);
13
+ bootstrap(): Promise<void>;
14
+ protected setupMatchesMap(filepath: string): void;
15
+ protected getFixer(): ((errors: LintResultRule[], warnings: LintResultRule[], state: LintFixState) => Promise<LintFixState>) | undefined;
16
+ protected addLintCriteriaMatch(apiCall: ApiCall, filepath: string): void;
17
+ }
18
+ export {};
19
+ //# sourceMappingURL=storage-module-linter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-module-linter.d.ts","sourceRoot":"","sources":["../../../../src/lint/linters/storage-module-linter/storage-module-linter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,IAAI,QAAQ,EAAW,MAAM,iBAAiB,CAAC;AACtE,OAAO,UAAU,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,OAAO,EAAgB,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAItE,UAAU,gCAAgC;IACxC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,EAAE,CAAC;IACzB,GAAG,EAAE,OAAO,EAAE,CAAC;CAChB;AAMD,eAAO,MAAM,iBAAiB,WACpB,cAAc,EAAE,YACd,cAAc,EAAE,SACnB,YAAY,KAClB,QAAQ,YAAY,CAoBtB,CAAC;AACF,qBAAa,oBAAqB,SAAQ,UAAU,CAAC,OAAO,EAAE,gCAAgC,EAAE,OAAO,EAAE,CAAC;IAGtG,OAAO,CAAC,QAAQ;gBADhB,WAAW,EAAE,MAAM,EACX,QAAQ,EAAE,QAAQ,EAC1B,MAAM,EAAE,UAAU;IAKP,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAQvC,SAAS,CAAC,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAMjD,SAAS,CAAC,QAAQ,IACd,CAAC,CAAC,MAAM,EAAE,cAAc,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,EAAE,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC,GACtG,SAAS;IAIb,SAAS,CAAC,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;CAOzE"}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StorageModulesLinter = exports.fixMissingModules = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const base_linter_1 = tslib_1.__importDefault(require("../../base-linter"));
6
+ const api_call_interface_1 = require("./api-call-interface");
7
+ const sql_node_visitor_1 = require("./visitors/sql-node-visitor");
8
+ const sql_verifier_1 = require("./verifiers/sql-verifier");
9
+ var SqlEngine;
10
+ (function (SqlEngine) {
11
+ SqlEngine["mysql"] = "mysql";
12
+ })(SqlEngine || (SqlEngine = {}));
13
+ const fixMissingModules = async (errors, warnings, state) => {
14
+ const currentModules = (await state.configFile.readConfig())?.modules ?? {};
15
+ if (warnings.length && !currentModules.sql) {
16
+ const newModules = {
17
+ ...currentModules,
18
+ sql: [
19
+ {
20
+ key: 'db',
21
+ engine: SqlEngine.mysql
22
+ }
23
+ ]
24
+ };
25
+ await state.configFile.writeToConfigFile('modules', newModules);
26
+ state.warningsFixed++;
27
+ }
28
+ return state;
29
+ };
30
+ exports.fixMissingModules = fixMissingModules;
31
+ class StorageModulesLinter extends base_linter_1.default {
32
+ manifest;
33
+ constructor(environment, manifest, logger) {
34
+ super(environment, logger);
35
+ this.manifest = manifest;
36
+ }
37
+ async bootstrap() {
38
+ this.nodeVisitors = [new sql_node_visitor_1.SQLNodeVisitor()];
39
+ this.verifiers = {
40
+ sql: new sql_verifier_1.SQLVerifier(this.environment, this.manifest)
41
+ };
42
+ }
43
+ setupMatchesMap(filepath) {
44
+ this.matches.set(filepath, {
45
+ sql: []
46
+ });
47
+ }
48
+ getFixer() {
49
+ return exports.fixMissingModules;
50
+ }
51
+ addLintCriteriaMatch(apiCall, filepath) {
52
+ const criteriaMatches = this.matches.get(filepath);
53
+ if (apiCall.type === api_call_interface_1.ApiCallTypes.SQL) {
54
+ criteriaMatches.sql.push(apiCall);
55
+ }
56
+ }
57
+ }
58
+ exports.StorageModulesLinter = StorageModulesLinter;
@@ -0,0 +1,8 @@
1
+ import { LintResultRule, LintClass } from '../../../linter-interface';
2
+ import { ApiCall } from '../api-call-interface';
3
+ import { LintIssueVerifier, BaseLintIssueVerifier } from '../../verifier-interface';
4
+ export declare class SQLVerifier extends BaseLintIssueVerifier implements LintIssueVerifier<ApiCall[]> {
5
+ protected getLintClass(): LintClass;
6
+ process(apiCalls: ApiCall[]): Promise<LintResultRule[]>;
7
+ }
8
+ //# sourceMappingURL=sql-verifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sql-verifier.d.ts","sourceRoot":"","sources":["../../../../../src/lint/linters/storage-module-linter/verifiers/sql-verifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAKpF,qBAAa,WAAY,SAAQ,qBAAsB,YAAW,iBAAiB,CAAC,OAAO,EAAE,CAAC;IAC5F,SAAS,CAAC,YAAY,IAAI,SAAS;IAItB,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;CAerE"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SQLVerifier = void 0;
4
+ const linter_interface_1 = require("../../../linter-interface");
5
+ const verifier_interface_1 = require("../../verifier-interface");
6
+ const text_1 = require("../../../text");
7
+ const SQL_MODULE = 'sql';
8
+ class SQLVerifier extends verifier_interface_1.BaseLintIssueVerifier {
9
+ getLintClass() {
10
+ return linter_interface_1.LintClass.Warning;
11
+ }
12
+ async process(apiCalls) {
13
+ if (this.manifest.modules && SQL_MODULE in this.manifest.modules) {
14
+ return [];
15
+ }
16
+ return apiCalls.map((apiCall) => ({
17
+ class: this.getLintClass(),
18
+ message: text_1.messages.verifiers.sql.message(SQL_MODULE),
19
+ reference: text_1.messages.verifiers.sql.reference,
20
+ ...apiCall,
21
+ metadata: {
22
+ missingSQLModule: SQL_MODULE
23
+ }
24
+ }));
25
+ }
26
+ }
27
+ exports.SQLVerifier = SQLVerifier;
@@ -0,0 +1,10 @@
1
+ import { TSESTree } from '@typescript-eslint/typescript-estree';
2
+ import { NodeVisitor } from '../../node-visitor-interface';
3
+ import { ApiCall, ApiCallTypes } from '../api-call-interface';
4
+ export interface SQLApiCall extends ApiCall {
5
+ type: ApiCallTypes.SQL;
6
+ }
7
+ export declare class SQLNodeVisitor implements NodeVisitor<ApiCall> {
8
+ visit(node: TSESTree.Node, _parent: TSESTree.Node | undefined, callback: (apiCall: ApiCall) => void): void;
9
+ }
10
+ //# sourceMappingURL=sql-node-visitor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sql-node-visitor.d.ts","sourceRoot":"","sources":["../../../../../src/lint/linters/storage-module-linter/visitors/sql-node-visitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE9D,MAAM,WAAW,UAAW,SAAQ,OAAO;IACzC,IAAI,EAAE,YAAY,CAAC,GAAG,CAAC;CACxB;AAED,qBAAa,cAAe,YAAW,WAAW,CAAC,OAAO,CAAC;IAClD,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,IAAI,GAAG,SAAS,EAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI;CAelH"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SQLNodeVisitor = void 0;
4
+ const typescript_estree_1 = require("@typescript-eslint/typescript-estree");
5
+ const api_call_interface_1 = require("../api-call-interface");
6
+ class SQLNodeVisitor {
7
+ visit(node, _parent, callback) {
8
+ if (node.type === typescript_estree_1.AST_NODE_TYPES.ImportDeclaration && node.source.value === '@forge/sql') {
9
+ node.specifiers.forEach((specifier) => {
10
+ if (specifier.type === 'ImportDefaultSpecifier' && specifier.local.type === 'Identifier') {
11
+ if (specifier.loc) {
12
+ const sqlApiCall = {
13
+ type: api_call_interface_1.ApiCallTypes.SQL,
14
+ ...specifier.loc.start
15
+ };
16
+ callback(sqlApiCall);
17
+ }
18
+ }
19
+ });
20
+ }
21
+ }
22
+ }
23
+ exports.SQLNodeVisitor = SQLNodeVisitor;
@@ -37,6 +37,10 @@ export declare const messages: {
37
37
  message: (product: string, hook: string, scope: string) => string;
38
38
  reference: string;
39
39
  };
40
+ sql: {
41
+ message: (module: string) => string;
42
+ reference: string;
43
+ };
40
44
  };
41
45
  };
42
46
  //# sourceMappingURL=messages.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/lint/text/messages.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ;;;2BAGA,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"}
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/lint/text/messages.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ;;;2BAGA,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;;;;8BAKpC,MAAM;;;;CAI7B,CAAC"}
@@ -39,6 +39,10 @@ exports.messages = {
39
39
  uiHook: {
40
40
  message: (product, hook, scope) => `${product} UI hook: "${hook}" requires the "${scope}" scope`,
41
41
  reference: 'permission-scope-required'
42
+ },
43
+ sql: {
44
+ message: (module) => `SQL package is used but '${module}' module is not defined in the manifest`,
45
+ reference: 'https://developer.atlassian.com/platform/forge/manifest-reference/#modules'
42
46
  }
43
47
  }
44
48
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/lint",
3
- "version": "5.5.2-next.9",
3
+ "version": "5.6.0-next.12",
4
4
  "description": "Linting for forge apps",
5
5
  "main": "out/index.js",
6
6
  "license": "UNLICENSED",
@@ -19,9 +19,9 @@
19
19
  "eslint-plugin-import": "^2.29.1"
20
20
  },
21
21
  "dependencies": {
22
- "@forge/cli-shared": "6.2.1-next.9",
22
+ "@forge/cli-shared": "6.3.0-next.11",
23
23
  "@forge/egress": "1.2.13",
24
- "@forge/manifest": "8.0.0-next.8",
24
+ "@forge/manifest": "8.0.0-next.9",
25
25
  "@typescript-eslint/typescript-estree": "^5.62.0",
26
26
  "array.prototype.flatmap": "^1.3.2",
27
27
  "atlassian-openapi": "^1.0.18",