npm package diff

Package: @forge/lint

Versions: 5.12.0-next.6 - 5.12.0-next.7

File: package/out/lint/linters/llm-module-linter/llm-node-visitor.js

Index: package/out/lint/linters/llm-module-linter/llm-node-visitor.js
===================================================================
--- package/out/lint/linters/llm-module-linter/llm-node-visitor.js
+++ package/out/lint/linters/llm-module-linter/llm-node-visitor.js
@@ -0,0 +1,29 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.LlmNodeVisitor = void 0;
+const llm_linter_interface_1 = require("./llm-linter-interface");
+const typescript_estree_1 = require("@typescript-eslint/typescript-estree");
+class LlmNodeVisitor {
+    visit(node, _parent, onMatchCallback) {
+        if (this.isNodeSDKPackageImport(node) && 'specifiers' in node) {
+            node.specifiers.forEach((specifier) => {
+                if (this.isImportSpecifier(specifier)) {
+                    if (specifier.loc) {
+                        onMatchCallback({
+                            type: 'llm',
+                            ...specifier.loc.start
+                        });
+                    }
+                }
+            });
+        }
+    }
+    isNodeSDKPackageImport(node) {
+        return node.type === typescript_estree_1.AST_NODE_TYPES.ImportDeclaration && node.source.value === llm_linter_interface_1.LLM_SDK_PACKAGE;
+    }
+    isImportSpecifier(specifier) {
+        return ((specifier.type === typescript_estree_1.AST_NODE_TYPES.ImportSpecifier || specifier.type === typescript_estree_1.AST_NODE_TYPES.ImportDefaultSpecifier) &&
+            specifier.local.type === typescript_estree_1.AST_NODE_TYPES.Identifier);
+    }
+}
+exports.LlmNodeVisitor = LlmNodeVisitor;