fix: add JS-003/JS-004 to full validation + fix Alpine components
The JS-003 and JS-004 rules were only in single-file validation, not in full project validation. Also fixed regex to match functions with parameters (like adminMessages(initialId = null)). Fixed: - messages.js: Added ...data() and currentPage - notifications.js: Added ...data() and currentPage - logs.js: Added noqa (uses baseData pattern with safety check) - settings.js: Added noqa (uses baseData pattern with safety check) - login.js: Added noqa (standalone page, no sidebar) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -515,10 +515,11 @@ class ArchitectureValidator:
|
|||||||
if "noqa: js-003" in content.lower():
|
if "noqa: js-003" in content.lower():
|
||||||
return
|
return
|
||||||
|
|
||||||
# Look for Alpine component function pattern: function adminXxx() { return { ... } }
|
# Look for Alpine component function pattern: function adminXxx(...) { return { ... } }
|
||||||
# These are page-level components that should inherit from data()
|
# These are page-level components that should inherit from data()
|
||||||
|
# Allow optional parameters in the function signature
|
||||||
component_pattern = re.compile(
|
component_pattern = re.compile(
|
||||||
r"function\s+(admin\w+|vendor\w+|shop\w+)\s*\(\s*\)\s*\{", re.IGNORECASE
|
r"function\s+(admin\w+|vendor\w+|shop\w+)\s*\([^)]*\)\s*\{", re.IGNORECASE
|
||||||
)
|
)
|
||||||
|
|
||||||
for match in component_pattern.finditer(content):
|
for match in component_pattern.finditer(content):
|
||||||
@@ -2641,6 +2642,12 @@ class ArchitectureValidator:
|
|||||||
suggestion="Replace window.apiClient with apiClient",
|
suggestion="Replace window.apiClient with apiClient",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# JS-003: Check Alpine components spread ...data()
|
||||||
|
self._check_alpine_data_spread(file_path, content, lines)
|
||||||
|
|
||||||
|
# JS-004: Check Alpine components set currentPage
|
||||||
|
self._check_alpine_current_page(file_path, content, lines)
|
||||||
|
|
||||||
def _validate_templates(self, target_path: Path):
|
def _validate_templates(self, target_path: Path):
|
||||||
"""Validate template patterns"""
|
"""Validate template patterns"""
|
||||||
print("📄 Validating templates...")
|
print("📄 Validating templates...")
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
// static/admin/js/login.js
|
// static/admin/js/login.js
|
||||||
|
// noqa: js-003 - Standalone login page, doesn't use base layout
|
||||||
|
// noqa: js-004 - No sidebar on login page, doesn't need currentPage
|
||||||
|
|
||||||
// ✅ Use centralized logger - ONE LINE!
|
// ✅ Use centralized logger - ONE LINE!
|
||||||
// Create custom logger for login page
|
// Create custom logger for login page
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
// static/admin/js/logs.js
|
// static/admin/js/logs.js
|
||||||
|
// noqa: JS-003 - Uses ...baseData which is data() with safety check
|
||||||
|
|
||||||
const logsLog = window.LogConfig?.loggers?.logs || console;
|
const logsLog = window.LogConfig?.loggers?.logs || console;
|
||||||
|
|
||||||
function adminLogs() {
|
function adminLogs() {
|
||||||
// Get base data
|
// Get base data with safety check for standalone usage
|
||||||
const baseData = typeof data === 'function' ? data() : {};
|
const baseData = typeof data === 'function' ? data() : {};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ const messagesLog = window.LogConfig?.createLogger('MESSAGES') || console;
|
|||||||
*/
|
*/
|
||||||
function adminMessages(initialConversationId = null) {
|
function adminMessages(initialConversationId = null) {
|
||||||
return {
|
return {
|
||||||
|
...data(),
|
||||||
|
currentPage: 'messages',
|
||||||
|
|
||||||
// Loading states
|
// Loading states
|
||||||
loading: true,
|
loading: true,
|
||||||
loadingConversations: false,
|
loadingConversations: false,
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ const notificationsLog = window.LogConfig?.createLogger('NOTIFICATIONS') || cons
|
|||||||
*/
|
*/
|
||||||
function adminNotifications() {
|
function adminNotifications() {
|
||||||
return {
|
return {
|
||||||
|
...data(),
|
||||||
|
currentPage: 'notifications',
|
||||||
|
|
||||||
// Loading states
|
// Loading states
|
||||||
loading: true,
|
loading: true,
|
||||||
loadingNotifications: false,
|
loadingNotifications: false,
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
// static/admin/js/settings.js
|
// static/admin/js/settings.js
|
||||||
|
// noqa: JS-003 - Uses ...baseData which is data() with safety check
|
||||||
|
|
||||||
const settingsLog = window.LogConfig?.loggers?.settings || console;
|
const settingsLog = window.LogConfig?.loggers?.settings || console;
|
||||||
|
|
||||||
function adminSettings() {
|
function adminSettings() {
|
||||||
// Get base data
|
// Get base data with safety check for standalone usage
|
||||||
const baseData = typeof data === 'function' ? data() : {};
|
const baseData = typeof data === 'function' ? data() : {};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user