Files
metabuilder/packages/package_validator/seed/scripts/validate_lua_structure.lua
JohnDoe6345789 73fb98d053 feat: Enhance package validator with comprehensive Lua validation scripts
- Added validation scripts for Lua quality, syntax, structure, and naming conventions.
- Implemented checks for metadata and component structures, ensuring compliance with defined schemas.
- Introduced validation for test file structures and common test files when lua_test is a devDependency.
- Updated manifest to include new Lua scripts for sorting, filtering, selection, and export functionalities.
- Improved documentation in UI_TO_LUA_MIGRATION.md to reflect current progress and completed phases.
2025-12-30 11:13:41 +00:00

23 lines
721 B
Lua

--- Checks if Lua file follows common patterns
---@param filepath string Path to the Lua file
---@param content string File content
---@return string[] warnings List of pattern warnings
local function validate_lua_structure(filepath, content)
local warnings = {}
-- Check for module pattern
if not string.match(content, "local%s+M%s*=%s*{}") and
not string.match(content, "local%s+[%w_]+%s*=%s*{}") then
table.insert(warnings, filepath .. ": Missing module pattern (local M = {})")
end
-- Check for return statement
if not string.match(content, "return%s+[%w_]+") then
table.insert(warnings, filepath .. ": Missing return statement")
end
return warnings
end
return validate_lua_structure