Skip to content

Rule Change: func-style ignore overloaded function declarations #19738

@JoshuaKGoldberg

Description

@JoshuaKGoldberg

What rule do you want to change?

func-style

What change do you want to make?

Generate fewer warnings

How do you think the change should be implemented?

A new default behavior

Example code

/* eslint func-style: "error" */

// func-style report: Expected a function expression.
function noOverloads() {}

// No func-style report
function hasOverloads(value: string): string
function hasOverloads(value: number): number
function hasOverloads(value: unknown) {
  return value;
}

What does the rule currently do for this code?

Expected a function expression. 9:1 - 11:2

What will the rule do after it's changed?

Not report on the function declaration.

Participation

  • I am willing to submit a pull request to implement this change.

Additional comments

Quoting #19719 (comment):

I would take JoshuaKGoldberg's suggestion a step further and always allow overloaded function declarations. Don’t even add the option to report it. Otherwise it’s simply a TypeScript error.

Playground

function hasOverloads(value: string): string
function hasOverloads(value: number): number
var hasOverloads = function(value: unknown) {
  return value;
}

If there’s user demand, there could be a rule to disallow TypeScript function overloads. But IMO that feels out of scope for func-style.

Metadata

Metadata

Labels

acceptedThere is consensus among the team that this change meets the criteria for inclusionenhancementThis change enhances an existing feature of ESLintruleRelates to ESLint's core rules

Type

No type

Projects

Status

Complete

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions