fix: add Pydantic models for customer/inventory endpoints and align JS rules
- Add Pydantic response models for vendor customer endpoints - Add InventoryMessageResponse for delete endpoint - Align JS rule IDs between YAML and validation script (JS-001=logger, JS-002=apiClient) - Add exception for init-*.js files in console logging check 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -334,14 +334,32 @@ class ArchitectureValidator:
|
||||
"""Validate a single JavaScript file"""
|
||||
print("🟨 Validating JavaScript...")
|
||||
|
||||
# JS-001: Check for window.apiClient
|
||||
# JS-001: Check for console usage (must use centralized logger)
|
||||
# Skip init-*.js files - they run before logger is available
|
||||
if not file_path.name.startswith("init-"):
|
||||
for i, line in enumerate(lines, 1):
|
||||
if re.search(r"console\.(log|warn|error)", line):
|
||||
if "//" in line or "✅" in line or "eslint-disable" in line:
|
||||
continue
|
||||
self._add_violation(
|
||||
rule_id="JS-001",
|
||||
rule_name="Use centralized logger",
|
||||
severity=Severity.WARNING,
|
||||
file_path=file_path,
|
||||
line_number=i,
|
||||
message="Use centralized logger instead of console",
|
||||
context=line.strip()[:80],
|
||||
suggestion="Use window.LogConfig.createLogger('moduleName')",
|
||||
)
|
||||
|
||||
# JS-002: Check for window.apiClient (must use lowercase apiClient)
|
||||
for i, line in enumerate(lines, 1):
|
||||
if "window.apiClient" in line:
|
||||
before_occurrence = line[: line.find("window.apiClient")]
|
||||
if "//" not in before_occurrence:
|
||||
self._add_violation(
|
||||
rule_id="JS-001",
|
||||
rule_name="Use apiClient directly",
|
||||
rule_id="JS-002",
|
||||
rule_name="Use lowercase apiClient",
|
||||
severity=Severity.WARNING,
|
||||
file_path=file_path,
|
||||
line_number=i,
|
||||
@@ -350,22 +368,6 @@ class ArchitectureValidator:
|
||||
suggestion="Replace window.apiClient with apiClient",
|
||||
)
|
||||
|
||||
# JS-002: Check for console usage
|
||||
for i, line in enumerate(lines, 1):
|
||||
if re.search(r"console\.(log|warn|error)", line):
|
||||
if "//" in line or "✅" in line or "eslint-disable" in line:
|
||||
continue
|
||||
self._add_violation(
|
||||
rule_id="JS-002",
|
||||
rule_name="Use centralized logger",
|
||||
severity=Severity.WARNING,
|
||||
file_path=file_path,
|
||||
line_number=i,
|
||||
message="Use centralized logger instead of console",
|
||||
context=line.strip()[:80],
|
||||
suggestion="Use window.LogConfig.createLogger('moduleName')",
|
||||
)
|
||||
|
||||
def _validate_html_file(self, file_path: Path, content: str, lines: list[str]):
|
||||
"""Validate a single HTML template file"""
|
||||
print("📄 Validating template...")
|
||||
@@ -870,15 +872,35 @@ class ArchitectureValidator:
|
||||
content = file_path.read_text()
|
||||
lines = content.split("\n")
|
||||
|
||||
# JS-001: Check for window.apiClient
|
||||
# JS-001: Check for console usage (must use centralized logger)
|
||||
# Skip init-*.js files - they run before logger is available
|
||||
if not file_path.name.startswith("init-"):
|
||||
for i, line in enumerate(lines, 1):
|
||||
if re.search(r"console\.(log|warn|error)", line):
|
||||
# Skip if it's a comment or bootstrap message
|
||||
if "//" in line or "✅" in line or "eslint-disable" in line:
|
||||
continue
|
||||
|
||||
self._add_violation(
|
||||
rule_id="JS-001",
|
||||
rule_name="Use centralized logger",
|
||||
severity=Severity.WARNING,
|
||||
file_path=file_path,
|
||||
line_number=i,
|
||||
message="Use centralized logger instead of console",
|
||||
context=line.strip()[:80],
|
||||
suggestion="Use window.LogConfig.createLogger('moduleName')",
|
||||
)
|
||||
|
||||
# JS-002: Check for window.apiClient (must use lowercase apiClient)
|
||||
for i, line in enumerate(lines, 1):
|
||||
if "window.apiClient" in line:
|
||||
# Check if it's not in a comment
|
||||
before_occurrence = line[: line.find("window.apiClient")]
|
||||
if "//" not in before_occurrence:
|
||||
self._add_violation(
|
||||
rule_id="JS-001",
|
||||
rule_name="Use apiClient directly",
|
||||
rule_id="JS-002",
|
||||
rule_name="Use lowercase apiClient",
|
||||
severity=Severity.WARNING,
|
||||
file_path=file_path,
|
||||
line_number=i,
|
||||
@@ -887,24 +909,6 @@ class ArchitectureValidator:
|
||||
suggestion="Replace window.apiClient with apiClient",
|
||||
)
|
||||
|
||||
# JS-002: Check for console usage
|
||||
for i, line in enumerate(lines, 1):
|
||||
if re.search(r"console\.(log|warn|error)", line):
|
||||
# Skip if it's a comment or bootstrap message
|
||||
if "//" in line or "✅" in line or "eslint-disable" in line:
|
||||
continue
|
||||
|
||||
self._add_violation(
|
||||
rule_id="JS-002",
|
||||
rule_name="Use centralized logger",
|
||||
severity=Severity.WARNING,
|
||||
file_path=file_path,
|
||||
line_number=i,
|
||||
message="Use centralized logger instead of console",
|
||||
context=line.strip()[:80],
|
||||
suggestion="Use window.LogConfig.createLogger('moduleName')",
|
||||
)
|
||||
|
||||
def _validate_templates(self, target_path: Path):
|
||||
"""Validate template patterns"""
|
||||
print("📄 Validating templates...")
|
||||
|
||||
Reference in New Issue
Block a user