Expand description
A module that contains the different rules that mutates a Lua block.
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
- The intent of this struct is to hold data shared across all rules applied to a file.
- Context
Builder - 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
Require - A rule that converts require calls between environments
- 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.
- 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 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 - Roblox
Index Style - 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_
REQUIRE_ 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_ 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 - Rule
- Defines an interface that will be used to mutate blocks and how to serialize and deserialize the rule configuration.
- Rule
Configuration
Functions§
- get_
all_ rule_ names - get_
default_ rules - A function to get the default rule stack for darklua. All the rules here must preserve all the functionalities of the original code after being applied. They must guarantee that the processed block will work as much as the original one.