Module rules

Module rules 

Source
Expand description

A module that contains the different rules that mutates a Lua/Luau block.

Rules are transformations that can be applied to Lua code blocks to modify their structure or behavior while preserving functionality. Each rule implements the Rule trait and can be configured through properties.

Modules§

bundle

Structs§

AppendTextComment
A rule to append a comment at the beginning or the end of each file.
ComputeExpression
A rule that compute expressions that do not have any side-effects.
Context
A context that holds data shared across all rules applied to a file.
ContextBuilder
A builder for creating a Context with optional configuration.
ConvertIndexToField
A rule that converts index expression into field expression.
ConvertLocalFunctionToAssign
Convert local function statements into local assignements when the function is not recursive.
ConvertLuauNumber
A rule that converts Luau number literals to regular Lua numbers.
ConvertRequire
A rule that converts require calls between environments
ConvertSquareRootCall
A rule that converts square root calls (math.sqrt(x)) to exponentiation calls (x ^ 0.5).
FilterAfterEarlyReturn
A rule that removes statements that will never be executed because of an earlier return statement.
GroupLocalAssignment
Group local assign statements into one statement.
InjectGlobalValue
A rule to replace global variables with values.
PathRequireMode
A require mode for handling content from file system paths.
RemoveAssertions
A rule that removes assert calls.
RemoveComments
A rule that removes comments associated with AST nodes.
RemoveCompoundAssignment
A rule that converts compound assignment (like +=) into regular assignments.
RemoveContinue
A rule that removes continue statements and converts them into break statements.
RemoveDebugProfiling
A rule that removes debug.profilebegin and debug.profileend calls.
RemoveEmptyDo
A rule that removes empty do statements.
RemoveFloorDivision
A rule that removes interpolated strings.
RemoveFunctionCallParens
A rule that removes parentheses when calling functions with a string or a table.
RemoveIfExpression
A rule that removes trailing nil in local assignments.
RemoveInterpolatedString
A rule that removes interpolated strings.
RemoveMethodCall
A rule that converts method calls with identifier prefixes to regular function calls.
RemoveMethodDefinition
Change method functions into regular functions.
RemoveNilDeclaration
A rule that removes trailing nil in local assignments.
RemoveSpaces
A rule that removes whitespaces associated with AST nodes.
RemoveTypes
A rule that removes Luau types from all AST nodes.
RemoveUnusedIfBranch
A rule that removes unused if branches. It can also turn a if statement into a do block statement.
RemoveUnusedVariable
A rule that removes unused variables.
RemoveUnusedWhile
A rule that removes while statements with a known false condition.
RenameVariables
Rename all identifiers to small and meaningless names.
RobloxRequireMode

Enums§

RequireMode
A representation of how require calls are handled and transformed.
RobloxIndexStyle
Represents the different styles of indexing in Roblox.
RuleConfigurationError
When implementing the configure method of the Rule trait, the method returns a result that uses this error type.
RulePropertyValue
In order to be able to weakly-type the properties of any rule, this enum makes it possible to easily use serde to gather the value associated with a property.

Constants§

APPEND_TEXT_COMMENT_RULE_NAME
COMPUTE_EXPRESSIONS_RULE_NAME
CONVERT_INDEX_TO_FIELD_RULE_NAME
CONVERT_LOCAL_FUNCTION_TO_ASSIGN_RULE_NAME
CONVERT_LUAU_NUMBER_RULE_NAME
CONVERT_REQUIRE_RULE_NAME
CONVERT_SQUARE_ROOT_CALL_RULE_NAME
FILTER_AFTER_EARLY_RETURN_RULE_NAME
GROUP_LOCAL_ASSIGNMENT_RULE_NAME
INJECT_GLOBAL_VALUE_RULE_NAME
REMOVE_ASSERTIONS_RULE_NAME
REMOVE_COMMENTS_RULE_NAME
REMOVE_COMPOUND_ASSIGNMENT_RULE_NAME
REMOVE_CONTINUE_RULE_NAME
REMOVE_DEBUG_PROFILING_RULE_NAME
REMOVE_EMPTY_DO_RULE_NAME
REMOVE_FLOOR_DIVISION_RULE_NAME
REMOVE_FUNCTION_CALL_PARENS_RULE_NAME
REMOVE_IF_EXPRESSION_RULE_NAME
REMOVE_INTERPOLATED_STRING_RULE_NAME
REMOVE_METHOD_CALL_RULE_NAME
REMOVE_METHOD_DEFINITION_RULE_NAME
REMOVE_NIL_DECLARATION_RULE_NAME
REMOVE_SPACES_RULE_NAME
REMOVE_TYPES_RULE_NAME
REMOVE_UNUSED_IF_BRANCH_RULE_NAME
REMOVE_UNUSED_VARIABLE_RULE_NAME
REMOVE_UNUSED_WHILE_RULE_NAME
RENAME_VARIABLES_RULE_NAME

Traits§

FlawlessRule
A trait for rules that are guaranteed to succeed without errors.
Rule
Defines an interface for rules that can transform Lua blocks.
RuleConfiguration
Defines the configuration interface for rules.

Functions§

get_all_rule_names
Returns a list of all available rule names.
get_default_rules
Returns the default set of rules that preserve code functionality.

Type Aliases§

RuleProcessResult
The result type for rule processing operations.
RuleProperties