Commit 030cf98
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- internal
- config
- plugins/typescript/rules/explicit_function_return_type
- packages/rslint-test-tools
3 files changed
+576
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
380 | 381 | | |
381 | 382 | | |
382 | 383 | | |
| 384 | + | |
383 | 385 | | |
384 | 386 | | |
385 | 387 | | |
| |||
0 commit comments