Skip to content
This repository was archived by the owner on Feb 9, 2025. It is now read-only.
This repository was archived by the owner on Feb 9, 2025. It is now read-only.

Allow one line arrow functions #22

@jhnns

Description

@jhnns

We currently disallow arrow functions in favor of a consistent function style. They are only allowed within other functions. However, if the function returns immediately (which is very common in functional programming), it is more readable if we use arrow functions:

// Good
const bla = () => true;
// Good
const bla = () => ({
    prop: true
});
// Bad
const bla = () => {
    return true;
};
// Bad
const bla = () => {
    const blub = true;
    return  blub;
};

See also discussion: eslint/eslint#7765

With the https://github.com/TristonJ/eslint-plugin-prefer-arrow plugin, it's finally possible to define that rule:

        "func-style": [
            "error",
            "declaration",
            {
                "allowArrowFunctions": true
            }
        ],
        "prefer-arrow/prefer-arrow-functions": [
            "error",
            {
                "singleReturnOnly": true
            }
        ]

We should do that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions