@forge/lint

6.2.3-next.216.3.0-next.22
out/lint/linters/teamwork-graph-linter/teamwork-graph-linter.js
+out/lint/linters/teamwork-graph-linter/teamwork-graph-linter.jsNew file
+41
Index: package/out/lint/linters/teamwork-graph-linter/teamwork-graph-linter.js
===================================================================
--- package/out/lint/linters/teamwork-graph-linter/teamwork-graph-linter.js
+++ package/out/lint/linters/teamwork-graph-linter/teamwork-graph-linter.js
@@ -0,0 +1,41 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.TeamworkGraphLinter = void 0;
+const cli_shared_1 = require("@forge/cli-shared");
+const manifest_1 = require("@forge/manifest");
+const utils_1 = require("../utils");
+const detect_teamwork_graph_usage_1 = require("./detect-teamwork-graph-usage");
+const abstract_linter_1 = require("../../abstract-linter");
+const linter_interface_1 = require("../../linter-interface");
+class TeamworkGraphLinter extends abstract_linter_1.AbstractLinter {
+    manifest;
+    constructor(manifest, logger) {
+        super(logger);
+        this.manifest = manifest;
+    }
+    async bootstrap() {
+    }
+    hasDeclaredTeamworkGraphScope() {
+        const declaredScopes = (0, utils_1.getAllScopeKeys)(this.manifest.permissions?.scopes ?? []);
+        const teamworkGraphScopes = (0, manifest_1.getTeamworkGraphScopes)();
+        return declaredScopes.some((scope) => teamworkGraphScopes.has(scope));
+    }
+    async batchExecuteImpl(inputs = []) {
+        if (this.hasDeclaredTeamworkGraphScope()) {
+            return [];
+        }
+        const usesTeamworkGraph = inputs.some(({ ast }) => (0, detect_teamwork_graph_usage_1.doesAstUseTeamworkGraph)(ast));
+        if (!usesTeamworkGraph)
+            return [];
+        const result = new linter_interface_1.LintResult(manifest_1.MANIFEST_FILE);
+        result.add({
+            class: linter_interface_1.LintClass.Warning,
+            message: cli_shared_1.Text.lint.teamworkGraphScopes,
+            reference: 'teamwork-graph-scopes',
+            line: 0,
+            column: 0
+        });
+        return [result];
+    }
+}
+exports.TeamworkGraphLinter = TeamworkGraphLinter;