Skip to content

Latest commit

 

History

History
49 lines (32 loc) · 1.19 KB

top-level-functions.md

File metadata and controls

49 lines (32 loc) · 1.19 KB

Require all top-level functions to be named/regular functions (th-rules/top-level-functions)

💼 This rule is enabled in the following configs: ✅ recommended, recommended-react, recommended-typescript.

🔧 This rule is automatically fixable by the --fix CLI option.

Description

This rule requires all top-level functions to be named/regular functions, preventing the use of arrow functions at the top level. This rule aims to improve code readability and maintainability by enforcing consistent function declaration styles.

Rule Details

This rule checks for arrow functions at the top level and reports them as errors.

Examples of incorrect code for this rule:

const myFunction = () => {
  // Function body
};

Examples of correct code for this rule:

function myFunction() {
  // Function body
}

Usage

{
  "rules": {
    "th-rules/top-level-functions": "error"
  }
}

Options

This rule has no options.

When Not To Use It

If you do not want to enforce consistent function declaration styles, you can disable this rule.