linkedin / linkedin/css-blocks

Add custom linter for return types

Open
#67 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
6.3k
Forks
154
PR merge metrics
No merged PRs in 30d

Description

[This builtin rule](https://palantir.github.io/tslint/rules/typedef/) will check that there's a declared return type for functions, which I think is overkill. But whenever a function has multiple `return` statements (or multiple `yield` statements in a generator), return type should be required.

Possible option: only require a type declaration if the return statements have different types.

This will require a custom linter.

This issue is being filed because it was too complex to fit into https://github.com/css-blocks/css-blocks/pull/65

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the linked TSLint typedef rule and the context in css-blocks#65, since no repository file or test is named here. Define the intended behavior for functions and generators with multiple return or yield statements, including whether differing inferred types change the requirement, then add tests showing the chosen rule is enforced.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.