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§
Structs§
- Append
Text Comment - A rule to append a comment at the beginning or the end of each file.
- Compute
Expression - 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.
- Context
Builder - A builder for creating a
Context
with optional configuration. - Convert
Index ToField - A rule that converts index expression into field expression.
- Convert
Local Function ToAssign - Convert local function statements into local assignements when the function is not recursive.
- Convert
Luau Number - A rule that converts Luau number literals to regular Lua numbers.
- Convert
Require - A rule that converts require calls between environments
- Convert
Square Root Call - A rule that converts square root calls (
math.sqrt(x)
) to exponentiation calls (x ^ 0.5
). - Filter
After Early Return - A rule that removes statements that will never be executed because of an earlier
return
statement. - Group
Local Assignment - Group local assign statements into one statement.
- Inject
Global Value - A rule to replace global variables with values.
- Path
Require Mode - A require mode for handling content from file system paths.
- Remove
Assertions - A rule that removes
assert
calls. - Remove
Comments - A rule that removes comments associated with AST nodes.
- Remove
Compound Assignment - A rule that converts compound assignment (like
+=
) into regular assignments. - Remove
Continue - A rule that removes continue statements and converts them into break statements.
- Remove
Debug Profiling - A rule that removes
debug.profilebegin
anddebug.profileend
calls. - Remove
Empty Do - A rule that removes empty do statements.
- Remove
Floor Division - A rule that removes interpolated strings.
- Remove
Function Call Parens - A rule that removes parentheses when calling functions with a string or a table.
- Remove
IfExpression - A rule that removes trailing
nil
in local assignments. - Remove
Interpolated String - A rule that removes interpolated strings.
- Remove
Method Call - A rule that converts method calls with identifier prefixes to regular function calls.
- Remove
Method Definition - Change method functions into regular functions.
- Remove
NilDeclaration - A rule that removes trailing
nil
in local assignments. - Remove
Spaces - A rule that removes whitespaces associated with AST nodes.
- Remove
Types - A rule that removes Luau types from all AST nodes.
- Remove
Unused IfBranch - A rule that removes unused if branches. It can also turn a if statement into a do block statement.
- Remove
Unused Variable - A rule that removes unused variables.
- Remove
Unused While - A rule that removes while statements with a known false condition.
- Rename
Variables - Rename all identifiers to small and meaningless names.
- Roblox
Require Mode
Enums§
- Require
Mode - A representation of how require calls are handled and transformed.
- Roblox
Index Style - Represents the different styles of indexing in Roblox.
- Rule
Configuration Error - When implementing the configure method of the Rule trait, the method returns a result that uses this error type.
- Rule
Property Value - 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§
- Flawless
Rule - A trait for rules that are guaranteed to succeed without errors.
- Rule
- Defines an interface for rules that can transform Lua blocks.
- Rule
Configuration - 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§
- Rule
Process Result - The result type for rule processing operations.
- Rule
Properties