GDShrapt.Linter provides configurable style checking for GDScript 2.0 (Godot 4.x) with gdtoolkit-compatible suppression. Rule Categories: - Naming: PascalCase, snake_case, SCREAMING_SNAKE_CASE for classes/functions/variables/constants/signals/enums - Style: Line length limits, member ordering, private member prefix (_underscore) - Best Practices: Unused variables/parameters/signals, empty functions, type hint suggestions - Strict Typing (GDL215): Per-element configurable severity for required type hints Key Features: - Comment-based rule suppression (gdtoolkit compatible): gdlint:ignore, gdlint:disable/enable - Configurable severity per rule and per element type - Presets: Default, Strict, Minimal - Support for both rule IDs (GDL001) and names (variable-name) in suppressions Usage: new GDLinter(options).Lint(tree) or LintCode(code) Requires: GDShrapt.Reader
$ dotnet add package GDShrapt.LinterConfigurable style checking for GDScript 2.0 (Godot 4.x) with gdtoolkit-compatible suppression.
gdlint:ignore, gdlint:disable/enableusing GDShrapt.Reader;
var code = @"
var MyVariable = 10 # Should be snake_case
const lowercase = 5 # Should be SCREAMING_SNAKE_CASE
func BadName(): # Should be snake_case
pass
";
var linter = new GDLinter();
var result = linter.LintCode(code);
foreach (var issue in result.Issues)
{
// Output: "warning GDL101: Variable 'MyVariable' should use snake_case (2:4)"
Console.WriteLine(issue.ToString());
}
var options = new GDLinterOptions
{
// Naming conventions
ClassNameCase = NamingCase.PascalCase,
FunctionNameCase = NamingCase.SnakeCase,
VariableNameCase = NamingCase.SnakeCase,
ConstantNameCase = NamingCase.ScreamingSnakeCase,
RequireUnderscoreForPrivate = true,
// Style
MaxLineLength = 100,
// Best practices
WarnUnusedVariables = true,
WarnEmptyFunctions = true
};
var linter = new GDLinter(options);
Require type hints with configurable severity per element:
var options = new GDLinterOptions();
options.StrictTypingClassVariables = GDLintSeverity.Warning;
options.StrictTypingParameters = GDLintSeverity.Error;
options.StrictTypingReturnTypes = GDLintSeverity.Error;
var linter = new GDLinter(options);
Suppress warnings using gdtoolkit-compatible comments:
# gdlint:ignore = variable-name
var my_Var = 10 # No warning
# gdlint: disable=function-name
func BadName():
pass
# gdlint: enable=function-name
var linter = new GDLinter(GDLinterOptions.Default); // Standard rules
var linter = new GDLinter(GDLinterOptions.Strict); // All rules enabled
var linter = new GDLinter(GDLinterOptions.Minimal); // Critical rules only
| Package | Description |
|---|---|
| GDShrapt.Reader | Core parser and AST (required) |
| GDShrapt.Builder | Fluent API for code generation |
| GDShrapt.Validator | Compiler-style AST validation |
| GDShrapt.Formatter | Code formatting with type inference |
Full documentation and examples: GitHub Repository
MIT License - see LICENSE for details.