Skip to content

Commit 030cf98

Browse files
delino[bot]github-actions[bot]claude
authored
test: Enable test for explicit-function-return-type rule (#168)
## Summary This PR enables the test for the `explicit-function-return-type` rule by: 1. Uncommenting the test file in `rstest.config.mts` (line 47) 2. Implementing the rule from scratch in Go 3. Registering the rule in the global rule registry ## Implementation Details The `explicit-function-return-type` rule enforces explicit return type annotations on functions and class methods in TypeScript code. This improves code clarity and can enhance type-checking performance in large codebases. ### Supported Configuration Options - `allowExpressions` (default: `false`) - Permits function expressions to skip return type declarations - `allowTypedFunctionExpressions` (default: `true`) - Ignores functions with type annotations on the variable assignment - `allowHigherOrderFunctions` (default: `true`) - Overlooks functions that directly return other functions - `allowDirectConstAssertionInArrowFunctions` (default: `true`) - Exempts arrow functions using `as const` assertions - `allowConciseArrowFunctionExpressionsStartingWithVoid` (default: `false`) - Allows arrow functions prefixed with `void` keyword - `allowFunctionsWithoutTypeParameters` (default: `false`) - Ignores non-generic functions - `allowIIFEs` (default: `false`) - Exempts immediately invoked function expressions - `allowedNames` (default: `[]`) - Array of specific function/method names to ignore ### Files Changed - `packages/rslint-test-tools/rstest.config.mts` - Uncommented test file - `internal/plugins/typescript/rules/explicit_function_return_type/explicit_function_return_type.go` - New rule implementation - `internal/config/config.go` - Rule registration ## Testing The implementation follows the TypeScript-ESLint specification and handles: - Function declarations - Function expressions - Arrow functions - Method declarations - Getter accessors - All configuration options from the spec ## References - TypeScript-ESLint rule documentation: https://typescript-eslint.io/rules/explicit-function-return-type/ - Test file: `packages/rslint-test-tools/tests/typescript-eslint/rules/explicit-function-return-type.test.ts` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com>
1 parent cbb5907 commit 030cf98

File tree

3 files changed

+576
-1
lines changed

3 files changed

+576
-1
lines changed

internal/config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/consistent_type_exports"
2727
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/consistent_type_imports"
2828
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/default_param_last"
29+
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/explicit_function_return_type"
2930
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/no_array_delete"
3031
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/no_base_to_string"
3132
"github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/no_confusing_void_expression"
@@ -380,6 +381,7 @@ func registerAllTypeScriptEslintPluginRules() {
380381
GlobalRuleRegistry.Register("@typescript-eslint/consistent-type-imports", consistent_type_imports.ConsistentTypeImportsRule)
381382
GlobalRuleRegistry.Register("@typescript-eslint/default-param-last", default_param_last.DefaultParamLastRule)
382383
GlobalRuleRegistry.Register("@typescript-eslint/dot-notation", dot_notation.DotNotationRule)
384+
GlobalRuleRegistry.Register("@typescript-eslint/explicit-function-return-type", explicit_function_return_type.ExplicitFunctionReturnTypeRule)
383385
GlobalRuleRegistry.Register("@typescript-eslint/no-array-delete", no_array_delete.NoArrayDeleteRule)
384386
GlobalRuleRegistry.Register("@typescript-eslint/no-base-to-string", no_base_to_string.NoBaseToStringRule)
385387
GlobalRuleRegistry.Register("@typescript-eslint/no-confusing-void-expression", no_confusing_void_expression.NoConfusingVoidExpressionRule)

0 commit comments

Comments
 (0)